User Tools

Site Tools


arduino:displays_for_classic_arduinos:display_ssd1306_oled_u8g2.ino
display_SSD1306_OLED_U8g2.ino
/*
 * display_SSD1306_OLED_U8g2lib.ino
 *  
 * Test screen update speed with large solid fonts on 
 * a 128x64 OLED screen that uses the SD1306 chip.
 * 
 * Consumes 46% of program storage space and
 * 28% 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_SSD1306_128X64_NONAME_1_4W_HW_SPI disp = U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI(U8G2_R0, CS_PIN, DC_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 13 fps with 16 MHz processor 
     (without additional delay). */
  delay(500);
}
arduino/displays_for_classic_arduinos/display_ssd1306_oled_u8g2.ino.txt · Last modified: 2018/02/24 01:45 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki