 }
 
 //-----------------------------------------------
+// Define the PixelVFO menu system
+//-----------------------------------------------
+
+struct MenuItem mi_reset_no = {"No", NULL, &reset_no_action};
+struct MenuItem mi_reset_yes = {"Yes", NULL, &reset_action};
+struct MenuItem *mia_reset[] = {&mi_reset_no, &mi_reset_yes};
+struct Menu reset_menu = {"Reset all", ALEN(mia_reset), mia_reset};
+
+struct MenuItem mi_brightness = {"Brightness", NULL, &brightness_action};
+struct MenuItem mi_contrast = {"Contrast", NULL, &contrast_action};
+struct MenuItem mi_holdclick = {"Hold click", NULL, &holdclick_action};
+struct MenuItem mi_doubleclick = {"Double click", NULL, &doubleclick_action};
+struct MenuItem mi_calibrate = {"Calibrate", NULL, &calibrate_action};
+struct MenuItem *mia_settings[] = {&mi_brightness, &mi_contrast, &mi_holdclick,
+                                   &mi_doubleclick, &mi_calibrate};
+struct Menu settings_menu = {"Settings", ALEN(mia_settings), mia_settings};
+
+struct MenuItem mi_saveslot = {"Save slot", NULL, &saveslot_action};
+struct MenuItem mi_restoreslot = {"Restore slot", NULL, &restoreslot_action};
+struct MenuItem mi_deleteslot = {"Delete slot", NULL, &deleteslot_action};
+struct MenuItem *mia_slots[] = {&mi_saveslot, &mi_restoreslot, &mi_deleteslot};
+struct Menu slots_menu = {"Slots", ALEN(mia_slots), mia_slots};
+
+struct MenuItem mi_slots = {"Slots", &slots_menu, NULL};
+struct MenuItem mi_settings = {"Settings", &settings_menu, NULL};
+struct MenuItem mi_reset = {"Reset all", &reset_menu, NULL};
+struct MenuItem mi_credits = {"Credits", NULL, &credits_action};
+struct MenuItem *mia_main[] = {&mi_slots, &mi_settings, &mi_reset, &mi_credits};
+struct Menu menu_main = {"Menu", ALEN(mia_main), mia_main};
+
+//-----------------------------------------------
 // Setup the whole shebang.
 //-----------------------------------------------
+
 void setup(void)
 {
   Serial.begin(115200);

  // read touch position, add DOWN event to event queue
  ts_read(&last_x, &last_y);
  event_push(event_Down, last_x, last_y);
}

//////////////////////////////////////////////////////////////////////////////

#define MENU_BG2            ILI9341_BLACK
#define MENU_FG             ILI9341_BLACK

// constants for the menu system
#define MENUITEM_HEIGHT     35
#define MAXMENUITEMROWS     5

// macro to get number of elements in an array
#define ALEN(a)    (sizeof(a)/sizeof((a)[0]))

// the VFO states
enum VFOState
{
