Skip to content

Commit

Permalink
made the esp8266 setup code more consistent, include the same functio…
Browse files Browse the repository at this point in the history
…n declarations and the same defines in all code
  • Loading branch information
robertoostenveld committed Jun 12, 2018
1 parent 28bf26e commit 9938a92
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
Binary file not shown.
17 changes: 10 additions & 7 deletions esp8266_artnet_dmx512/setup_ota.h
Expand Up @@ -9,15 +9,12 @@
#include <FS.h>

#define JSON_TO_CONFIG(x, y) { if (root.containsKey(y)) { config.x = root[y]; } }
#define CONFIG_TO_JSON(x, y) { root[y] = config.x; }
#define CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); config.x = str.toInt(); } }


struct Config {
int universe;
int channels;
int delay;
};
#define S_JSON_TO_CONFIG(x, y) { if (root.containsKey(y)) { strcpy(config.x, root[y]); } }
#define S_CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define S_KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); strcpy(config.x, str.c_str()); } }

bool initialConfig(void);
bool loadConfig(void);
Expand All @@ -33,5 +30,11 @@ void handleStaticFile(String);
void handleStaticFile(const char *);
void handleJSON();

struct Config {
int universe;
int channels;
int delay;
};

#endif // _SETUP_OTA_H_

33 changes: 18 additions & 15 deletions esp8266_artnet_neopixel/setup_ota.h
Expand Up @@ -9,23 +9,12 @@
#include <FS.h>

#define JSON_TO_CONFIG(x, y) { if (root.containsKey(y)) { config.x = root[y]; } }
#define CONFIG_TO_JSON(x, y) { root[y] = config.x; }
#define CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); config.x = str.toInt(); } }


struct Config {
int universe;
int offset;
int pixels;
int leds;
int white;
int brightness;
int hsv;
int mode;
int reverse;
int speed;
int position;
};
#define S_JSON_TO_CONFIG(x, y) { if (root.containsKey(y)) { strcpy(config.x, root[y]); } }
#define S_CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define S_KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); strcpy(config.x, str.c_str()); } }

bool initialConfig(void);
bool loadConfig(void);
Expand All @@ -41,5 +30,19 @@ void handleStaticFile(String);
void handleStaticFile(const char *);
void handleJSON();

struct Config {
int universe;
int offset;
int pixels;
int leds;
int white;
int brightness;
int hsv;
int mode;
int reverse;
int speed;
int position;
};

#endif // _SETUP_OTA_H_

19 changes: 14 additions & 5 deletions esp8266_imu_osc/setup_ota.h
Expand Up @@ -16,6 +16,20 @@
#define S_CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define S_KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); strcpy(config.x, str.c_str()); } }

bool initialConfig(void);
bool loadConfig(void);
bool saveConfig(void);

void handleUpdate1(void);
void handleUpdate2(void);
void handleDirList(void);
void handleNotFound(void);
void handleRedirect(String);
void handleRedirect(const char *);
void handleStaticFile(String);
void handleStaticFile(const char *);
void handleJSON();

struct Config {
int sensors;
int decimate;
Expand All @@ -24,9 +38,4 @@ struct Config {
int port;
};

void handleNotFound();
void handleStaticFile(String filename);
void handleStaticFile(const char * filename);
void handleJSON();

#endif
19 changes: 14 additions & 5 deletions esp8266_polar_wearlink/setup_ota.h
Expand Up @@ -16,14 +16,23 @@
#define S_CONFIG_TO_JSON(x, y) { root.set(y, config.x); }
#define S_KEYVAL_TO_CONFIG(x, y) { if (server.hasArg(y)) { String str = server.arg(y); strcpy(config.x, str.c_str()); } }

bool initialConfig(void);
bool loadConfig(void);
bool saveConfig(void);

void handleUpdate1(void);
void handleUpdate2(void);
void handleDirList(void);
void handleNotFound(void);
void handleRedirect(String);
void handleRedirect(const char *);
bool handleStaticFile(String);
bool handleStaticFile(const char *);
void handleJSON();

struct Config {
char redis[32];
int port;
};

void handleNotFound();
bool handleStaticFile(String filename);
bool handleStaticFile(const char * filename);
void handleJSON();

#endif

0 comments on commit 9938a92

Please sign in to comment.