ESP_IOT v2.5
IOT ESP Coding
ModelController.cpp File Reference
#include "../../Defines.h"
#include "ModelController.h"
Include dependency graph for ModelController.cpp:

Go to the source code of this file.

Macros

#define MenusModel_Help   0
 a pseudo Class More...
 
#define MenusModel_Settings   1
 
#define MenusModel_Pairing   2
 
#define MenusModel_APMode   3
 
#define MenusModel_Timer   4
 
#define MenusModel_Status   5
 
#define MenusModel_Advanced   6
 
#define MenusModel_WIFIShare   7
 
#define MenusModel_GuestFeed   8
 
#define MenusModel_GuestPage   9
 
#define MenusModel_DocFollow   10
 
#define MenusModel_Max   11
 

Functions

ModelStateStructgetModel (ModelKindEnum modelKind)
 retrieves the state model for the modelKind More...
 
void initMenuToSMMode ()
 init the mapping More...
 
void initModelStructs_ModelController ()
 initialize the objects More...
 
void setTimerDelaySeconds_mainModule (int delaySeconds)
 
void startStopTimer_mainModule (boolean startTimer)
 
void printDeviceState (ModelStateStruct *deviceState)
 print it out.. More...
 
ModelStateStructhasModelForSM_Mode (int SM_Mode)
 retrieves the state model for the SM_Mode (SM_0 .. SM_LAST) null if none More...
 
void incrementMenuState (ModelKindEnum modelKind)
 increments the device states deviceState (wrapping around) More...
 
void restartAllMenuStates_ModelController ()
 restarts all the menu states to the first one .. useful for getting a clean start. This doesn't care if the menu is being shown More...
 
void invokeFeedLocally ()
 storage.. More...
 
void invokeFeed_ModelController ()
 performs the BLE feed More...
 
void invokeUnpairNoNameBASE_ModelController ()
 
void invokeUnpairNoName_ModelController ()
 
void invokeUnpair_ModelController (char *nameOrAddress)
 performs the unpairing More...
 
void invokePair_ModelController ()
 
void invokeSkip_ModelController (char *nameOrAddress)
 performs skip More...
 
void invokeToggleGen3_ModelController ()
 toggles the GEN3 setting More...
 
void updateMenuState (ModelKindEnum modelKind)
 updates the model for the menu state, this sets max etc More...
 
char * menuForState (ModelKindEnum modelKind, int item)
 returns the menu string for the deviceState's item number (use woudl go 0..maxItems -1 More...
 
boolean invokeMenuState (ModelKindEnum modelKind)
 invokes the menu state, return true if the model state has change enough to refreesh your View (such as new menu items) More...
 
char * getModelSemanticMarker (ModelKindEnum modelKind)
 retrieves a semantic marker for the current selected item More...
 

Variables

int _menuToSMMode [MenusModel_Max]
 storage of mapping More...
 
ModelStateStruct _modelStateStructs [ModelKindEnumMax]
 
char _timerBuffer [10]
 

Macro Definition Documentation

◆ MenusModel_Advanced

#define MenusModel_Advanced   6

Definition at line 13 of file ModelController.cpp.

◆ MenusModel_APMode

#define MenusModel_APMode   3

Definition at line 10 of file ModelController.cpp.

◆ MenusModel_DocFollow

#define MenusModel_DocFollow   10

Definition at line 17 of file ModelController.cpp.

◆ MenusModel_GuestFeed

#define MenusModel_GuestFeed   8

Definition at line 15 of file ModelController.cpp.

◆ MenusModel_GuestPage

#define MenusModel_GuestPage   9

Definition at line 16 of file ModelController.cpp.

◆ MenusModel_Help

#define MenusModel_Help   0

a pseudo Class

Definition at line 7 of file ModelController.cpp.

◆ MenusModel_Max

#define MenusModel_Max   11

Definition at line 18 of file ModelController.cpp.

◆ MenusModel_Pairing

#define MenusModel_Pairing   2

Definition at line 9 of file ModelController.cpp.

◆ MenusModel_Settings

#define MenusModel_Settings   1

Definition at line 8 of file ModelController.cpp.

◆ MenusModel_Status

#define MenusModel_Status   5

Definition at line 12 of file ModelController.cpp.

◆ MenusModel_Timer

#define MenusModel_Timer   4

Definition at line 11 of file ModelController.cpp.

◆ MenusModel_WIFIShare

#define MenusModel_WIFIShare   7

Definition at line 14 of file ModelController.cpp.

Function Documentation

◆ getModel()

ModelStateStruct * getModel ( ModelKindEnum  modelKind)

retrieves the state model for the modelKind

Definition at line 226 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getModelSemanticMarker()

char * getModelSemanticMarker ( ModelKindEnum  modelKind)

retrieves a semantic marker for the current selected item

retrieves a semantic marker for the current selected item. Return null if none specified YET TODO.. right now the logis is in MQTTNetworking .. so need to figure something nice out..

default is the view is the same

what model struct to use

Definition at line 1171 of file ModelController.cpp.

Here is the call graph for this function:

◆ hasModelForSM_Mode()

ModelStateStruct * hasModelForSM_Mode ( int  SM_Mode)

retrieves the state model for the SM_Mode (SM_0 .. SM_LAST) null if none

retrieves the state model for the SM_Mode (SM_0 .. SM_LAST)l. NULL if none

Definition at line 236 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ incrementMenuState()

void incrementMenuState ( ModelKindEnum  modelKind)

increments the device states deviceState (wrapping around)

Definition at line 254 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initMenuToSMMode()

void initMenuToSMMode ( )

init the mapping

Definition at line 26 of file ModelController.cpp.

Here is the caller graph for this function:

◆ initModelStructs_ModelController()

void initModelStructs_ModelController ( )

initialize the objects

for the next page state 0..n

true if still waiting for delay to finish

length of delay get from in EPROM

feed local instead of MQTT or BLE.. if camera then feed local == take a picture..

Definition at line 77 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeFeed_ModelController()

void invokeFeed_ModelController ( )

performs the BLE feed

feed always (done after the code below..)

unfortunately, the incrementFeedCount() is AFTER the redrawSemanticMarker.. This sets the semantic marker .. which is current SM

Definition at line 290 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeFeedLocally()

void invokeFeedLocally ( )

storage..

send the command to the stepper.. not a BLE command

Definition at line 284 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeMenuState()

boolean invokeMenuState ( ModelKindEnum  modelKind)

invokes the menu state, return true if the model state has change enough to refreesh your View (such as new menu items)

invokes the menu state, return true if the model state has change enough to refreesh your View (such as new menu items) NOTE: This is the LONG press on the M5 button (the BLUE item)

default is the view is the same

what model struct to use

the pairdDeviceModel kind

factory default but not connecte to anything..

for now, the color is incremented in the displayModule

BUT at the MQTT level not web page level

9.30.22 IF SET .. send a feed but to all devices except ours and our pair (if any) uses new wildcard syntax either ! OUR NAME [ & ! OUR_CONNECTED_NAME

BUT at the MQTT level not web page level

9.30.22 IF SET .. send a feed but to all devices except ours and our pair (if any) uses new wildcard syntax either ! OUR NAME [ & ! OUR_CONNECTED_NAME

this has the # so it is treated slightly different, but tacking on the device for example..

BUT at the MQTT level not web page level

9.30.22 IF SET .. send a feed but to all devices except ours and our pair (if any) uses new wildcard syntax either ! OUR NAME [ & ! OUR_CONNECTED_NAME

This just goes to the 0'th page in the stream..

1 based (not 0 based)

this has the # so it is treated slightly different, but tacking on the device for example..

set transient look for PTClicker

11.4.22 (after Maggie Bluetic was fed with Pumpking Uno and GreyGoose

use lookup

Issue: #222 for #206, this sets the current mode to SM_doc_follow, but when at that page in the the current mode (which is now SM_doc_follow) won't let the page go somewhere else (except in this case we are the same page). Only but a physical button click. I THINK THE ANSWER: if current and next are the same an SM_doc_follow, then do the page change..

if HELP then printout preferences to the debug window

if HELP .. show the status print the preferences to SerialDebug

reset to default

Definition at line 872 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokePair_ModelController()

void invokePair_ModelController ( )

performs the pairing.. to whatever is currently connected, this means a message could make that happen for a device (ESP-32) with no user interface.

this is where it needs to know if GEN3. If so, then if their is a paired name .. If GEN3, don't overreight the device name in case it was set by the user..

always set the ADDRESS

This means the name

Definition at line 347 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeSkip_ModelController()

void invokeSkip_ModelController ( char *  nameOrAddress)

performs skip

Definition at line 372 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeToggleGen3_ModelController()

void invokeToggleGen3_ModelController ( )

toggles the GEN3 setting

change GEN3 preference

if connected and not a GEN3 but want only GEN3 .. then disconnect, otherwise keep connected

also unpair..

Definition at line 384 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeUnpair_ModelController()

void invokeUnpair_ModelController ( char *  nameOrAddress)

performs the unpairing

refactored base

Definition at line 334 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeUnpairNoName_ModelController()

void invokeUnpairNoName_ModelController ( )

just unpair .. don't skip performs the unpairing

refactored base

Definition at line 323 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invokeUnpairNoNameBASE_ModelController()

void invokeUnpairNoNameBASE_ModelController ( )

just unpair .. don't skip performs the unpairing

also unset the main storage..

Definition at line 309 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ menuForState()

char * menuForState ( ModelKindEnum  modelKind,
int  item 
)

returns the menu string for the deviceState's item number (use woudl go 0..maxItems -1

MENUS Pairing APMode Timer Advanced Status WIFI sharing Guest Feed Settings DocFollow help HomePage /WIFI Feed WIFI Share

draw the state we are in..

update menu with seconds countdown

only if stopped...

Definition at line 611 of file ModelController.cpp.

Here is the call graph for this function:

◆ printDeviceState()

void printDeviceState ( ModelStateStruct deviceState)

print it out..

Definition at line 158 of file ModelController.cpp.

Here is the caller graph for this function:

◆ restartAllMenuStates_ModelController()

void restartAllMenuStates_ModelController ( )

restarts all the menu states to the first one .. useful for getting a clean start. This doesn't care if the menu is being shown

Definition at line 269 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTimerDelaySeconds_mainModule()

void setTimerDelaySeconds_mainModule ( int  delaySeconds)

! TIMER Remote control set delay seconds MQTT: set: timerdelay, val:seconds

save in EPROM

Definition at line 134 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startStopTimer_mainModule()

void startStopTimer_mainModule ( boolean  startTimer)

! TIMER Remote control start MQTT: set: starttimer, val: true/false (true == start timer, false = stop timer)

Definition at line 148 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateMenuState()

void updateMenuState ( ModelKindEnum  modelKind)

updates the model for the menu state, this sets max etc

updates the model for the menu state (this will initialize if not done yet..)

must save since many preferences are called...

the pairedName stored in EPROM can be an Address (eg. 03:34:23:33)

show the BLE connected status at the bottom (G3 if gen3), WIFI, and AP if APmode

whether the gateway is on.. this isn't using the Gx just BLE or GE3

name of paired device (if any) in EPROM

name of connected device, or "" if not specified, which means not pairable

compare to what's connected ..

is paired and connected (to that pair .. if BLECLient working right)

if connectedBLE then either paired or not-paired

if the EPROM's pairedDevice/Address == what's connected, then we are paired and connected

is paired

not connected, so paired if a valid paired name/address

if the EPROM's pairedDevice/Address is set then paired and NOT connected

unpaired

MENUS Pairing APMode Timer Advanced Status WIFI sharing Guest Feed Settings DocFollow help HomePage /WIFI Feed WIFI Share

calculate the current second counter..

substract the seconds from the set delay

if count <=0 then finished..

if local .. send a command directly to the device..

send the command to the stepper.. not a BLE command

for now only invoke the feed ... todo mroe things.. STATUS, WIFI FEED, DOCFOLLOW

TODO: look at a scrolling idea if > 6 ...

Definition at line 400 of file ModelController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _menuToSMMode

int _menuToSMMode[MenusModel_Max]

storage of mapping

Definition at line 24 of file ModelController.cpp.

◆ _modelStateStructs

ModelStateStruct _modelStateStructs[ModelKindEnumMax]

create state variables for the ModelKindEnum entries

Definition at line 73 of file ModelController.cpp.

◆ _timerBuffer

char _timerBuffer[10]

Definition at line 74 of file ModelController.cpp.