// U8g2 Tutorial
#include <Arduino.h>
//#include <SPI.h>
#include <U8g2lib.h>
#include <Wire.h>
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
//U8X8_SSD1306_128X64_NONAME_HW_I2C display(U8X8_PIN_NONE);
// Use with u8x8 mode
// ---------- This works! ----------
//U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
/* Use with u8g2 mode, '1' or 'F' for buffer size, 'HW' hardware 12C
1: Only one page of the display memory is stored in the microcontroller RAM.
Use a firstPage()/nextPage() loop for drawing on the display.
F: Keep a copy of the full display frame buffer in the microcontroller RAM.
Use clearBuffer() to clear the RAM and sendBuffer() to transfer the microcontroller RAM to the display.
*/
// ---------- This works! had to add 'u8g2'! ----------
// Below is the 'constructor' from u8g2setupcpp setup guide
// U8G2_SSD1306_128X64_NONAME_1_HW_I2C(rotation, [reset [, clock, data]]) [page buffer, size = 128 bytes]
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);
// Use with u8g2 mode, '1' or 'F' for buffer size, 'HW' hardware 12C
// ---------- This works! 1 Buffer ----------
//U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
void setup(void) {
u8g2.begin(); // u8g2.begin() is required and will set the setup/init sequence to the display
//u8x8.begin();
}
void loop(void) {
/*
// u8x8 mode, fast, no ram required, no graphics, write directly to display
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.drawString(0,1,"Hello World!");
*/
//*
// Full buffer mode (F) fast, but uses alot of memory
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,15,"Hello World!");
u8g2.sendBuffer();
delay(2000);
u8g2.clearBuffer();
u8g2.setCursor(0, 30);
u8g2.print("HTTP request...");
u8g2.sendBuffer();
//*/
delay(2000);
// Page buffer mode (1) all graphics supported, slow, uses less memory
/*
Page size is 8 pixels x 128 pixels. First 'page' is taken from the buffer and
drawn on the oled. Code moves to 'nextPage' and is repeated 8 times until all
pages are displayed on the oled. (8 pixels x 8 pages = 64 pixels)
*/
//*
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,15,"Do While!");
} while (u8g2.nextPage());
//*/
delay(2000);
}