/* * display_st7920_126x64_u8g2.ino * * Test screen update speed with large solid fonts on * a 128x64 LCD screen that uses the ST7920 chip. * * Consumes 46% of program storage space and * 27% of dynamic memory on a Nano. * * Mithat Konar */ #include /* Pin assignments: RS [CE/CS/SCE]: 10 R/W [DIN/DN/MOSI/DATA]: 11 (Arduino HW standard) E [CLK/SCLK/SCK]: 13 (Arduino HW standard) PSB: ground (enable SPI) VCC/VDD: 5V GND/VSS: ground */ const unsigned int CLOCK_PIN = 13, DATA_PIN = 11, CS_PIN = 10; U8G2_ST7920_128X64_1_HW_SPI disp = U8G2_ST7920_128X64_1_HW_SPI(U8G2_R0, CS_PIN); unsigned int counter = 80; char dispStr[4]; // null terminated char array used to pass to renderer. void setup(void) { disp.begin(); disp.setColorIndex(1); } void loop(void) { counter = (counter + 1) % 1000; // picture loop disp.firstPage(); do { disp.setFont(u8g2_font_6x13_tr); disp.drawStr(0, 13, "SSD1306 u8g2"); disp.setFont(u8g2_font_logisoso46_tr); String(counter).toCharArray(dispStr, 4); disp.drawStr( 0, 63, dispStr); } while ( disp.nextPage() ); /* inherent frame rate is about 9.4 fps with 16 MHz processor (without additional delay). */ delay(500); }