olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.24k stars 313 forks source link

Drawing string without re-drawing all screen #485

Closed zmechu closed 5 years ago

zmechu commented 5 years ago

Hello!

I have simple questiuon. Got 128x64 OLED I2C display, which forks fine with u8glib. But as I see, to update screen informations, I must execute: u8g.firstPage(); do {
draw();
} while( u8g.nextPage() ); where draw(); got all drawing procedures I need (strings, graphics, data etc), which is re-draw all every time.

But is there a way to re-daw ONLY selected part. For example, I have: u8g.setPrintPos(0, 20);u8g.print(" SIGNAL:");u8g.print(x); where string " SIGNAL:" didnt change at all, only "x" changes. It is not nessesary to draw " SIGNAL:" all the time.

Is there a way to draw " SIGNAL:" once at start and further draw only "x" data, look like: void setup () { [...] u8g.setPrintPos(0, 20);u8g.print(" SIGNAL:"); [...] }

void loop() { [...] u8g.setPrintPos(0, 40);u8g.print(x); [...] }

olikraus commented 5 years ago

In u8g2 you can use full buffer mode to do a partial update.

zmechu commented 5 years ago

Thank you for your answer! I've tested speed and U8G2 with: U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, / reset=/ U8X8_PIN_NONE); and U8GLIB with U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST); // Fast I2C / TWI seems to be slowest (about 1.5-2 times slower), so I would like to stay with older lib :-)

So, there is not possible to do "partial" screen update?

olikraus commented 5 years ago

No, the full buffer mode was newly introduced with U8g2.

zmechu commented 5 years ago

OK! Thank you for great job :-)