ESP_IOT v2.5
IOT ESP Coding
M5Atom_NoModuleClass.cpp
Go to the documentation of this file.
1//
2// M5Atom_NoModuleClass.cpp
3// ESP_IOT
4//
5// Created by Scott Moody on 10/26/25.
6//
7
9
10
11#ifdef USE_FAST_LED
12#include "../ATOM_LED_Module/M5Display.h"
13#endif
14
15//! TODO.. have only 1 of these included in build, but change the callback
16//! That requires that ATOM be a class, OR there is a single Sensor but different callback..
17//#define KEY_UNIT_SENSOR_CLASS in defines.h
18#ifdef KEY_UNIT_SENSOR_CLASS
19
20#include "../SensorClass/SensorClassType.h"
21#include "../SensorClass/KeyUnitSensorClass.h"
22
23
24//#include "TimerDelayClass.h"
25//! create instance of the timer class
27
28//! default .. this could be set via Preferences (TODO)
30
31//! keyUnitSensorClass object for the BUTTON
33
34//!a pointer to a callback function that takes (char*) and returns void
35void M5AtomCallback_M5AtomNoModule(char *parameter, boolean flag)
36{
37 SerialDebug.printf("M5AtomCallback_M5AtomNoModule.sensorCallbackSignature(%s,%d)\n", parameter, flag);
38
39 // sendMessageString_mainModule((char*)"M5Atom.KEY Pressed ");
40
41
42 ///feed always (done after the code below..)
44
45 //!send status after power on/off change..
46 //sendStatusMQTT_mainModule();
47
48}
49#endif //KEY_UNIT_SENSOR_CLASS
50
52{
53 SerialDebug.printf("M5Atom_NoModuleClass init %s\n", config);
54
56}
57
58
59//! Data members of class
60//! Generic config info .. specific the the sensor type
61
62//!starts the PTStepper
64{
65}
66
67//!setup the PTStepper
69{
70 SerialDebug.println("M5Atom_NoModuleClass::setup_M5AtomClassType");
71 //! call super..
72 //M5AtomClassType::setup_M5AtomClassType();
73
74#ifdef USE_FAST_LED
75 SerialDebug.println("M5Atom_NoModuleClass.M5.begin");
76
77 // M5.begin(true,false,true);
78 //!NOTE: this could probably be done by ESP_IOT.ino .. but for now keep here (and in the other ATOM code..)
80 // fillpix(L_GREEN);
82 M5.update();
83
84#endif
85
86
87#ifdef KEY_UNIT_SENSOR_CLASS
88 _KeyUnitSensorClass_M5AtomNoModule = new KeyUnitSensorClass((char*)"KeyUnitSensorClass_M5AtomNoModule");
89 //! specify the callback
91 //! call the setup
93 SerialDebug.printf("_Key = %d\n", _KeyUnitSensorClass_M5AtomNoModule);
94#endif
95
96}
97
98
99
100//! stops motor
102{
103
104 //!user timer class instance
106}
107
108//!setup the PTStepper
110{
111 M5.update();
112
113#ifdef KEY_UNIT_SENSOR_CLASS
114 //SerialDebug.printf("_Key = %d\n", _KeyUnitSensorClass_M5AtomNoModule);
115
117#endif
118
119 //! see if timer done .. change color back
120 //!user timer class instance
122 {
123#ifdef USE_FAST_LED
125 M5.update();
126#endif
127 }
128
129}
130
131//! ATOM specific
132
133//! these are from the ATOM
134
135//! 8.28.23 Adding a way for others to get informed on messages that arrive
136//! for the set,val
137//! 12.27.23 support setName == "socket"
138//! 1.10.24 if deviceNameSpecified then this matches this device, otherwise for all.
139//! It's up to the receiver to decide if it has to be specified
140void M5Atom_NoModuleClass::messageSetVal_M5AtomClassType(char *setName, char* valValue, boolean deviceNameSpecified)
141{
142
143}
144
145//! 12.28.23, 8.28.23 Adding a way for others to get informed on messages that arrive
146//! for the send -
147void M5Atom_NoModuleClass::messageSend_M5AtomClassType(char *sendValue, boolean deviceNameSpecified)
148{
149
150}
151
152//! BUTTON PROCESSING abstraction
153//!short press on buttonA (top button)
155{
156 SerialDebug.println("M5Atom::buttonA_ShortPress_M5Atom_NoModuleClass");
157 //! feed
158 SerialDebug.printf("Feed BLE\n");
159 // send the _lastSemanticMarker again ...
160 //!send this as a DOCFOLLOW message
161 //sendSemanticMarkerDocFollow_mainModule(_lastSemanticMarker);
162 // strcpy(_lastSemanticMarker,"https://iDogWatch.com/bot/feed/test/test");
163
164#ifdef USE_FAST_LED
165 fillpix(L_RED);
166 M5.update();
167
168#endif
169
170 ///feed always (done after the code below..)
172
173 //! 11.26.25 send status as well .. so we can hear what's happening
174 //! 8.16.25 MQTT
175 //!also send a #STATUS
176 //sendMessageMQTT((char*)"#STATUS");
177
178 //! start the delay.. (which at .5 might not be needed...)
179 //! 10.26.25 when done .. change to BLUE again
181}
182
183//!long press on buttonA (top button)
185{
186 SerialDebug.println("M5Atom_HDriverModuleClass::buttonA_LongPress_M5Atom_NoModuleClass");
187
188#define USE_OPTION_1
189#ifdef USE_OPTION_1
190 //! 11.26.25
191 //! as per issue #412 option 1 is to store locally,
193 //! 8.16.25 BLE CLIENT //!optimized to not send the wrapper around the message
194 // need to send B or b .. depending on result
196 {
197 SerialDebug.println("*** NoModuleClass sending Buzzer = on 'B'");
199 }
200 else
201 {
202 SerialDebug.println("*** NoModuleClass sending Buzzer = off 'b'");
204 }
205
206#else
207 //! 11.25.25 cold out, no snow but needed for skiing
208 //! add a version of the long press that turns on.off the buzzer ..
209 //! actually will call Toggle if connected via BLE
210 //! see if connected to a BLE device..
211 char *connectedBLEDeviceName = connectedBLEDeviceName_mainModule()?connectedBLEDeviceName_mainModule():NULL;
212 SerialDebug.printf("connectedBLEDeviceName = %s\n", connectedBLEDeviceName);
213 if (connectedBLEDeviceName)
214 {
215 //! make a BLE call to our connected device
217
218 //! call their toggle the buzzer...
219 // processClientCommandChar_mainModule('F');
220 }
221#endif
222
223#ifdef IN_BASE_TYPE_NOW
224
225 //
226 SerialDebug.printf("CLEAN CREDENTIALS and reboot to AP mode\n");
227
228 //! dispatches a call to the command specified. This is run on the next loop()
230#endif
231
232}
233
234//!returns a string in in URL so: status&battery=84'&buzzon='off' } .. etc
235//!starts with "&"*
237{
238 //! 8.4.25 add k=GPS
239 //! 8.4.25 add k=HD (HDriver)
240 return (char*)"&k=NO";
241}
242
243//!returns a string in in JSON so: status&battery=84'&buzzon='off' } .. etc
244//!starts with "&"*
246{
247 return (char*)"'kind':'NO'";
248}
249
250
251//!6.6.24 D-Day 81 years
252//!return true or false if this should be a PTFeeder or PTClicker
253//!default 'false' to PTClicker. The Bluetooth will use this
255{
256 SerialDebug.printf("M5Atom_NoModuleClass isPTFeeder = false\n");
257
258 return false;
259}
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
void M5AtomCallback_M5AtomNoModule(char *parameter, boolean flag)
a pointer to a callback function that takes (char*) and returns void
KeyUnitSensorClass * _KeyUnitSensorClass_M5AtomNoModule
keyUnitSensorClass object for the BUTTON
TimerDelayClass * _timerDelayClass_M5NoModuleClass
create instance of the timer class
float _delaySeconds_M5NoModuleClass_setting
default .. this could be set via Preferences (TODO)
void setup_M5Display()
the setup() no loop()
Definition: M5Display.cpp:11
void fillpix(CRGB Color)
color the button light
Definition: M5Display.cpp:67
#define L_RED
colors
Definition: M5Display.h:36
#define L_BLUE
Definition: M5Display.h:38
void main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
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 ASYNC_CALL_CLEAN_CREDENTIALS
cleans out the credentials and restarts in AP (Access Point) mode.
Definition: MainModule.h:197
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
#define PREFERENCE_STEPPER_BUZZER_VALUE
stepper preferences
void setup()
Pure Virtual Function.
void loop()
Pure Virtual Function.
void setup_M5AtomClassType()
setup the PTStepper
M5Atom_NoModuleClass(char *config)
constructor
void messageSend_M5AtomClassType(char *sendValue, boolean deviceNameSpecified)
void buttonA_LongPress_M5AtomClassType()
long press on buttonA (top button)
void messageSetVal_M5AtomClassType(char *setName, char *valValue, boolean deviceNameSpecified)
ATOM specific.
void stop_M5AtomClassType()
stops motor
void loop_M5AtomClassType()
setup the PTStepper
void start_M5AtomClassType()
starts the PTStepper
An mostly virtual class.
void registerCallback(sensorCallbackSignature *callback)
An concrete class.
void startDelay(float delayAmountSeconds)
starts delay calculation
boolean delayFinished()
whether the currently delay is finished, false if not running at all
void stopDelay()
stops delay