diff --git a/src/sketch_oct28a2.cpp b/src/main.cpp similarity index 91% rename from src/sketch_oct28a2.cpp rename to src/main.cpp index dedc4d5..f09eff9 100755 --- a/src/sketch_oct28a2.cpp +++ b/src/main.cpp @@ -4,44 +4,17 @@ #include #include #include -#define RELAY_ON 0 -#define RELAY_OFF 1 -#define BALLAST_SIZE 3 - +#include "main.h" SoftwareSerial s(5, 6); //RX,TX RTC_DS1307 rtc; -struct ballast -{ - int id; - int shour; - int smin; - uint32_t fadePeriod; - int ehour; - int emin; - int stage; - int brightness; - int pin; - unsigned long fadeStartMillis; - int relayPin; -}; struct ballast ballast1, ballast2, ballast3; struct ballast *ballasts[BALLAST_SIZE] = { &ballast1, &ballast2, &ballast3}; -void setupBallast(ballast *b); -int setupBallasts(ballast *b_arr[], size_t arr_size, JsonObject &root); -void doBallast(ballast *b, int hr, int mn); -void updateBallast(ballast *b, JsonObject &root); -void manualMode(ballast *b); -int getFreeRam(); -const size_t bufferSize = JSON_ARRAY_SIZE(3) + JSON_OBJECT_SIZE(2) + 3 * JSON_OBJECT_SIZE(5) + 180; - unsigned long currentMillis; unsigned long loopMillis; -const unsigned long loopPeriod = 1000; unsigned long data_send_millis; -const unsigned long data_send_period = 2000; static bool manualFlag; void setup() diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..e6643be --- /dev/null +++ b/src/main.h @@ -0,0 +1,31 @@ +#include +#define RELAY_ON 0 +#define RELAY_OFF 1 +#define BALLAST_SIZE 3 + +struct ballast +{ + int id; + int shour; + int smin; + uint32_t fadePeriod; + int ehour; + int emin; + int stage; + int brightness; + int pin; + unsigned long fadeStartMillis; + int relayPin; +}; + +void setupBallast(ballast *b); +int setupBallasts(ballast *b_arr[], size_t arr_size, JsonObject &root); +void doBallast(ballast *b, int hr, int mn); +void updateBallast(ballast *b, JsonObject &root); +void manualMode(ballast *b); +int getFreeRam(); +const size_t bufferSize = JSON_ARRAY_SIZE(3) + JSON_OBJECT_SIZE(2) + 3 * JSON_OBJECT_SIZE(5) + 180; + +const unsigned long loopPeriod = 1000; + +const unsigned long data_send_period = 2000;