ESP_IOT v2.5
IOT ESP Coding
PreferencesController.cpp
Go to the documentation of this file.
1
2#include "../../Defines.h"
4//! PREFERENCES for the main module
5//1075325 vs 1074301
6//1075781 after refactor (removed stpper preferences)
7//1075833
8
9//!for returning a 'String" NOTE: THIS IS NOT GREAT .. as if you don't grab it before another query, and use it -- the result might be 1 instead of deviceName..
11//!buffer for the string
13
14//! 8.2.24 includeGroups
15//! 8.2.24 break up the list..
16#define NUMBER_GROUPS 4
17#define STRING_MAX_SIZE 40
19//!resulting group names
21
22
23//!Issue #103
24//!NOTE: the EPROM space might be limiting: https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/default.csv
25//!to 4KB .. https://www.esp32.com/viewtopic.php?t=9136
26//! So we should start limiting our use, and start with these string indexes..
27//! main module preferences
28//! gateway is on THESE MUST ALL BE UNIQUE
29#define EPROM_MAIN_GATEWAY_VALUE "1gt"
30//!BLEServer mode
31#define EPROM_MAIN_BLE_SERVER_VALUE "2bs"
32//!BLEClient mode
33#define EPROM_MAIN_BLE_CLIENT_VALUE "3bc"
34
35//!buzzer on or off
36#define EPROM_STEPPER_BUZZER_VALUE "4bz"
37//! single feed mode
38#define EPROM_STEPPER_SINGLE_FEED_VALUE "5sf"
39//!auto feed
40#define EPROM_STEPPER_AUTO_FEED_VALUE "6af"
41//!jackpot feed
42#define EPROM_STEPPER_JACKPOT_FEED_VALUE "7jf"
43//! the step kind
44#define EPROM_STEPPER_KIND_VALUE "8sk"
45//num feeds in jackpot mode
46#define EPROM_STEPPER_FEEDS_PER_JACKPOT_VALUE "9jp"
47//! sensor preferences for tilt on or off
48#define EPROM_SENSOR_TILT_VALUE "TILT_10" //10tt"
49 //!proximity PIR
50#define EPROM_SENSOR_PIR_VALUE "11pr"
51//! display preferences zoomed or not zoomed
52#define EPROM_SEMANTIC_MARKER_ZOOMED_VALUE "12sz"
53
54//! Display preferences - show messages on blank screen- boolean
55#define EPROM_DISPLAY_ON_BLANK_SCREEN_VALUE "13bk"
56//! sets the timeout value
57#define EPROM_DISPLAY_SCREEN_TIMEOUT_VALUE "14to"
58//! sets the max temp for a poweroff
59#define EPROM_HIGH_TEMP_POWEROFF_VALUE "15pw"
60//!whether to show the minimal or expanded menu
61#define EPROM_IS_MINIMAL_MENU_SETTING "16mm"
62//! sets stepper angle, a floating point number
63#define EPROM_STEPPER_ANGLE_FLOAT_SETTING "17sa"
64
65//! sets screentimeout if not button clicks (set,noclick,val,seconds)
66#define EPROM_NO_BUTTON_CLICK_POWEROFF_SETTING "18po"
67
68//!for now, save 2 WIFI Credentials
69#define EPROM_WIFI_CREDENTIAL_1_SETTING "19w1"
70//!second wifi credential
71#define EPROM_WIFI_CREDENTIAL_2_SETTING "20w2"
72
73//! the guest device paired with this M5 device (or NONE)
74#define EPROM_PAIRED_DEVICE_SETTING "21pd"
75
76//! the device name
77#define EPROM_DEVICE_NAME_SETTING "22dn"
78
79//!a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
80#define EPROM_FIRST_TIME_FEATURE_SETTING "23fs"
81
82//! if true, only BLEClient connect to GEN3 feeders..
83#define EPROM_ONLY_GEN3_CONNECT_SETTING "23gs"
84
85//!color of the M5 screen
86#define EPROM_SCREEN_COLOR_SETTING "24sc"
87
88//!if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
89#define EPROM_BLE_SERVER_USE_DEVICE_NAME_SETTING "25bs"
90//!if set, the BLE Client will look for its service base name (PTFeeder or PTClicker), but if that name
91//!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
92#define EPROM_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING "26bd"
93//!NOTE: these EPROM have to be lockstep the same as the PREFERENCE definitions in MainModule.h
94
95#define EPROM_USE_DOC_FOLLOW_SETTING "27df"
96
97//! 8.17.22 to turn on/off subscribing to the dawgpack topic
98#define EPROM_SUB_DAWGPACK_SETTING "28dg"
99
100//! 8.22.22 to turn on/off SPIFF use
101#define EPROM_USE_SPIFF_SETTING "29sf"
102
103//! 9.3.22 eprom of the Address of desired BLE
104#define EPROM_PAIRED_DEVICE_ADDRESS_SETTING "30da"
105
106//!retreives the motor direction| true default, clockwise; false = REVERSE, counterclockwise 9.8.22
107//! false = reverse == counterclockwise
108//! true = default
109#define EPROM_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING "31md"
110
111//!send WIFI to all except our device (and our paired) when
112#define EPROM_SENDWIFI_WITH_BLE "32wb"
113
114//! starts the BLE Discovery notification process - which might be internal or externa (via messages).
115#define EPROM_NOTIFY_BLE_DISCOVERY "33bd"
116
117//! the preference timer
118#define EPROM_PREFERENCE_TIMER_INT_SETTING "34tm"
119
120//! the preference for supporting GROUPS (*default true)*
121#define EPROM_PREFERENCE_SUPPORT_GROUPS_SETTING "35g"
122
123//! the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wildcard in the future)
124#define EPROM_PREFERENCE_GROUP_NAMES_SETTING "36g"
125
126//! a place to put some kind of Last Will of what went wrong .. for now (> max tries)
127#define EPROM_PREFERENCE_DEBUG_INFO_SETTING "37db"
128
129
130//!9.28.23 #272 only show Semantic Markers that are sent directly to the device
131#define EPROM_DEV_ONLY_SM_SETTING "38dsm"
132
133//! 11.29.23 add the max time .. so a random can be used
134#define EPROM_PREFERENCE_TIMER_MAX_INT_SETTING "39x"
135
136//! 1.1.24 the preference for all the ATOM plugs (format: atomType:value} .. for now just use socket:on
137#define EPROM_PREFERENCE_ATOMS_SETTING "40a"
138
139//!1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
140#define EPROM_PREFERENCE_ATOM_KIND_SETTING "41Atom"
141
142//! 1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
143#define EPROM_PREFERENCE_SM_ON_PIR_SETTING "42pir"
144//! 1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
145#define EPROM_PREFERENCE_SM_COMMAND_PIR_SETTING "43pir"
146//! 1.11.24 The Semantic Marker command is sent on PIR, and the Command to send
147#define EPROM_PREFERENCE_SM_COMMAND_PIR_OFF_SETTING "44pir"
148//! 1.12.24 Whether the AtomSocket accepts global on/off messages
149#define EPROM_PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING "45sock"
150
151//! 4.4.24 for MQTT use of spiff (or not)
152#define EPROM_USE_SPIFF_MQTT_SETTING "46spiff"
153//! 4.4.24 for QRATOM use of spiff (or not)
154#define EPROM_USE_SPIFF_QRATOM_SETTING "47spiff"
155
156//! 8.2.24 to let older Tumbler NOT do the auto direction (back and forth)
157//! Isue #332
158//! it will set via message: autoMotorDirection
159//! {"set":"autoMotorDirection","val":"true"}
160#define EPROM_STEPPER_AUTO_MOTOR_DIRECTION_SETTING "48a"
161
162//! include these topics groups..
163#define EPROM_INCLUDE_GROUP_NAMES_SETTING "49e"
164
165//!retreives the FACTORY motor direction| true default, clockwise; false = REVERSE, counterclockwise 9.8.22
166//! false = reverse == counterclockwise
167//! true = default
168#define EPROM_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING "50sf"
169
170
171//! issue #338 sensor definition (in work)
172//! This will be a string in JSON format with various PIN and BUS information
173#define EPROM_SENSOR_PLUGS_SETTING "51sp"
174
175//!5.14.25 Dead 5.14.74 Montana
176//! issue #365 Object Oriented Sensors as well
177//! define the sensors (not sensorPlugs). MQTT: set:sensor, set:sensors
178#define EPROM_SENSORS_SETTING "52sensors"
179
180//!8.14.25 Dead Movie from 10.19.1974 tonight..
181//! issue #394 stepperRPM
182//! stepper RPM
183#define EPROM_STEPPER_RPM_SETTING "53sRPM"
184
185//! 9.3.25 back from LA, Horses out. Tyler on lap. Europe next week
186//! sets the 2feed option (go back and forth)
187#define EPROM_STEPPER_2FEED_SETTING "542feed"
188
189//!12.21.25 Winter Solstice party ..
190//! issue #365 Object Oriented Sensors as well
191//! define the sensors (not sensorPlugs). MQTT: set:sensor, set:sensors
192#define EPROM_CHAIN_SENSORS_SETTING "6Chain5snsors"
193
194
195//!the EPROM is in preferences.h
196#include <Preferences.h>
197//!name of main prefs eprom
198#define PREFERENCES_EPROM_MAIN_NAME "MainPrefs"
199
200
201
202//! preferences for MAIN
204//!array of preference names (those used in process()
206//!array of default values to store in the EPROM if not defined..
208//!initialize the _preferencesMainLookup with EPROM lookup names
210
211//!Cache for heavy hitter boolean values (those referenced every loop.. seems to be hard on the EPROM to keep up:
212//! This array will only have the Boolean values set.. the 'save' will fill them, and the 'get' will return
214
215//!array of boolean if the ID is cached..
217
218//! another cache for the Int values..
220
221//!array of boolean if the ID is cached..
223
224//! 8.2.24 retrieve the includeGroup
225//! really ask a topic if it's in the include group
226//! modifies the _
227boolean topicInIncludeGroup(char *topic)
228{
229 // for now just see if topc in groups..
230 //! 8.2.24 just string match for now..
231 //! NOTE: topic is a full path .. but
232 //! MessageArrived: '#FEED {'deviceName':'MaggieMae'}', onTopic=usersP/groups/atlasDogs
233 boolean found = false;
234
235 //! find the topic (eg. usersP/groups/atlasDogs , is atlasDogs
236 char *topicName = rindex(topic,'/');
237 //! go past the "/"
238 topicName++;
239
240 //! go through list..
241 for (int i=0; i< _includeGroupLen; i++)
242 {
243 char *group = _includeGroupsStringArray[i];
244 if (group && strlen(group) == 0)
245 {
246 //!empty is a find .. not specified
247 found = true;
248 break;
249 }
250 //! note "group" the short name is 2nd so it's asking if "/userP/groups/atlasDogs contains string atlasDogs
251 //! that way the topic doesn't need to be parsed.. (although it could be wrong :eg atlas also matches..
252 //if (containsSubstring(topic, group))
253 SerialTemp.printf("compare: %s to %s\n", topicName, group);
254 if (strcmp(topicName, group) == 0)
255 {
256 found = true;
257 break;
258 }
259 }
260 if (_includeGroupLen == 0)
261 {
262 found = true;
263 }
264
265 SerialTemp.printf("topicInIncludeGroup(%s) =%d\n", topicName, found);
266 return found;
267}
268
269//! 8.2.24 set the include group (and cache it), called (indirectly from MQTT via setIncludeGroups
270void parseIncludeGroups(char *groups)
271{
272 SerialTemp.printf("parseIncludeGroups %s\n", groups);
273
274 //! parse the groups (if nothing, then it's ok if no "," use full string)
275 /**
276 The strtok_r() function is a reentrant version strtok(). The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string.
277 On the first call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored. In subsequent calls, str should be NULL, and saveptr should be unchanged since the previous call.
278
279 char *strtok_r(char *str, const char *delim, char **saveptr);
280 @see https://www.tutorialspoint.com/c_standard_library/c_function_strtok.htm
281 @see https://linux.die.net/man/3/strtok_r
282 */
283
285 if (!index(groups,','))
286 {
287 //!no comma
290 SerialTemp.printf("Add Group[%d] %s\n", _includeGroupLen, groups);
291 }
292 else
293 {
294 char *str = groups;
295 char *rest = NULL;
296 char *token;
297 for (token = strtok_r(str,",",&rest); token != NULL; token = strtok_r(NULL, ",", &rest))
298 {
300 SerialTemp.printf("Add Group[%d] %s\n", _includeGroupLen, _includeGroupsStringArray[_includeGroupLen]);
302
303 }
304 }
305}
306
307//! 8.2.24 set the include group (and cache it), called from MQTT
308void setIncludeGroups(char *groups)
309{
310 //!process the groups..
311 parseIncludeGroups(groups);
312
313 //!save persistently
315}
316
317//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
318void savePreference_mainModule(int preferenceID, String preferenceValue)
319{
320#ifdef NOT_NOW
321 if (preferenceID != PREFERENCE_DEBUG_INFO_SETTING)
322 SerialTemp.printf("savePreference .. %d = '%s'\n", preferenceID, preferenceValue.c_str());
323#endif
324 // cannot invoke the preference, as this would be an infinite loop back to here..
325
326 //save in EPROM
327 _preferencesMainModule.begin(PREFERENCES_EPROM_MAIN_NAME, false); //readwrite..
328 _preferencesMainModule.putString(_preferenceMainModuleLookupEPROMNames[preferenceID], preferenceValue);
329
330 // Close the Preferences
332
333}
334
335//! special preference string for saving and printing back later..
336#define MAX_APPEND 1500
337//!storage for the appending string
339//! called to init the preference. This won't save anything until storePreference called
341{
343}
344
345//! called to init the preference. This won't save anything until storePreference called
347{
349}
350//! called to append to a a preference (which will be an identifier and a string, which can be converted to a number or boolean)
351void appendPreference_mainModule(int preferenceID, String preferenceValue)
352{
354 {
355 SerialDebug.println(" *** preference > max, emptying .. ");
357 }
358 _appendingPreferenceString += "\n" + preferenceValue;
359}
360//! called to append to a a preference (which will be an identifier and a string, which can be converted to a number or boolean)
361void storePreference_mainModule(int preferenceID, String preferenceValue)
362{
363#ifdef AP_DEBUG_MODE
364
365 appendPreference_mainModule(preferenceID, preferenceValue);
366 // SerialDebug.printf("storePref(%d): %s\n", _appendingPreferenceString.length(), _appendingPreferenceString.c_str());
368#else
369 //!turn AP_DEBUG_MODe off for now...
370 //!1.1.24 seems the append is goofing things..
371 savePreference_mainModule(preferenceID, preferenceValue);
372
373#endif
374}
375
376//! called to reset to blank a preference (which will be an identifier and a string, which can be converted to a number or boolean)
377void resetPreference_mainModule(int preferenceID)
378{
379#ifdef DO_ERASE
380 savePreference_mainModule(preferenceID,"");
382#endif
383}
384
385
386//!sets an int preference
387void savePreferenceInt_mainModule(int preferenceID, int val)
388{
389 if (_isCachedPreferenceInt[preferenceID])
390 {
391 //! CACHE SETTINGS 1
392 _cachedPreferenceIntValues[preferenceID] = val;
393 }
394
395 //!convert to a string..
396 char str[20];
397 sprintf(str,"%d",val);
398 savePreference_mainModule(preferenceID, str);
399}
400
401//!sets an int, but only if a valid integer, and no signs. If bad, then a 0 is stored
402void savePreferenceIntFromString_mainModule(int preferenceID, char* val)
403{
404 //This function returns the converted integral number as an int value. If no valid conversion could be performed, it returns zero.
405 int num = atoi(val);
406 savePreferenceInt_mainModule(preferenceID, num);
407}
408
409//!toggles a preference boolean
411{
412 boolean val = getPreferenceBoolean_mainModule(preferenceID);
413 val = !val;
414 savePreferenceBoolean_mainModule(preferenceID, val);
415}
416
417
418
419//! called to get a preference (which will be an identifier and a string, which can be converted to a number or boolean)
420//! Note: no CACHE is looked at here. It's up to the Boolean or Int to do that..
421char* getPreference_mainModule(int preferenceID)
422{
423 // cannot invoke the preference, as this would be an infinite loop back to here..
424
425 //!get from EPROM
427
428 strcpy(_preferenceBuffer, _preferencesMainModule.getString( _preferenceMainModuleLookupEPROMNames[preferenceID]).c_str());
429#ifdef TOOMUCH
430 SerialLots.printf("getPreference_mainModule[%d] = %s\n", preferenceID, _preferenceBuffer);
431#endif
432 // Close the Preferences
434 return _preferenceBuffer;
435}
436
437
438//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
439boolean getPreferenceBoolean_mainModule(int preferenceID)
440{
441 boolean valBool;
442 // check some of the boolean ones
443 if (_isCachedPreferenceBoolean[preferenceID])
444 {
445 //! CACHE SETTINGS 5
446 valBool = _cachedPreferenceBooleanValues[preferenceID];
447#ifdef TOOMUCH
448 SerialLots.print(" CACHE preference = ");
449 SerialLots.printf(" [%d] = ",preferenceID);
450 SerialLots.println(valBool);
451#endif
452 }
453 else
454 {
455 char* val = getPreference_mainModule(preferenceID);
456#ifdef TOOMUCH
457 SerialLots.print(" preference = ");
458 SerialLots.printf(" [%d] = ",preferenceID);
459 SerialLots.println(val);
460#endif
461 valBool = (strcmp(val,"1")==0)?true:false;
462 }
463 return valBool;
464}
465
466//! save a boolean preference
467void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
468{
469 if (_isCachedPreferenceBoolean[preferenceID])
470 {
471 //! CACHE SETTINGS 5
472 _cachedPreferenceBooleanValues[preferenceID] = flag;
473
474 SerialLots.print(" set CACHE preference");
475 SerialLots.printf(" [%d] = ",preferenceID);
476 SerialLots.println(flag);
477 }
478
479 savePreference_mainModule(preferenceID, flag?(char*)"1":(char*)"0");
480}
481
482
483
484//!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
485char* getPreferenceString_mainModule(int preferenceID)
486{
489}
490//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
491int getPreferenceInt_mainModule(int preferenceID)
492{
493 int ival = 0;
494 if (_isCachedPreferenceInt[preferenceID])
495 {
496 ival = _cachedPreferenceIntValues[preferenceID];
497 }
498 else
499 {
500 ival = atoi(getPreference_mainModule(preferenceID));
501 }
502
503 return ival;
504}
505
506//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
507float getPreferenceFloat_mainModule(int preferenceID)
508{
509 //!TODO: 8.18.24 add a cache for floats ..
510 //!actially cache the string value??
511 char* val = getPreference_mainModule(preferenceID);
512 float fval = atof(val);
513 return fval;
514}
515//! called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
516void savePreferenceFloat_mainModule(int preferenceID, float val)
517{
518 //!convert to a string..
519 char str[20];
520 sprintf(str,"%2f",val);
521 savePreference_mainModule(preferenceID, str);
522}
523
524//! clean the preferencesMainModule in EPROM
526{
527 _preferencesMainModule.begin(PREFERENCES_EPROM_MAIN_NAME, false); //readwrite..
530}
531
532//!set some defaults on boot - that override EPROM
533//!This is also called when going back tot he MAIN menu (HOME SCREEN)
535{
536 SerialTemp.println("setOnBootPreferences_mainModule");
537 //!set zoomed = true (no semantic marker)
539
540 //!use the minimal menu on boot
542
543
544}
545
546//! reads the preferences. Save is everytime the savePreference is called
547//! 5.14.25 (Dead 5.14.74 3rd Wall of Sound)
548//! add the Sensors as well..
550{
551 SerialDebug.printf("readPreferences_mainModule(%s)\n",PREFERENCES_EPROM_MAIN_NAME);
552
553 //!clean the cached, and initialize what are cached..
554 for (int i = 0; i < MAX_MAIN_PREFERENCES; i++)
555 {
559 _isCachedPreferenceInt[i] = false;
560 }
561
562 //!intiialize the preferences arrays from EPROM. This also updates the defaults
563 //! BUT: the caches below are from the value retrieved (and defult if need be)
565
566 //!start the read-write of the EPROM
567 _preferencesMainModule.begin(PREFERENCES_EPROM_MAIN_NAME, false); //readwrite..
568
569 for (int i = 0; i < MAX_MAIN_PREFERENCES; i++)
570 {
571 String preferenceValue;
572 int preferenceID = i;
573 preferenceValue = _preferencesMainModule.getString(_preferenceMainModuleLookupEPROMNames[preferenceID]);
574 //SerialLots.printf("preverenceValue[%s] = %s\n", _preferenceMainModuleLookupEPROMNames[preferenceID], preferenceValue);
575 if (preferenceValue && preferenceValue.length() > 0)
576 {
577 // already set
578 SerialLots.printf(" *** alreadySet %s\n",_preferenceMainModuleLookupEPROMNames[preferenceID] );
579 }
580 else
581 {
582 //otherwise go to the preference defaults
583 preferenceValue = _preferenceMainModuleLookupDefaults[i];
584 _preferencesMainModule.putString(_preferenceMainModuleLookupEPROMNames[preferenceID], preferenceValue);
585 }
586 SerialLots.printf("Preference[%s] = ",_preferenceMainModuleLookupEPROMNames[preferenceID]);
587 SerialLots.println(preferenceValue);
588
589 //! check some of the boolean ones to cache .. so don't have to go to the EPROM everytime..
590 switch (i)
591 {
592 //! 9.4.25 STRANGE: the BOOLEAN aren't working too good
593 //! so removing CLOCKWISE and STEPPER_2FEED
594 //!**** NOTE: THis is where whether things are cached or not is set! Eventually all boolean and int could be cached..
595 //! CACHE SETTINGS (boolean)
605 //!8.2.24
607 //! 9.3.25 strange wasn't working ... if in cache..
608 // case PREFERENCE_STEPPER_2FEED_SETTING:
609 // case PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING:
610
611 //SerialLots.printf("setting Cached[%d] = %s\n", i, preferenceValue);
613 _cachedPreferenceBooleanValues[i] = (preferenceValue.compareTo("1")==0)?true:false;
614 break;
615 //! CACHE SETTINGS (int)
620
621 _isCachedPreferenceInt[i] = true;
622 _cachedPreferenceIntValues[i] = atoi(&preferenceValue[0]);
623 break;
624
625 //! 8.2.24 set the includeGroups
627 //! grab the state at the start, then it's only modified from a MQTT message
628 {
630 //!save
631 //! parse (do it this way, instead of setIncludeGroups (as that stored in eprom again)
632 parseIncludeGroups(groups);
633 }
634 break;
635#ifdef TODO_THIS_CACHE
636 //! 8.18.24 figure this out ..
637 //! the UNO is not using this .. so let's not worry about it for now ... only Tumbler.
639 {
640 //! do this in the "string" part, not the float part..
641 break;
642 }
643#endif
644 default:
645 break;
646 }
647 }
648 //! Close the Preferences
650
651 //! set onbootPreferences
653
654 //! 5.14.25 (Dead 5.14.74 3rd Wall of Sound)
655 //! add the Sensors as well..
657
658#pragma mark CHAIN
659 //! 1.23.26 do the same for chain
660 //! 1.30.26 THIS is done whether we have the actual buttons or not,
661 //! that is defined which SensorClass -- ChainButtonClassType
663
664}
665
666//!initialize the _preferencesMainLookup with EPROM lookup names
667//!BUT these are not stored in EPROM. The next method
669{
670 SerialDebug.println("***initPreferencesMainModule");
671#ifdef AP_DEBUG_MODE
672#else
673 // savePreference_mainModule(PREFERENCE_DEBUG_INFO_SETTING,"");
675#endif
676
677 strcpy(_preferenceBufferString,(char*)"");
678 strcpy(_preferenceBuffer,(char*)"");
679
680 //! 9.4.25 NOTE: tese are in case the EPROM wasn't set. So the EPROM is used over these values..
681 for (int i = 0; i < MAX_MAIN_PREFERENCES; i++)
682 {
683 switch (i)
684 {
688#ifdef ESP_M5
689 //! 12.27.23 ON for all M5 (the reason is credentials ...)
690#ifdef ESP_M5_CAMERA
691 //!default on for the M5 Camera (but it can be turned on later..)
693#else
694#ifdef ATOM_QRCODE_MODULE
695 //! 12.8.22 default back TRUE
696 //!default off for the M5 (but it can be turned on later..)
698#else
699 //! 12.8.22 default back TRUE
700 //!default off for the M5 (but it can be turned on later..)
702#endif //ATOM
703#endif //ESP_M5_CAMERA
704#else
705 //! 12.8.22 default back TRUE
706 //!default off for the M5 (but it can be turned on later..)
708#endif //ESP_M5
709 SerialLots.printf(" **** setting PREFERENCE_MAIN_BLE_SERVER_VALUE[%d]: %s\n", i,_preferenceMainModuleLookupDefaults[i]);
710 break;
713#ifdef ESP_M5
714 //! 12.27.23 ON for most M5 , but off for the SOCKET
715#ifdef ATOM_SOCKET_MODULE
716 //! only the SOCKET will be off by default for now...
718#else
720#endif // ESP_M5_ATOM_LITE
721
722#else
724#endif
725 break;
726 //! Sensor preferences
730 break;
735 break;
736 //!used for first time features..
740 //! This is a feeder that gateways to a GEN3
741#ifdef ESP_32_FEEDER_BLE_GEN3
743#else
744 //! This is a feeder that gateways to a GEN3
746#endif
747 break;
748
749 //INT SETTINGS..
754 break;
755
756
757 //! REST ARE NOT CACHED
758 //These are hard coded default values for the preferences
762 break;
763
764 //! STEPPER preferences (no ifdef.. )
768 break;
772 break;
776 break;
778 /*
779 per issue @269, stepper angle default = 45 (which it has been for awhile)
780 */
783#ifdef ESP_M5
784 //! 5.2.25 default 0.5 SECONDS (not angle for the HDriver
785 _preferenceMainModuleLookupDefaults[i] = (char*)"1.25";
786#else
787 _preferenceMainModuleLookupDefaults[i] = (char*)"22.5";
788#endif
789 break;
792 //! 3.28.23 change default to 5 (from 30)
794 break;
797 //! 11.29.23 add a max so random can be used
799 break;
802 /*
803 #define STEPPER_IS_UNO 1
804 #define STEPPER_IS_MINI 2
805 #define STEPPER_IS_TUMBLER 3
806 per issue @269, default is now Tumbler
807 */
809 break;
813 break;
817 break;
818
822 break;
826 break;
830 break;
833 _preferenceMainModuleLookupDefaults[i] = (char*)"480";
834 break;
838 break;
843 break;
847 _preferenceMainModuleLookupDefaults[i] = (char*)"NONE";
848 break;
852 _preferenceMainModuleLookupDefaults[i] = (char*)"NONE";
853 break;
857 _preferenceMainModuleLookupDefaults[i] = (char*)"NONE";
858 break;
862#ifdef ESP_M5
863#ifdef ESP_M5_CAMERA
864 _preferenceMainModuleLookupDefaults[i] = (char*)"M5Camera";
865#else
866#ifdef ESP_M5_ATOM_LITE
867 _preferenceMainModuleLookupDefaults[i] = (char*)"M5Atom";
868#else
870#endif //ESP_m5
871#endif //ESP_M5_Camera
872#else
873 _preferenceMainModuleLookupDefaults[i] = (char*)"ESP32";
874#endif
875 break;
876
877 //!set with message: set:bleusedevicename,val:on/off
880 //! 12.8.22 setting to TRUE as default
882#ifdef ESP_M5
883 //! 1.6.23 .. PetTutor Blue app still not always discovering new syntax
885#else
886 //! 3.24.25 use the BLE name in the feeder too..
888 //_preferenceMainModuleLookupDefaults[i] = (char*)"0";
889
890#endif
891 break;
892 //!set with message: set:bleusepaireddevicename,val:on/off
896 break;
897
901 break;
902 //!used for first time features..
907 break;
908
909 //! 8.17.22 to turn on/off subscribing to the dawgpack topic
913#ifdef ESP_M5
915#else
917#endif
918 break;
919
920 //!//! 8.22.22 to turn on/off SPIFF use (not cached yet as it's an infrequent event)
924#ifdef ESP_M5_CAMERA
926#else
928
929#endif
930 break;
931
932 //!the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
937
938 break;
939
940 ///!retreives the motor direction| 0 (false) = default, clockwise; 1 (true) = REVERSE, counterclockwise 9.8.22
941 //! TRUE = reverse == counterclockwise
942 //! FALSE = default
947
948 break;
949 //! 8.18.24 the factory setting
950 ///!retreives the motor direction| 0 (false) = default, clockwise; 1 (true) = REVERSE, counterclockwise 9.8.22
951 //! TRUE = reverse == counterclockwise
952 //! FALSE = default
957
958 break;
959
960 //! 10.4.22
965
966 break;
967
968 //! 11.1.22 TODO.. messages for this..
973 break;
974
975 //! 7.26.23 added group message support (or turn it off)
976 //! PREFERENCE_SUPPORT_GROUPS_SETTING
977 //! default OFF 1.15.24
978 //! @see https://github.com/konacurrents/ESP_IOT/issues/300
983 break;
984
985 //! 7.26.23 added group message support (or turn it off)
986 //! PREFERENCE_GROUP_NAMES_SETTING
987 //! the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wildcard in the future)
992 break;
993
994 //! a place to put some kind of Last Will of what went wrong .. for now (> max tries)
995 //! 9.16.23
999 _preferenceMainModuleLookupDefaults[i] = (char*)"none";
1000 break;
1001
1002 //! 9.28.23 #272 only show Semantic Markers that are sent directly to the device, default OFF
1007 break;
1008
1009 //! 1.1.24 first version of preferences for the ATOMs depending on which ATOM kind
1010 //! first version, only the socket and the value is on/off
1011 //! syntaxURL socket=off&smscanner=on
1015 _preferenceMainModuleLookupDefaults[i] = (char*)"socket=off";
1016 break;
1017
1018 //!1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
1022 _preferenceMainModuleLookupDefaults[i] = (char*)"M5AtomScanner";
1023 break;
1024
1025 //! 1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
1030 break;
1031
1032 //! 1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
1036 _preferenceMainModuleLookupDefaults[i] = (char*)"{'set':'socket','val':'on'}";
1037 break;
1038 //! 1.11.24 The Semantic Marker command is sent on PIR, and the Command to send for OFF
1042 _preferenceMainModuleLookupDefaults[i] = (char*)"{'set':'socket','val':'off'}";
1043 break;
1044
1045 //! 1.12.24 whether global on/off is allowed. Default on..
1050 break;
1051
1052 //!//! 4.4.24 to turn on/off SPIFF use (not cached yet as it's an infrequent event)
1056#ifdef USE_SPIFF_MQTT_SETTING
1058#endif //USE_SPIFF_MQTT_SETTING
1059 break;
1060 //!//! 4.4.24 to turn on/off SPIFF use (not cached yet as it's an infrequent event)
1064#ifdef USE_SPIFF_QRATOM_SETTING
1066#endif //USE_SPIFF_QRATOM_SETTING
1067 break;
1068
1069
1070 //! 8.2.24 to let older Tumbler NOT do the auto direction (back and forth)
1071 //! Isue #332
1072 //! it will set via message: autoMotorDirection
1073 //! {"set":"autoMotorDirection","val":"true"}
1078 break;
1079
1080 //! 8.2.24 include these groups (or none)
1081 //! {"set":"includeGroups","val":"group1,group2"}
1086 break;
1087
1088 //! issue #338 sensor definition (in work)
1089 //! This will be a string in JSON format with various PIN and BUS information
1093 _preferenceMainModuleLookupDefaults[i] = (char*)"L9110S_DCStepperClass";
1094 break;
1095
1096 //! 12.21.25 Winter Solstice, Eagles, Party,
1097 //! these are the CHAIN_SENSORS
1102 break;
1103
1104 //!5.14.25 Dead 5.14.74 Montana
1105 //! issue #365 Object Oriented Sensors as well
1106 //! define the sensors (not sensorPlugs). MQTT: set:sensor, set:sensors
1107 //! 7.9.25 default to BuzzerSensorClass and L9110S_DCStepperClass
1110 (char*)EPROM_SENSORS_SETTING;
1111 _preferenceMainModuleLookupDefaults[i] = (char*)"BuzzerSensorClass,23,33,L9110S_DCStepperClass,21,25";
1112 break;
1113
1114
1115 //!8.14.25 Dead Movie from 10.19.1974 tonight..
1116 //! issue #394 stepperRPM
1117 //! stepper RPM
1121 _preferenceMainModuleLookupDefaults[i] = (char*)"15.0";
1122 break;
1123
1124 //!9.3.25 Dead Movie.. let it grow
1125 //!
1130 SerialLots.println(" ** setting PREFERENCE_STEPPER_2FEED_SETTING = 0");
1131 break;
1132
1133
1134 default:
1135 SerialError.printf(" ** NO default for preference[%d]\n", i);
1136 }
1137 SerialLots.printf("** setting [%d] = %s\n", i, _preferenceMainModuleLookupDefaults[i]);
1138 }
1139}
1140
1141#ifdef NOT_USED
1142//! 7.9.25 reset SENSORS to default
1143//! "BuzzerSensorClass,23,33,L9110S_DCStepperClass,21,25"
1144void resetSensorToDefault_mainModule()
1145{
1146 setSensorsString_mainModule((char*)"BuzzerSensorClass,23,33,L9110S_DCStepperClass,21,25");
1147}
1148#endif
1149
1150//!print the preferences to SerialDebug
1152{
1153 //!this inits the string to the EPROM value
1155
1156#ifdef SERIAL_DEBUG_TEMP
1157 SerialTemp.println("******************");
1158 SerialTemp.println(VERSION);
1159 SerialTemp.printf("CHIP_ID: %s\n", getChipIdString());
1160 SerialTemp.printf("PREFERENCE_DEVICE_NAME_SETTING: %s\n", getPreference_mainModule(PREFERENCE_DEVICE_NAME_SETTING));
1161 {
1162 const char *BLEDeviceName = connectedBLEDeviceName_mainModule()?connectedBLEDeviceName_mainModule():"none";
1163
1164 SerialTemp.printf("CONNECTED_BLE_DEVICE: %s\n", BLEDeviceName);
1165 }
1166 //! 12.24.25 return the username and password, Kevin feature .. he was setting to WIFI acidently. I updated APP to make that harder
1167 //! note on reboot this won't be set until later, so do another ""
1168 SerialTemp.printf("USERNAME: %s\n", main_getUsername());
1169 SerialTemp.printf("PASSWORD: %s\n", main_getPassword());
1170
1171 //ouch.. this sets 2 values ..
1172 // readPreferences_mainModule();
1173 SerialTemp.printf("STEPPER_KIND: %d 1=UNO,2=MINI,3=TUMBLER\n", getPreferenceInt_mainModule(PREFERENCE_STEPPER_KIND_VALUE));
1174 SerialTemp.printf("PREFERENCE_TIMER_INT_SETTING: %d\n", getPreferenceInt_mainModule(PREFERENCE_TIMER_INT_SETTING));
1175 SerialTemp.printf("STEPPER_AUTO_FEED: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_AUTO_FEED_VALUE));
1176 SerialTemp.printf("STEPPER_JACKPOT_FEED: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_JACKPOT_FEED_VALUE));
1177 SerialTemp.printf("PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING: %f\n", getPreferenceFloat_mainModule(PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING));
1178 SerialTemp.printf("STEPPER_FEEDS_PER_JACKPOT: %d\n", getPreferenceInt_mainModule(PREFERENCE_STEPPER_FEEDS_PER_JACKPOT));
1179 SerialTemp.printf("DISPLAY_SCREEN_TIMEOUT: %d\n", getPreferenceInt_mainModule(PREFERENCE_DISPLAY_SCREEN_TIMEOUT_VALUE));
1180 SerialTemp.printf("PREFERENCE_STEPPER_BUZZER_VALUE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_BUZZER_VALUE));
1181
1182 SerialTemp.printf("PREFERENCE_HIGH_TEMP_POWEROFF_VALUE: %d\n", getPreferenceInt_mainModule(PREFERENCE_HIGH_TEMP_POWEROFF_VALUE));
1183 SerialTemp.printf("PREFERENCE_IS_MINIMAL_MENU_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_IS_MINIMAL_MENU_SETTING));
1184 SerialTemp.printf("PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE));
1185 SerialTemp.printf("PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING: %d\n", getPreferenceInt_mainModule(PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING));
1186 SerialTemp.printf("PREFERENCE_MAIN_GATEWAY_VALUE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_MAIN_GATEWAY_VALUE));
1187 SerialTemp.printf("PREFERENCE_SENSOR_TILT_VALUE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_SENSOR_TILT_VALUE));
1188 SerialTemp.printf("WIFI_CREDENTIAL_1: %s\n", getPreference_mainModule(PREFERENCE_WIFI_CREDENTIAL_1_SETTING));
1189 SerialTemp.printf("WIFI_CREDENTIAL_2: %s\n", getPreference_mainModule(PREFERENCE_WIFI_CREDENTIAL_2_SETTING));
1190 SerialTemp.printf("PREFERENCE_PAIRED_DEVICE_SETTING: %s\n", getPreference_mainModule(PREFERENCE_PAIRED_DEVICE_SETTING));
1191 SerialTemp.printf("PREFERENCE_PAIRED_DEVICE_ADDRESS_SETTING: %s\n", getPreference_mainModule(PREFERENCE_PAIRED_DEVICE_ADDRESS_SETTING));
1192 SerialTemp.printf("PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING));
1193
1194 SerialTemp.printf("PREFERENCE_MAIN_BLE_CLIENT_VALUE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_MAIN_BLE_CLIENT_VALUE));
1195 SerialTemp.printf("PREFERENCE_MAIN_BLE_SERVER_VALUE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_MAIN_BLE_SERVER_VALUE));
1196
1197#ifdef TOO_SOON
1198 //! DARN: the class hasn't been instantiated yet ...
1199 //! 10.10.25 #405 #406
1200 //! see if the device is a PTClicker if the M5Atom class is one..
1201 //! return the service name: PTClicker or PTFeeder
1202 SerialTemp.printf("PREFERENCE_BLE_SERVER_NAME: %s:%s\n", getServerServiceName_mainModule(),getPreference_mainModule(PREFERENCE_DEVICE_NAME_SETTING));
1203#endif
1204 SerialTemp.printf("PREFERENCE_FIRST_TIME_FEATURE_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_FIRST_TIME_FEATURE_SETTING));
1205 SerialTemp.printf("PREFERENCE_SCREEN_COLOR_SETTING: %d\n", getPreferenceInt_mainModule(PREFERENCE_SCREEN_COLOR_SETTING));
1206
1207 SerialTemp.printf("PREFERENCE_SUB_DAWGPACK_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_SUB_DAWGPACK_SETTING));
1208 SerialTemp.printf("PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING));
1209 SerialTemp.printf("PREFERENCE_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING));
1210 SerialTemp.printf("AUTO_MOTOR_DIRECTION: %d 1=reverseEachTime,2=dont\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING));
1211 //! don't change subscription but include these groups (eg. safeHouse,atlasDogs)
1212 SerialTemp.printf("PREFERENCE_INCLUDE_GROUP_NAMES_SETTING: %s\n", getPreference_mainModule(PREFERENCE_INCLUDE_GROUP_NAMES_SETTING));
1213 SerialTemp.printf("PREFERENCE_SENDWIFI_WITH_BLE: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_SENDWIFI_WITH_BLE));
1214 SerialTemp.printf("PREFERENCE_ONLY_GEN3_CONNECT_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_ONLY_GEN3_CONNECT_SETTING));
1215 SerialTemp.printf("PREFERENCE_SUPPORT_GROUPS_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_SUPPORT_GROUPS_SETTING));
1216 SerialTemp.printf("PREFERENCE_GROUP_NAMES_SETTING: %s\n", getPreference_mainModule(PREFERENCE_GROUP_NAMES_SETTING));
1217 SerialTemp.printf("PREFERENCE_DEV_ONLY_SM_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_DEV_ONLY_SM_SETTING));
1218
1219 SerialTemp.printf("PREFERENCE_ATOMS_SETTING: %s\n", getPreference_mainModule(PREFERENCE_ATOMS_SETTING));
1220 SerialTemp.printf("PREFERENCE_ATOM_KIND_SETTING (M5AtomClassType): %s\n", getPreference_mainModule(PREFERENCE_ATOM_KIND_SETTING));
1221
1222 //! 1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
1223 SerialTemp.printf("PREFERENCE_SM_ON_PIR_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_SM_ON_PIR_SETTING));
1224 //! 1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
1225 SerialTemp.printf("PREFERENCE_SM_COMMAND_PIR_SETTING: %s\n", getPreference_mainModule(PREFERENCE_SM_COMMAND_PIR_SETTING));
1226 //! 1.11.24 The Semantic Marker command is sent on PIR, and the Command to send
1227 SerialTemp.printf("PREFERENCE_SM_COMMAND_PIR_OFF_SETTING: %s\n", getPreference_mainModule(PREFERENCE_SM_COMMAND_PIR_OFF_SETTING));
1228 //! 1.12.24 The Semantic Marker command is sent on PIR, and the Command to send
1229 SerialTemp.printf("PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING));
1230
1231 SerialTemp.printf("PREFERENCE_SENSOR_PLUGS_SETTING (MotorStepperClassType): %s\n", getPreference_mainModule(PREFERENCE_SENSOR_PLUGS_SETTING));
1232
1233 //! 5.14.25
1234 SerialTemp.printf("PREFERENCE_SENSORS_SETTING: %s\n", getPreference_mainModule(PREFERENCE_SENSORS_SETTING));
1235
1236 //! 12.21.25
1237 //! 5.14.25
1238 SerialTemp.printf("PREFERENCE_CHAIN_SENSORS_SETTING: %s\n", getPreference_mainModule(PREFERENCE_CHAIN_SENSORS_SETTING));
1239
1240 //!8.14.25 Dead Movie from 10.19.1974 tonight..
1241 //! issue #394 stepperRPM
1242 //! stepper RPM
1243 SerialTemp.printf("PREFERENCE_STEPPER_RPM_SETTING: %s\n", getPreference_mainModule(PREFERENCE_STEPPER_RPM_SETTING));
1244
1245 //! 9.3.25 back from LA, Horses out. Tyler on lap. Europe next week
1246 //! sets the 2feed option (go back and forth)
1247 SerialTemp.printf("PREFERENCE_STEPPER_2FEED_SETTING: %d\n", getPreferenceBoolean_mainModule(PREFERENCE_STEPPER_2FEED_SETTING));
1248
1249
1250#ifdef M5CORE2_MODULE
1251 SerialTemp.printf("PREFERENCE_M5Core2_SETTING:\n");
1252#endif
1253#if (SERIAL_DEBUG_CALL)
1254 // this is many lines long .. so only show in the CALL settting..
1255 SerialTemp.printf("PREFERENCE_DEBUG_INFO_SETTING: %s\n", getPreference_mainModule(PREFERENCE_DEBUG_INFO_SETTING));
1256#endif
1257
1258
1259 SerialTemp.printf("WIFI_CREDENTIAL: %s\n", main_JSONStringForWIFICredentials());
1260 //!retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
1261
1262 //! 5.14.25 also print out the sensors
1263 //! print sensors
1265
1266 //! 1.24.26 Clear day .. 2 eagles again on walk
1268
1269 //! 7.31.25
1270 SerialTemp.println(" *** Example JSON messages you can modify and paste into serial monitor, no DEV required");
1271 //! TODO: add preference to not support this??
1272 //! show example JSON (break up as getPreference re-uses same string...
1273 SerialTemp.printf("{\"set\":\"sensors\",\"val\":\"%s\"}", (char*)"BuzzerSensorClass,19,22,L9110S_DCStepperClass,21,25");
1274 SerialTemp.println();
1275// SerialTemp.printf("{\"set\":\"sensors\",\"val\":\"%s\"}", (char*)"BuzzerSensorClass,21,25,ULN2003_StepperClass,23,33");
1276// SerialTemp.println();
1277 SerialTemp.printf("{\"set\":\"sensors\",\"val\":\"%s\"}", (char*)"PIRSensorClass,23,33");
1278 SerialTemp.println();
1279 SerialTemp.printf("{\"set\":\"sensorPlugs\",\"val\":\"L9110S_DCStepperClass\"}");
1280 SerialTemp.println();
1281 SerialTemp.printf("{\"set\":\"M5AtomKind\",\"val\":\"M5HDriver\"}");
1282 SerialTemp.println();
1283// SerialTemp.printf("{\"set\":\"stepperAngle\",\"val\":\"0.25\"} ");
1284// SerialTemp.println();
1285// SerialTemp.printf("{\"set\":\"stepperRPM\",\"val\":\"15.0\"}");
1286// SerialTemp.println();
1287// SerialTemp.printf("{\"set\":\"stepperAngle\",\"val\":\"2048.0\"}");
1288// SerialTemp.println();
1289 SerialTemp.printf("{\"set\":\"stepperAngle\",\"val\":\"150\"} --new Feeder");
1290 SerialTemp.println();
1291
1292
1293 SerialDebug.println("{\"ssid\":\"Bob\", \"ssidPassword\":\"scott\"}");
1294 SerialDebug.println("{\"set\":\"2feed\", \"val\":\"1\"}");
1295 SerialDebug.println("{\"set\":\"BLEUseDeviceName\", \"val\":\"off\"}");
1296
1297
1298 //! 7.31.25 PIN USE
1299 PinUseStruct* pinUseStruct = getPinUseStruct_mainModule();
1300 SerialTemp.printf(" *** PIN USE (%d) .. check for duplicated done next .. look for 'ERROR' \n", pinUseStruct->pinUseCount);
1301
1302 for (int i=0; i< pinUseStruct->pinUseCount; i++)
1303 {
1304 SerialTemp.println(pinUseStruct->pinUseArray[i]);
1305 }
1306 SerialTemp.printf(" *** PIN Count = %d\n", pinUseStruct->pinUseCount);
1307
1308 //! this needs to have a long pin in the array as well
1309 //! 8.30.25 check if duplicates
1310 //! @see https://stackoverflow.com/questions/8199403/how-to-check-if-an-array-has-any-duplicates
1311 int count = pinUseStruct->pinUseCount;
1312 boolean duplicatePins = false;
1313
1314 for (int i = 0; i < count - 1; i++)
1315 {
1316 for (int j = i + 1; j < count; j++)
1317 {
1318 long pin1 = pinUseStruct->pinNumArray[i];
1319 long pin2 = pinUseStruct->pinNumArray[j];
1320 if (pin1 == pin2)
1321 {
1322 // do whatever you do in case of a duplicate
1323 duplicatePins = true;
1324 SerialDebug.printf("*** ERROR: DUPLICATE PIN: %d, (%s) == (%s)\n",pin1, pinUseStruct->pinUseArray[i], pinUseStruct->pinUseArray[j]);
1325 }
1326 }
1327 }
1328
1329#endif
1330}
1331
1332
1333//!resets preferences.. Currently only reset all, but eventually reset(groups..)
1335{
1336// savePreferenceBoolean_mainModule(PREFERENCE_SENDWIFI_WITH_BLE, false);
1337// savePreferenceInt_mainModule(PREFERENCE_TIMER_INT_SETTING, 30);
1338
1339 SerialLots.println("Clean EPROM.. ");
1340 //! dispatches a call to the command specified. This is run on the next loop()
1342
1343}
1344
1345boolean _DiscoverM5PTClicker = false;
1346//!transient for now... 10.4.22
1347//! set the M5 PTClicker discovery option..
1348void setDiscoverM5PTClicker(boolean flag)
1349{
1350 SerialTemp.println("Setting _DiscoverM5PTClicker");
1351 _DiscoverM5PTClicker = flag;
1352}
1353//! get option
1355{
1356 return _DiscoverM5PTClicker;
1357}
1358
1359
1360//! if the preference was retrieved..
1361boolean _firstTimeAtomKind = true;
1363//!returned from mainModule
1364//#define ATOM_KIND_M5_SCANNER 0
1365//#define ATOM_KIND_M5_SOCKET 1
1366//! new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner)
1367//! 1.5.24 also set the initial atom storage
1368//! Then the device reboots.. so setup() and loop() are for the correct ATOM
1370{
1371 SerialDebug.printf("M5AtomKind = %s\n", value.c_str());
1372 _firstTimeAtomKind = true;
1374
1375 //! 1.5.24 also set the initial atom storage
1376 //! 1.4.24 use the _atomKind (which CAN change)
1377 switch (getM5ATOMKind_MainModule())
1378 {
1380 //! 8.1.23 for the ATOM Lite QRCode Reader
1382 break;
1384 //! 12.26.23 for the ATOM Socket Power
1386 break;
1387 }
1388
1389}
1390//! new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner)
1392{
1394 return atomKind;
1395}
1396
1397//! new 1.4.24 setting ATOM kind (eg. ATOM_KIND_M5_SCANNER, ATOM_KIND_M5_SOCKET)
1398//! sets global _ATOM_KIND
1400{
1401 //! optimize to only call this retrieval from EPROM 1 time.. unless changing the ATOMKind
1403 {
1404 char *atomKind = getPreferenceATOMKind_MainModule();
1405 if (strcasecmp(atomKind,"M5AtomScanner")==0)
1406 {
1408 }
1409 else if (strcasecmp(atomKind,"M5AtomSocket")==0)
1410 {
1412 }
1413 _firstTimeAtomKind = false;
1414 }
1415 return _ATOM_KIND;
1416}
1417
1418#define NEW_SENSORS_PREFERENCE
1419//! 5.14.25 Hanging with Tyler,
1420//! Dead Montana 5.14.74 great stuff
1421//! add the Sensors Preference .. first the parsing
1422//! 10.26.25 Power Out, Wind Storm, Tyler handing ..
1423//! remove the PRINT
1424
1425//! the memory for the sensorsEPROM
1427
1428
1429//! array of sensorStruct
1431
1432//! return array of SensorsStruct after parsing string syntax: {SENSOR,pin1,pin2}
1434
1435
1436
1437//! print sensor
1439{
1440 if (sensor)
1441 SerialDebug.printf("SENSOR: %s,%d,%d\n", sensor->sensorName, sensor->pin1, sensor->pin2);
1442 else
1443 SerialDebug.printf("SENSOR: **** Null sensor ***\n");
1444}
1445
1446
1447//! print sensors, passing in a struct
1449{
1450 int count = sensors->count;
1451 SerialDebug.printf("DEFINED_SENSORS SensorClassType (%ld):\n", count);
1452 SerialDebug.printf(" ******** \n");
1453 for (int i=0; i< count; i++)
1454 {
1455 printSensor_mainModule(&sensors->sensors[i]);
1456 }
1457 SerialDebug.printf(" ******** \n");
1458}
1459
1460//! return the sensors defined
1462{
1464}
1465
1466//! return the sensor specified or null
1468{
1469 SensorStruct *sensor = NULL;
1471 {
1472 SerialDebug.println(" **** sensorsStructs_mainModule NULL ****");
1473 return NULL;
1474 }
1475
1476 int count = _sensorsStructs_mainModule->count;
1477 for (int i=0; i< count; i++)
1478 {
1479 if (strcmp(_sensorsStructs_mainModule->sensors[i].sensorName, sensorName) == 0)
1480 {
1481 sensor = &_sensorsStructs_mainModule->sensors[i];
1482 break;
1483 }
1484 }
1485// if (!sensor)
1486// SerialDebug.printf("*** No sensor: %s\n", sensorName);
1487 return sensor;
1488}
1489
1490//! Only 1 setSensorsString now .. will always append
1491//! unless a null or blank "" string
1492//! set a sensor val (array of sensor,pin,pin,sensor,pin,pin...)
1493void setSensorsString_mainModule(char *sensorsString)
1494{
1495 //! for now .. resetting
1496 //! 5.17.25
1497 strcpy(_sensorsEPROM, "");
1498
1499 SerialDebug.printf("setSensorsString_mainModule(%s)\n", sensorsString);
1500 //! init EPROM
1501 if (!sensorsString || strlen(sensorsString)==0)
1502 strcpy(_sensorsEPROM, "");
1503 else if (strlen(_sensorsEPROM) > 0)
1504 {
1505 // add a ','
1506 strcat(_sensorsEPROM, ",");
1507 }
1508 strcat(_sensorsEPROM, sensorsString);
1509
1510 //! store in EPROM
1512
1513 //! Parse to the global..
1515 SerialDebug.printf("setSensors:_sensorsStructs_mainModule = %d\n", _sensorsStructs_mainModule);
1516}
1517
1518//! init the sensorString from EPROM
1519//!PREFERENCE_SENSOR_PLUGS_SETTING
1521{
1522 SerialDebug.println("**** initSensorStringsFromEPROM_mainModule ****");
1524 //! Parse to the global..
1526 SerialDebug.printf("initSensors:_sensorsStructs_mainModule = %d\n", _sensorsStructs_mainModule);
1527
1528}
1529
1530
1531//! copy string
1533{
1534 char *copy = strdup(str);
1535 return copy;
1536}
1537
1538
1539//! 3.29.25 Raiiiinier Beeer movie last night
1540//! 5.13.25 Home with Tyler, Mom in LA
1541//! Foundation triligy..
1542//! parseSensorString_mainModule the string
1544{
1545 //! result
1546 SensorsStruct *sensors;
1547 //! default create memory for the SensorsStruct which holds all the sensors..
1548 //! the array will be created on the 2nd pass
1549 sensors = (SensorsStruct*) calloc(1,sizeof(SensorsStruct));
1550 sensors->count = 0;
1551 sensors->sensors = NULL;
1552
1553 //! syntax: sensor,pin1,pin2
1554 SerialDebug.printf("*** parseSensorString_mainModule: %s\n", sensorsString);
1555
1556 if (!sensorsString || strlen(sensorsString)==0)
1557 {
1558 SerialDebug.println("parseSensorString_mainModule: *** No Sensors or string **");
1559 return sensors;
1560 }
1561
1562 char *rest = NULL;
1563 char *token;
1564 int arrayIndex = 0;
1565
1566 //! needed to copy sensorsString.. as the code below broke the callers' value to "https:" .. SIDE EFFECT
1567 char str[300];
1568 char strCopy[300];
1569 strcpy(str,sensorsString);
1570 strcpy(strCopy,sensorsString);
1571
1572 //! resulting array
1573 SensorStruct *sensorItems;
1574
1575 //! number of sensors
1576 int numSensors;
1577
1578 //! 2 pass
1579 for (int whichPass = 0; whichPass<2; whichPass++)
1580 {
1581#define secondPass (whichPass == 1)
1582 int max = 3;
1583
1584 if (secondPass)
1585 {
1586 numSensors = arrayIndex / max;
1587 strcpy(str,strCopy);
1588 SerialDebug.printf(" ** Create sensors %d\n", numSensors);
1589 sensorItems= (SensorStruct*) calloc(numSensors,sizeof(SensorStruct));
1590 }
1591
1592 //! reset arrayIndex (which will be increments of 3)
1593 arrayIndex = 0;
1594
1595 //! 2 pass, first count, 2nd parseSensorString_mainModule
1596
1597 //! look for tokens, comma seperated
1598 for (char *token= strtok(str,","); token!= NULL; token= strtok(NULL, ","))
1599 {
1600 int indexInSensor = arrayIndex / max;
1601 int indexInArray = arrayIndex % max;
1602 //SerialDebug.printf("%d Token[%d] = %s\n",indexInArray, indexInSensor, token);
1603
1604 //! which of the max is this..
1605 switch (indexInArray)
1606 {
1607 case 0:
1608 {
1609 if (secondPass)
1610 {
1611 //SerialDebug.printf("Sensor = %s\n", token);
1612 sensorItems[indexInSensor].sensorName = copyString_mainModule(token);
1613
1614 //! empty the class
1615 sensorItems[indexInSensor].sensorClassType = NULL;
1616
1617 }
1618 break;
1619 }
1620 case 1:
1621 {
1622 if (secondPass)
1623 {
1624 int pin = atoi(token);
1625 if (pin == 16 || pin == 17)
1626 {
1627 //!@see https://www.reddit.com/r/arduino/comments/1g89dlo/esp32_crashing_due_to_pinmode_and_fastled/
1628 SerialDebug.printf("*** BAD PIN: %d, setting to 22 ***\n", pin);
1629 pin = 22;
1630 }
1631 //SerialDebug.printf("Pin1= %d\n", pin);
1632 sensorItems[indexInSensor].pin1= pin;
1633 }
1634 break;
1635 }
1636 case 2:
1637 {
1638 if (secondPass)
1639 {
1640 int pin = atoi(token);
1641 if (pin == 16 || pin == 17)
1642 {
1643 SerialDebug.printf("*** BAD PIN: %d, setting to 22 ***\n", pin);
1644 pin = 22;
1645 }
1646 //SerialDebug.printf("Pin2= %d\n", pin);
1647 sensorItems[indexInSensor].pin2= pin;
1648 }
1649 break;
1650 }
1651 }
1652 //! only incremnet arrayIndex when
1653 arrayIndex++;
1654 }
1655 }
1656
1657 //! update the result (storage already created)
1658 sensors->count = numSensors;
1659 sensors->sensors = sensorItems;
1660
1661 SerialDebug.printf("parseSensorString_mainModule: ** sensors->count = %ld\n", sensors->count);
1662 return sensors;
1663}
1664
1665#pragma mark CHAIN
1666
1667#pragma mark CHAIN_STRUCT
1668/**
1669 #define CHAIN_USE_MAX 10
1670 typedef struct {
1671 //! number of chain
1672 int chainUseCount;
1673 //! the buton numbers
1674 int buttonNumberArray[PIN_USE_MAX];
1675 //! the set strings, val strings, device strings
1676 char *setStringArray[PIN_USE_MAX];
1677 //! val strings
1678 char *valStringArray[PIN_USE_MAX];
1679 //! the device strings
1680 char *deviceStringArray[PIN_USE_MAX];
1681
1682 } ChainUseStruct;
1683 */
1684
1685//! global for use. This is an object (not a pointer) and has all the storage created statically
1687//! get the pin use array
1689{
1690 return _chainUseStruct;
1691}
1692
1693
1694//! 1.23.26 storage for the chain sensors EPROM value ..
1695//! the memory for the chainSensorsEPROM
1697//! 1.23.26 Cold, Clear, Mt Nice ... need to use the version above with 5 items ..
1698//! pointer to the ChainSensors
1699//! return array of ChainUseStruct after parsing string syntax: {SENSOR,pin1,pin2}
1701{
1702 //! syntax: sensor,pin1,pin2
1703 SerialDebug.printf("*** parseChainSensorString_mainModule: %s\n", chainUseString);
1704
1705 //! result
1706 ChainUseStruct *chainUseStruct = (ChainUseStruct*) calloc(1,sizeof(ChainUseStruct));
1707 //! default
1708 chainUseStruct->chainUseCount = 0;
1709 //! create memory.. (the 2nd pass would do this in the future ...)
1710 chainUseStruct->chainButtonStructArray = (ChainButtonStruct*) calloc(CHAIN_USE_MAX, sizeof(ChainButtonStruct));
1711
1712 //! TEMP .. until parse working ... will do the same as registerChain does..
1713
1714 return chainUseStruct;
1715}
1716
1717//! 1.23.26 Cold, Clear, Mt Nice ... need to use the version above with 5 items ..
1718//! pointer to the ChainSensors
1719//! return array of ChainUseStruct after parsing string syntax: {SENSOR,pin1,pin2}
1721{
1722 //! syntax: sensor,pin1,pin2
1723 SerialDebug.printf("*** parseChainSensorString_mainModule: %s\n", chainUseString);
1724
1725 //! result
1726 ChainUseStruct *chainUseStruct = (ChainUseStruct*) calloc(1,sizeof(ChainUseStruct));
1727 //! default
1728 chainUseStruct->chainUseCount = 0;
1729
1730 if (!chainUseString || strlen(chainUseString)==0)
1731 {
1732 SerialDebug.println("parseSensorString_mainModule: *** No chainUseString or string **");
1733 return chainUseStruct;
1734 }
1735
1736 char *rest = NULL;
1737 char *token;
1738 int arrayIndex = 0;
1739
1740 //! needed to copy sensorsString.. as the code below broke the callers' value to "https:" .. SIDE EFFECT
1741#define MAX_CHAIN_STRING 300
1742 char str[MAX_CHAIN_STRING];
1743 char strCopy[MAX_CHAIN_STRING];
1744 if (strlen(chainUseString) > MAX_CHAIN_STRING)
1745 {
1746 SerialDebug.printf("ChainUseString length too big %d\n", strlen(chainUseString));
1747 return NULL;
1748 }
1749 strcpy(str,chainUseString);
1750 strcpy(strCopy,chainUseString);
1751
1752 //! resulting array
1753 ChainButtonStruct *chainButtonStructs;
1754
1755 //! number of sensors
1756 int numChainStructs;
1757
1758 //char *str = "BC,1,1,feed,,$localhost,
1759 // BC,1,2,feed,,,
1760 // BC,2,2,SM_Matrix,6,$dev,
1761 // BC,2,3, togglesocket,,M5AtomSocket,
1762 //! 2 pass
1763 for (int whichPass = 0; whichPass<2; whichPass++)
1764 {
1765#define secondPass (whichPass == 1)
1766 //! for this we have MAX = 6
1767 int max = 6;
1768
1769 if (secondPass)
1770 {
1771 //! create the storage
1772 numChainStructs = arrayIndex / max;
1773 strcpy(str,strCopy);
1774 SerialDebug.printf(" ** Create sensors %d\n", numChainStructs);
1775 chainButtonStructs= (ChainButtonStruct*) calloc(numChainStructs,sizeof(ChainButtonStruct));
1776 chainUseStruct->chainButtonStructArray = chainButtonStructs;
1777
1778 }
1779
1780 //! reset arrayIndex (which will be increments of 3)
1781 arrayIndex = 0;
1782
1783 //! 2 pass, first count, 2nd parseSensorString_mainModule
1784
1785 //! look for tokens, comma seperated (SEEMS cannot be null or empty .. ?? eg ,,,,
1786 for (char *token= strtok(str,","); token!= NULL; token= strtok(NULL, ","))
1787 {
1788 int indexInSensor = arrayIndex / max;
1789 int indexInArray = arrayIndex % max;
1790 SerialDebug.printf("%d Token[%d] = %s\n",indexInArray, indexInSensor, token);
1791
1792 if (!secondPass)
1793 {
1794 //! continut loop .. but increment (since code below wont' increment)
1795 arrayIndex++;
1796 continue;
1797
1798 }
1799
1800 //! which of the max is this..
1801 //! "BC,1,1,feed,,$localhost, <string> <int> <int> <string> <string> <string>
1802 switch (indexInArray)
1803 {
1804 case 0: // <string>
1805 {
1806 //TODO: strip the spaces of this token
1807 chainButtonStructs[indexInSensor].classType = copyString_mainModule(token);
1808 }
1809 break;
1810 case 1: // <int>
1811 {
1812 int num = atoi(token);
1813 chainButtonStructs[indexInSensor].buttonNumber = num;
1814 }
1815 break;
1816 case 2: // <int>
1817 {
1818 int num = atoi(token);
1819 chainButtonStructs[indexInSensor].pressKind = num;
1820 }
1821 break;
1822 case 3: // <string> setString
1823 chainButtonStructs[indexInSensor].setString = copyString_mainModule(token);
1824 break;
1825 case 4: // <string> valString
1826 chainButtonStructs[indexInSensor].valString = copyString_mainModule(token);
1827 break;
1828 case 5: // <string> device
1829 chainButtonStructs[indexInSensor].deviceString = copyString_mainModule(token);
1830
1831 {
1832 //! update the chain use string ..
1833 char chainUseSample[200];
1834 sprintf(chainUseSample,"CHAIN_USE: %s press=%d btn=%2d set= %s, val=%s dev=%s",chainButtonStructs[indexInSensor].classType, chainButtonStructs[indexInSensor].pressKind, chainButtonStructs[indexInSensor].buttonNumber, chainButtonStructs[indexInSensor].setString, chainButtonStructs[indexInSensor].valString, chainButtonStructs[indexInSensor].deviceString);
1835 chainButtonStructs[indexInSensor].chainUse = copyString_mainModule(chainUseSample);
1836 }
1837 break;
1838 }
1839
1840 //! only incremnet arrayIndex when
1841 arrayIndex++;
1842 }
1843 }
1844
1845 //! update the result (storage already created)
1846 chainUseStruct->chainUseCount = numChainStructs;
1847 chainUseStruct->chainButtonStructArray = chainButtonStructs;
1848
1849 SerialDebug.printf("parseSensorString_mainModule: ** sensors->count = %ld\n", numChainStructs);
1850
1851 return chainUseStruct;
1852}
1853
1854//! just try parsing for now..
1856{
1857
1858 //! 200 fixed problem..
1859 char str[200];
1860 //! needs spaces between "," or won't find them .. FIX THIS ..
1861 strcpy(str,"BC,1,1,feed, ,$localhost, BC,1,2,feed, , , BC,2,2,SM_Matrix,6,$dev, BC,2,3, togglesocket, ,M5AtomSocket");
1862 //! parse it
1864 //! print it
1865 printChainSensors_mainModule(chainUseStruct);
1866
1867 SerialDebug.println("DONE testParse");
1868
1869 //! bombing after this..
1870}
1871
1872#pragma mark CHAIN
1873//!TODO add code here
1874//! 1.23.26 storage for the chain sensors EPROM value ..
1875//!PREFERENCE_CHAIN_SENSORS_SETTING
1876//!FIRST do the registration maniually .. LATER .. parseSensros
1878{
1880 SerialDebug.printf("initSensors:initChainSensorStringsFromEPROM_mainModule = '%s'\n", _chainSensorsEPROM);
1881
1882 //! Parse to the global..
1884
1885 //! add this which is Button -0 (not a Chain button).
1886 //! So if a message comes in for button 0 .. it can find this one..
1887 registerChain_mainModule("BC", 0, BUTTON_SHORT_PRESS, "feed", "", "$localhost" );
1888 registerChain_mainModule("BC", 0, BUTTON_DOUBLE_PRESS,"feed", "", "" ); //wifi feed
1889
1890 //TODO: long press is the AP mode...
1891 //registerChain_mainModule("BC", 0, BUTTON_LONG_PRESS, clean credentials ... eg. "x" local .. something..
1892
1893 //! has to be after the _chainUseStruct global is set...
1894 if (true)
1895 {
1896 //! idea is you define the button and the press kind
1897 //! MatrixCell is Column Major 1,4, 7 // 2,5,8 // 3,6,9
1898 registerChain_mainModule("BC", 1, BUTTON_SHORT_PRESS, "feed", "", "$localhost" );
1899 registerChain_mainModule("BC", 1, BUTTON_DOUBLE_PRESS, "feed", "", "" ); //wifi
1900
1901 // registerChain_mainModule("BC", 2, BUTTON_SHORT_PRESS, "SM_MatrixCell", "5", "$dev" );
1902 registerChain_mainModule("BC", 2, BUTTON_DOUBLE_PRESS, "SM_MatrixCell", "6", "$dev");
1903 //{"cmd":"togglesocket","dev":"M5AtomSocket"}
1904 registerChain_mainModule("BC", 2, BUTTON_LONG_PRESS, "togglesocket", "", "M5AtomSocket");
1905 registerChain_mainModule("BC", 2, BUTTON_SHORT_PRESS, "togglesocket", "", "M5AtomSocket");
1906
1907 //!joystick buttons..
1908 registerChain_mainModule("JC", 3, BUTTON_SHORT_PRESS, "feed", "", "$localhost" );
1909 //! 1.24.26 don't know what to do yet ... x,y (or left, top, right, botton ??)
1910 registerChain_mainModule("JC", 3, BUTTON_JOYSTICK_LEFT, "feed", "", "" );
1911 registerChain_mainModule("JC", 3, BUTTON_JOYSTICK_TOP, "togglesocket", "", "M5AtomSocket");
1912 registerChain_mainModule("JC", 3, BUTTON_JOYSTICK_RIGHT, "feed", "", "" );
1913 registerChain_mainModule("JC", 3, BUTTON_JOYSTICK_BOTTOM, "status", "", "" );
1914
1915 //! eg:
1916 //char *str = "BC,1,1,feed,,$localhost, BC,1,2,feed,,, BC,2,2,SM_Matrix,6,$dev, BC,2,3, togglesocket,,M5AtomSocket, YC,
1917 }
1918
1919 //!test...
1920 testParse();
1921
1922 SerialDebug.println("done register chain buttons");
1923
1924}
1925
1926
1927
1928//! 1.23.26 Clear Day .. puppies, tyler, Clear Snowy Mt Rainier
1929//!
1930//! Only 1 setSensorsString now .. will always append
1931//! unless a null or blank "" string
1932//! PREFERENCE_CHAIN_SENSORS_SETTING
1933//! set a sensor val (array of sensor,pin,pin,sensor,pin,pin...)
1934void setChainSensorsString_mainModule(char *chainSensorsString)
1935{
1936 //! for now .. resetting
1937 //! 5.17.25
1938 strcpy(_chainSensorsEPROM, "");
1939
1940 SerialDebug.printf("setChainSensorsString_mainModule(%s)\n", chainSensorsString);
1941 //! init EPROM
1942 if (!chainSensorsString || strlen(chainSensorsString)==0)
1943 strcpy(_chainSensorsEPROM, "");
1944 else if (strlen(_chainSensorsEPROM) > 0)
1945 {
1946 // add a ','
1947 strcat(_chainSensorsEPROM, ",");
1948 }
1949 strcat(_chainSensorsEPROM, chainSensorsString);
1950
1951 //! store in EPROM
1953
1954 //! Parse to the global..
1956 //!printout
1957 SerialDebug.printf("setSensors:setChainSensorsString_mainModule = %d\n", _chainUseStruct->chainUseCount);
1958
1959}
1960
1961//! return a non 0 length string
1962char *non0string(char* str)
1963{
1964 if (!str)
1965 return " ";
1966 else if (strlen(str) == 0)
1967 return " ";
1968 else
1969 return str;
1970}
1971//! print sensors, passing in a struct
1973{
1974 if (chainUseStruct)
1975 {
1976 //! print it 2 ways, one as the EPROM wouild look, the other are the chain use string
1977 for (int lap = 0; lap < 2; lap++)
1978 {
1979 boolean showAsEPROM = (lap == 0);
1980
1981 //! go through looking for N one (0 based)
1982 for (int i=0; i< chainUseStruct->chainUseCount; i++)
1983 {
1984 //! grab the i'th struct, then look at the button number and pressKind
1985 ChainButtonStruct* chainButtonStruct = &chainUseStruct->chainButtonStructArray[i];
1986 if (showAsEPROM)
1987 {
1988 //! "JC", 3, BUTTON_JOYSTICK_RIGHT, "feed", "", "" );
1989 if (i > 0)
1990 SerialDebug.printf(",");
1991 SerialDebug.printf("%s,%d,%d,%s,%s,%s", chainButtonStruct->classType, chainButtonStruct->buttonNumber, chainButtonStruct->pressKind, non0string(chainButtonStruct->setString), non0string(chainButtonStruct->valString), non0string(chainButtonStruct->deviceString));
1992 }
1993 else
1994 SerialDebug.printf("%d -> %s\n", i, chainButtonStruct->chainUse?chainButtonStruct->chainUse:(char*)"NULL");
1995 }
1996 if (showAsEPROM)
1997 SerialDebug.println();
1998 }
1999 }
2000
2001}
2002
2003//! 1.27.26
2004
2005//! 7.9.25 reset SENSORS to default
2006//! "BuzzerSensorClass,23,33,L9110S_DCStepperClass,21,25"
2008{
2009 //UNUSED
2010}
2011
2012
2013
2014//!12.19.25 use the Chain
2015//! 5.3.25 add a central clearing house for defining PIN use
2016//! central clearing house for all pins used to we can analyze if there are overlaps
2017//! pin is the actual number, pinName is the local name (eg. IN1_PIN or VIN_PIN).
2018//! moduleName is the module in the code,
2019//! isI2C is whether this is a I2C bus (which we aren't using much yet)
2020//! 1.22.26 add pressKind and classType
2021void registerChain_mainModule(String classType, int buttonNumber, int pressKind, String setString, String valString, String deviceString)
2022{
2023
2025 {
2026 SerialError.printf("*** ERROR .. too many CHAINS defined ***");
2027 return;
2028 }
2029
2030 char chainUseSample[100];
2031 sprintf(chainUseSample,"CHAIN_USE: %s btn=%2d press=%d set= %s, val=%s dev=%s",classType, buttonNumber,pressKind, setString.c_str(), valString.c_str(), deviceString.c_str());
2032 SerialDebug.println(chainUseSample);
2033
2034 //! storage is supposed to have been created .. but this line blows ..
2035 SerialDebug.printf("chainButtonStruct = %d, count = %d\n", _chainUseStruct,_chainUseStruct? _chainUseStruct->chainUseCount:-1);
2036 //! update the n'th version
2037 //! grab a pointer to the size already created
2038 //! The array is really contiguous memory .. vs linked list, to the address of the n't array is the pointer to that struct
2039 //! grab the next entry (chainUseCount)
2041
2042 //! 1.23.26
2043 //! 5.3.25 create storage here
2044 char *chainUse = (char*)calloc(strlen(chainUseSample)+1, sizeof(char));
2045 strcpy(chainUse, chainUseSample);
2046
2047
2048 //!store globally
2049 chainbuttonStruct->chainUse = chainUse;
2050
2051 //!store classType
2052 chainbuttonStruct->classType = createCopy2(classType.c_str());
2053
2054 //! set the buttonNumber for this chain #
2055 chainbuttonStruct->buttonNumber = buttonNumber;
2056
2057 //! pressKind
2058 chainbuttonStruct->pressKind = pressKind;
2059
2060 //! set the set for this chain #
2061 chainbuttonStruct->setString = createCopy2(setString.c_str());
2062
2063 //! set the set for this chain #
2064 chainbuttonStruct->valString = createCopy2(valString.c_str());
2065
2066 //! set the set for this chain #
2067 chainbuttonStruct->deviceString = createCopy2(deviceString.c_str());
2068
2069 //! increment chainUseCound
2071
2072
2073}
2074
2075//! 1.27.26 moved here for generic use .. even by a non chain button
2076//! 1.22.26 with puppies, cold dry outside
2077//! get the ChainUseStruct for the buttonNumber (eg 1..9 (no 0)
2078//! Column Major in the Matrix (but sequential here)
2079//! return the definition for this 1 based button number (if any)] //TODO -1
2080//! pressKind = -1 (matches first one ..)
2081//! NOTE: pressKind for Joystick is here..
2082//! 1.28.26 you can ask for BUTTON 0 (which will be the deault for the M5Atom single press (or maybe long press)
2083ChainButtonStruct* getChainUseStruct(int buttonNumber_1based, int pressKind)
2084{
2085 SerialDebug.printf("getChainUseStruct(%d, %d)\n", buttonNumber_1based, pressKind);
2086 ChainUseStruct* chainUseStruct = getChainUseStruct_mainModule();
2087 if (chainUseStruct)
2088 {
2089 //! go through looking for N one (0 based)
2090 for (int i=0; i< chainUseStruct->chainUseCount; i++)
2091 {
2092 //! grab the i'th struct, then look at the button number and pressKind
2093 ChainButtonStruct* chainButtonStruct = &chainUseStruct->chainButtonStructArray[i];
2094
2095 //! i is just the entry .. not the button number
2096 //! N'th entry
2097 if (chainButtonStruct->buttonNumber == buttonNumber_1based)
2098 {
2099 SerialDebug.printf("chainButton (%d, press=%d) = %s\n", buttonNumber_1based, chainButtonStruct->pressKind, chainButtonStruct->chainUse);
2100 //! see if the right pressKind
2101 if (chainButtonStruct->pressKind == pressKind || chainButtonStruct->pressKind == BUTTON_ANY)
2102 {
2103 SerialDebug.printf("matched button %ld, press=%ld \n", buttonNumber_1based, pressKind);
2104
2105 //! found one .. go with it
2106 return chainButtonStruct;
2107 }
2108 }
2109 }
2110 }
2111 return NULL;
2112}
2113//! 1.27.26 Chain Buttons .. which non-chain can use too
2114//! storage tor a message
2116
2117//! 1.22.26 Dead Morning Dew
2118//! process the given button
2119//! 1.24.26 NOTE: this doesn't care about button press or joystick .. it's just run that button
2121{
2122 if (chainUseStruct)
2123 {
2124 SerialDebug.printf("processChainUseStruct: %s, %s\n", chainUseStruct->setString, chainUseStruct->valString);
2125 char *deviceName = chainUseStruct->deviceString;
2126 boolean isLocalHost = false;
2127 boolean useCurrentDevice = false;
2128 boolean nullValString = false;
2129 if (!chainUseStruct->valString || strlen(chainUseStruct->valString) == 0)
2130 nullValString = true;
2131 if (deviceName && strlen(deviceName) > 0)
2132 {
2133 //! 1.24.26 look at $options
2134 switch (deviceName[0])
2135 {
2136 case '$':
2137 {
2138 //! special
2139 if ( strcmp(deviceName,"$localhost")==0)
2140 isLocalHost = true;
2141 else if (strcmp(deviceName, "$dev")==0)
2142 useCurrentDevice = true;
2143 }
2144 break;
2145 }
2146
2147 }
2148 else
2149 deviceName = NULL;
2150
2151 if (isLocalHost && strcmp(chainUseStruct->setString,"feed")==0)
2152 {
2153 //! feed ..
2154 ///feed always (done after the code below..)
2156 //! This will send BLE to our connected device ..
2157
2158 }
2159 else
2160 {
2161 if (nullValString)
2162 {
2163 //! create a set/val message
2164 //! TODO; device, etc.. topic
2165 if (deviceName)
2166 sprintf(_mqttMessage_ChainButton, "{'cmd':'%s','dev':'%s'}", chainUseStruct->setString, deviceName);
2167 else
2168 sprintf(_mqttMessage_ChainButton, "{'cmd':'%s'}", chainUseStruct->setString);
2169
2170 }
2171 else
2172 {
2173 //! create a set/val message
2174 //! TODO; device, etc.. topic
2175 if (deviceName)
2176 sprintf(_mqttMessage_ChainButton, "{'set':'%s','val':'%s','dev':'%s'}", chainUseStruct->setString, chainUseStruct->valString, deviceName);
2177 else
2178 sprintf(_mqttMessage_ChainButton, "{'set':'%s','val':'%s'}", chainUseStruct->setString, chainUseStruct->valString);
2179
2180 }
2181 //! send this message
2183 }
2184 //!
2185 //! idea is you define the button and the press kind
2186 //! MatrixCell is Column Major 1,4, 7 // 2,5,8 // 3,6,9
2187 //registerChain_mainModule("ButtonClass", 1, BUTTON_SHORT_PRESS, "SM_MatrixCell", "15", "$dev" );
2188 //registerChain_mainModule("ButtonClass", 1, BUTTON_LONG_PRESS, "SM_MatrixCell", "6", "$dev");
2189 //registerChain_mainModule("JoystickClass", 2, BUTTON_SHORT_PRESS, "feed", "", "$localhost" );
2190
2191 }
2192}
void sendMessageNoChangeMQTT(char *message)
just send a message but without any extras
char * createCopy2(const char *stringA)
char * main_getUsername()
char * main_JSONStringForWIFICredentials()
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
char * main_getPassword()
return password
char * getServerServiceName_mainModule()
Definition: MainModule.cpp:375
void main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
PinUseStruct * getPinUseStruct_mainModule()
get the pin use array
char * getChipIdString()
3.17.24 get the chip id as a string
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
#define ASYNC_SEND_MQTT_FEED_MESSAGE
sends a message (like FEED) on the users topic
Definition: MainModule.h:207
#define NO_POWEROFF_AMOUNT_STRING_MAIN
Definition: MainModule.h:72
#define ASYNC_CALL_CLEAN_EPROM
cleans the EPROM totally, and reboots
Definition: MainModule.h:199
#define EPROM_DEV_ONLY_SM_SETTING
9.28.23 #272 only show Semantic Markers that are sent directly to the device
#define EPROM_NO_BUTTON_CLICK_POWEROFF_SETTING
sets screentimeout if not button clicks (set,noclick,val,seconds)
#define EPROM_MAIN_GATEWAY_VALUE
void cleanEPROM_mainModule()
clean the preferencesMainModule in EPROM
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int preference
boolean getDiscoverM5PTClicker()
get option
float getPreferenceFloat_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
#define EPROM_WIFI_CREDENTIAL_2_SETTING
second wifi credential
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
#define EPROM_FIRST_TIME_FEATURE_SETTING
a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
#define EPROM_PREFERENCE_SUPPORT_GROUPS_SETTING
the preference for supporting GROUPS (default true)
#define EPROM_PAIRED_DEVICE_SETTING
the guest device paired with this M5 device (or NONE)
void savePreferenceATOMKind_MainModule(String value)
returned from mainModule
#define EPROM_PREFERENCE_TIMER_MAX_INT_SETTING
11.29.23 add the max time .. so a random can be used
char * _preferenceMainModuleLookupDefaults[MAX_MAIN_PREFERENCES]
array of default values to store in the EPROM if not defined..
char _preferenceBuffer[100]
PREFERENCES for the main module.
#define EPROM_STEPPER_ANGLE_FLOAT_SETTING
sets stepper angle, a floating point number
#define EPROM_USE_DOC_FOLLOW_SETTING
NOTE: these EPROM have to be lockstep the same as the PREFERENCE definitions in MainModule....
#define EPROM_PREFERENCE_ATOM_KIND_SETTING
1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
void printSensors_mainModule(SensorsStruct *sensors)
print sensors, passing in a struct
#define EPROM_PREFERENCE_SM_COMMAND_PIR_SETTING
1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
SensorsStruct * getSensors_mainModule()
return the sensors defined
#define EPROM_PREFERENCE_SM_COMMAND_PIR_OFF_SETTING
1.11.24 The Semantic Marker command is sent on PIR, and the Command to send
char _includeGroupsStringArray[NUMBER_GROUPS][STRING_MAX_SIZE]
resulting group names
char * _preferenceMainModuleLookupEPROMNames[MAX_MAIN_PREFERENCES]
array of preference names (those used in process()
#define EPROM_PREFERENCE_ATOMS_SETTING
1.1.24 the preference for all the ATOM plugs (format: atomType:value} .. for now just use socket:on
void initChainSensorStringsFromEPROM_mainModule()
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 ...
#define EPROM_PAIRED_DEVICE_ADDRESS_SETTING
9.3.22 eprom of the Address of desired BLE
ChainUseStruct * parseChainSensorString_mainModuleNEW(char *chainUseString)
void setDiscoverM5PTClicker(boolean flag)
#define EPROM_SENDWIFI_WITH_BLE
send WIFI to all except our device (and our paired) when
void setSensorsString_mainModule(char *sensorsString)
#define EPROM_BLE_SERVER_USE_DEVICE_NAME_SETTING
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
String _appendingPreferenceString
storage for the appending string
void resetAllPreferences_mainModule()
resets preferences.. Currently only reset all, but eventually reset(groups..)
void testParse()
just try parsing for now..
#define EPROM_STEPPER_BUZZER_VALUE
buzzer on or off
#define EPROM_MAIN_BLE_SERVER_VALUE
BLEServer mode.
#define EPROM_STEPPER_SINGLE_FEED_VALUE
single feed mode
ChainUseStruct * getChainUseStruct_mainModule()
get the pin use array
#define EPROM_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define MAX_CHAIN_STRING
int _includeGroupLen
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...
#define EPROM_PREFERENCE_SM_ON_PIR_SETTING
1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
void registerChain_mainModule(String classType, int buttonNumber, int pressKind, String setString, String valString, String deviceString)
void togglePreferenceBoolean_mainModule(int preferenceID)
toggles a preference boolean
#define EPROM_USE_SPIFF_SETTING
8.22.22 to turn on/off SPIFF use
void printSensor_mainModule(SensorStruct *sensor)
print sensor
#define EPROM_PREFERENCE_DEBUG_INFO_SETTING
a place to put some kind of Last Will of what went wrong .. for now (> max tries)
#define EPROM_SCREEN_COLOR_SETTING
color of the M5 screen
void resetPreference_mainModule(int preferenceID)
called to reset to blank a preference (which will be an identifier and a string, which can be convert...
#define EPROM_ONLY_GEN3_CONNECT_SETTING
if true, only BLEClient connect to GEN3 feeders..
boolean _isCachedPreferenceBoolean[MAX_MAIN_PREFERENCES]
array of boolean if the ID is cached..
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)
#define EPROM_STEPPER_FEEDS_PER_JACKPOT_VALUE
ChainButtonStruct * getChainUseStruct(int buttonNumber_1based, int pressKind)
#define NUMBER_GROUPS
#define EPROM_PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING
1.12.24 Whether the AtomSocket accepts global on/off messages
#define STRING_MAX_SIZE
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 printChainSensors_mainModule(ChainUseStruct *chainUseStruct)
print sensors, passing in a struct
#define EPROM_DISPLAY_ON_BLANK_SCREEN_VALUE
Display preferences - show messages on blank screen- boolean.
#define EPROM_SENSOR_PIR_VALUE
proximity PIR
void savePreferenceIntFromString_mainModule(int preferenceID, char *val)
sets an int, but only if a valid integer, and no signs. If bad, then a 0 is stored
#define EPROM_USE_SPIFF_MQTT_SETTING
4.4.24 for MQTT use of spiff (or not)
#define EPROM_STEPPER_AUTO_MOTOR_DIRECTION_SETTING
#define EPROM_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define EPROM_INCLUDE_GROUP_NAMES_SETTING
include these topics groups..
void setOnBootPreferences_mainModule()
set some defaults on boot - that override EPROM this can be called on the HOME screen to set back to ...
#define EPROM_STEPPER_RPM_SETTING
SensorsStruct * parseSensorString_mainModule(char *str)
return array of SensorsStruct after parsing string syntax: {SENSOR,pin1,pin2}
#define secondPass
char * non0string(char *str)
return a non 0 length string
void initSensorStringsFromEPROM_mainModule()
ChainUseStruct * _chainUseStruct
global for use. This is an object (not a pointer) and has all the storage created statically
char _preferenceBufferString[100]
buffer for the string
#define EPROM_PREFERENCE_TIMER_INT_SETTING
the preference timer
boolean _cachedPreferenceBooleanValues[MAX_MAIN_PREFERENCES]
#define EPROM_STEPPER_JACKPOT_FEED_VALUE
jackpot feed
#define EPROM_SUB_DAWGPACK_SETTING
8.17.22 to turn on/off subscribing to the dawgpack topic
#define EPROM_NOTIFY_BLE_DISCOVERY
starts the BLE Discovery notification process - which might be internal or externa (via messages).
Preferences _preferencesMainModule
preferences for MAIN
#define EPROM_USE_SPIFF_QRATOM_SETTING
4.4.24 for QRATOM use of spiff (or not)
void parseIncludeGroups(char *groups)
8.2.24 set the include group (and cache it), called (indirectly from MQTT via setIncludeGroups
void resetChainSensorToDefault_mainModule()
1.27.26
#define EPROM_SENSOR_TILT_VALUE
sensor preferences for tilt on or off
#define MAX_APPEND
special preference string for saving and printing back later..
boolean topicInIncludeGroup(char *topic)
char * copyString_mainModule(char *str)
copy string
void setChainSensorsString_mainModule(char *chainSensorsString)
SensorsStruct * _sensorsStructs_mainModule
array of sensorStruct
#define EPROM_STEPPER_KIND_VALUE
the step kind
#define EPROM_HIGH_TEMP_POWEROFF_VALUE
sets the max temp for a poweroff
int getM5ATOMKind_MainModule()
new 1.4.24 setting ATOM kind (eg. ATOM_KIND_M5_SCANNER, ATOM_KIND_M5_SOCKET)
#define EPROM_STEPPER_AUTO_FEED_VALUE
auto feed
#define EPROM_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCES_EPROM_MAIN_NAME
the EPROM is in preferences.h
#define EPROM_WIFI_CREDENTIAL_1_SETTING
for now, save 2 WIFI Credentials
ChainUseStruct * parseChainSensorString_mainModule(char *chainUseString)
#define EPROM_MAIN_BLE_CLIENT_VALUE
BLEClient mode.
#define EPROM_DISPLAY_SCREEN_TIMEOUT_VALUE
sets the timeout value
int getPreferenceInt_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
int _cachedPreferenceIntValues[MAX_MAIN_PREFERENCES]
another cache for the Int values..
boolean _firstTimeAtomKind
if the preference was retrieved..
char _mqttMessage_ChainButton[100]
#define EPROM_SENSORS_SETTING
#define EPROM_PREFERENCE_GROUP_NAMES_SETTING
the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wi...
char * getPreference_mainModule(int preferenceID)
#define EPROM_SEMANTIC_MARKER_ZOOMED_VALUE
display preferences zoomed or not zoomed
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
boolean _DiscoverM5PTClicker
#define EPROM_STEPPER_2FEED_SETTING
void readAppendingPreference_mainModule(int preferenceID)
called to init the preference. This won't save anything until storePreference called
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
#define EPROM_IS_MINIMAL_MENU_SETTING
whether to show the minimal or expanded menu
#define EPROM_DEVICE_NAME_SETTING
the device name
char _chainSensorsEPROM[500]
boolean _isCachedPreferenceInt[MAX_MAIN_PREFERENCES]
array of boolean if the ID is cached..
#define EPROM_SENSOR_PLUGS_SETTING
#define EPROM_CHAIN_SENSORS_SETTING
void processChainUseStruct(ChainButtonStruct *chainUseStruct)
void initPreferencesMainModule()
initialize the _preferencesMainLookup with EPROM lookup names
char _sensorsEPROM[500]
the memory for the sensorsEPROM
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...
void readPreferences_mainModule()
reads the preferences. Save is everytime the savePreference is called
#define PREFERENCE_USE_SPIFF_SETTING
8.22.22 to turn on/off SPIFF use (more below..)
#define PREFERENCE_PAIRED_DEVICE_ADDRESS_SETTING
the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
#define PREFERENCE_STEPPER_KIND_VALUE
uses STEPPER type
#define PREFERENCE_SENSOR_TILT_VALUE
Sensor preferences.
#define BUTTON_JOYSTICK_BOTTOM
#define PREFERENCE_SUB_DAWGPACK_SETTING
8.17.22 to turn on/off subscribing to the dawgpack topic
#define PREFERENCE_STEPPER_SINGLE_FEED_VALUE
#define PREFERENCE_SM_COMMAND_PIR_OFF_SETTING
1.11.24 The Semantic Marker command is sent on PIR, and the Command to send on OFF (or opposite)
#define PREFERENCE_SENSOR_PLUGS_SETTING
#define PREFERENCE_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define ATOM_KIND_M5_SCANNER
returned from mainModule
#define PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
#define PREFERENCE_ONLY_GEN3_CONNECT_SETTING
if true, only BLEClient connect to GEN3 feeders..
#define PREFERENCE_SENDWIFI_WITH_BLE
sends the WIFI to all except current device if set
#define PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING
#define PREFERENCE_SENSOR_PIR_VALUE
#define PREFERENCE_SUPPORT_GROUPS_SETTING
the preference for supporting GROUPS (default true)
#define PREFERENCE_INCLUDE_GROUP_NAMES_SETTING
8.2.24 don't change subscription but include these groups (eg. safeHouse,atlasDogs)
#define PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_STEPPER_JACKPOT_FEED_VALUE
#define BUTTON_JOYSTICK_LEFT
map x,y to quadrants
#define PREFERENCE_WIFI_CREDENTIAL_2_SETTING
#define ATOM_KIND_M5_SOCKET
#define PREFERENCE_STEPPER_RPM_SETTING
#define PREFERENCE_MAIN_BLE_SERVER_VALUE
#define BUTTON_DOUBLE_PRESS
#define PREFERENCE_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define PREFERENCE_STEPPER_BUZZER_VALUE
stepper preferences
#define PREFERENCE_DEV_ONLY_SM_SETTING
adding AP_DEBUG_MODE to let others know that DEBUG eprom is available. Turn this OFF for non dev
#define MAX_MAIN_PREFERENCES
******* 1 greater than last value **** IMPORTANT *** and no gaps..
#define PREFERENCE_ATOMS_SETTING
1.1.24 the preference for all the ATOM plugs (format: atomType:value} .. for now just use socket:on
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define BUTTON_JOYSTICK_RIGHT
#define PREFERENCE_USE_DOC_FOLLOW_SETTING
for
#define PREFERENCE_WIFI_CREDENTIAL_1_SETTING
#define CHAIN_USE_MAX
#define PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING
1.12.24 Whether the AtomSocket accepts global on/off messages
#define PREFERENCE_USE_SPIFF_MQTT_SETTING
#define PREFERENCE_DEBUG_INFO_SETTING
a place to put some kind of Last Will of what went wrong .. for now (> max tries)
#define PREFERENCE_CHAIN_SENSORS_SETTING
#define BUTTON_SHORT_PRESS
#define PREFERENCE_FIRST_TIME_FEATURE_SETTING
a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
#define PREFERENCE_DISPLAY_SCREEN_TIMEOUT_VALUE
sets the timeout value
#define PREFERENCE_DISPLAY_ON_BLANK_SCREEN_VALUE
Display preferences - show messages on blank screen- boolean.
#define PREFERENCE_IS_MINIMAL_MENU_SETTING
sets the max temp for a poweroff
#define BUTTON_ANY
#define PREFERENCE_SCREEN_COLOR_SETTING
ithe color of the screen 0..n
#define PREFERENCE_NOTIFY_BLE_DISCOVERY
starts the BLE Discovery notification process - which might be internal or externa (via messages).
#define PREFERENCE_USE_SPIFF_QRATOM_SETTING
For MQTT writing to the QRATOM.
#define PREFERENCE_DEVICE_NAME_SETTING
the device name itself (6.6.22)
#define PREFERENCE_HIGH_TEMP_POWEROFF_VALUE
sets the max temp for a poweroff
#define PREFERENCE_STEPPER_FEEDS_PER_JACKPOT
#define PREFERENCE_GROUP_NAMES_SETTING
the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wi...
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
#define BUTTON_LONG_PRESS
#define PREFERENCE_STEPPER_2FEED_SETTING
#define PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING
#define PREFERENCE_TIMER_MAX_INT_SETTING
the preference timer MAX (pairs with PREFERENCE_TIMER_INT_SETTING)
#define PREFERENCE_MAIN_GATEWAY_VALUE
#define BUTTON_JOYSTICK_TOP
#define PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define PREFERENCE_MAIN_BLE_CLIENT_VALUE
#define PREFERENCE_SM_ON_PIR_SETTING
1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
#define PREFERENCE_TIMER_INT_SETTING
the preference timer
#define PREFERENCE_ATOM_KIND_SETTING
1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
#define PREFERENCE_SM_COMMAND_PIR_SETTING
1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
#define PREFERENCE_SENSORS_SETTING
#define PREFERENCE_STEPPER_AUTO_FEED_VALUE
char * chainUse
chain use string for debugging printout
char * valString
val strings
int pressKind
press kind: 0 = short press, 1 = long press, 2 = long long press, -1 any, 100,101,...
char * setString
the set strings, val strings, device strings
ChainButtonStruct * chainButtonStructArray
1.22.26 define a Chainbutton and creates N of them
int chainUseCount
number of chain
long pinNumArray[PIN_USE_MAX]
each pin
Definition: MainModule.h:507
char * pinUseArray[PIN_USE_MAX]
string describing the module, etc
Definition: MainModule.h:505
SensorClassType * sensorClassType
and the pointer to matching SensorClassType
SensorStruct * sensors
array of sensorStruct