Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/againpsychox/lc7981_240x128
Library to control LC7981-based 240x128 monochromatic display for Arduino compatible microcontroller
https://github.com/againpsychox/lc7981_240x128
arduino display ew24d40 lc7981 microcontroller u8g
Last synced: 18 days ago
JSON representation
Library to control LC7981-based 240x128 monochromatic display for Arduino compatible microcontroller
- Host: GitHub
- URL: https://github.com/againpsychox/lc7981_240x128
- Owner: AgainPsychoX
- Created: 2021-05-22T21:57:25.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-11T14:15:30.000Z (11 months ago)
- Last Synced: 2024-11-13T17:16:47.217Z (3 months ago)
- Topics: arduino, display, ew24d40, lc7981, microcontroller, u8g
- Language: C++
- Homepage:
- Size: 30.2 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Library to control LC7981 240x128 display for Arduino
Library aim to allow easy and efficient control over LC7981-based EW24D40 (or similar) 240x128 monochromatic display using Arduino compatible microcontroller. The repository include example Arduino project that allow test various features.
## About display
* [Sanyo LC7981 controller datasheet PDF](https://www.crystalfontz.com/controllers/Sanyo/LC7981/246/)
* [EW24D40 monochromatic display module (240x128) using LC7981 controller PDF](http://www.mstlcd.co.kr/s_source/download.php?table=es_free4&filename=EW24D40.pdf)
###### Few photos for identification and inspiration (my board running Breakout example)
## Notes
### Alternative library
There already exist library for this controller/display, [u8glib](https://github.com/olikraus/u8glib) or [u8g2](https://github.com/olikraus/u8g2/), however, as those libraries support multiple other displays, they aren't fully optimized for handling this exact display - in result, they are using more memory (buffering image before putting on display) and processing power (small buffer require the drawing to be done 2-3 times on smaller Arduino). That was problem that forced me into developing other implementation myself.
### Display orientation, size and coords
Display orientation is specification 240 width and 128 height. Point at x = 0 and y = 0 relates to very first pixel in left top corner of the display. Last pixel have coords of x = 239 and y = 127. The display does not support changing orientation by hardware. It could be however implemented within library, with performance trade off.
In cases user try to draw on invalid coords (x > 239 or y > 127) the behavior is undefined, usually resulting in graphical glitches. The protection against invalid input could be implemented by user if necessary, no point in forcing it into the library (which could provide unnecessary overhead).
### Namespace
All code should be contained `LC7981` namespace and all defines should use `LC7981` prefix, to avoid conflicts with other libraries and user code.
### Display base class and specializations
Display management is divided into base display class, that use few virtual functions that divide I/O related code aside from providing actual features. This allow library users to define better I/O for their specific use. There is basic template (compile-time definable pins, to avoid memory usage) class `DisplayByPins` that provide a bit slow, but easy and compatible implementation for most Arduino. For more details see source code of `DisplayByPins` and example of specialization in [`examples/`](examples/) directory ([`fastio_example.hpp`](examples/testing/fastio_example.hpp)). In my example (described more in the file) it boost performance by over 4 times, so it's worth the hassle. When writing your own specialization for I/O, don't forget to use proper delays (90ns address/control setup, 140ns for reading, 220ns for writing - more details in datasheet).
### Chip select
If you are using only one display, chip select pin can be usually connected to ground resulting in the display always being selected. For `DisplayByPins` you can provide `NOT_A_PIN` option instead pin number to let the code get optimized for this case. If you are using multiple displays, they can share the data bus and Register Select and Read/Write control pins.
## Features
+ graphical mode
+ moving cursor
+ fast bulk (blocks) writing/reading,
+ single bit setting/clearing,
+ drawing lines and basic figures,
+ simple patterns fill drawing,
+ drawing vertical text with few fonts (converter script included),Todo:
- fix problem with reading from the controller when using fast I/O example (my board specific)
- character mode
- graphical mode
- drawing fonts (font converter with few example fonts included),
- horizontal font drawing,
- graphics bitmap drawing,
- minimalistic example,
- link to where buy the display,
- image of real life connections for main example,
- more interesting main example,
- benchmark in main example (compare with other libraries?),
- reference
- change orientation## Example
Examples are included under [`examples/`](examples/) folder:
* [`examples/testing/`](examples/testing/) - connect to Arduino via Serial port in order to send commands to draw on the display.
* [`examples/breakout/`](examples/breakout/) - Atari Breakout inspired game using the library.Below there is minimalistic example of setup and usage:
```cpp
// Prepare display object using `DisplayByPins` (compile-time pin definition)
LC7981::DisplayByPins<
// EN / CS / DI / RW
22, 23, 20, 21,
// DB0 to DB7
10, 11, 12, 13, 14, 15, 18, 19
> display;void setup() {
// Initialize the display into graphic mode
display.initGraphicMode();// Your code to draw stuff
display.clearWhite();
display.drawBlackLine(0, 0, 239, 127);
}
```