Hey, im not a programmer, but i needed an 'active' state for my gui elements, so i've hacked your lib with a few lines here:
SSD1306Ascii.h:
at initialization: SSD1306Ascii() : m_magFactor(1), m_font(0), m_invert(false) {}
somewhere near set2X(): void invert() {m_invert = !m_invert;}
and at the bottom vars: bool m_invert;
and here SSD1306Ascii.cpp, function write:
after the uint8_t b = readFontByte(base + c + r*w);
line: if (m_invert) b = 0xFF - b;
and replaced the ssd1306WriteRamBuf(0); few lines below with
uint8_t v = m_invert ? 0xFF : 0;ssd1306WriteRamBuf(v);
Then within my sketch i can turn on and off this inverted colors like such:
oled.println("Hello world!."); // white on black
oled.invert();
oled.println("inverted"); // black on white
oled.invert();
oled.println("A long line may be truncated"); // white on black again
I am aware this is a dirty dirty hack, but you could include a similar functionality in the library since it doesn't take much space and is potentially quite useful...
Hey, im not a programmer, but i needed an 'active' state for my gui elements, so i've hacked your lib with a few lines here:
SSD1306Ascii.h:
SSD1306Ascii() : m_magFactor(1), m_font(0), m_invert(false) {}
void invert() {m_invert = !m_invert;}
bool m_invert;
and here SSD1306Ascii.cpp, function
write
:uint8_t b = readFontByte(base + c + r*w);
line:if (m_invert) b = 0xFF - b;
ssd1306WriteRamBuf(0);
few lines below withuint8_t v = m_invert ? 0xFF : 0;
ssd1306WriteRamBuf(v);
Then within my sketch i can turn on and off this inverted colors like such:
I am aware this is a dirty dirty hack, but you could include a similar functionality in the library since it doesn't take much space and is potentially quite useful...
cheers!