mp3 thing — Esp32 Devkit C V4 simulation

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by zenos-vn0.

Components

Sketch code

#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

#define TFT_CS   15
#define TFT_DC   2
#define TFT_RST  4
#define SD_CS    5

#define DISP_W   320
#define DISP_H   240

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

// Bang mau co dinh
#define C_BLUE      0x001F
#define C_GREEN     0x07E0
#define C_ORANGE    0xFD20
#define C_CYAN      0x07FF
#define C_PURPLE    0x781F
#define C_YELLOW    0xFFE0
#define C_RED       0xF800
#define C_GRAY      0x8410
#define C_WHITE     0xFFFF
#define C_BLACK     0x0000
#define SPOT_GREEN  0x07E0

// Custom Accent Color (0: Cyan, 1: Blue, 2: Green, 3: Red, 4: Yellow, 5: Orange, 6: Gray, 7: Purple)
int accentPreset = 0;
const int ACCENT_COUNT = 8;
const uint16_t accentPalette[ACCENT_COUNT] = {
  0x07FF, // Cyan
  0x03DF, // Sky Blue
  0x07E0, // Neon Green
  0xF800, // Red
  0xFFE0, // Yellow
  0xFD20, // Orange
  0x9492, // Silver Gray
  0xC81F  // Vivid Purple
};
const char* accentNamesEN[ACCENT_COUNT] = {
  "Cyan", "Blue", "Green", "Red", "Yellow", "Orange", "Gray", "Purple"
};
const char* accentNamesVI[ACCENT_COUNT] = {
  "Xanh Ngoc", "Xanh Duong", "Xanh La", "Do", "Vang", "Cam", "Xam", "Tim"
};

// Bang mau dong theo Light / Dark Mode + Custom Accent
bool darkMode = true;
uint16_t C_BG     = 0x0000;
uint16_t C_PANEL  = 0x18E3;
uint16_t C_HEADER = 0x294A;
uint16_t C_TEXT   = 0xFFFF;
uint16_t C_MUTED  = 0xBDF7;
uint16_t C_DARK   = 0x0000;
uint16_t C_ACCENT = 0x07FF;

// Ngon ngu: false = English, true = Tieng Viet
bool langVI = false;

// Chan dieu khien
#define ENC_CLK        14
#define ENC_DT         34
#define ENC_SW         33
#define PIN_HOME       13
#define PIN_VOLUP      16
#define PIN_VOLDN      17
#define PIN_BUZZER     25
#define PIN_WASD_A     26
#define PIN_WASD_W     32
#define PIN_WASD_S     27
#define PIN_WASD_D     21
#define PIN_E_TUONGTAC 22

enum ScreenState {
  SCR_MENU,
  SCR_MUSIC,
  SCR_PLAYER,
  SCR_PHOTOS,
  SCR_VIDEOS,
  SCR_FILES,
  SCR_BLUETOOTH,
  SCR_SETTINGS,
  SCR_WALLPAPER,
  SCR_SET_TIME,
  SCR_CLOCK,
  SCR_OFF
};

ScreenState currentScreen = SCR_CLOCK;
ScreenState lastDrawnScreen = SCR_OFF;

// Menu chinh
int menuIndex = 0;
int lastMenuIndex = 0;
const int MENU_COUNT = 6;
const char* menuItemsEN[MENU_COUNT] = {"Music", "Photos", "Videos", "Files", "Bluetooth", "Settings"};
const char* menuItemsVI[MENU_COUNT] = {"Nghe Nhac", "Hinh Anh", "Video", "Tep Tin", "Bluetooth", "Cai Dat"};

// Danh sach nhac that doc tu the SD
const int MAX_TRACKS = 16;
String trackTitles[MAX_TRACKS];
int trackLengthsSec[MAX_TRACKS];
int trackCount = 0;
int selectedTrack = 0;
bool isPlaying = false;
int trackElapsedSec = 0;
unsigned long lastPlayTick = 0;

// Danh sach anh that doc tu the SD (khong chua anh nen he thong)
const int MAX_PHOTOS = 16;
String sdPhotoList[MAX_PHOTOS];
int sdPhotoCount = 0;
int selectedPhoto = 0;

// Anh nen he thong chi dung cho Lock Screen & Wallpaper Settings
const char* wallpaperName = "WinXP