#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
// 'Menu', 128x64px
const unsigned char epd_bitmap_Menu [] 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, 0x02,
0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xc3, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x04, 0x81, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x08, 0x38, 0x50, 0x0f, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
0x09, 0x24, 0x10, 0x08, 0x80, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x02,
0x08, 0x24, 0x10, 0x08, 0x8e, 0x1c, 0x78, 0xf0, 0xe1, 0xc4, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x00,
0x08, 0x18, 0x50, 0x08, 0x91, 0x22, 0x44, 0x89, 0x12, 0x25, 0x08, 0x80, 0x00, 0x00, 0x00, 0x02,
0x08, 0x00, 0x10, 0x08, 0x81, 0x20, 0x44, 0x89, 0x10, 0x26, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00,
0x04, 0xbd, 0x20, 0x08, 0x8f, 0x1c, 0x44, 0x89, 0x11, 0xe4, 0x08, 0x80, 0x00, 0x00, 0x00, 0x02,
0x04, 0x3c, 0x20, 0x08, 0x91, 0x02, 0x44, 0x89, 0x12, 0x24, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x40, 0x08, 0x91, 0x22, 0x44, 0x89, 0x12, 0x24, 0x08, 0x80, 0x00, 0x00, 0x00, 0x02,
0x01, 0xc3, 0x80, 0x0f, 0x0f, 0x1c, 0x44, 0xf0, 0xe1, 0xe4, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
0x4f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x42, 0x20, 0x00, 0x1f, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
0x44, 0x10, 0x20, 0x19, 0x80, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x4f, 0xe8, 0x20, 0x19, 0x8f, 0x19, 0x99, 0x80, 0xf0, 0xf1, 0xf0, 0xf0, 0xf1, 0x98, 0x00, 0x12,
0x40, 0x08, 0xa0, 0x19, 0x99, 0x9b, 0x9b, 0x01, 0x99, 0x99, 0x99, 0x99, 0x99, 0xb8, 0x00, 0x10,
0x40, 0xc8, 0xa0, 0x1f, 0x01, 0x9c, 0x1e, 0x01, 0x81, 0x99, 0x99, 0x81, 0x99, 0xc0, 0x00, 0x12,
0x41, 0x2a, 0xa0, 0x18, 0x0f, 0x98, 0x1c, 0x00, 0xf1, 0xf9, 0x98, 0xf1, 0x99, 0x80, 0x00, 0x10,
0x4d, 0x28, 0xa0, 0x18, 0x19, 0x98, 0x1e, 0x00, 0x19, 0x81, 0x98, 0x19, 0x99, 0x80, 0x00, 0x12,
0x40, 0xc0, 0xa0, 0x18, 0x19, 0x98, 0x1b, 0x01, 0x99, 0x99, 0x99, 0x99, 0x99, 0x80, 0x00, 0x10,
0x40, 0x00, 0x20, 0x18, 0x0f, 0x98, 0x19, 0x80, 0xf0, 0xf1, 0x98, 0xf0, 0xf1, 0x80, 0x00, 0x12,
0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe2,
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
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, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x10, 0x1f, 0x00, 0x00, 0x80, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x04, 0x00, 0x10, 0x04, 0x00, 0x00, 0x80, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x07, 0x10, 0x04, 0x22, 0x4c, 0xf0, 0xe0, 0x20, 0x38, 0x88, 0xf1, 0xc0, 0x00, 0x00, 0x02,
0x08, 0x38, 0xe0, 0x04, 0x22, 0x50, 0x89, 0x10, 0x20, 0x44, 0x89, 0x12, 0x20, 0x00, 0x00, 0x00,
0x08, 0x6c, 0x00, 0x04, 0x22, 0x60, 0x89, 0x10, 0x26, 0x04, 0x89, 0x12, 0x20, 0x00, 0x00, 0x02,
0x08, 0x54, 0x20, 0x04, 0x22, 0x40, 0x89, 0x10, 0x22, 0x3c, 0x89, 0x13, 0xe0, 0x00, 0x00, 0x00,
0x08, 0x6c, 0x20, 0x04, 0x22, 0x40, 0x89, 0x10, 0x22, 0x44, 0x89, 0x12, 0x00, 0x00, 0x00, 0x02,
0x08, 0x38, 0x20, 0x04, 0x22, 0x40, 0x89, 0x10, 0x22, 0x44, 0x88, 0xf2, 0x20, 0x00, 0x00, 0x00,
0x04, 0x00, 0x40, 0x04, 0x1c, 0x40, 0xf0, 0xe0, 0x1e, 0x3c, 0x70, 0x11, 0xc0, 0x00, 0x00, 0x02,
0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x02,
0x01, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7c, 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, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 1040)
// 'icon_battery', 16x16px
const unsigned char epd_bitmap_icon_battery [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x40, 0x04, 0x5b, 0x66, 0x5b, 0x66,
0x5b, 0x66, 0x40, 0x04, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'icon_3dcube', 16x16px
const unsigned char epd_bitmap_icon_3dcube [] PROGMEM = {
0x00, 0x00, 0x01, 0x80, 0x07, 0x60, 0x19, 0x18, 0x61, 0x06, 0x51, 0x0a, 0x45, 0xa2, 0x41, 0x02,
0x45, 0x22, 0x41, 0x02, 0x45, 0xa2, 0x51, 0x0a, 0x61, 0x06, 0x19, 0x18, 0x07, 0x60, 0x01, 0x80
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 96)
// 'ikona_dashboard', 16x16px
const unsigned char epd_bitmap_ikona_dashboard [] PROGMEM = {
0x03, 0xc0, 0x1c, 0x38, 0x20, 0x04, 0x50, 0x82, 0x48, 0x12, 0x84, 0x01, 0x83, 0x85, 0x92, 0x41,
0x82, 0x41, 0x81, 0x85, 0x80, 0x01, 0x4b, 0xd2, 0x43, 0xc2, 0x20, 0x04, 0x1c, 0x38, 0x03, 0xc0
};
// 'ikona_senzor', 16x16px
const unsigned char epd_bitmap_ikona_senzor [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x22, 0x00, 0x41, 0x02, 0xfe, 0x82, 0x00, 0x8a, 0x0c, 0x8a,
0x12, 0xaa, 0xd2, 0x8a, 0x0c, 0x0a, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'ikona_turbo', 16x16px
const unsigned char epd_bitmap_ikona_turbo [] PROGMEM = {
0x00, 0x0e, 0x07, 0xf1, 0x18, 0x01, 0x20, 0x01, 0x40, 0x01, 0x40, 0x71, 0x83, 0x8e, 0x86, 0xc0,
0x85, 0x42, 0x86, 0xc2, 0x83, 0x82, 0x40, 0x04, 0x40, 0x04, 0x20, 0x08, 0x18, 0x30, 0x07, 0xc0
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144)
const unsigned char* bitmap_icons[5] = {
epd_bitmap_ikona_dashboard,
epd_bitmap_ikona_senzor,
epd_bitmap_ikona_turbo,
epd_bitmap_icon_3dcube,
epd_bitmap_icon_battery
};
// 'item_selected_background', 127x21px
const unsigned char epd_bitmap_item_selected_background [] PROGMEM = {
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80
};
// 'scroll_bar_background', 8x64px
const unsigned char epd_bitmap_scroll_bar_background [] PROGMEM = {
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 432)
const int NUM_ITEMS = 5;
char menu_items [NUM_ITEMS] [20] = {
{"Dashboard"},
{"Park senzor"},
{"Turbo gauge"},
{"3D Cube"},
{"Battery"}
};
#define Button_up_pin 4
#define Button_selected_pin 8
#define Button_down_pin 12
int item_selected = 0;
int item_sel_previous;
int item_sel_next;
int button_up_clicked;
int button_down_clicked;
void setup() {
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
pinMode(Button_up_pin, INPUT_PULLUP);
pinMode(Button_selected_pin, INPUT_PULLUP);
pinMode(Button_down_pin, INPUT_PULLUP);
}
void loop() {
if(digitalRead(Button_up_pin) == 0 && button_up_clicked == 0){
item_selected--;
button_up_clicked = 1;
if(item_selected < 0){item_selected = NUM_ITEMS - 1;}
}
if(digitalRead(Button_down_pin) == LOW && button_down_clicked == 0){
item_selected++;
button_down_clicked = 1;
if(item_selected >= NUM_ITEMS){item_selected = 0;}
}
if(digitalRead(Button_up_pin) == 1){button_up_clicked = 0;}
if(digitalRead(Button_down_pin) == 1){button_down_clicked = 0;}
item_sel_previous = item_selected - 1;
if(item_sel_previous < 0){item_sel_previous = NUM_ITEMS - 1;}
item_sel_next = item_selected + 1;
if(item_sel_next >= NUM_ITEMS) {item_sel_next = 0;}
u8g.firstPage();
do {
u8g.setFont(u8g_font_7x14);
u8g.drawStr(26, 17, menu_items[item_sel_previous]);
u8g.drawBitmapP(4,2, 16/8 , 16, bitmap_icons[item_sel_previous]); //draw Dasboard icon
u8g.setFont(u8g_font_7x14B);
u8g.drawStr(26, 36, menu_items[item_selected]);
u8g.drawBitmapP(4,24 , 16/8 , 16, bitmap_icons[item_selected]);//draw Park sensor icon
u8g.setFont(u8g_font_7x14);
u8g.drawStr(26, 60, menu_items[item_sel_next]);
u8g.drawBitmapP(4,46, 16/8 , 16, bitmap_icons[item_sel_next]);//draw Turbo Gauge icon
u8g.drawBitmapP(0,22, 128/8 , 21, epd_bitmap_item_selected_background);
u8g.drawBitmapP(120,0, 8/8 , 64, epd_bitmap_scroll_bar_background);
} while ( u8g.nextPage() );
}