#include "U8glib.h"
const char err[] PROGMEM = {"1234"};
char msg[] = {"abcd"};
char msg2[4];
U8GLIB_SSD1306_128X64 u8g; // create an instant of OLED display
int i2=0;
void setup() {
Serial.begin(9600);
Serial.println("test");
Serial.println(msg);
for (byte i = 0; i < strlen(err); i++) {
// we need to recall each char one byte at a time, and
// use the i as an incrementer to get each new byte in a sequence
char c = pgm_read_byte_near(err + i);
msg2[i]=c;
Serial.println(c);
}
Serial.println(msg2);
u8g.setFont(u8g_font_7x13); // set the font for text
//u8g.setColorIndex(1); set the display colour can be done outside picture loop
}
int x = 0;
void loop() {
if (x < 108){
x = x + 6;
}else{
x = 0;
}
u8g.setColorIndex(1); // set the colour to white
u8g.drawStr(0, 50, "hello");
u8g.firstPage(); //marks the beginning of the picture loop.
do {
u8g.setColorIndex(1); // set the colour to white
u8g.drawStr(i2, 50, "Christian"); //display "hello world" text (0,50)
u8g.drawStr(i2, 10, "123456789");
u8g.drawStr(i2, 24, msg);
u8g.drawStr(i2, 30, msg2);
i2=i2+1;
delay(100);
//note (X,Y) position is the lower left corner of the first character of the string
// u8g.drawStr(0, 5, "hello world"); //Y position = 5 < height of texts so cant see the text fully.
// u8g.drawFrame(0, 10, 128, 20); //draw frame at (0,10) with width = 128, height = 20
// u8g.drawBox(10, 15, x, 10); //draw box at (10,15) with width = x, height = 10
//in drawBox and drawFrame, (X,Y) position is upper left edge
// u8g.drawCircle(110,50,10); // draw circle with centre at (110,50) and radius = 20
u8g.setColorIndex(0); //change the colour back to black
u8g.drawPixel(15,18); //update the colour of pixel at (15,18) to black colour
} while ( u8g.nextPage() ); //marks the end of the body of the picture loop
u8g.setColorIndex(1);
u8g.drawStr(0, 20, "outside");
//drawing function must use inside the picture loop.
}