add 2 variables to the class:
uint8_t m_underline; // Underline flag.
uint8_t m_inverse; // Inverse flag.
add 2 set methods:
/**
@brief Set the flag for underlining.
*/
void setU(uint8_t flag) {m_underline = flag;}
/**
@brief Set the flag for inverse display
*/
void setI(uint8_t flag) {m_inverse = flag;}
change the init method (add 2 lines):
m_underline=0;
m_inverse=0;
change the write method:
ssd1306WriteRamBuf((b);
to
ssd1306WriteRamBuf((b|m_underline)^m_inverse);
and
ssd1306WriteRamBuf(0);
to
ssd1306WriteRamBuf(m_underline^m_inverse);
inverse (a little bit more tricky, because you have to underline the previous line completely and pad both prev. line and current line with blanks (to avoid missing inverted dots):
if(line==invertedLine)
{
oled.setU(128);
oled.setI(127);
oled.print(' ');
uint8_t ml=strlen(Strings[line);
strcpy((char*)gbuf,Strings[line]);
if(ml<16)
{
for (size_t s = ml ;s < 16; s++) {
gbuf[s]=' ';
}
gbuf[16]=0;
}
oled.print((char *)gbuf);
}
if(line== invertedLine-1)
{
oled.setU(128);
uint8_t ml=strlen(Strings[line]);
strcpy((char*)gbuf,Strings[line]);
if(ml<16)
{
for (size_t s = ml ;s < 16; s++) {
gbuf[s]=' ';
}
gbuf[16]=0;
}
oled.print((char *)gbuf);
}
// normal display:
oled.setU(0);
oled.setI(0);
Doing underlining and inverting is quite easy:
add 2 variables to the class: uint8_t m_underline; // Underline flag. uint8_t m_inverse; // Inverse flag.
add 2 set methods: /**
change the init method (add 2 lines): m_underline=0; m_inverse=0;
change the write method: ssd1306WriteRamBuf((b); to ssd1306WriteRamBuf((b|m_underline)^m_inverse); and ssd1306WriteRamBuf(0); to ssd1306WriteRamBuf(m_underline^m_inverse);
Usage: underline:
inverse (a little bit more tricky, because you have to underline the previous line completely and pad both prev. line and current line with blanks (to avoid missing inverted dots):
I think, the code should be integrated.