add clear() method with no need to apply afterwards

- it would be bufferred if the cost is low later if it brings flicker, but for now let's consider that it will be fast enough and if we can avoid buffering, we would
This commit is contained in:
Adrien Marquès 2020-05-30 19:29:36 +02:00
parent 88c6b256ce
commit 1dce4908b8
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
2 changed files with 34 additions and 0 deletions

View File

@ -21,10 +21,12 @@ void temporary(){
display.begin(); display.begin();
// display.clearDisplay(); // display.clearDisplay();
display.clear(true); // no need to call display() after to apply
// display.drawPixel(x, y, SSD1306_WHITE) // display.drawPixel(x, y, SSD1306_WHITE)
// display.drawPixel(x, y, SSD1306_BLACK) // display.drawPixel(x, y, SSD1306_BLACK)
// display.display()
} }
void Display::send_command(const uint8_t c){ void Display::send_command(const uint8_t c){
@ -121,4 +123,35 @@ void Display::begin(){
TRANSACTION_END TRANSACTION_END
return; return;
}
void Display::clear(){
TRANSACTION_START
static const uint8_t PROGMEM dlist1[] = {
DSP_PAGEADDR,
0, // Page start address
0xFF, // Page end (not really, but works here)
DSP_COLUMNADDR,
0 // Column start address
};
send_commands(dlist1, sizeof(dlist1));
send_command(_width - 1); // Column end address
_wire->beginTransmission(_i2caddr);
_wire->write((uint8_t) 0x40);
uint16_t count = _width * ((_height + 7) / 8);
uint8_t written = 1;
while(count--){
if( written >= WIRE_MAX ){
_wire->endTransmission();
_wire->beginTransmission(_i2caddr);
_wire->write((uint8_t) 0x40);
written = 1;
}
_wire->write(0);
}
_wire->endTransmission();
TRANSACTION_END
} }

View File

@ -41,6 +41,7 @@
public: public:
void Display(const uint8_t width=128, const uint8_t height=32, const resetPin=-1); void Display(const uint8_t width=128, const uint8_t height=32, const resetPin=-1);
void begin(); void begin();
void clear();
protected: protected:
void send_command(const uint8_t c); void send_command(const uint8_t c);