User Tools

Site Tools


No renderer 'pdf' found for mode 'pdf'
arduino:displays_for_classic_arduinos:display_ssd1306_oled_u8glib.ino
display_SSD1306_OLED_u8glib.ino
/*
 * display_SSD1306_OLED_u8glib.ino
 *  
 * Test screen update speed with large solid fonts on 
 * a 128x64 OLED screen that uses the SD1306 chip.
 * 
 * Consumes 56% of program storage space and
 * 13% of dynamic memory on a Nano.
 *  
 * Mithat Konar
 */
 
 
#include "U8glib.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;
 
U8GLIB_SSD1306_128X64 disp(CS_PIN, DC_PIN, RESET_PIN);   // HW SPI
 
unsigned int counter = 80;
char dispStr[4];    // null terminated char array used to pass to renderer.
 
void setup(void) {
  disp.setColorIndex(1);
}
 
void loop(void) {
  counter = (counter + 1) % 1000;
 
  // picture loop
  disp.firstPage();
  do {
 
    disp.setFont(u8g_font_unifont);
    disp.drawStr(0, 13, "SSD1306 u8glib");
 
    disp.setFont(u8g_font_fub25r);  // the largest font with chars that ships w/ lib
    String(counter).toCharArray(dispStr, 4);
    disp.drawStr( 0, 63, dispStr);
  } while ( disp.nextPage() );
 
  // rebuild the picture after some delay
  delay(500);
}
arduino/displays_for_classic_arduinos/display_ssd1306_oled_u8glib.ino.txt · Last modified: 2018/01/28 04:09 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki