wip - doing config structure things
This commit is contained in:
parent
13087c0cc1
commit
4f42b64c7e
3 changed files with 96 additions and 37 deletions
|
@ -34,6 +34,15 @@
|
|||
* like -DCANGROW_VER="0.x-dev" or -DCANGROW_BUILD="commitid-core-timestamp"
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Constants
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CANGROW_VER
|
||||
#define CANGROW_VER "0.x-dev"
|
||||
#endif
|
||||
|
@ -43,13 +52,39 @@
|
|||
|
||||
#define CANGROW_SSID "CanGrow-unconfigured"
|
||||
|
||||
// do we need a restart? (e.g. after wifi settings change)
|
||||
bool needRestart = false;
|
||||
// this triggers Restart() from the main loop
|
||||
bool doRestart = false;
|
||||
// previous value of millis within the scheduler loop
|
||||
unsigned long schedulerPrevMillis = 0;
|
||||
/* actual structure initialization for Pin_Index is done within the header files
|
||||
* for ESP32 and ESP8266
|
||||
*
|
||||
* Pin_Index.note explenation:
|
||||
* 1 - BOOTFAILS_LOW: BootFails when LOW
|
||||
* 2 - BOOTFAILS_HIGH: BootFails when HIGH
|
||||
* 3 - FLASHMODE_LOW: FlashMode needs LOW to enter
|
||||
* 4 - INPUT_ONLY: Input Only
|
||||
* 5 - NO_PWM: No PWM output
|
||||
* 6 - PWM_BOOT: PWM at boot time
|
||||
*/
|
||||
const byte BOOTFAILS_LOW = 1;
|
||||
const byte BOOTFAILS_HIGH = 2;
|
||||
const byte FLASHMODE_LOW = 3;
|
||||
const byte INPUT_ONLY = 4;
|
||||
const byte NO_PWM = 5;
|
||||
|
||||
struct Pin_Index {
|
||||
const byte gpio;
|
||||
const byte note;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Config
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Config WiFi
|
||||
*/
|
||||
struct Config_WiFi {
|
||||
char ssid[32];
|
||||
char password[64];
|
||||
|
@ -60,9 +95,27 @@ struct Config_WiFi {
|
|||
byte dns[4] = {0,0,0,0};
|
||||
};
|
||||
|
||||
Config_WiFi configWifi;
|
||||
|
||||
/*
|
||||
* Config System
|
||||
*/
|
||||
|
||||
/*
|
||||
* Config System Outputs
|
||||
*
|
||||
* - type: output type like GPIO, I2C, URL
|
||||
* - gpio: which gpio
|
||||
*
|
||||
*/
|
||||
struct Config_System_Outputs {
|
||||
byte type;
|
||||
byte gpio;
|
||||
char url[64];
|
||||
bool httpLogSerial;
|
||||
unsigned short schedulerInterval = 1000;
|
||||
};
|
||||
|
||||
/* main System struct */
|
||||
struct Config_System {
|
||||
byte ntpOffset;
|
||||
unsigned short maintenanceDuration;
|
||||
|
@ -71,13 +124,14 @@ struct Config_System {
|
|||
char httpPass[32];
|
||||
bool httpLogSerial;
|
||||
unsigned short schedulerInterval = 1000;
|
||||
|
||||
|
||||
Config_System_Outputs outputs;
|
||||
};
|
||||
|
||||
Config_System configSystem;
|
||||
|
||||
|
||||
/*
|
||||
* Config Grow
|
||||
*/
|
||||
struct Config_Grow {
|
||||
char growName[64] = "CanGrow";
|
||||
unsigned short dayOfGrow;
|
||||
|
@ -90,34 +144,39 @@ struct Config_Grow {
|
|||
byte sunriseMinute;
|
||||
bool sunFade;
|
||||
byte sunFadeDuration;
|
||||
|
||||
};
|
||||
|
||||
Config_Grow configGrow;
|
||||
|
||||
|
||||
/*
|
||||
* main Config struct
|
||||
*/
|
||||
struct Config {
|
||||
char test[16] = "123";
|
||||
Config_WiFi wifi;
|
||||
Config_System system;
|
||||
Config_Grow grow;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Config config;
|
||||
|
||||
/* actual structure initialization for Pin_Index is done within the header files
|
||||
* for ESP32 and ESP8266
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Global Runtime variables
|
||||
*
|
||||
*
|
||||
* Pin_Index.note explenation:
|
||||
* 1 - BF_L: BootFails when LOW
|
||||
* 2 - BF_H: BootFails when HIGH
|
||||
* 3 - FM_L: FlashMode needs LOW to enter
|
||||
* 4 - IN_O: Input Only
|
||||
*/
|
||||
const byte BF_L = 1;
|
||||
const byte BF_H = 2;
|
||||
const byte FM_L = 3;
|
||||
const byte IN_O = 4;
|
||||
|
||||
struct Pin_Index {
|
||||
const byte gpio;
|
||||
const byte note;
|
||||
};
|
||||
|
||||
// do we need a restart? (e.g. after wifi settings change)
|
||||
bool needRestart = false;
|
||||
// this triggers Restart() from the main loop
|
||||
bool doRestart = false;
|
||||
// previous value of millis within the scheduler loop
|
||||
unsigned long schedulerPrevMillis = 0;
|
||||
|
|
|
@ -63,10 +63,10 @@
|
|||
//
|
||||
const byte PinIndex_length = 21;
|
||||
// initialize pinIndex with all usable GPIOs
|
||||
Pin_Index PinIndex[] = { { 0, FM_L },
|
||||
Pin_Index PinIndex[] = { { 0, FLASHMODE_LOW },
|
||||
{ 4 },
|
||||
{ 5 },
|
||||
{ 12, BF_H },
|
||||
{ 12, BOOTFAILS_HIGH },
|
||||
{ 13 },
|
||||
{ 14 },
|
||||
{ 15 },
|
||||
|
@ -80,8 +80,8 @@ Pin_Index PinIndex[] = { { 0, FM_L },
|
|||
{ 27 },
|
||||
{ 32 },
|
||||
{ 33 },
|
||||
{ 34, IN_O },
|
||||
{ 35, IN_O },
|
||||
{ 36, IN_O },
|
||||
{ 39, IN_O } };
|
||||
{ 34, INPUT_ONLY },
|
||||
{ 35, INPUT_ONLY },
|
||||
{ 36, INPUT_ONLY },
|
||||
{ 39, INPUT_ONLY } };
|
||||
#endif
|
||||
|
|
|
@ -47,11 +47,11 @@
|
|||
|
||||
const byte PinIndex_length = 6;
|
||||
// initialize pinIndex with all usable GPIOs
|
||||
Pin_Index PinIndex[] = { { 0, BF_L },
|
||||
Pin_Index PinIndex[] = { { 0, BOOTFAILS_LOW },
|
||||
{ 12 },
|
||||
{ 13 },
|
||||
{ 14 },
|
||||
{ 15, BF_H },
|
||||
{ 16 } };
|
||||
{ 15, BOOTFAILS_HIGH },
|
||||
{ 16, NO_PWM } };
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue