1- /*
2- * This is an example for using the i2c library with a monochrome OLED
3- * display based on SSD1306 drivers.
4- *
5- * The display has 128x64 pixel and uses only SCL and SDA for communication,
6- * there is no reset pin.
7- *
8- * The framebuffer needs to be kept in RAM as reading the display is not
9- * supported by the driver chips. Since the STM8S103F3 has only 1kB RAM
10- * total, we will see the stack contents in the lower part of the display
11- * as a wild bit pattern. Using drawPixel() on this memory would mess up
12- * the stack contents and would result in an immediate crash. So don't
13- * use the lower lines on low memory devices!
14- *
15- * This code is adopted from the Adafruit example code contained in the
16- * Adafruit_SSD1306 library.
17- *
18- * modified 2017 by Michael Mayer
19- */
20-
21-
221/*
232 * This is an example for using the i2c library with a monochrome OLED
243 * display based on SSD1306 drivers.
@@ -78,7 +57,7 @@ All text above, and the splash screen below must be included in any redistributi
7857# define i2c_write (A ,C ,D ) I2C_write_c(A,C,D)
7958# define i2c_write_sn (A ,C ,B ,N ) I2C_write_sn(A,C,B,N)
8059#endif
81- #include "ssd1306 .h"
60+ #include "Mini_SSD1306 .h"
8261
8362// private:
8463 static int8_t _i2caddr , _vccstate , sid , sclk , dc , rst , cs ;
@@ -171,7 +150,7 @@ static void ssd1306_command(uint8_t c);
171150
172151
173152// the most basic function, set a single pixel
174- void drawPixel (int16_t x , int16_t y , uint8_t color ) {
153+ void Mini_SSD1306_drawPixel (int16_t x , int16_t y , uint8_t color ) {
175154// if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
176155// return;
177156
@@ -202,13 +181,13 @@ void drawPixel(int16_t x, int16_t y, uint8_t color) {
202181}
203182
204183// initializer for I2C - we only indicate the reset pin!
205- void display_init (int8_t reset ) {
184+ void Mini_SSD1306_init (int8_t reset ) {
206185 sclk = dc = cs = sid = -1 ;
207186 rst = reset ;
208187}
209188
210189#if 1
211- void display_begin (uint8_t vccstate , uint8_t i2caddr , bool reset ) {
190+ void Mini_SSD1306_begin (uint8_t vccstate , uint8_t i2caddr , bool reset ) {
212191 _vccstate = vccstate ;
213192 _i2caddr = i2caddr ;
214193
@@ -295,7 +274,7 @@ void display_begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
295274}
296275#endif
297276
298- void display_invertDisplay (uint8_t i ) {
277+ void Mini_SSD1306_invertDisplay (uint8_t i ) {
299278 if (i ) {
300279 ssd1306_command (SSD1306_INVERTDISPLAY );
301280 } else {
@@ -324,7 +303,7 @@ static void ssd1306_command(uint8_t c) {
324303// Activate a right handed scroll for rows start through stop
325304// Hint, the display is 16 rows tall. To scroll the whole display, run:
326305// display.scrollright(0x00, 0x0F)
327- void display_startscrollright (uint8_t start , uint8_t stop ){
306+ void Mini_SSD1306_startscrollright (uint8_t start , uint8_t stop ){
328307 ssd1306_command (SSD1306_RIGHT_HORIZONTAL_SCROLL );
329308 ssd1306_command (0X00 );
330309 ssd1306_command (start );
@@ -339,7 +318,7 @@ void display_startscrollright(uint8_t start, uint8_t stop){
339318// Activate a right handed scroll for rows start through stop
340319// Hint, the display is 16 rows tall. To scroll the whole display, run:
341320// display.scrollright(0x00, 0x0F)
342- void display_startscrollleft (uint8_t start , uint8_t stop ){
321+ void Mini_SSD1306_startscrollleft (uint8_t start , uint8_t stop ){
343322 ssd1306_command (SSD1306_LEFT_HORIZONTAL_SCROLL );
344323 ssd1306_command (0X00 );
345324 ssd1306_command (start );
@@ -354,7 +333,7 @@ void display_startscrollleft(uint8_t start, uint8_t stop){
354333// Activate a diagonal scroll for rows start through stop
355334// Hint, the display is 16 rows tall. To scroll the whole display, run:
356335// display.scrollright(0x00, 0x0F)
357- void display_startscrolldiagright (uint8_t start , uint8_t stop ){
336+ void Mini_SSD1306_startscrolldiagright (uint8_t start , uint8_t stop ){
358337 ssd1306_command (SSD1306_SET_VERTICAL_SCROLL_AREA );
359338 ssd1306_command (0X00 );
360339 ssd1306_command (SSD1306_LCDHEIGHT );
@@ -371,7 +350,7 @@ void display_startscrolldiagright(uint8_t start, uint8_t stop){
371350// Activate a diagonal scroll for rows start through stop
372351// Hint, the display is 16 rows tall. To scroll the whole display, run:
373352// display.scrollright(0x00, 0x0F)
374- void display_startscrolldiagleft (uint8_t start , uint8_t stop ){
353+ void Mini_SSD1306_startscrolldiagleft (uint8_t start , uint8_t stop ){
375354 ssd1306_command (SSD1306_SET_VERTICAL_SCROLL_AREA );
376355 ssd1306_command (0X00 );
377356 ssd1306_command (SSD1306_LCDHEIGHT );
@@ -384,14 +363,14 @@ void display_startscrolldiagleft(uint8_t start, uint8_t stop){
384363 ssd1306_command (SSD1306_ACTIVATE_SCROLL );
385364}
386365
387- void display_stopscroll (void ){
366+ void Mini_SSD1306_stopscroll (void ){
388367 ssd1306_command (SSD1306_DEACTIVATE_SCROLL );
389368}
390369
391370// Dim the display
392371// dim = true: display is dimmed
393372// dim = false: display is normal
394- void display_dim (boolean dim ) {
373+ void Mini_SSD1306_dim (boolean dim ) {
395374 uint8_t contrast ;
396375
397376 if (dim ) {
@@ -410,7 +389,7 @@ void display_dim(boolean dim) {
410389}
411390
412391
413- void display_display (void ) {
392+ void Mini_SSD1306_display (void ) {
414393 ssd1306_command (SSD1306_COLUMNADDR );
415394 ssd1306_command (0 ); // Column start address (0 = reset)
416395 ssd1306_command (SSD1306_LCDWIDTH - 1 ); // Column end address (127 = reset)
@@ -449,6 +428,6 @@ void display_display(void) {
449428}
450429
451430// clear everything
452- void display_clearDisplay (void ) {
431+ void Mini_SSD1306_clearDisplay (void ) {
453432 memset (buffer , 0 , (SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT /8 ));
454433}
0 commit comments