You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
1.7 KiB

2 years ago
#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";
2 years ago
enum ViewMode {
ViewModeArtists = 0,
ViewModeAlbums = 1,
ViewModeTracks = 2,
};
typedef struct UIEntry {
// OwnTone ID
int id;
// Text (name, title, etc.)
String text;
} UIEntry;
2 years ago
typedef struct AppState {
unsigned long sinceBoot;
bool wifiOnline;
IPAddress wifiIP;
2 years ago
ViewMode viewMode;
size_t uiEntriesCount;
int uiEntryIndex;
UIEntry *uiEntries;
int songCount;
int artistCount;
int albumCount;
2 years ago
int volume; // out of 100;
} AppState;
AppState AppStateMake(void) {
AppState out;
out.sinceBoot = 0;
out.wifiOnline = false;
out.wifiIP = IPAddress();
2 years ago
out.viewMode = ViewModeArtists;
out.uiEntriesCount = 0;
out.uiEntryIndex = 0;
out.uiEntries = NULL;
out.songCount = 0;
out.artistCount = 0;
out.albumCount = 0;
2 years ago
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);
}