Skip to content

Instantly share code, notes, and snippets.

@weldtype
Created July 23, 2016 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weldtype/b07b47cec14e03c4f5f8dd94dda58125 to your computer and use it in GitHub Desktop.
Save weldtype/b07b47cec14e03c4f5f8dd94dda58125 to your computer and use it in GitHub Desktop.
/*
小型I2C接続 128x64 OLED ディスプレイの動作確認
2016/07/23 edy
このスケッチはu8glibのサンプルをカスタマイズしたものです。
Universal 8bit Graphics Library
https://github.com/olikraus/u8glib
*/
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // I2C / TWI
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
//u8g.setFont(u8g_font_courB18);
// u8g.setFont(u8g_font_helvR14);
//u8g.setFont(u8g_font_profont22);
//u8g.setFont(u8g_font_courR18);
u8g.setFont(u8g_font_10x20);
//u8g.setFont(u8g_font_fur30);
u8g.setFontPosTop();
u8g.drawStr(0, 0, " 24.9c");
u8g.drawStr(0, 23, " 51.0%");
u8g.drawStr(0, 46, "1012.0hPa");
}
void setup(void) {
u8g.setColorIndex(1); // pixel on
}
void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while ( u8g.nextPage() );
// rebuild the picture after some delay
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment