ESP_IOT v2.5
IOT ESP Coding
PreferencesController.h
Go to the documentation of this file.
1
2
3#ifndef PreferencesController_h
4#define PreferencesController_h
5
6/*STEPPER feederType*/
7#define STEPPER_IS_UNO 1
8#define STEPPER_IS_MINI 2
9#define STEPPER_IS_TUMBLER 3
10//! These are the "preferenceID" in the calls below..
11//! **** Preferences Setup, called from reading EPROM, and from someone saving a preference ****
12#define PREFERENCE_MAIN_GATEWAY_VALUE 0
13#define PREFERENCE_MAIN_BLE_SERVER_VALUE 1
14#define PREFERENCE_MAIN_BLE_CLIENT_VALUE 2
15
16//! stepper preferences
17#define PREFERENCE_STEPPER_BUZZER_VALUE 3
18//these 3 are mutually exclutive
19#define PREFERENCE_STEPPER_SINGLE_FEED_VALUE 4
20#define PREFERENCE_STEPPER_AUTO_FEED_VALUE 5
21#define PREFERENCE_STEPPER_JACKPOT_FEED_VALUE 6
22#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING 7
23//! uses STEPPER type
24#define PREFERENCE_STEPPER_KIND_VALUE 8
25#define PREFERENCE_STEPPER_FEEDS_PER_JACKPOT 9
26
27//! Sensor preferences
28#define PREFERENCE_SENSOR_TILT_VALUE 10
29#define PREFERENCE_SENSOR_PIR_VALUE 11
30//! Display preferences (SemanticMarker etc) - boolean
31#define PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE 12
32//! Display preferences - show messages on blank screen- boolean
33#define PREFERENCE_DISPLAY_ON_BLANK_SCREEN_VALUE 13
34//! sets the timeout value
35#define PREFERENCE_DISPLAY_SCREEN_TIMEOUT_VALUE 14
36//! sets the max temp for a poweroff
37#define PREFERENCE_HIGH_TEMP_POWEROFF_VALUE 15
38//! sets the max temp for a poweroff
39#define PREFERENCE_IS_MINIMAL_MENU_SETTING 16
40//! sets stepper angle, a floating point number
41//! sets screentimeout if not button clicks (set,noclick,val,seconds)
42//! NO poweroff with the GATEWAY mode
43#define PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING 17
44
45//!for now, save 2 WIFI Credentials
46#define WIFI_CREDENTIALS_MAX 2
47#define PREFERENCE_WIFI_CREDENTIAL_1_SETTING 18
48#define PREFERENCE_WIFI_CREDENTIAL_2_SETTING 19
49//!the paired device for guest device feeding (6.6.22)
50#define PREFERENCE_PAIRED_DEVICE_SETTING 20
51//!the device name itself (6.6.22)
52#define PREFERENCE_DEVICE_NAME_SETTING 21
53//!a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
54#define PREFERENCE_FIRST_TIME_FEATURE_SETTING 22
55//! if true, only BLEClient connect to GEN3 feeders..
56#define PREFERENCE_ONLY_GEN3_CONNECT_SETTING 23
57//! ithe color of the screen 0..n
58#define PREFERENCE_SCREEN_COLOR_SETTING 24
59
60//!if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
61#define PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING 25
62//!if set, the BLE Client will look for its service base name (PTFeeder or PTClicker), but if that name
63//!also has an extension (:ScoobyDoo), and this is set, it will only connect if the PREFERENCE_PAIRED_DEVICE_SETTING has the same device name in the discovered name
64#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING 26
65//! for
66#define PREFERENCE_USE_DOC_FOLLOW_SETTING 27
67
68//! 8.17.22 to turn on/off subscribing to the dawgpack topic
69#define PREFERENCE_SUB_DAWGPACK_SETTING 28
70//! 8.22.22 to turn on/off SPIFF use (more below..)
71#define PREFERENCE_USE_SPIFF_SETTING 29
72
73//!the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
74#define PREFERENCE_PAIRED_DEVICE_ADDRESS_SETTING 30
75
76//!retreives the motor direction| 1) = default, clockwise; 0 = REVERSE, counterclockwise 9.8.22
77//! false = reverse == counterclockwise
78//! TRUE == default
79//! 8.18.24 note this changes so you can switch directions. the FACTORY_CLOCKWISE
80//! below is the original one time setting.
81//! Renamed to FACTORY for backward compatible
82#define PREFERENCE_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING 31
83
84//! sends the WIFI to all except current device if set
85#define PREFERENCE_SENDWIFI_WITH_BLE 32
86
87//! starts the BLE Discovery notification process - which might be internal or externa (via messages).
88#define PREFERENCE_NOTIFY_BLE_DISCOVERY 33
89
90//! the preference timer
91#define PREFERENCE_TIMER_INT_SETTING 34
92
93//! the preference for supporting GROUPS (*default true)*
94#define PREFERENCE_SUPPORT_GROUPS_SETTING 35
95
96
97//! the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wildcard in the future)
98#define PREFERENCE_GROUP_NAMES_SETTING 36
99
100//! a place to put some kind of Last Will of what went wrong .. for now (> max tries)
101#define PREFERENCE_DEBUG_INFO_SETTING 37
102//! adding AP_DEBUG_MODE to let others know that DEBUG eprom is available. Turn this OFF for non dev
103//#define AP_DEBUG_MODE
104
105//!9.28.23 #272 only show Semantic Markers that are sent directly to the device
106#define PREFERENCE_DEV_ONLY_SM_SETTING 38
107
108//! the preference timer MAX (pairs with PREFERENCE_TIMER_INT_SETTING)
109#define PREFERENCE_TIMER_MAX_INT_SETTING 39
110
111//!1.1.24 the preference for all the ATOM plugs (format: atomType:value} .. for now just use socket:on
112#define PREFERENCE_ATOMS_SETTING 40
113
114//!1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
115#define PREFERENCE_ATOM_KIND_SETTING 41
116
117//! 1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
118#define PREFERENCE_SM_ON_PIR_SETTING 42
119//! 1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
120#define PREFERENCE_SM_COMMAND_PIR_SETTING 43
121//! 1.11.24 The Semantic Marker command is sent on PIR, and the Command to send on OFF (or opposite)
122#define PREFERENCE_SM_COMMAND_PIR_OFF_SETTING 44
123//! 1.12.24 Whether the AtomSocket accepts global on/off messages
124#define PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING 45
125
126//! 4.4.24 Adding SPIFF for MQTT and QRATOM seperately
127//! For MQTT writing to the SPIFF
128#define PREFERENCE_USE_SPIFF_MQTT_SETTING 46
129//! For MQTT writing to the QRATOM
130#define PREFERENCE_USE_SPIFF_QRATOM_SETTING 47
131
132//! 8.2.24 to let older Tumbler NOT do the auto direction (back and forth)
133//! Isue #332
134//! it will set via message: autoMotorDirection
135//! {"set":"autoMotorDirection","val":"true"}
136#define PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING 48
137
138//! 8.2.24 don't change subscription but include these groups (eg. safeHouse,atlasDogs)
139#define PREFERENCE_INCLUDE_GROUP_NAMES_SETTING 49
140
141//!retreives the motor direction| 1) = default, clockwise; 0 = REVERSE, counterclockwise 9.8.22
142//! false = reverse == counterclockwise
143//! TRUE == default
144//! 8.18.24 this one changes ...
145#define PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING 50
146
147//! issue #338 sensor definition (in work)
148//! This will be a string in JSON format with various PIN and BUS information
149#define PREFERENCE_SENSOR_PLUGS_SETTING 51
150
151//!5.14.25 Dead 5.14.74 Montana
152//! issue #365 Object Oriented Sensors as well
153//! define the sensors (not sensorPlugs). MQTT: set:sensor, set:sensors
154#define PREFERENCE_SENSORS_SETTING 52
155
156//!8.14.25 Dead Movie from 10.19.1974 tonight..
157//! issue #394 stepperRPM
158//! stepper RPM
159#define PREFERENCE_STEPPER_RPM_SETTING 53
160
161//! ******* 1 greater than last value **** IMPORTANT *** and no gaps..
162#define MAX_MAIN_PREFERENCES 54
163
164//! 8.2.24 retrieve the includeGroup
165//! really ask a topic if it's in the include group
166boolean topicInIncludeGroup(char *topic);
167//! 8.2.24 set the include group (and cache it), called from MQTT
168void setIncludeGroups(char *groups);
169
170//!initialize the _preferencesMainLookup with EPROM lookup names
172
173//!print the preferences to SerialDebug
175
176//! Preferences for the MainModule .. basically generic settings. So any settings you want, add them here.
177//! NOTE: These are just "state" values, no methods or events are generated on saving these values.. It's up to the caller to perform events
178//! such as turning on the buzzer..
179
180//! called to init the preference. This won't save anything until storePreference called
181void initAppendingPreference_mainModule(int preferenceID);
182//! called to append to a a preference (which will be an identifier and a string, which can be converted to a number or boolean)
183void appendPreference_mainModule(int preferenceID, String preferenceValue);
184//! called to append to a a preference (which will be an identifier and a string, which can be converted to a number or boolean)
185void storePreference_mainModule(int preferenceID, String preferenceValue);
186
187//! called to reset to blank a preference (which will be an identifier and a string, which can be converted to a number or boolean)
188void resetPreference_mainModule(int preferenceID);
189
190
191
192//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
193void savePreference_mainModule(int preferenceID, String preferenceValue);
194
195//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
196boolean getPreferenceBoolean_mainModule(int preferenceID);
197
198//!TODO: put them in somewhere that is saving EPROM .. a SettingsModule
199//! these are implemented in the MainModule (since they are writing to the EPROM)
200//!sets and gets the "gateway" functionality
201void savePreferenceBoolean_mainModule(int preferenceID, boolean flag);
202
203//!toggles a preference boolean
204void togglePreferenceBoolean_mainModule(int preferenceID);
205
206//! called to get a preference (which will be an identifier and a string, which can be converted to a number or boolean)
207//! NOTE: this reuses same string buffer so will be overwritten on next call. Save value if you need more than one result (such as WIFI credentials, ouch)
208//! This mean any getPreference will use the same string .. so unless the result is a number or boolean, then copy it locally..
209char* getPreference_mainModule(int preferenceID);
210
211//!returns the preference but in it's own string buffer. As long as you use it before calling getPreferenceString again, it won't be overwritten
212char* getPreferenceString_mainModule(int preferenceID);
213
214//! called to get a preference (which will be an identifier and a string, which can be converted to a number or boolean)
215int getPreferenceInt_mainModule(int preferenceID);
216
217//!sets an int
218void savePreferenceInt_mainModule(int preferenceID, int val);
219
220//!sets an int, but only if a valid integer, and no signs
221void savePreferenceIntFromString_mainModule(int preferenceID, char* val);
222
223//! called to get a preference (which will be an identifier and a string, which can be converted to a number or boolean)
224float getPreferenceFloat_mainModule(int preferenceID);
225
226//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
227void savePreferenceFloat_mainModule(int preferenceID, float val);
228
229//!set some defaults on boot - that override EPROM this can be called on the HOME screen to set back to normal mode..
231
232//!returns if the paired device is not NONE
234
235//!returns if the paired device is not NONE
237
238//!returns if the paired device is not NONE
240
241
242//!returns if the paired device is not NONE .. returns address or device
244
245//!resets preferences.. Currently only reset all, but eventually reset(groups..)
247
248//!transient for now... 10.4.22
249//! set the M5 PTClicker discovery option..
250void setDiscoverM5PTClicker(boolean flag);
251//! get option
252boolean getDiscoverM5PTClicker();
253
254#pragma mark ATOM Processing
255
256//! new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner). MQTT message "set":"M5AtomKind", val=
257void savePreferenceATOMKind_MainModule(String value);
258//! new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner)
260
261//!returned from mainModule
262#define ATOM_KIND_M5_SCANNER 0
263#define ATOM_KIND_M5_SOCKET 1
264//! new 1.4.24 setting ATOM kind (eg. ATOM_KIND_M5_SCANNER, ATOM_KIND_M5_SOCKET)
266
267
268
269#define NEW_SENSORS_PREFERENCE
270//! store the SensorClassType instance as well
271#include "../SensorClass/SensorClassType.h"
272//!issue #365 sensor plugs and more
273//! 5.14.25 Hanging with Tyler,
274//! Dead Montana 5.14.74 great stuff
275//! add the Sensors Preference .. first the parsing
276
277//!forward definition
278class SensorClassType;
279
280//! sensor struct
281//! defines the structure
282typedef struct sensorStruct
283{
285 int pin1;
286 int pin2;
287 //! and the pointer to matching SensorClassType
290
291//! wrap sensors
292typedef struct sensorsStruct
293{
294 int count;
295 //! array of sensorStruct
298
299//! return the sensor specified or null
301
302//! return the sensor specified or null
303SensorStruct* getSensor_mainModule(char *sensorName);
304
305//! Only 1 setSensorsString now .. will always append
306//! message: set:sensors, val:<val> or empty to clean it out
307//! unless a null or blank "" string
308//! set a sensor val (array of sensor,pin,pin,sensor,pin,pin...)
309//! After each set, the SensorsStruct will be updated
310void setSensorsString_mainModule(char *sensorsString);
311
312//! init the sensorString from EPROM
313//!PREFERENCE_SENSOR_PLUGS_SETTING
315
316//! print sensors, passing in a struct
318
319//! 7.9.25 reset SENSORS to default
320//! "BuzzerSensorClass,23,33,L9110S_DCStepperClass,21,25"
322
323#endif // PreferensesController_h
struct sensorsStruct SensorsStruct
wrap sensors
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int
boolean getDiscoverM5PTClicker()
get option
void resetSensorToDefault_mainModule()
float getPreferenceFloat_mainModule(int preferenceID)
called to get a preference (which will be an identifier and a string, which can be converted to a num...
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
void savePreferenceATOMKind_MainModule(String value)
new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner). MQTT message "set":"M5AtomKind",...
void printSensors_mainModule(SensorsStruct *sensors)
print sensors, passing in a struct
SensorsStruct * getSensors_mainModule()
return the sensor specified or null
void appendPreference_mainModule(int preferenceID, String preferenceValue)
called to append to a a preference (which will be an identifier and a string, which can be converted ...
void setDiscoverM5PTClicker(boolean flag)
void setSensorsString_mainModule(char *sensorsString)
void resetAllPreferences_mainModule()
resets preferences.. Currently only reset all, but eventually reset(groups..)
boolean getPreferenceBoolean_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
void togglePreferenceBoolean_mainModule(int preferenceID)
toggles a preference boolean
void resetPreference_mainModule(int preferenceID)
called to reset to blank a preference (which will be an identifier and a string, which can be convert...
void storePreference_mainModule(int preferenceID, String preferenceValue)
called to append to a a preference (which will be an identifier and a string, which can be converted ...
void initAppendingPreference_mainModule(int preferenceID)
called to init the preference. This won't save anything until storePreference called
char * getPreferenceATOMKind_MainModule()
new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner)
void savePreferenceFloat_mainModule(int preferenceID, float val)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
void savePreferenceIntFromString_mainModule(int preferenceID, char *val)
sets an int, but only if a valid integer, and no signs
void setOnBootPreferences_mainModule()
set some defaults on boot - that override EPROM this can be called on the HOME screen to set back to ...
void initSensorStringsFromEPROM_mainModule()
char * getPairedDeviceOrAddress_mainModule()
returns if the paired device is not NONE .. returns address or device
Definition: MainModule.cpp:825
char * getPairedDevice_mainModule()
returns if the paired device is not NONE
Definition: MainModule.cpp:794
boolean topicInIncludeGroup(char *topic)
int getM5ATOMKind_MainModule()
new 1.4.24 setting ATOM kind (eg. ATOM_KIND_M5_SCANNER, ATOM_KIND_M5_SOCKET)
int getPreferenceInt_mainModule(int preferenceID)
called to get a preference (which will be an identifier and a string, which can be converted to a num...
char * getPreference_mainModule(int preferenceID)
boolean isValidPairedDevice_mainModule()
returns if the paired device is not NONE
Definition: MainModule.cpp:806
SensorStruct * getSensor_mainModule(char *sensorName)
return the sensor specified or null
void setIncludeGroups(char *groups)
8.2.24 set the include group (and cache it), called from MQTT
char * getPreferenceString_mainModule(int preferenceID)
returns the preference but in it's own string buffer. As long as you use it before calling getPrefere...
void printPreferenceValues_mainModule()
print the preferences to SerialDebug
void initPreferencesMainModule()
initialize the _preferencesMainLookup with EPROM lookup names
void savePreference_mainModule(int preferenceID, String preferenceValue)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
struct sensorStruct SensorStruct
char * getPairedDeviceAddress_mainModule()
returns if the paired device is not NONE
Definition: MainModule.cpp:800
SensorClassType * sensorClassType
and the pointer to matching SensorClassType
SensorStruct * sensors
array of sensorStruct