#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeMono9pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define DISPLAY_WIDTH 128 // OLED display width, in pixels
#define DISPLAY_HEIGHT 64 // OLED display height, in pixels
#define OLED_ADDR 0x3C // OLED display TWI address
Adafruit_SSD1306 display(DISPLAY_WIDTH, DISPLAY_HEIGHT, &Wire, OLED_RESET);
// ' icon_home', 16x16px
const unsigned char epd_bitmap__icon_home [] PROGMEM = {
0x00, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x3f, 0xfc,
0x7f, 0xfe, 0x7f, 0xfe, 0x1f, 0xf8, 0x1f, 0xf8, 0x11, 0x18, 0x11, 0x18, 0x1f, 0x18, 0x1f, 0x18
};
// ' icon_input', 16x16px
const unsigned char epd_bitmap__icon_input [] PROGMEM = {
0x90, 0x89, 0x20, 0xc4, 0x40, 0xe2, 0x80, 0xf1, 0x00, 0xf8, 0x00, 0xfc, 0xff, 0xfe, 0xff, 0xff,
0xff, 0xfe, 0x00, 0xfc, 0x00, 0xf8, 0x00, 0xf0, 0x80, 0xe1, 0x40, 0xc2, 0x20, 0x84, 0x90, 0x09
};
// ' icon_midi', 16x16px
const unsigned char epd_bitmap__icon_midi [] PROGMEM = {
0x0c, 0x30, 0x12, 0x48, 0x23, 0xc4, 0x40, 0x02, 0x40, 0x02, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
0xb0, 0x0d, 0xb0, 0x0d, 0x80, 0x01, 0x4c, 0x32, 0x4d, 0xb2, 0x21, 0x84, 0x18, 0x18, 0x07, 0xe0
};
// ' icon_motor', 16x16px
const unsigned char epd_bitmap__icon_motor [] PROGMEM = {
0x47, 0xe2, 0x98, 0x19, 0x20, 0x04, 0x40, 0x02, 0x40, 0x02, 0x81, 0x81, 0x83, 0xc1, 0x86, 0x61,
0x86, 0x61, 0x83, 0xc1, 0x81, 0x81, 0x40, 0x02, 0x40, 0x02, 0x20, 0x04, 0x98, 0x19, 0x47, 0xe2
};
// ' icon_wifi', 16x16px
const unsigned char epd_bitmap__icon_wifi [] PROGMEM = {
0x00, 0x00, 0x03, 0xc0, 0x04, 0x20, 0x09, 0x90, 0x12, 0x48, 0x24, 0x24, 0x49, 0x92, 0x92, 0x49,
0x24, 0x24, 0x08, 0x10, 0x00, 0x00, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00
};
// ' item_sel_background', 128x21px
const unsigned char epd_bitmap__item_sel_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, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0
};
// ' scrollbar_background', 8x64px
const unsigned char epd_bitmap__scrollbar_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 = 240)
const int NUM_ITEMS = 5;
char menu_items[NUM_ITEMS][20] = {
{"INPUT"},
{"MOTOR"},
{"WIFI"},
{"MIDI"},
{"HOME"},
};
const unsigned char* bitmap_icons[5] = {
epd_bitmap__icon_input,
epd_bitmap__icon_motor,
epd_bitmap__icon_wifi,
epd_bitmap__icon_midi,
epd_bitmap__icon_home,
};
void setupDisplay(void) {
// Initialize the display object here.
if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
; // Don't proceed, loop forever
}
display.clearDisplay();
}
// drawBitmap(x, y, bitmap, size_x, size_y, colour)
void setup() {
Serial.begin(115200);
setupDisplay();
display.clearDisplay();
// Set font for labels
display.setFont(&FreeMono9pt7b); // Set normal font
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
// Prev Selection
display.drawBitmap(4, 2, bitmap_icons[0], 16, 16, SSD1306_WHITE);
display.setCursor(24, 15); // Adjust the position accordingly
display.print(menu_items[0]);
// Selected item background
display.drawBitmap(0, 22, epd_bitmap__item_sel_background, 128, 21, SSD1306_WHITE);
// Current Selection
display.setFont(&FreeMonoBold9pt7b); // Set bold font for center label
display.setCursor(24, 37);
display.print(menu_items[1]); // Center label in bold
display.drawBitmap(4, 24, bitmap_icons[1], 16, 16, SSD1306_WHITE);
// Next selection
display.setFont(&FreeMono9pt7b); // Revert to normal font for bottom label
display.drawBitmap(4, 46, bitmap_icons[2], 16, 16, SSD1306_WHITE);
display.setCursor(24, 59);
display.print(menu_items[2]);
// Scrollbar background
display.drawBitmap(120, 0, epd_bitmap__scrollbar_background, 8, 64,
SSD1306_WHITE);
display.display(); // Update the display with the new data
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}