#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "U8glib.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST);
// ' 1ghz', 16x16px
const unsigned char epd_bitmap__1ghz [] PROGMEM = {
0x00, 0x00, 0x0f, 0xf0, 0x10, 0x08, 0x20, 0x04, 0x48, 0x2a, 0x5f, 0xba, 0x4c, 0x2a, 0x4c, 0x02,
0x4d, 0xba, 0x4c, 0x8a, 0x5f, 0x92, 0x40, 0x3a, 0x20, 0x04, 0x10, 0x08, 0x0f, 0xf0, 0x00, 0x00
};
// ' ducky', 16x16px
const unsigned char epd_bitmap__ducky [] PROGMEM = {
0x00, 0x00, 0x0f, 0xf0, 0x10, 0x08, 0x21, 0xf4, 0x42, 0x0a, 0x44, 0xe6, 0x41, 0x12, 0x40, 0x42,
0x43, 0xc2, 0x44, 0x42, 0x43, 0xc2, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x0f, 0xf0, 0x00, 0x00
};
// ' deauth', 16x16px
const unsigned char epd_bitmap__deauth [] PROGMEM = {
0x00, 0x00, 0x0f, 0xf0, 0x10, 0x08, 0x30, 0x04, 0x58, 0x02, 0x4f, 0xe2, 0x4e, 0x12, 0x53, 0xca,
0x45, 0xa2, 0x41, 0xc2, 0x40, 0x62, 0x40, 0x32, 0x20, 0x1c, 0x10, 0x08, 0x0f, 0xf0, 0x00, 0x00
};
// ' nfc', 16x16px
const unsigned char epd_bitmap__nfc [] PROGMEM = {
0x00, 0x00, 0x0f, 0xf0, 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x44, 0x22, 0x46, 0x22, 0x45, 0x22,
0x44, 0xa2, 0x44, 0x62, 0x44, 0x22, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x0f, 0xf0, 0x00, 0x00
};
// ' rfid', 16x16px
const unsigned char epd_bitmap__rfid [] PROGMEM = {
0x00, 0x00, 0x0f, 0xf0, 0x10, 0x08, 0x20, 0x04, 0x40, 0x1a, 0x41, 0xa2, 0x42, 0x42, 0x44, 0x22,
0x44, 0x22, 0x42, 0x42, 0x41, 0x82, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x0f, 0xf0, 0x00, 0x00
};
// ' shock', 16x16px
const unsigned char epd_bitmap__shock [] PROGMEM = {
0x00, 0x00, 0x0f, 0xf0, 0x10, 0x08, 0x20, 0x04, 0x40, 0x42, 0x40, 0x82, 0x41, 0x02, 0x43, 0xc2,
0x40, 0x82, 0x41, 0x02, 0x42, 0x02, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x0f, 0xf0, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 288)
const unsigned int total_items = 6;
const unsigned char* bitmap_icons[total_items] = {
epd_bitmap__1ghz,
epd_bitmap__deauth,
epd_bitmap__ducky,
epd_bitmap__nfc,
epd_bitmap__rfid,
epd_bitmap__shock
};
char items[total_items][20] = {
"1ghz",
"Deauth",
"Ducky",
"NFC",
"RFID",
"Shock"
};
// ' selection', 128x21px
const unsigned char bitmap_selection [] PROGMEM = {
0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0
};
// ' scrollbar', 1x61px
const unsigned char bitmap_scrollBar [] PROGMEM = {
0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
};
// ' selectiondot', 8x5px
const unsigned char bitmap_selectiondot [] PROGMEM = {
0x07, 0x07, 0x07, 0x07, 0x07
};
#define up 7
#define enter 8
#define down 12
int up_clicked = 0;
int enter_clicked = 0;
int down_clicked = 0;
int selected_item = 1;
int top_item;
int bottom_item;
void setup() {
// if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
// Serial.println(F("SSD1306 allocation failed"));
// for(;;); // Don't proceed, loop forever
// }
display.display();
u8g.setColorIndex(1);
pinMode(up, INPUT_PULLUP);
pinMode(enter, INPUT_PULLUP);
pinMode(down, INPUT_PULLUP);
}
void loop() {
if(digitalRead(up)==LOW && up_clicked == 0){
selected_item = selected_item - 1;
up_clicked = 1;
if(selected_item < 0){
selected_item = total_items - 1;
}
}
if(digitalRead(down)==LOW && down_clicked == 0){
selected_item = selected_item + 1;
down_clicked = 1;
if(selected_item >= total_items){
selected_item = 0;
}
}
if(digitalRead(up) == HIGH && up_clicked == 1){
up_clicked = 0;
}
if(digitalRead(down) == HIGH && down_clicked == 1){
down_clicked = 0;
}
top_item = selected_item - 1;
bottom_item = selected_item + 1;
if(top_item < 0){
top_item = total_items - 1;
}
if(bottom_item >= total_items){
bottom_item = 0;
}
u8g.firstPage(); // required for page drawing mode for u8g library
do {
u8g.drawBitmapP(4,2,16/8,16,bitmap_icons[top_item]);
// display.drawBitmap(4,2,bitmap_icons[top_item],16/8,16,SSD1306_WHITE);
u8g.drawBitmapP(4,24,16/8,16,bitmap_icons[selected_item]);
u8g.drawBitmapP(4,46,16/8,16,bitmap_icons[bottom_item]);
u8g.setFont(u8g_font_7x14);
u8g.drawStr(26,14,items[top_item]);
u8g.setFont(u8g_font_7x14B);
u8g.drawStr(26,37,items[selected_item]);
u8g.setFont(u8g_font_7x14);
u8g.drawStr(26,58,items[bottom_item]);
u8g.drawBitmapP(0,22,128/8,21,bitmap_selection);
u8g.drawBox(126,2,1,60);
u8g.drawBox(125, 64/total_items * selected_item, 3, 64/total_items);
} while ( u8g.nextPage() );
}