Alex — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by alexkz333.

Components

Sketch code

// ============================================================
// TUFMON MEV 281
// ESP32 DevKit V1
// ============================================================

// ---------------- SEGMENTS ----------------
const int SEG_A = 4;
const int SEG_B = 5;
const int SEG_C = 15;
const int SEG_D = 2;
const int SEG_E = 18;
const int SEG_F = 19;
const int SEG_G = 21;

// ---------------- DIGITS -----------------
const int DIG1 = 22;
const int DIG2 = 23;
const int DIG3 = 25;
const int DIG4 = 26;

// ---------------- BUTTONS ----------------
const int BTN_DOWN  = 27;
const int BTN_ENTER = 32;
const int BTN_UP    = 33;

const int segPins[7]   = { SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G };
const int digitPins[4] = { DIG1, DIG2, DIG3, DIG4 };

// 7-SEGMENT SYMBOLS (A-G)
const byte NUM[10][7] = {
  {1,1,1,1,1,1,0}, // 0
  {0,1,1,0,0,0,0}, // 1
  {1,1,0,1,1,0,1}, // 2
  {1,1,1,1,0,0,1}, // 3
  {0,1,1,0,0,1,1}, // 4
  {1,0,1,1,0,1,1}, // 5
  {1,0,1,1,1,1,1}, // 6
  {1,1,1,0,0,0,0}, // 7
  {1,1,1,1,1,1,1}, // 8
  {1,1,1,1,0,1,1}  // 9
};

const byte LETTER_P[7] = {1,1,0,0,1,1,1};
const byte BLANK[7]    = {0,0,0,0,0,0,0};

byte displayBuffer[4][7];

// ============================================================
// PARAMETERS STRUCT
// ============================================================

struct Parameter {
  int number;
  long value;
  long minimum;
  long maximum;
};

Parameter parameters[] = {
  { 0, 0,     0,     99999 },
  { 1, 150,   60,    300   },
  { 2, 250,   100,   1800  },
  { 4, 2000,  0,     9999  },
  { 5, 0,     0,     1     },
  { 11, 6,    0,     999   },
  { 12, 8,    0,     999   },
  { 14, 9,    0,     999   },
  { 15, 9,    0,     999   },
  { 16, 1000, 0,     9999  },
  { 20, 9,    0,     999   },
  { 21, 1,    0,     1     },
  { 22, 125,  0,     9999  },
  { 23, 1,    0,     1     },
  { 26, 50,   0,     9999  },
  { 27, 60,   0,     9999  },
  { 28, 6,    0,     999   },
  { 31, 0,    0,     1     },
  { 32, 1,    0,     1     },
  { 33, 1,    0,     1     },
  { 34, 1,    0,     1     },
  { 35, 0,    0,     9999  },
  { 36, 0,    0,     9999  },
  { 37, 0,    0,     2359  },
  { 38, 0,    0,     3112  },
  { 39, 0,    0,     9999  },
  { 40, 0,    0,     1     },
  { 41, 2,    0,     2     },
  { 47, 4,    0,     15    },
  { 48, 1,    0,     15    },
  { 52, 4,    0,     15    },
  { 53, 2,    0,     15    },
  { 54, 1,    0,     15    },
  { 62, 8,    0,     15    },
  { 63, 8,    0,     15    },
  { 64, 8,    0,     15    },
  { 69, 7400, 7100,  9999  }
};

const int PARAM_COUNT = sizeof(parameters) / sizeof(parameters[0]);

enum State {
  MODE_NORMAL,
  MODE_SELECT_PARAM,
  MODE_EDIT_PARAM
};

State currentState = MODE_NORMAL;
int paramIdx = 0;
long editValue = 0;
unsigned long holdTimer = 0;

// ============================================================
// DISPLAY FUNCTIONS
// ============================================================

void digitsOff() {
  for (int i = 0; i < 4; i++) digitalWrite(digitPins[i],