|
|
@ -4,44 +4,17 @@ |
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <SoftwareSerial.h>
|
|
|
|
#include <Streaming.h>
|
|
|
|
#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() |