Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
Settings.h
Go to the documentation of this file.
1#pragma once
2
12static const uint8_t Version = 9;
13
15
17static const uint8_t MaxWordLength = 32;
18static const uint8_t MaxShotTextLength = 64;
19static const uint16_t MaxLongTextLength = 256;
20static const uint8_t QueueDepth = 8;
21static const uint8_t MovingAverageDepth = 10;
22
24extern char LongMessage[MaxLongTextLength]; // Temp storage for assembling long messages (REST API - Google Sheets reporting)
25extern char ShortMessage[MaxShotTextLength]; // Temp storage for assembling short messages (Log entries, Error messages)
26extern char CurrentTime[MaxWordLength]; // Buffer for storing current time in text format
27
29static const uint8_t WirelessCSNPin = 9;
30static const uint8_t WirelessCEPin = 10;
31static const uint8_t WirelessChannel[6] = {"Aero1"};
32static const uint8_t WirelessPayloadSize = 32;
33static const uint16_t WirelessMessageTimeout = 500;
34static const uint16_t WirelessReceiveTimeout = 60000;
35
38
39typedef struct
40{
41 bool Debug = true;
42 bool Metric = true;
43
44 //<initialized via Designated initializer https://riptutorial.com/c/example/18609/using-designated-initializers
45 struct AeroponicsModuleSettings
46 {
47 bool SerialReportDate;
48 bool SerialReportMemory;
49 bool SerialReportJSONFriendly;
50 bool SerialReportJSON;
51 bool SerialReportWireless;
52 };
53 struct AeroponicsModuleSettings Aero1 = {.SerialReportDate = false, .SerialReportMemory = false, .SerialReportJSONFriendly = false, .SerialReportJSON = false, .SerialReportWireless = true};
54
55 struct AeroponicsSettings
56 {
57 bool SprayEnabled;
58 float Duration;
61 float MaxPressure;
62 };
63 struct AeroponicsSettings AeroNT1 = {.SprayEnabled = true, .Duration = 3.0, .DayInterval = 6, .NightInterval = 10, .MaxPressure = 7.0};
64
65 struct PressureSensorSettings
66 {
67 uint8_t Pin;
68 float Offset;
69 float Ratio;
70 };
71 struct PressureSensorSettings Pres1 = {.Pin = A7, .Offset = 0.57, .Ratio = 2.7};
72
73 struct SoundSettings
74 {
75 uint8_t Pin;
76 bool Enabled;
77 };
78 struct SoundSettings Sound1 = {.Pin = 2, .Enabled = true};
79
80 struct PressurePumpSettings
81 {
82 uint8_t PumpPin;
83 bool PumpPinNegativeLogic;
84 uint8_t BypassSolenoidPin;
85 bool BypassSolenoidNegativeLogic;
86 uint16_t BypassSolenoidMaxOpenTime;
87 uint16_t BypassSolenoidClosingDelay;
88 bool PumpEnabled;
89 uint8_t Speed;
90 uint8_t SpeedLimitLow;
91 uint8_t SpeedLimitHigh;
92 uint16_t PumpTimeOut;
93 uint16_t PrimingTime;
94 uint16_t BlowOffTime;
95 };
96 struct PressurePumpSettings AeroPump1 = {.PumpPin = 3, .PumpPinNegativeLogic = false, .BypassSolenoidPin = 4, .BypassSolenoidNegativeLogic = true, .BypassSolenoidMaxOpenTime = 180, .BypassSolenoidClosingDelay = 600, .PumpEnabled = true, .Speed = 100, .SpeedLimitLow = 30, .SpeedLimitHigh = 100, .PumpTimeOut = 420, .PrimingTime = 10, .BlowOffTime = 3};
97
98 struct WeightSensorSettings
99 {
100 uint8_t DTPin;
101 uint8_t SCKPin;
102 long Offset;
103 float Scale;
104 };
105 struct WeightSensorSettings Weight1 = {.DTPin = A0, .SCKPin = A1, .Offset = 19793, .Scale = -22280.70};
106
107 uint8_t CompatibilityVersion = Version;
108} Settings;
109
114void saveSettings(Settings *ToSave);
120Settings *loadSettings(bool ResetEEPROM = false);
121void restoreDefaults();
Settings * loadSettings(bool ResetEEPROM=false)
Load settings from EEPROM.
Definition Settings.cpp:20
void restoreDefaults()
Load sketch default settings into EEPROM.
Definition Settings.cpp:45
char CurrentTime[MaxWordLength]
Buffer for storing current time in text format.
char LongMessage[MaxLongTextLength]
Temp storage for assembling long messages (REST API, MQTT reporting)
char ShortMessage[MaxShotTextLength]
Temp storage for assembling short text messages (Log entries, Error messages,etc)
void saveSettings(Settings *ToSave)
Store settings in EEPROM - Only updates changed bits.
Definition Settings.cpp:10
bool & Debug
True - Turns on extra debug messages on the Serial Output.
bool & Metric
True - Use metric units, False - Use imperial units.
constexpr uint8_t Version
Default Settings for each component within the module. Loaded when the Arduino starts.
Definition Settings.h:12
constexpr uint16_t WirelessMessageTimeout
(ms) One package should be exchanged within this timeout (Including retries and delays)
Definition Settings.h:32
constexpr uint8_t WirelessPayloadSize
Size of the wireless packages exchanged with the Main module. Max 32 bytes are supported on nRF24L01+...
Definition Settings.h:31
constexpr uint8_t WirelessCEPin
nRF24l01+ wireless transmitter CE pin - Pre-connected on RF-Nano
Definition Settings.h:29
constexpr uint8_t MaxShotTextLength
Default char * buffer length for storing mutiple words. Memory intense!
Definition Settings.h:18
constexpr uint8_t QueueDepth
Limits the maximum number of active modules. Memory intense!
Definition Settings.h:20
constexpr uint8_t MaxWordLength
Default char * buffer length for storing a word + null terminator. Memory intense!
Definition Settings.h:17
constexpr uint16_t MaxLongTextLength
Default char * buffer length for storing a long text. Memory intense!
Definition Settings.h:19
constexpr uint16_t WirelessReceiveTimeout
(ms) If no packages are received from the Main module over this limit, try reseting the nRF24L01+ wir...
Definition Settings.h:33
constexpr uint8_t WirelessCSNPin
< nRF24L01+ wireless receiver
Definition Settings.h:28
constexpr uint8_t WirelessChannel[6]
This needs to be unique and match with the Name of the HempyModule_Web object in the MainModule_Web....
Definition Settings.h:30
< Aeroponics_Tank default settings
Definition Settings.h:57
int NightInterval
Spray every X minutes - When the lights are OFF.
Definition Settings.h:60
int DayInterval
Spray every X minutes - When the lights are ON.
Definition Settings.h:59
bool SprayEnabled
Enable/disable spraying cycle.
Definition Settings.h:63