#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
//'loading', 128x64px
const unsigned char myBitmap1 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x0a, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0xe0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x18, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'menu_1', 128x64px
const unsigned char myBitmap2 [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0x81,
0x83, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0xc1,
0x86, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x19, 0x80, 0x00, 0x80, 0x61,
0x84, 0x00, 0x78, 0x00, 0x90, 0x00, 0xc0, 0x02, 0x40, 0x78, 0x0c, 0x09, 0x00, 0x07, 0x80, 0x21,
0x84, 0x00, 0xfc, 0x00, 0x90, 0x0d, 0xec, 0x02, 0x40, 0x18, 0x1e, 0x09, 0x03, 0x84, 0x00, 0x21,
0x84, 0x01, 0xfe, 0x00, 0x90, 0x1f, 0xfe, 0x02, 0x41, 0x08, 0x3e, 0x09, 0x07, 0xcf, 0xf0, 0x21,
0x84, 0x01, 0xfe, 0x00, 0x90, 0x1f, 0xfe, 0x02, 0x41, 0x08, 0x7c, 0x09, 0x0e, 0xef, 0xf8, 0x21,
0x84, 0x01, 0xfe, 0x00, 0x90, 0x0f, 0xfc, 0x02, 0x41, 0x98, 0xf8, 0x09, 0x0c, 0x6d, 0xfc, 0x21,
0x84, 0x01, 0xfe, 0x00, 0x90, 0x1f, 0x3e, 0x02, 0x41, 0xfc, 0x70, 0x09, 0x0e, 0xef, 0xdc, 0x21,
0x84, 0x00, 0xfc, 0x00, 0x90, 0x3e, 0x1f, 0x02, 0x40, 0x0e, 0xa0, 0x09, 0x07, 0xcf, 0x8e, 0x21,
0x84, 0x00, 0x78, 0x00, 0x90, 0x3e, 0x1f, 0x02, 0x40, 0x07, 0x00, 0x09, 0x03, 0x9a, 0xde, 0x21,
0x84, 0x00, 0x00, 0x00, 0x90, 0x1f, 0x3e, 0x02, 0x40, 0x03, 0x80, 0x09, 0x08, 0x3f, 0xfe, 0x21,
0x84, 0x00, 0x00, 0x00, 0x90, 0x0f, 0xfc, 0x02, 0x40, 0x05, 0xc0, 0x09, 0x0f, 0xff, 0xfe, 0x21,
0x84, 0x01, 0xfe, 0x00, 0x90, 0x1f, 0xfe, 0x02, 0x40, 0x08, 0xe0, 0x09, 0x0f, 0xe0, 0xfe, 0x21,
0x84, 0x07, 0xff, 0x80, 0x90, 0x1f, 0xfe, 0x02, 0x40, 0x10, 0x70, 0x09, 0x07, 0xc0, 0x7c, 0x21,
0x84, 0x0f, 0xff, 0xc0, 0x90, 0x0d, 0xec, 0x02, 0x40, 0x20, 0x38, 0x09, 0x07, 0xc0, 0x7c, 0x21,
0x84, 0x1f, 0xff, 0xe0, 0x90, 0x00, 0xc0, 0x02, 0x40, 0x40, 0x18, 0x09, 0x03, 0x80, 0x38, 0x21,
0x86, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x19, 0x80, 0x00, 0x00, 0x61,
0x83, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0xc1,
0x81, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0x81,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0x81,
0x83, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0xc1,
0x86, 0x00, 0x00, 0x01, 0x98, 0x00, 0x80, 0x06, 0x60, 0x03, 0x80, 0x19, 0x80, 0x00, 0x00, 0x61,
0x84, 0x07, 0x87, 0x80, 0x90, 0x01, 0xc0, 0x02, 0x40, 0x03, 0xc0, 0x09, 0x00, 0x7f, 0x80, 0x21,
0x84, 0x0f, 0xff, 0xc0, 0x90, 0x03, 0xe0, 0x02, 0x40, 0xc3, 0x60, 0x09, 0x00, 0xf3, 0xc0, 0x21,
0x84, 0x1f, 0xff, 0xe0, 0x90, 0x70, 0x87, 0x02, 0x40, 0xe3, 0x30, 0x09, 0x01, 0xf3, 0xe0, 0x21,
0x84, 0x3f, 0xff, 0xf0, 0x90, 0x60, 0x83, 0x02, 0x40, 0x73, 0x18, 0x09, 0x03, 0xff, 0xf0, 0x21,
0x84, 0x3f, 0xff, 0xf0, 0x90, 0x51, 0xc5, 0x02, 0x42, 0x3b, 0x32, 0x09, 0x03, 0xe3, 0xf0, 0x21,
0x84, 0x7e, 0x79, 0xf8, 0x90, 0x0b, 0xe8, 0x02, 0x44, 0x1f, 0x61, 0x09, 0x03, 0xf3, 0xf0, 0x21,
0x84, 0x7c, 0x30, 0xf8, 0x90, 0x07, 0x70, 0x02, 0x45, 0x0f, 0xc5, 0x09, 0x03, 0xf3, 0xf0, 0x21,
0x84, 0x7c, 0x30, 0xf8, 0x90, 0x06, 0x30, 0x02, 0x44, 0x1f, 0x61, 0x09, 0x03, 0xf3, 0xf0, 0x21,
0x84, 0x7e, 0x79, 0xf8, 0x90, 0x07, 0x70, 0x02, 0x42, 0x3b, 0x32, 0x09, 0x03, 0xf3, 0xf0, 0x21,
0x84, 0x7f, 0xff, 0xf8, 0x90, 0x0b, 0xe8, 0x02, 0x40, 0x73, 0x18, 0x09, 0x03, 0xf3, 0xf0, 0x21,
0x84, 0x79, 0xfe, 0x78, 0x90, 0x51, 0xc5, 0x02, 0x40, 0xe3, 0x30, 0x09, 0x01, 0xf1, 0xe0, 0x21,
0x84, 0x7c, 0x00, 0xf8, 0x90, 0x60, 0x03, 0x02, 0x40, 0xc3, 0x60, 0x09, 0x00, 0xff, 0xc0, 0x21,
0x84, 0x3f, 0x03, 0xf0, 0x90, 0x70, 0x07, 0x02, 0x40, 0x03, 0xc0, 0x09, 0x00, 0x7f, 0x80, 0x21,
0x84, 0x1f, 0x03, 0xe0, 0x90, 0x00, 0x00, 0x02, 0x40, 0x03, 0x80, 0x09, 0x00, 0x00, 0x00, 0x21,
0x86, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x19, 0x80, 0x00, 0x00, 0x61,
0x83, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0xc1,
0x81, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0x81,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// Joystick pins
int x_pin = A1;
int y_pin = A0;
int s_pin = 2;
// Joystick values
int x_val;
int y_val;
int s_val;
//Joystick cursor values
int pointer_x = 3 ;
int pointer_y = 16 ;
//Setting the boundary
int cursor_x = 3 ;
int cursor_y = 16 ;
int lastPointerX = -1;
int lastPointerY = -1;
// ----- Setup -----
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
delay(20);
pinMode(x_pin, INPUT);
pinMode(y_pin, INPUT);
pinMode(s_pin, INPUT_PULLUP);
Serial.begin(9600);
//Gamepad logo
display.clearDisplay();
display.drawBitmap(0, 0, myBitmap1, 128, 64, WHITE);
display.display();
//Loading bar animation
screen_load();
}//setup() ends
// ----- Loop -----
void loop() {
joystick_control();
icon_name();
// Joystick input
x_val = analogRead(x_pin);
y_val = analogRead(y_pin);
s_val = digitalRead(s_pin);
// Debug output
Serial.print(" | Joystick: ");
Serial.print(x_val);
Serial.print(" , ");
Serial.print(y_val);
Serial.print(" , ");
Serial.println(s_val);
Serial.println(pointer_x);
Serial.println(pointer_y);
}// loop() ends
//Loading screen
void screen_load(){
display.drawRoundRect(2, 2, 124, 60, 3, WHITE); //Defining background
display.drawRoundRect(0, 0, 128, 64, 3, WHITE); //Defining background
//Loading bar & its animation
display.drawRoundRect(19, 35, -21+111, 10, 1, WHITE);
for(int i=0; i<=107; i=i+1){
display.fillRect(21, 37, i-21, 6, WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(24, 48);
display.print(" Loading ");
display.print(int (100*i)/107);
display.print("% ");
display.display();
display.fillRect(73,48,28,8,BLACK);
}
delay(2000);
display.clearDisplay();
display.display();
}//screen_load() ends
//Title of each icons
void icon_name() {
// Only update if pointer moved
if (pointer_x != lastPointerX || pointer_y != lastPointerY) {
lastPointerX = pointer_x;
lastPointerY = pointer_y;
// Clear old title area
display.fillRect(3, 1, 123, 15, BLACK);
display.setTextSize(1);
display.setTextColor(WHITE);
if (pointer_x == 3 && pointer_y == 16) {
display.setCursor(44, 6);
display.print("Profile");
}
else if (pointer_x == 33 && pointer_y == 16) {
display.setCursor(40, 6);
display.print("Settings");
}
else if (pointer_x == 63 && pointer_y == 16) {
display.setCursor(35, 6);
display.print("Input Test");
}
else if (pointer_x == 93 && pointer_y == 16) {
display.setCursor(39, 6);
display.print("Game Mode");
}
else if (pointer_x == 3 && pointer_y == 38) {
display.setCursor(43, 6);
display.print("Discord");
}
else if (pointer_x == 33 && pointer_y == 38) {
display.setCursor(5, 6);
display.print("Motion Visualisation");
}
else if (pointer_x == 63 && pointer_y == 38) {
display.setCursor(39, 6);
display.print("Bluetooth");
}
else if (pointer_x == 93 && pointer_y == 38) {
display.setCursor(52, 6);
display.print("Info");
}
display.display();
}
}
// Highlight box control using joystick
void joystick_control() {
display.drawBitmap(0, 0, myBitmap2, 128, 64, WHITE);
display.display();
//Box top
display.drawLine(pointer_x, pointer_y, pointer_x + 2, pointer_y, WHITE);
display.drawLine(pointer_x + 29, pointer_y, pointer_x + 31, pointer_y, WHITE);
//Box bottom
display.drawLine(pointer_x, pointer_y + 23, pointer_x + 2, pointer_y + 23, WHITE);
display.drawLine(pointer_x + 29 , pointer_y + 23, pointer_x + 31 , pointer_y + 23, WHITE);
//Box left
display.drawLine(pointer_x, pointer_y , pointer_x, pointer_y + 2, WHITE);
display.drawLine(pointer_x, pointer_y + 21, pointer_x, pointer_y + 23 , WHITE);
//Box right
display.drawLine(pointer_x + 31, pointer_y, pointer_x + 31, pointer_y + 2, WHITE);
display.drawLine(pointer_x + 31, pointer_y + 21, pointer_x + 31, pointer_y + 23, WHITE);
display.display();
// ---- Joystick Right ----
if (x_val == 0 && y_val == 512) {
display.drawRect(pointer_x, pointer_y, 32, 24, BLACK);
display.display();
pointer_x += 30;
if (pointer_x > 93) pointer_x = 93; // limit right boundary
//Box top
display.drawLine(pointer_x, pointer_y, pointer_x + 2, pointer_y, WHITE);
display.drawLine(pointer_x + 29, pointer_y, pointer_x + 31, pointer_y, WHITE);
//Box bottom
display.drawLine(pointer_x, pointer_y + 23, pointer_x + 2, pointer_y + 23, WHITE);
display.drawLine(pointer_x + 29 , pointer_y + 23, pointer_x + 31 , pointer_y + 23, WHITE);
//Box left
display.drawLine(pointer_x, pointer_y , pointer_x, pointer_y + 2, WHITE);
display.drawLine(pointer_x, pointer_y + 21, pointer_x, pointer_y + 23 , WHITE);
//Box right
display.drawLine(pointer_x + 31, pointer_y, pointer_x + 31, pointer_y + 2, WHITE);
display.drawLine(pointer_x + 31, pointer_y + 21, pointer_x + 31, pointer_y + 23, WHITE);
display.display();
}
// ---- Joystick Left ----
if (x_val == 1023 && y_val == 512) {
display.drawRect(pointer_x, pointer_y, 32, 24, BLACK);
display.display();
pointer_x -= 30;
if (pointer_x < 3) pointer_x = 3; // limit left boundary
//Box top
display.drawLine(pointer_x, pointer_y, pointer_x + 2, pointer_y, WHITE);
display.drawLine(pointer_x + 29, pointer_y, pointer_x + 31, pointer_y, WHITE);
//Box bottom
display.drawLine(pointer_x, pointer_y + 23, pointer_x + 2, pointer_y + 23, WHITE);
display.drawLine(pointer_x + 29 , pointer_y + 23, pointer_x + 31 , pointer_y + 23, WHITE);
//Box left
display.drawLine(pointer_x, pointer_y , pointer_x, pointer_y + 2, WHITE);
display.drawLine(pointer_x, pointer_y + 21, pointer_x, pointer_y + 23 , WHITE);
//Box right
display.drawLine(pointer_x + 31, pointer_y, pointer_x + 31, pointer_y + 2, WHITE);
display.drawLine(pointer_x + 31, pointer_y + 21, pointer_x + 31, pointer_y + 23, WHITE);
display.display();
}
// ---- Joystick Down ----
if (x_val == 512 && y_val == 0) {
display.drawRect(pointer_x, pointer_y, 32, 24, BLACK);
display.display();
pointer_y += 22;
if (pointer_y > 38) pointer_y = 38; // limit bottom boundary
//Box top
display.drawLine(pointer_x, pointer_y, pointer_x + 2, pointer_y, WHITE);
display.drawLine(pointer_x + 29, pointer_y, pointer_x + 31, pointer_y, WHITE);
//Box bottom
display.drawLine(pointer_x, pointer_y + 23, pointer_x + 2, pointer_y + 23, WHITE);
display.drawLine(pointer_x + 29 , pointer_y + 23, pointer_x + 31 , pointer_y + 23, WHITE);
//Box left
display.drawLine(pointer_x, pointer_y , pointer_x, pointer_y + 2, WHITE);
display.drawLine(pointer_x, pointer_y + 21, pointer_x, pointer_y + 23 , WHITE);
//Box right
display.drawLine(pointer_x + 31, pointer_y, pointer_x + 31, pointer_y + 2, WHITE);
display.drawLine(pointer_x + 31, pointer_y + 21, pointer_x + 31, pointer_y + 23, WHITE);
display.display();
}
// ---- Joystick Up ----
if (x_val == 512 && y_val == 1023) {
display.drawRect(pointer_x, pointer_y, 32, 24, BLACK);
display.display();
pointer_y -= 22;
if (pointer_y < 16) pointer_y = 16; // limit top boundary
//Box top
display.drawLine(pointer_x, pointer_y, pointer_x + 2, pointer_y, WHITE);
display.drawLine(pointer_x + 29, pointer_y, pointer_x + 31, pointer_y, WHITE);
//Box bottom
display.drawLine(pointer_x, pointer_y + 23, pointer_x + 2, pointer_y + 23, WHITE);
display.drawLine(pointer_x + 29 , pointer_y + 23, pointer_x + 31 , pointer_y + 23, WHITE);
//Box left
display.drawLine(pointer_x, pointer_y , pointer_x, pointer_y + 2, WHITE);
display.drawLine(pointer_x, pointer_y + 21, pointer_x, pointer_y + 23 , WHITE);
//Box right
display.drawLine(pointer_x + 31, pointer_y, pointer_x + 31, pointer_y + 2, WHITE);
display.drawLine(pointer_x + 31, pointer_y + 21, pointer_x + 31, pointer_y + 23, WHITE);
display.display();
}
}// joystick_control() ends