ThingPulse OLED SSD1306

Dependents:   Turtle_RadioShuttle mbed-os5-F303-18650-Manager-tp4056 Kretanje_kroz_izbornike_OLED128x64_4tipke

Files at this revision

API Documentation at this revision

Comitter:
Helmut Tschemernjak
Date:
Thu Jun 06 09:29:02 2019 +0200
Parent:
2:4ed55dfe5be7
Commit message:
Updated with latest version for github

Changed in this revision

OLEDDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
OLEDDisplay.h Show annotated file Show diff for this revision Revisions of this file
diff -r 4ed55dfe5be7 -r 99a409809366 OLEDDisplay.cpp
--- a/OLEDDisplay.cpp	Wed May 29 11:17:58 2019 +0200
+++ b/OLEDDisplay.cpp	Thu Jun 06 09:29:02 2019 +0200
@@ -33,7 +33,6 @@
   * TODO Helmut
   * - test/finish dislplay.printf() on mbed-os
   * - Finish _putc with drawLogBuffer when running display
-  * - Fix problem that the x is larger than 0 (somehow shifted display) on single buffer
   */
 
 #include "OLEDDisplay.h"
@@ -134,6 +133,17 @@
   }
 }
 
+void OLEDDisplay::clearPixel(int16_t x, int16_t y) {
+  if (x >= 0 && x < this->width() && y >= 0 && y < this->height()) {
+    switch (color) {
+      case BLACK:   buffer[x + (y / 8) * this->width()] |=  (1 << (y & 7)); break;
+      case WHITE:   buffer[x + (y / 8) * this->width()] &= ~(1 << (y & 7)); break;
+      case INVERSE: buffer[x + (y / 8) * this->width()] ^=  (1 << (y & 7)); break;
+    }
+  }
+}
+
+
 // Bresenham's algorithm - thx wikipedia and Adafruit_GFX
 void OLEDDisplay::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1) {
   int16_t steep = abs(y1 - y0) > abs(x1 - x0);
diff -r 4ed55dfe5be7 -r 99a409809366 OLEDDisplay.h
--- a/OLEDDisplay.h	Wed May 29 11:17:58 2019 +0200
+++ b/OLEDDisplay.h	Thu Jun 06 09:29:02 2019 +0200
@@ -179,6 +179,9 @@
     // Draw a pixel at given position
     void setPixel(int16_t x, int16_t y);
 
+    // Clear a pixel at given position FIXME: INVERSE is untested with this function
+    void clearPixel(int16_t x, int16_t y);
+
     // Draw a line from position 0 to position 1
     void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1);