#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
// OLED display setup - adjust pins according to your wiring
// For I2C: SDA = GPIO 21, SCL = GPIO 22 (default ESP32 pins)
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
// Button pins
#define BUTTON_SELECT 0 // GPIO0 - built-in button (select/enter)
#define BUTTON_UP 2 // GPIO2 - up navigation
#define BUTTON_DOWN 4 // GPIO4 - down navigation
// Whale image data (64x42 pixels)
static const uint8_t image_whale_copy_bits[] = {
0x00,0x00,0xfe,0x03,0x00,0x00,0x00,0x00,0x00,0xe0,0x0f,0x3c,0x00,0x00,0x00,0x00,
0x00,0xf8,0x0f,0xc0,0x00,0x00,0x00,0x00,0x00,0xfc,0x1f,0x00,0x03,0x00,0x00,0x00,
0x00,0xfe,0x03,0x00,0x04,0x00,0x00,0x00,0x80,0xfd,0x03,0x00,0x08,0x00,0x00,0x00,
0x80,0xfc,0x00,0x00,0x08,0x00,0x00,0x00,0x40,0x18,0x00,0x00,0x10,0x00,0x00,0x00,
0x60,0x00,0x00,0x00,0x60,0x20,0x00,0x80,0xf0,0x00,0x00,0x1c,0x80,0x60,0x00,0xe0,
0xf0,0x01,0x00,0x3e,0x1e,0xa1,0x00,0x90,0x30,0x01,0x00,0x67,0x1e,0x21,0x07,0x8e,
0x10,0x01,0x00,0x63,0x7e,0x21,0x04,0x82,0xd8,0x01,0x00,0x7b,0xfe,0x23,0x08,0x81,
0x18,0x01,0x00,0x63,0xfe,0x23,0x90,0x80,0x18,0x01,0x00,0x63,0xfe,0x23,0x90,0x80,
0x18,0xf8,0x3f,0x60,0xfc,0x27,0x50,0x80,0x08,0xfc,0x7f,0x00,0xfc,0x27,0x50,0x80,
0x08,0x02,0x80,0x00,0xf8,0x47,0x20,0x40,0xc8,0x03,0x80,0x0f,0xf0,0xc7,0x00,0x60,
0xf8,0x83,0x87,0x3f,0x80,0x05,0x01,0x18,0xf8,0xe3,0x9f,0x7f,0x00,0x04,0x07,0x06,
0xf0,0xe7,0xdf,0x7f,0x00,0x18,0x08,0x01,0xf0,0xcf,0xcf,0xff,0x0f,0x10,0x08,0x01,
0xf0,0x9f,0xe7,0x7f,0x3c,0x10,0x08,0x01,0xf0,0x3f,0xf0,0x7f,0xe0,0x10,0x04,0x01,
0xe0,0xff,0xff,0x7f,0xc0,0x21,0x03,0x01,0xe0,0xff,0xff,0x7f,0x80,0x43,0x01,0x01,
0x20,0xff,0xff,0x3f,0x00,0x87,0x00,0x01,0x10,0xff,0xff,0x3f,0x00,0x0c,0x00,0x01,
0x10,0xff,0xff,0x3f,0x00,0x08,0x00,0x01,0x10,0xff,0xff,0x7f,0x00,0x18,0x00,0x01,
0x08,0xfe,0xff,0x7f,0x00,0x18,0x00,0x01,0x06,0xfe,0xff,0xff,0x01,0x18,0x80,0x00,
0x02,0xfc,0xff,0x3f,0x07,0x0c,0x80,0x00,0x01,0xfc,0xff,0x7f,0x0e,0x06,0x80,0x00,
0x01,0xf8,0xff,0xff,0xf8,0x01,0x40,0x00,0x01,0xf8,0xff,0xff,0xe0,0x01,0x40,0x00,
0x01,0xf8,0xff,0xff,0x01,0x00,0x20,0x00,0x01,0xff,0xff,0xff,0x03,0x00,0x20,0x00,
0xfe,0xf9,0xff,0xff,0x07,0x00,0x10,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x0f,0x00
};
// Wallet icons
static const unsigned char image_Layer_2_bits[] = {0xc3,0x86,0x01,0x00,0xe3,0x86,0x01,0x00,0x73,0x86,0x01,0x00,0x3b,0x86,0xfd,0x01,0x1f,0xfe,0xfd,0x01,0x0f,0xfe,0xc1,0x00,0x1f,0x86,0x61,0x00,0x3b,0x86,0x31,0x00,0x73,0x86,0x19,0x00,0xe3,0x86,0xfd,0x01,0xc3,0x86,0xfd,0x01};
static const unsigned char image_Layer_4_bits[] = {0xc3,0xfe,0xf1,0x00,0xc7,0xfe,0xf9,0x01,0xcf,0x06,0x0c,0x03,0xdb,0x06,0x0c,0x03,0xf3,0x7e,0x0c,0x00,0xe3,0x7e,0x0c,0x00,0xc3,0x06,0x0c,0x00,0xc3,0x06,0x0c,0x03,0xc3,0x06,0x0c,0x03,0xc3,0x06,0xf8,0x01,0xc3,0x06,0xf0,0x00};
static const unsigned char image_Layer_5_bits[] = {0x00,0x00,0x3f,0x00,0x00,0x60,0x00,0x00,0x4e,0x00,0x00,0x58,0xe7,0xb9,0x53,0x29,0x90,0x54,0xe9,0x90,0x44,0x27,0x90,0x04,0x29,0x90,0x04,0x29,0xb8,0x03};
static const unsigned char image_Layer_6_bits[] = {0x00,0xf8,0x01,0x00,0x00,0x03,0x00,0x70,0x02,0x00,0xc0,0x02,0xe9,0x99,0x02,0x2b,0xa4,0x02,0xed,0x04,0x02,0x29,0x04,0x00,0x29,0x24,0x00,0x29,0x18,0x00};
static const unsigned char image_MHz_bits[] = {0xc3,0x86,0x01,0x00,0xe7,0x86,0x01,0x00,0xff,0x86,0x01,0x00,0xff,0x86,0xfd,0x01,0xdb,0xfe,0xfd,0x01,0xdb,0xfe,0xc1,0x00,0xdb,0x86,0x61,0x00,0xc3,0x86,0x31,0x00,0xc3,0x86,0x19,0x00,0xc3,0x86,0xfd,0x01,0xc3,0x86,0xfd,0x01};
// Menu icons
static const uint8_t image_folder_open_file_bits[] = {
0x3e,0x00,0x00,0xc1,0x3f,0x00,0x01,0x40,0x00,0x01,0x40,0x00,0xf1,0xff,0x00,0x09,
0x00,0x01,0xe9,0xff,0x03,0x25,0x00,0x02,0x15,0x00,0x02,0x13,0x00,0x01,0x0b,
0x00,0x01,0x09,0x80,0x00,0x05,0x80,0x00,0xfe,0x7f,0x00
};
static const uint8_t image_Layer_4_menu_bits[] = {
0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,
0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03
};
static const uint8_t image_Layer_6_menu_bits[] = {
0x00,0x04,0x00,0x0a,0x00,0x11,0x80,0x22,0x40,0x14,0x20,0x08,0x10,0x04,0x08,0x02,
0x04,0x01,0x82,0x00,0x41,0x00,0x21,0x00,0x11,0x00,0x0f,0x00
};
static const uint8_t image_music_radio_streaming_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x40,0x00,0x02,0x80,0x00,0x12,0x90,0x00,0x09,
0x21,0x01,0xa5,0x4b,0x01,0x95,0x52,0x01,0xa5,0x4b,0x01,0x09,0x21,0x01,0x12,0x90,
0x00,0x02,0x80,0x00,0x04,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
// NFC/Card reading interface icons
static const unsigned char image_arrow_curved_right_up_down_bits[] = {0x11,0x36,0x7c,0x30,0x10};
static const unsigned char image_Layer_4_large_bits[] = {
0xff,0xff,0xff,0xff,0xff,0x01,0x01,0x00,0x00,0x00,0x00,0x03,0x01,0x00,0x00,0x00,
0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0xf1,0x07,0x00,0x00,0x00,0x05,0x11,0x04,
0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,
0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,
0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,
0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0xf1,0x07,0x00,0x00,0x00,0x05,
0x01,0x00,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x00,
0x00,0x05,0xff,0xff,0xff,0xff,0xff,0x05,0x03,0x00,0x00,0x00,0x00,0x06,0x06,0x00,
0x00,0x00,0x00,0x04,0xfc,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0x01,0x00,0x00,
0x00,0x00,0xf0,0x01,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x03,0x01,0x00,0xf0,0x01,
0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,
0xf0,0x01,0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xfe,0x0f,0x7e,0x04,
0x01,0x00,0xfc,0x07,0x99,0x04,0x01,0x00,0xf8,0x03,0xa5,0x04,0x01,0x00,0xf0,0x01,
0xa5,0x04,0x01,0x00,0xe0,0x00,0x99,0x04,0x01,0x00,0x40,0x00,0x7e,0x04,0x01,0x00,
0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,
0xf9,0x3f,0xff,0x3f,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0xf9,0x7c,0x00,0x00,
0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0xff,0xff,
0xff,0xff,0xff,0x07,0xfe,0xff,0xff,0xff,0xff,0x03
};
void displayCrackingScreen() {
static const unsigned char image_Layer_3_bits[] = {
0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0xfc,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0xc0,0x1f,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x00,0x00,0x00,0xf0,0x1f,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x00,0x00,0x00,0xf8,0x3f,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x41,0x02,0x00,0x00,0x00,0xfc,0x07,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x60,0x40,0x41,0x04,0x00,0x00,0x00,0xfb,0x07,0x00,0x10,0x00,0x00,0x00,0x00,0x30,0x50,0x40,0x41,0x04,0x00,0x00,0x00,0xf9,0x01,0x08,0x10,0x00,0x00,0x00,0x00,0x28,0x50,0x40,0x41,0x04,0x00,0x00,0x80,0x32,0x00,0x08,0x20,0x00,0x00,0x00,0x00,0x28,0x50,0x40,0x41,0x08,0x00,0x00,0xc0,0x02,0x00,0x04,0xc0,0x40,0x00,0x00,0x01,0x28,0x50,0x40,0x41,0x08,0x00,0x00,0x20,0x04,0x00,0xc2,0x00,0xc1,0x00,0xc0,0x01,0xff,0x50,0x40,0x21,0x08,0x00,0x00,0x60,0x08,0x00,0xe1,0x3c,0x42,0x01,0x20,0x01,0xff,0xff,0x5f,0x21,0x08,0x00,0x00,0xe0,0x10,0x80,0x70,0x3c,0x42,0x0e,0x1c,0x01,0xa8,0xff,0xf5,0x3f,0x08,0x00,0x00,0xe0,0x03,0x00,0x7c,0xfc,0x42,0x08,0x04,0x01,0x28,0xf8,0xfb,0x2b,0x18,0x00,0x00,0x90,0x0f,0x00,0x3f,0xfc,0x47,0x10,0x02,0x01,0x28,0x50,0xfc,0x37,0xf8,0x7f,0x00,0x10,0x0e,0x00,0x1f,0xfc,0x47,0x20,0x01,0x01,0x28,0x50,0x40,0x3f,0x58,0x80,0x00,0x10,0x00,0x00,0x06,0xfc,0x47,0x20,0x01,0x01,0x18,0x50,0x40,0x21,0x78,0xbe,0x01,0x10,0xf0,0x7f,0x00,0xf8,0x4f,0xa0,0x00,0x01,0x00,0x50,0x40,0x21,0x68,0xbe,0x01,0x10,0xf8,0xff,0x00,0xf8,0x4f,0xa0,0x00,0x01,0x00,0x30,0x40,0x21,0x44,0x80,0x02,0x10,0xfc,0xff,0x03,0xf0,0x8f,0x40,0x80,0x00,0x00,0x00,0x40,0x11,0x44,0xc0,0x02,0x90,0xff,0xff,0x1e,0xe0,0x8f,0x01,0xc0,0x00,0x00,0x00,0x40,0x11,0x42,0xc0,0x05,0xf0,0xff,0x7f,0x7e,0x00,0x0b,0x02,0x30,0x00,0x00,0x00,0xc0,0x10,0x42,0xe0,0x05,0xf0,0x07,0x00,0xff,0x00,0x08,0x0e,0x0c,0x00,0x00,0x00,0x00,0x10,0x81,0xff,0x0b,0xe0,0x0f,0x80,0xff,0x00,0x30,0x10,0x02,0x00,0x00,0x00,0x00,0x10,0x01,0xf8,0x0b,0xe0,0xff,0xff,0xff,0x1f,0x20,0x10,0x02,0x00,0x00,0x00,0x00,0x90,0x00,0xf8,0x0b,0xe0,0xff,0xff,0xff,0x78,0x20,0x10,0x02,0x00,0x00,0x00,0x00,0x48,0x00,0xf0,0x17,0xe0,0xff,0xff,0xff,0xc0,0x21,0x08,0x02,0x00,0x00,0x00,0x00,0x28,0x00,0xf0,0x17,0xc0,0xff,0xff,0xff,0x80,0x43,0x06,0x02,0x00,0x00,0x00,0x00,0x18,0x00,0xf0,0x77,0xc0,0xff,0xff,0xff,0x00,0x87,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xdf,0x40,0xfe,0xff,0x7f,0x00,0x0e,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x8f,0x61,0xfe,0xff,0x7f,0x00,0x18,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x0f,0x23,0xfe,0xff,0x7f,0x00,0x10,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0x26,0xfe,0xff,0xff,0x00,0x30,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0x3c,0xfc,0xff,0xff,0x00,0x30,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x0f,0x18,0xfc,0xff,0xff,0x03,0x30,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0f,0x00,0xf8,0xff,0x7f,0x0e,0x18,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0xf8,0xff,0xff,0x1c,0x0c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0xf0,0xff,0xff,0xf1,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0xf0,0xff,0xff,0xc1,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0xf0,0xff,0xff,0x03,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xf0,0xff,0xff,0x07,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xf0,0xff,0xff,0x0f,0x00,0x20,0x00,0x00};
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.setFont(u8g2_font_5x8_tr);
u8g2.drawStr(37, 12, "Cracking...");
u8g2.drawXBM(4, 21, 121, 43, image_Layer_3_bits);
u8g2.sendBuffer();
}
// Menu system states
enum MenuState {
WHALE_SCREEN,
MAIN_MENU,
WALLET_MENU,
WALLET_SCREEN,
READ_MENU,
WRITE_MENU,
SCANNING_SCREEN,
CRACKING_SCREEN,
LAYER_4_SCREEN
};
// Menu variables
MenuState currentState = WHALE_SCREEN;
int selectedItem = 0;
int maxItems = 3;
// Wallet data
float walletBalance = 1234.56;
String walletAddress = "1A2B3C4D5E6F7890ABCDEF";
String lastTransaction = "Received 0.05 BTC";
// Button debouncing
unsigned long lastButtonPress = 0;
const unsigned long debounceDelay = 200;
void setup() {
Serial.begin(115200);
Serial.println("ESP32 OLED Wallet System Starting...");
// Initialize button pins
pinMode(BUTTON_SELECT, INPUT_PULLUP);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
// Initialize display
u8g2.begin();
u8g2.enableUTF8Print();
// Display the whale screen initially
displayWhale();
Serial.println("System initialized successfully!");
}
void loop() {
handleButtons();
delay(50);
}
void handleButtons() {
unsigned long currentTime = millis();
// Debounce check
if (currentTime - lastButtonPress < debounceDelay) {
return;
}
// Check SELECT button
if (digitalRead(BUTTON_SELECT) == LOW) {
lastButtonPress = currentTime;
handleSelectButton();
}
// Check UP button (only in menus)
if (digitalRead(BUTTON_UP) == LOW && currentState != WHALE_SCREEN && currentState != WALLET_SCREEN) {
lastButtonPress = currentTime;
handleUpButton();
}
// Check DOWN button (only in menus)
if (digitalRead(BUTTON_DOWN) == LOW && currentState != WHALE_SCREEN && currentState != WALLET_SCREEN) {
lastButtonPress = currentTime;
handleDownButton();
}
}
void handleSelectButton() {
switch (currentState) {
case WHALE_SCREEN:
currentState = MAIN_MENU;
selectedItem = 0;
displayMainMenu();
break;
case MAIN_MENU:
switch (selectedItem) {
case 0: // Wallet
currentState = WALLET_SCREEN;
displayWalletScreen();
break;
case 1: // Read
currentState = READ_MENU;
selectedItem = 0;
maxItems = 3;
displayReadMenu();
break;
case 2: // Write
currentState = WRITE_MENU;
selectedItem = 0;
maxItems = 3;
displayWriteMenu();
break;
}
break;
case WALLET_SCREEN:
currentState = MAIN_MENU;
selectedItem = 0;
displayMainMenu();
break;
case READ_MENU:
if (selectedItem == 0) { // Back
currentState = MAIN_MENU;
selectedItem = 1; // Keep Read menu highlighted when returning
displayMainMenu();
}
else if (selectedItem == 1) { // Scan QR
currentState = SCANNING_SCREEN;
displayCardReader();
}
else { // Import
handleSubMenuAction();
}
break;
case WRITE_MENU:
if (selectedItem == 0) { // Back
currentState = MAIN_MENU;
selectedItem = 2; // Keep Write menu highlighted when returning
displayMainMenu();
}
else if (selectedItem == 1) { // Send
handleSubMenuAction();
}
else { // Generate
handleSubMenuAction();
}
break;
case SCANNING_SCREEN:
currentState = CRACKING_SCREEN;
displayCrackingScreen();
break;
case LAYER_4_SCREEN:
currentState = CRACKING_SCREEN;
displayCrackingScreen();
break;
case CRACKING_SCREEN:
currentState = MAIN_MENU;
selectedItem = 1; // Return to Read menu
displayMainMenu();
break;
default:
if (selectedItem == 0) { // Back option
currentState = MAIN_MENU;
selectedItem = 0;
maxItems = 3;
displayMainMenu();
} else {
handleSubMenuAction();
}
break;
}
}
void handleUpButton() {
selectedItem--;
if (selectedItem < 0) {
selectedItem = maxItems - 1;
}
updateDisplay();
}
void handleDownButton() {
selectedItem++;
if (selectedItem >= maxItems) {
selectedItem = 0;
}
updateDisplay();
}
void updateDisplay() {
switch (currentState) {
case MAIN_MENU:
displayMainMenu();
break;
case WALLET_MENU:
displayWalletMenu();
break;
case READ_MENU:
displayReadMenu();
break;
case WRITE_MENU:
displayWriteMenu();
break;
}
}
void handleSubMenuAction() {
u8g2.clearBuffer();
switch (currentState) {
case WALLET_MENU:
switch (selectedItem) {
case 1: // Balance
displayWalletScreen();
return;
case 2: // Address
u8g2.setFont(u8g2_font_profont12_tr);
u8g2.drawStr(10, 15, "Full Address:");
u8g2.setFont(u8g2_font_profont10_tr);
u8g2.drawStr(10, 30, walletAddress.c_str());
break;
case 3: // History
u8g2.setFont(u8g2_font_profont12_tr);
u8g2.drawStr(10, 15, "Last Transaction:");
u8g2.drawStr(10, 30, lastTransaction.c_str());
break;
}
break;
case READ_MENU:
switch (selectedItem) {
case 1: // Scan QR
displayCardReader();
return;
case 2: // Import
currentState = WALLET_SCREEN;
displayWalletScreen();
return;
}
break;
case WRITE_MENU:
switch (selectedItem) {
case 1: // Send
u8g2.setFont(u8g2_font_profont12_tr);
u8g2.drawStr(10, 20, "Send Bitcoin");
u8g2.drawStr(10, 40, "Enter address");
break;
case 2: // Generate
u8g2.setFont(u8g2_font_profont12_tr);
u8g2.drawStr(10, 20, "Generate Address");
u8g2.drawStr(10, 40, "New address created");
// Update wallet address to show it changed
walletAddress = "NewAddr" + String(random(1000, 9999));
break;
}
break;
}
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(10, 60, "Press SELECT to return");
u8g2.sendBuffer();
}
void displayCardReader() {
u8g2.clearBuffer();
// Set font and drawing modes
u8g2.setFontMode(1); // Transparent font mode
u8g2.setBitmapMode(1); // Transparent bitmap mode
u8g2.setFont(u8g2_font_4x6_tr); // Small 4x6 pixel font
// Draw text
u8g2.drawStr(14, 7, "Place the card or the tag");
u8g2.drawStr(12, 14, "on the back and hold still");
// Draw main image (43x47 pixels at position 42,16)
u8g2.drawXBM(42, 16, 43, 47, image_Layer_4_large_bits);
// Draw "start" text and small arrow
u8g2.drawStr(102, 56, "start");
u8g2.drawXBM(113, 58, 7, 5, image_arrow_curved_right_up_down_bits);
// Send the buffer to the display
u8g2.sendBuffer();
}
void displayWhale() {
u8g2.clearBuffer();
u8g2.setBitmapMode(1);
u8g2.setFontMode(1);
// Draw the whale image
u8g2.drawXBM(32, 23, 64, 42, image_whale_copy_bits);
// Draw "Willy" text
u8g2.setFont(u8g2_font_profont17_tr);
u8g2.drawStr(42, 16, "Willy");
// Draw "Press select" text
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.sendBuffer();
}
void displayWalletScreen() {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
// Draw wallet icons
u8g2.drawXBM(6, 6, 25, 11, image_MHz_bits);
u8g2.drawXBM(6, 19, 25, 11, image_Layer_2_bits);
// Draw NFC label
u8g2.setFont(u8g2_font_profont10_tr);
u8g2.drawStr(7, 42, "NFC");
// Draw additional wallet icons
u8g2.drawXBM(37, 6, 26, 11, image_Layer_4_bits);
u8g2.drawXBM(29, 32, 23, 10, image_Layer_5_bits);
u8g2.drawXBM(7, 32, 18, 10, image_Layer_6_bits);
// Draw wallet text info
u8g2.setFont(u8g2_font_profont11_tr);
u8g2.drawStr(84, 18, "Balance:");
u8g2.drawStr(84, 30, String(walletBalance, 2).c_str());
u8g2.drawStr(84, 42, walletAddress.substring(0, 6).c_str());
u8g2.drawStr(84, 54, "...");
u8g2.sendBuffer();
}
void displayMainMenu() {
u8g2.clearBuffer();
u8g2.setBitmapMode(1);
u8g2.setFontMode(1);
// Draw menu background boxes with selection highlight
for (int i = 0; i < 3; i++) {
if (i == selectedItem) {
// Highlight selected item
u8g2.setDrawColor(1);
u8g2.drawBox(0, 1 + i * 21, 128, 20);
u8g2.setDrawColor(0); // Invert text color for selected item
} else {
u8g2.setDrawColor(1);
}
u8g2.drawXBM(2, 1 + i * 21, 124, 20, image_Layer_4_menu_bits);
}
// Reset draw color
u8g2.setDrawColor(1);
// Draw icons and text for each menu item
u8g2.drawXBM(17, 3, 18, 14, image_folder_open_file_bits);
u8g2.setFont(u8g2_font_profont17_tr);
if (selectedItem == 0) u8g2.setDrawColor(0);
u8g2.drawStr(48, 16, "Wallet");
u8g2.setDrawColor(1);
u8g2.drawXBM(17, 24, 17, 16, image_music_radio_streaming_bits);
if (selectedItem == 1) u8g2.setDrawColor(0);
u8g2.drawStr(49, 37, "Read");
u8g2.setDrawColor(1);
u8g2.drawXBM(19, 45, 14, 14, image_Layer_6_menu_bits);
if (selectedItem == 2) u8g2.setDrawColor(0);
u8g2.drawStr(49, 58, "Write");
u8g2.sendBuffer();
}
void displayWalletMenu() {
static const char* walletItems[] = {"< Back", "Balance", "Address", "History"};
displaySubMenu("WALLET MENU", walletItems, 4);
}
void displayReadMenu() {
static const char* readItems[] = {"< Back", "Scan QR", "Import"};
displaySubMenu("READ MENU", readItems, 3);
}
void displayWriteMenu() {
static const char* writeItems[] = {"< Back", "Send", "Generate"};
displaySubMenu("WRITE MENU", writeItems, 3);
}
void displaySubMenu(const char* title, const char* items[], int itemCount) {
u8g2.clearBuffer();
// Draw title
u8g2.setFont(u8g2_font_profont12_tr);
u8g2.drawStr(5, 10, title);
u8g2.drawHLine(0, 12, 128);
// Draw menu items
u8g2.setFont(u8g2_font_profont10_tr);
for (int i = 0; i < itemCount; i++) {
if (i == selectedItem) {
// Highlight selected item
u8g2.drawBox(0, 15 + i * 12, 128, 10);
u8g2.setDrawColor(0); // Invert text color for selected item
u8g2.drawStr(5, 23 + i * 12, items[i]);
u8g2.setDrawColor(1);
} else {
u8g2.drawStr(5, 23 + i * 12, items[i]);
}
}
u8g2.sendBuffer();
}Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1