10#ifdef USE_BUTTON_MODULE
77#include <M5StickCPlus.h>
84int _channelBuzzer = 0;
85int _channelREDLED = 1;
87int _resolution_bits = 8;
105 SerialCall.printf(
"startDelay_ButtonProcessing: %d\n", seconds);
118 SerialCall.println(
"delayFinished_ButtonProcessing..");
127 SerialCall.println(
"stopDelay_ButtonProcessing _delayRunning=false");
147 SerialLots.println(
"refreshDelayButtonTouched_ButtonProcessing");
204#ifdef USE_MQTT_NETWORKING
236 SerialCall.print(
"performProcessCurrentMode: blank:");
237 SerialCall.println(justWakeup);
242 SerialTemp.print(
"currentSMMode: ");
254 SerialTemp.printf(
"modelChanged(%d)\n", modelChanged);
263 SerialTemp.printf(
"SMmode=%d, now=%d\n", currentSMMode,currentSMModeNow);
264 if (currentSMMode != currentSMModeNow)
276 SerialCall.println(
"SM_home_simple");
286 SerialCall.println(
"SM_home_simple_1");
289#ifdef USE_BLE_CLIENT_NETWORKING
304 SerialCall.println(
"SM_home_simple_2");
316 SerialCall.println(
"SM_home_simple_3");
327#ifdef USE_MQTT_NETWORKING
349#ifdef USE_MQTT_NETWORKING
361#ifdef USE_MQTT_NETWORKING
378#ifdef USE_MQTT_NETWORKING
380 sprintf(
_smMessage,
"FEED {'deviceName':'%s'}",pairDevice);
391#ifdef USE_MQTT_NETWORKING
402#ifdef CHANGED_TO_JUST_MIN_MAX
410 SerialCall.print(
"Setting MINIMAL_MENU: ");
411 SerialCall.println(isZoomed?
"ZOOMED":
"UNZOOMED");
440 SerialTemp.print(
"SM_doc_follow: ");
441 SerialTemp.println(statusURL);
448 SerialMin.println(
"rebooting..");
461 SerialCall.print(
"currentSMMode: ");
482 ledcSetup(_channelREDLED, _freq, _resolution_bits);
483 ledcAttachPin(_LEDPin, _channelREDLED);
486 ledcWrite(_channelBuzzer, 300);
488 ledcWrite(_channelBuzzer, 0);
493 ledcWrite(_channelREDLED, 0);
505 SerialCall.println(
"long press.. processMode");
519 SerialLots.println(
"buttonA_ShortPress");
547#ifdef USE_MQTT_NETWORKING
565 boolean buttonTouched =
true;
568 if (M5.BtnA.wasReleasefor(500))
572 else if (M5.BtnA.wasReleased())
578 buttonTouched =
false;
596 SerialCall.println(
"B.long press.. toggleZoom or incrementColor");
612#ifdef USE_MQTT_NETWORKING
654 SerialCall.print(
"current mode:");
669 boolean buttonTouched =
true;
673 if (M5.BtnB.wasReleasefor(500))
675 SerialCall.println(
"buttonB_LongPress");
680 else if (M5.BtnB.wasReleased())
682 SerialCall.println(
"buttonB_ShortPress");
689 buttonTouched =
false;
694 SerialLots.println(
" .. buttonB .. calling refresh");
703#define SENSORS_MOTION_PIR
704#ifdef SENSORS_MOTION_PIR
712#define Elapsed3secs 3000
713#define Elapsed4secs 4000
715#define Elapsed3mins 180000
749 boolean triggeredPIR = digitalRead(
PIR_PIN);
756 SerialLots.println(
"triggeredPIR = true");
759 triggeredPIR =
false;
815 SerialLots.printf(
"diff: %.2f \r\n",
_IMU.
diffXYZ);
873 if ( (millis() - PrevTriggerTime) > InactivityTimeOut) {
883 SerialTemp.println(
"motion detected");
893 SerialTemp.println(
"PIR detected");
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
void incrementScreenColor_displayModule()
boolean isBlankScreen_displayModule()
whether screen is blank (so the button can be a wake, vs action..)
void showText_displayModule(String text)
void redrawSemanticMarker_displayModule(boolean startNew)
redraws the Semantic Marker image..
const char * currentSemanticMarkerAddress_displayModule()
returns the current semantic marker (eg. guest page)
void sendMessageMQTT(char *message)
boolean processJSONMessageMQTT(char *ascii, char *topic)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not,...
void sendSemanticMarkerDocFollow_mainModule(const char *SMDocFollowAddress)
sends the SM on the DOCFOLLOW channel (publish it..)
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
char * main_currentStatusURL()
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc
char * main_JSONStringForWIFICredentials()
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter)
int getCurrentSMMode_mainModule()
returns the current SM Mode
void resetFeedCount_mainModule()
sets the feed count max
void sendMessageString_mainModule(char *messageString)
adding a synchronous call to send a message over the network (assuming MQTT but not specified),...
void setCurrentSMMode_mainModule(int whichSMMode)
sets the current screen mode .. which can be used by Button and Display processing
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 * main_nextJSONWIFICredential()
! cycle through the next WIFI saved credential
void incrementSMMode_mainModule()
increment the currentSMMode, wrapping and using the max menu
#define SM_pair_dev
guest feed device
#define ASYNC_REBOOT
sets the GATEWAY mode off
#define ASYNC_CALL_BLE_CLIENT_PARAMETER
these are the async with a string parameter. This sends a BLE command
#define SM_guest_feed
guest feed
#define SM_guest_page
guest page
#define NO_POWEROFF_AMOUNT_MAIN
10000 == no poweroff
#define ASYNC_SEND_MQTT_FEED_MESSAGE
sends a message (like FEED) on the users topic
#define SM_HOME_SIMPLE_LAST
#define SM_status
//status
#define ASYNC_CALL_CLEAN_CREDENTIALS
cleans out the credentials and restarts in AP (Access Point) mode.
#define ASYNC_POWEROFF
sets the GATEWAY mode off
#define SM_doc_follow
docfollow
#define SM_smart_clicker_homepage
//! homepage
#define SM_WIFI_ssid
WIFI ssid.
#define SM_ap_mode
AP MODE.
void incrementMenuState(ModelKindEnum modelKind)
increments the device states deviceState (wrapping around)
boolean invokeMenuState(ModelKindEnum modelKind)
invokes the menu state, return true if the model state has change enough to refreesh your View (such ...
ModelStateStruct * hasModelForSM_Mode(int SM_Mode)
retrieves the state model for the SM_Mode (SM_0 .. SM_LAST) null if none
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
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
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...
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 PREFERENCE_SENSOR_TILT_VALUE
Sensor preferences.
#define PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING
#define PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define PREFERENCE_STEPPER_BUZZER_VALUE
stepper preferences
#define PREFERENCE_IS_MINIMAL_MENU_SETTING
sets the max temp for a poweroff
#define PREFERENCE_MAIN_GATEWAY_VALUE
the struct for the models. Since this isn't straight OO, we are overlaying information....
ModelKindEnum modelKindEnum
What kind of model.