User Tools

Site Tools


arduino:displays_for_classic_arduinos:display_st7920_126x64_u8g2.ino

This is an old revision of the document!


display_st7920_126x64_u8g2.ino
/*
 * 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 <U8g2lib.h>
 
/*
   Pin assignments:
   RST: 8
   CE/CS/SCE: 10
   DC/"D/C"/A0: 9
   DIN/DN/MOSI/DATA: 11 (Arduino HW standard)
   CLK/SCLK/SCK: 13  (Arduino HW standard)
   VCC: 5V (part is allegedly 5V tolerant)
   GND: ground
*/
 
const unsigned int CLOCK_PIN = 13,
                   DATA_PIN = 11,
                   CS_PIN = 10,
                   DC_PIN = 9,
                   RESET_PIN = 8;
 
U8G2_ST7920_128X64_1_HW_SPI disp = U8G2_ST7920_128X64_1_HW_SPI(U8G2_R0, CS_PIN, RESET_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);
}
arduino/displays_for_classic_arduinos/display_st7920_126x64_u8g2.ino.1519437695.txt.gz · Last modified: 2018/02/24 02:01 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki