#ifndef config_h #define config_h #include "Arduino.h" #include "options.h" #define EEPROM_SIZE 768 #define EEPROM_START 0 #define EEPROM_START_IR 100 #define BUFLEN 140 #define PLAYLIST_PATH "/data/playlist.csv" #define SSIDS_PATH "/data/wifi.csv" #define TMP_PATH "/data/tmpfile.txt" #define INDEX_PATH "/data/index.dat" struct config_t { unsigned int config_set; //must be 4256 byte volume; int8_t balance; int8_t trebble; int8_t middle; int8_t bass; uint16_t lastStation; uint16_t countStation; byte lastSSID; bool audioinfo; byte smartstart; byte tz_set; // must be 57 int8_t tzHour; int8_t tzMin; uint16_t timezoneOffset; }; #if IR_PIN!=255 struct ircodes_t { unsigned int ir_set; //must be 4224 uint64_t irVals[20][3]; }; #endif struct station_t { char name[BUFLEN]; char url[BUFLEN]; char title[BUFLEN]; uint16_t bitrate; int ovol; }; struct neworkItem { char ssid[20]; char password[40]; }; class Config { public: config_t store; station_t station; #if IR_PIN!=255 int irindex; uint8_t irchck; ircodes_t ircodes; #endif neworkItem ssids[5]; byte ssidsCount; public: Config() {}; void save(); #if IR_PIN!=255 void saveIR(); #endif void init(); byte setVolume(byte val); void saveVolume(); void setTone(int8_t bass, int8_t middle, int8_t trebble); void setBalance(int8_t balance); byte setLastStation(byte val); byte setCountStation(byte val); byte setLastSSID(byte val); void setTitle(const char* title); void setStation(const char* station); bool parseCSV(const char* line, char* name, char* url, int &ovol); bool parseJSON(const char* line, char* name, char* url, int &ovol); bool parseWsCommand(const char* line, char* cmd, char* val, byte cSize); bool parseSsid(const char* line, char* ssid, char* pass); void loadStation(uint16_t station); bool initNetwork(); bool saveWifi(const char* post); void setSmartStart(byte ss); void initPlaylist(); void indexPlaylist(); void fillPlMenu(char plmenu[][40], int from, byte count, bool removeNum=false); void setTimezone(int8_t tzh, int8_t tzm); void setTimezoneOffset(uint16_t tzo); uint16_t getTimezoneOffset(); private: template int eepromWrite(int ee, const T& value); template int eepromRead(int ee, T& value); void setDefaults(); }; extern Config config; #endif