#include "rpcWiFi.h" #define DEBUG (false) const char *WIFI_SSID = "TortugaNoT"; const char *WIFI_PASS = "april302021"; const char *OWNTONE_SERVER_ADDRESS = "http://192.168.1.2:3689"; enum ViewMode { ViewModeArtists = 0, ViewModeAlbums = 1, ViewModeTracks = 2, }; typedef struct UIEntry { // OwnTone ID int id; // Text (name, title, etc.) String text; } UIEntry; typedef struct AppState { unsigned long sinceBoot; bool wifiOnline; IPAddress wifiIP; ViewMode viewMode; size_t uiEntriesCount; int uiEntryIndex; UIEntry *uiEntries; int songCount; int artistCount; int albumCount; int volume; // out of 100; } AppState; AppState AppStateMake(void) { AppState out; out.sinceBoot = 0; out.wifiOnline = false; out.wifiIP = IPAddress(); out.viewMode = ViewModeArtists; out.uiEntriesCount = 0; out.uiEntryIndex = 0; out.uiEntries = NULL; out.songCount = 0; out.artistCount = 0; out.albumCount = 0; out.volume = 0; return out; } AppState state; void debug() { wifiDebug(&state); uiDebug(&state); apiDebug(&state); } void handleInput() { } void setup() { state = AppStateMake(); uiSetup(&state); wifiJoin(&state); apiSetup(&state); // prepare buttons pinMode(WIO_KEY_A, INPUT_PULLUP); pinMode(WIO_KEY_B, INPUT_PULLUP); pinMode(WIO_KEY_C, INPUT_PULLUP); pinMode(WIO_5S_UP, INPUT_PULLUP); pinMode(WIO_5S_DOWN, INPUT_PULLUP); pinMode(WIO_5S_LEFT, INPUT_PULLUP); pinMode(WIO_5S_RIGHT, INPUT_PULLUP); pinMode(WIO_5S_PRESS, INPUT_PULLUP); } void loop() { if (DEBUG) { debug(); } state.sinceBoot = millis(); uiLoop(&state); wifiLoop(&state); apiLoop(&state); }