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/
Graphics/TextDisplay.cpp
- Committer:
- charly
- Date:
- 2018-10-30
- Revision:
- 38:1b6f9fc49a03
- Parent:
- 0:75ec1b3cde17
File content as of revision 38:1b6f9fc49a03:
/* mbed TextDisplay Display Library Base Class * Copyright (c) 2007-2009 sford * Released under the MIT License: http://mbed.org/license/mit */ #include "TextDisplay.h" TextDisplay::TextDisplay(const char *name) : Stream(name){ _row = 0; _column = 0; if (name == NULL) { _path = NULL; } else { _path = new char[strlen(name) + 2]; sprintf(_path, "/%s", name); } } int TextDisplay::_putc(int value) { if(value == '\n') { _column = 0; _row++; if(_row >= rows()) { _row = 0; } } else { character(_column, _row, value); _column++; if(_column >= columns()) { _column = 0; _row++; if(_row >= rows()) { _row = 0; } } } return value; } // crude cls implementation, should generally be overwritten in derived class void TextDisplay::cls() { locate(0, 0); for(int i=0; i<columns()*rows(); i++) { putc(' '); } } void TextDisplay::locate(int column, int row) { _column = column; _row = row; } int TextDisplay::_getc() { return -1; } void TextDisplay::foreground(uint16_t colour) { _foreground = colour; } void TextDisplay::background(uint16_t colour) { _background = colour; } bool TextDisplay::claim (FILE *stream) { if ( _path == NULL) { fprintf(stderr, "claim requires a name to be given in the instantioator of the TextDisplay instance!\r\n"); return false; } if (freopen(_path, "w", stream) == NULL) { // Failed, should not happen return false; } // make sure we use line buffering setvbuf(stdout, NULL, _IOLBF, columns()); return true; }