UniGraphic-Fork for ST7920-LCD-controller and SH1106. Tested with 128x64 LCD with SPI and 128x64-OLED with IIC
Dependents: UniGraphic-St7920-Test AfficheurUTILECO
Fork of UniGraphic by
Fork of the UniGraphic-Library for monochrome LCDs with ST7920 controller and 128x64-IIC-OLED-Display with SH1106-Controller
Had to adapt LCD for following reasons:
- Give access to screenbuffer buffer[] to parent class
- pixel() and pixel_read() as they are hardware-dependent
- added reset-pin to IIC-Interface
GraphicDisplay:: sends buffer to LCD when auto_update is set to true.
Testprogram for ST7920 can be found here:
https://developer.mbed.org/users/charly/code/UniGraphic-St7920-Test/
Diff: Display/LCD.cpp
- Revision:
- 38:1b6f9fc49a03
- Parent:
- 36:668396f861d2
diff -r 5de028b08308 -r 1b6f9fc49a03 Display/LCD.cpp --- a/Display/LCD.cpp Wed Apr 25 20:55:59 2018 +0000 +++ b/Display/LCD.cpp Tue Oct 30 20:00:29 2018 +0000 @@ -35,7 +35,9 @@ { if(displayproto==PAR_8) proto = new PAR8(port, CS, reset, DC, WR, RD); useNOP=false; - buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //posix_memalign(void **memptr, size_t alignment, size_t size); + posix_memalign((void **)&buffer, 16,screensize_X*_LCDPAGES); buffer16 = (unsigned short*)buffer; draw_mode = NORMAL; set_orientation(1); @@ -59,7 +61,9 @@ proto = new BUS8(pins, CS, reset, DC, WR, RD); } useNOP=false; - buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //posix_memalign(void **memptr, size_t alignment, size_t size); + posix_memalign((void **)&buffer, 16,screensize_X*_LCDPAGES); buffer16 = (unsigned short*)buffer; draw_mode = NORMAL; set_orientation(1); @@ -83,7 +87,9 @@ proto = new SPI16(Hz, mosi, miso, sclk, CS, reset, DC); useNOP=true; } - buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //posix_memalign(void **memptr, size_t alignment, size_t size); + posix_memalign((void **)&buffer, 16,screensize_X*_LCDPAGES); buffer16 = (unsigned short*)buffer; draw_mode = NORMAL; // cls(); @@ -101,8 +107,11 @@ proto = new I2C_bus(Hz,address,sda,scl, reset); useNOP=false; } - buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //buffer = (unsigned char*) malloc (screensize_X*_LCDPAGES); + //posix_memalign(void **memptr, size_t alignment, size_t size); + posix_memalign((void **)&buffer, 16,screensize_X*_LCDPAGES); buffer16 = (unsigned short*)buffer; + draw_mode = NORMAL; // cls(); set_orientation(1); @@ -283,8 +292,10 @@ lenght--; } } + void LCD::pixel(int x, int y, unsigned short color) { + /* if(!(orientation&1)) SWAP(x,y); // first check parameter if((x >= screensize_X) || (y >= screensize_Y)) return; @@ -296,10 +307,12 @@ //buffer[0]=0xFF; //buffer[16]=0xAA; //buffer[1023]=0xFF; +*/ +} -} unsigned short LCD::pixelread(int x, int y) { + /* if(!(orientation&1)) SWAP(x,y); // first check parameter if((x >= screensize_X) || (y >= screensize_Y)) return 0; @@ -307,9 +320,12 @@ if((buffer[(x>>3)+(y*_IC_X_SEGS>>4)] & (1 << (7-(x&7))))==0) return 0xFFFF ; // pixel not set, White else return 0; // pixel set, Black + */ + return 0; } void LCD::copy_to_lcd(void) { + /* unsigned short i=0; unsigned short setcolcmd = 0x0010 | ((col_offset&0xF)<<8) | (col_offset>>4); for(int page=0; page<_LCDPAGES; page++) @@ -321,9 +337,11 @@ wr_grambuf(buffer16+i, screensize_X>>1); // send whole page pixels i+=screensize_X>>1; } + */ } void LCD::cls(void) { + /* unsigned short tmp = _background^0xFFFF; memset(buffer,tmp,screensize_X*_LCDPAGES); // clear display buffer unsigned short setcolcmd = 0x0010 | ((col_offset&0xF)<<8) | (col_offset>>4); @@ -335,6 +353,7 @@ wr_cmd8(0xB0|(page+page_offset)); // set page wr_gram(tmp, screensize_X>>1); // send whole page pixels = background } + */ } int LCD::sizeX() {