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:
parent
88c6b256ce
commit
1dce4908b8
|
@ -21,10 +21,12 @@ void temporary(){
|
|||
display.begin();
|
||||
|
||||
// display.clearDisplay();
|
||||
display.clear(true); // no need to call display() after to apply
|
||||
|
||||
// display.drawPixel(x, y, SSD1306_WHITE)
|
||||
// display.drawPixel(x, y, SSD1306_BLACK)
|
||||
|
||||
// display.display()
|
||||
}
|
||||
|
||||
void Display::send_command(const uint8_t c){
|
||||
|
@ -121,4 +123,35 @@ void Display::begin(){
|
|||
TRANSACTION_END
|
||||
|
||||
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
|
||||
}
|
|
@ -41,6 +41,7 @@
|
|||
public:
|
||||
void Display(const uint8_t width=128, const uint8_t height=32, const resetPin=-1);
|
||||
void begin();
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
void send_command(const uint8_t c);
|
||||
|
|
Loading…
Reference in New Issue