ThingPulse OLED SSD1306

Dependents:   Turtle_RadioShuttle

Revision:
3:99a409809366
Parent:
2:4ed55dfe5be7
--- 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);