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
12constexpr uint8_t Version = 16;
13
15
17constexpr uint8_t MaxWordLength = 32;
18constexpr uint8_t MaxShotTextLength = 64;
19constexpr uint16_t MaxLongTextLength = 168;
20constexpr uint8_t QueueDepth = 6;
21
23extern char LongMessage[MaxLongTextLength]; // Temp storage for assembling long messages (REST API - Google Sheets reporting)
24extern char ShortMessage[MaxShotTextLength]; // Temp storage for assembling short messages (Log entries, Error messages)
25extern char CurrentTime[MaxWordLength]; // Buffer for storing current time in text format
26
28constexpr uint8_t WirelessCSNPin = 9;
29constexpr uint8_t WirelessCEPin = 10;
30constexpr uint8_t WirelessChannel[6] = {"Hemp1"};
31constexpr uint8_t WirelessPayloadSize = 32;
32constexpr uint16_t WirelessMessageTimeout = 500;
33constexpr uint16_t WirelessReceiveTimeout = 60000;
34
37
38typedef struct
39{
40 bool Debug = true;
41 bool Metric = true;
42
43 // initialized via Designated initializer https://riptutorial.com/c/example/18609/using-designated-initializers
44 struct HempyModuleSettings
45 {
51 };
52 struct HempyModuleSettings Hemp1 = {.SerialReportDate = true, .SerialReportMemory = true, .SerialReportJSONFriendly = true, .SerialReportJSON = true, .SerialReportWireless = true};
53
55 {
56 float EvaporationTarget; //< (kg/lbs) Amount of water that should evaporate before starting the watering cycles
57 float MaxWeight;
61 uint16_t DrainWaitTime;
62 };
63 struct HempyBucketSettings Bucket1 = {.EvaporationTarget = 2.0, .MaxWeight = 20.0, .StartWeight = 18.0, .WateringIncrement = 0.3, .DrainTargetWeight = 0.1, .DrainWaitTime = 180};
64 struct HempyBucketSettings Bucket2 = {.EvaporationTarget = 2.0, .MaxWeight = 20.0, .StartWeight = 18.0, .WateringIncrement = 0.3, .DrainTargetWeight = 0.1, .DrainWaitTime = 180};
65
66 struct SoundSettings
67 {
68 uint8_t Pin;
69 bool Enabled;
70 };
71 struct SoundSettings Sound1 = {.Pin = 2, .Enabled = true};
72
74 {
75 uint8_t PumpPin;
78 uint16_t PumpTimeOut;
79 uint8_t Speed;
80 uint8_t SpeedLimitLow;
82 };
83 struct WaterPumpSettings HempyPump1 = {.PumpPin = 3, .PumpPinNegativeLogic = false, .PumpEnabled = true, .PumpTimeOut = 120, .Speed = 100, .SpeedLimitLow = 30, .SpeedLimitHigh = 100};
84 struct WaterPumpSettings HempyPump2 = {.PumpPin = 5, .PumpPinNegativeLogic = false, .PumpEnabled = true, .PumpTimeOut = 120, .Speed = 100, .SpeedLimitLow = 30, .SpeedLimitHigh = 100};
85
87 {
88 uint8_t DTPin;
89 uint8_t SCKPin;
90 long Offset;
91 float Scale;
92 };
93 struct WeightSensorSettings WeightB1 = {.DTPin = 4, .SCKPin = 6, .Offset = -176962, .Scale = -22654.00};
94 struct WeightSensorSettings WeightB2 = {.DTPin = 7, .SCKPin = 8, .Offset = 377473, .Scale = -21506.86};
95
96 uint8_t CompatibilityVersion = Version;
97} Settings;
98
103void saveSettings(Settings *ToSave);
109Settings *loadSettings(bool ResetEEPROM = false);
110void 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
< HempyBucket default settings
Definition Settings.h:55
float WateringIncrement
How much water to pump in one cycle, then wait for DrainWaitTime seconds before either starting a new...
Definition Settings.h:59
float DrainTargetWeight
(kg/lbs) Amount of water that should go to the waste reservoir after a watering cycle
Definition Settings.h:60
float MaxWeight
Waste reservoir full weight -> Pump gets disabled if reached.
Definition Settings.h:57
uint16_t DrainWaitTime
(sec) How long to wait after watering for the water to drain
Definition Settings.h:61
float StartWeight
(kg/lbs) When the module starts up start watering if Bucket weight is below this. Set to 0 to instant...
Definition Settings.h:58
< Hempy default settings
Definition Settings.h:137
bool SerialReportJSONFriendly
Enable/disable sending Text formatted reports to the Serial output.
Definition Settings.h:48
bool SerialReportWireless
Enable/disable sending wireless package exchange reports to the Serial output.
Definition Settings.h:50
bool SerialReportJSON
Enable/disable sending JSON formatted reports to the Serial output.
Definition Settings.h:49
bool SerialReportDate
Enable/disable reporting the current time to the Serial output.
Definition Settings.h:46
bool SerialReportMemory
Enable/disable reporting the remaining free memory to the Serial output.
Definition Settings.h:47
< WaterPump default settings
Definition Settings.h:74
uint8_t Speed
Duty cycle of the PWM Motor speed.
Definition Settings.h:79
bool PumpEnabled
Enable/disable pump. false= Block running the pump.
Definition Settings.h:77
uint16_t PumpTimeOut
(Sec) Max pump run time
Definition Settings.h:78
uint8_t SpeedLimitHigh
Duty cycle limit, does not allow raising the speed too high.
Definition Settings.h:81
bool PumpPinNegativeLogic
true - Relay turns on to LOW signal, false - Relay turns on to HIGH signal
Definition Settings.h:76
uint8_t PumpPin
Pump relay pin.
Definition Settings.h:75
uint8_t SpeedLimitLow
Duty cycle limit, does not allow lowering the speed too much. Avoids stalling the motor.
Definition Settings.h:80
< WeightSensor default settings
Definition Settings.h:87
float Scale
Scale factor.
Definition Settings.h:91
uint8_t DTPin
Weight sensor DT pin.
Definition Settings.h:88
long Offset
Reading at 0 weight on the scale.
Definition Settings.h:90
uint8_t SCKPin
Weight sensor SCK pin.
Definition Settings.h:89