Trust is earned, not given

A different perspective

2019-09-08 · Projects

A math practice toy, part 3: A 128x64 graphics LCD and bigger fonts

Part 3from the A math practice toy series · 4 parts in all

Part 3 of the series, Nano-MathToyMix100-12864, replaces the 16-character text LCD with a 128x64 pixel graphics LCD (the "12864" module family, ST7565/ST7920 driven). Suddenly the toy is not limited to two rows of text: big digits, drawn icons, a proper layout.

Text LCD vs. graphics LCD — what actually changes in code

A 16x2 LCD gives you lcd.print("37 + 45") and that is it. A graphics LCD gives you a pixel canvas: you choose where every glyph goes. With the u8g2 library the question becomes:

u8g2.clearBuffer();
u8g2.setFont(u8g2_font_logisoso28_tn);   // 28-pixel-tall digits
u8g2.setCursor(4, 40);
u8g2.print("37+45");
u8g2.sendBuffer();

The trade-offs beginners should know: graphics displays need more RAM for the framebuffer (that is what _F_ vs _1_ constructors choose), they are slower to update, and you now own the layout. In exchange you can draw anything.

Structure of the sketch

That last point is the lesson: because the game logic never knew about the display, swapping the entire display technology took an afternoon, not a rewrite. Repositories: Nano-MathToyMix100-12864, with parts 1–2 at NANO-MathToyPlusMinus100-1602 and NANO-MathToyMix100-1602.