#include <U8glib.h>
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0);
#define buttonUpPin 12
#define buttonSelectPin 11
#define buttonDownPin 10
#define buttonBackPin 9
int y = 10;
int clicked = 0;
void setup() {
u8g.setFont(u8g_font_unifont);
pinMode(buttonUpPin, INPUT_PULLUP);
pinMode(buttonSelectPin, INPUT_PULLUP);
pinMode(buttonDownPin, INPUT_PULLUP);
pinMode(buttonBackPin, INPUT_PULLUP);
}
void loop() {
if (digitalRead(buttonDownPin) == LOW) {
y = y + 12;
if (y > 58) {
y = 10;
}
}
if (digitalRead(buttonUpPin) == LOW) {
y = y - 12;
if (y < 5) {
y = 58;
}
}
if ((digitalRead(buttonSelectPin) == LOW) && (y == 10)) {
time();
}
if (digitalRead(buttonBackPin) == LOW) {
menu();
clicked = 1;
}
u8g.firstPage();
do {
menu();
} while (u8g.nextPage());
delay(50);
}
void menu() {
do {
u8g.drawStr(20, 10, "Time");
u8g.drawStr(20, 22, "RFID / NFC");
u8g.drawStr(20, 34, "433 mHz");
u8g.drawStr(20, 46, "Infra Red");
u8g.drawStr(20, 58, "Bad USB");
u8g.drawStr(5, y, ">");
} while (u8g.nextPage());
}
void time() {
while (clicked == 0) {
u8g.firstPage();
do {
u8g.drawStr(20, 20, "TIME");
} while (u8g.nextPage());
}
}