2#ifdef USE_DISPLAY_MODULE
63 M5.Lcd.drawRGBBitmap(0,0, (uint16_t *)bitmap, 135,100);
69void printText(String text,
int maxLen);
72String _currentSemanticMarkerAddress=
"https://iDogWatch.com";
79 return _currentSemanticMarkerAddress.c_str();
81String _lastSemanticMarkerAddress =
"";
83String _semanticTitle =
"M5 Clicker";
85String _currentSemanticMarkerAddressBase =
"https://iDogWatch.com";
87const char* (*_getStatusFunc)(void) = NULL;
90boolean _semanticMarkerShown =
false;
95#define SCREEN_TYPE_NORMAL 0
97#define SCREEN_TYPE_HOME 1
98#define SCREEN_TYPE_STATUS 2
99#define SCREEN_TYPE_HELP 3
100#define SCREEN_TYPE_WIFI 4
101#define SCREEN_TYPE_TILT 5
102#define SCREEN_TYPE_BUZZ 6
103#define SCREEN_TYPE_AP 7
104#define SCREEN_TYPE_GUEST_PAGE 8
105#define SCREEN_TYPE_FEED_GUEST 9
106#define SCREEN_TYPE_PAIRED_DEV 10
107#define SCREEN_TYPE_RESET 11
108#define SCREEN_TYPE_REBOOT 12
110#define SCREEN_TYPE_HOME_SIMPLE 13
111#define SCREEN_TYPE_HOME_SIMPLE_1 14
112#define SCREEN_TYPE_HOME_SIMPLE_2 15
113#define SCREEN_TYPE_HOME_SIMPLE_3 16
114#define SCREEN_TYPE_DOC_FOLLOW 17
115#define SCREEN_TYPE_TIMER 18
118int _currentScreenType = SCREEN_TYPE_NORMAL;
122int screenTypeForTitle_displayModule(String title)
126 int screenType = SCREEN_TYPE_NORMAL;
127 if (title.compareTo(
"MINI CLICKER")==0)
129 screenType = SCREEN_TYPE_HOME_SIMPLE;
131 else if (title.compareTo(
"MINI-1")==0)
133 screenType = SCREEN_TYPE_HOME_SIMPLE_1;
135 else if (title.compareTo(
"MINI-2")==0)
137 screenType = SCREEN_TYPE_HOME_SIMPLE_2;
141 else if (title.compareTo(
"MINI-3")==0)
143 screenType = SCREEN_TYPE_HOME_SIMPLE_3;
146 else if (title.compareTo(
"WIFI FEED")==0)
148 screenType = SCREEN_TYPE_HOME;
150 else if (title.startsWith(
"HELP"))
152 screenType = SCREEN_TYPE_HELP;
154 else if (title.startsWith(
"WIFI"))
156 screenType = SCREEN_TYPE_WIFI;
158 else if (title.startsWith(
"TILT"))
160 screenType = SCREEN_TYPE_TILT;
162 else if (title.startsWith(
"BUZZ"))
164 screenType = SCREEN_TYPE_BUZZ;
166 else if (title.startsWith(
"AP"))
168 screenType = SCREEN_TYPE_AP;
170 else if (title.startsWith(
"GUEST PAGE"))
172 screenType = SCREEN_TYPE_GUEST_PAGE;
174 else if (title.startsWith(
"FEED GUEST"))
176 screenType = SCREEN_TYPE_FEED_GUEST;
178 else if (title.startsWith(
"STATUS"))
180 screenType = SCREEN_TYPE_STATUS;
182 else if (title.startsWith(
"RESET"))
184 screenType = SCREEN_TYPE_RESET;
186 else if (title.startsWith(
"DOC FOLLOW"))
188 screenType = SCREEN_TYPE_DOC_FOLLOW;
190 else if (title.startsWith(
"REBOOT"))
192 screenType = SCREEN_TYPE_REBOOT;
194 else if (title.startsWith(
"TIMER"))
196 screenType = SCREEN_TYPE_TIMER;
199 else if (title.startsWith(
"P:"))
201 screenType = SCREEN_TYPE_PAIRED_DEV;
204 _currentScreenType = screenType;
225#define HEIGHT_3_2LINE 60
240typedef struct TextPosition
243 uint16_t width, height;
246 uint16_t textColorBackground;
257TextPositionStruct _actionTextPosition = {0,2,WIDTH,HEIGHT_2,FONT_2,BLUE,WHITE,BLACK,ROTATE_0,11};
258TextPositionStruct _actionTextPositionZoomed = {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,BLUE,WHITE,BLACK,ROTATE_0,14};
259TextPositionStruct _actionTextHomePositionZoomed= {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,ORANGE,BLACK,BLACK,ROTATE_0,14};
261TextPositionStruct _actionTextHomeSimplePositionZoomed = {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,YELLOW,BLUE,BLACK,ROTATE_0,15};
262TextPositionStruct _actionTextHomeSimplePositionZoomed_1= {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,BLUE,YELLOW,BLACK,ROTATE_0,15};
263TextPositionStruct _actionTextHomeSimplePositionZoomed_2= {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,BLACK,GREEN,BLACK,ROTATE_0,15};
264TextPositionStruct _actionTextHomeSimplePositionZoomed_3= {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,BLACK,WHITE,BLACK,ROTATE_0,15};
265TextPositionStruct _actionTextHomeSimplePositionZoomed_4= {0,2,WIDTH,HEIGHT_3_2LINE,FONT_3,WHITE,RED,BLACK,ROTATE_0,15};
268#define MAX_ACTION_TEXT_HOME_COLORS 5
269TextPositionStruct _actionTextHomeSimpleColor[MAX_ACTION_TEXT_HOME_COLORS] =
271 _actionTextHomeSimplePositionZoomed,
272 _actionTextHomeSimplePositionZoomed_1,
273 _actionTextHomeSimplePositionZoomed_2,
274 _actionTextHomeSimplePositionZoomed_3,
275 _actionTextHomeSimplePositionZoomed_4,
279TextPositionStruct _sensorStatusTextPosition = {0,27,WIDTH,HEIGHT_2,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,22};
280TextPositionStruct _sensorStatusTextPositionZoomed = {0,65,WIDTH,HEIGHT_3,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,22};
282TextPositionStruct _helpStatusTextPosition =
283 {0,65,WIDTH,HEIGHT_3,FONT_2,ORANGE,BLACK,BLACK,ROTATE_0,22};
285TextPositionStruct _multilineStatusTextPosition = {0,27,WIDTH,HEIGHT_4,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,40};
286TextPositionStruct _multilineStatusTextPositionZoomed = {0,65,WIDTH,HEIGHT_4,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,40};
289TextPositionStruct _moduleStatusTextPosition = {0,67,WIDTH,HEIGHT_3,FONT_3,YELLOW,BLUE,BLACK,ROTATE_0,7};
290TextPositionStruct _moduleStatusTextPositionZoomed = {0,105,WIDTH,HEIGHT_3,FONT_3,YELLOW,BLUE,BLACK,ROTATE_0,7};
293TextPositionStruct _homeSimpleStatusTextPositionZoomed = {0,105,WIDTH,HEIGHT_3,FONT_3,ORANGE,BLACK,BLACK,ROTATE_0,7};
295TextPositionStruct _homeSimpleStatusTextPositionZoomedRED = {0,105,WIDTH,HEIGHT_3,FONT_3,RED,BLACK,BLACK,ROTATE_0,7};
298TextPositionStruct _connectedStatusTextPositionZoomed = {0,213,WIDTH,HEIGHT_2,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,11};
301TextPositionStruct _menuTextPositionZoomed_4less = {0,105,WIDTH,HEIGHT_3,FONT_3,ORANGE,BLACK,BLACK,ROTATE_0,7};
302TextPositionStruct _menuTextPositionZoomed_4plus = {0,105,WIDTH,HEIGHT_2,FONT_2,ORANGE,BLACK,BLACK,ROTATE_0,22};
308#define SM_ACTION_SMALL 2
309#define QRAVATAR_ACTION 3
313#define TRY_SWAPPED_COLORS
314#ifdef TRY_SWAPPED_COLORS
315TextPositionStruct _zoomedTextPositions[MAX_ACTIONS] = {
316 {0,145,WIDTH,HEIGHT_3,FONT_3,ORANGE,BLACK,BLACK,ROTATE_0,7},
317 {0,180,WIDTH,HEIGHT_3,FONT_3,WHITE,BLUE,BLACK,ROTATE_0,7},
320 {0,145,WIDTH,HEIGHT_2,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,40},
322 {50,150,1,HEIGHT_3,FONT_3,RED,YELLOW,BLACK,ROTATE_0,2}
325TextPositionStruct _zoomedTextPositions[MAX_ACTIONS] = {
326 {0,145,WIDTH,HEIGHT_3,FONT_3,WHITE,BLUE,BLACK,ROTATE_0,7},
327 {0,180,WIDTH,HEIGHT_3,FONT_3,WHITE,BLACK,BLACK,ROTATE_0,7},
329 {0,180,WIDTH,HEIGHT_3,FONT_3,ORANGE,BLACK,BLACK,ROTATE_0,7},
332 {0,145,WIDTH,HEIGHT_2,FONT_2,WHITE,BLACK,BLACK,ROTATE_0,40},
334 {50,150,1,HEIGHT_3,FONT_3,RED,YELLOW,BLACK,ROTATE_0,2}
339void setupTextPositionOverrideTextColor(TextPositionStruct textP, TextPositionStruct textColor)
342 M5.Lcd.setRotation(textP.rotation);
343 M5.Lcd.fillRect(textP.x, textP.y, textP.width, textP.height, textColor.blankColor );
344 M5.Lcd.setTextColor(textColor.textColor, textColor.textColorBackground);
345 M5.Lcd.setCursor(textP.x + 2, textP.y);
346 M5.Lcd.setTextSize(textP.textSize);
355 M5.Lcd.fillRect(0, 60, 135, 140, ORANGE);
356 M5.Lcd.setTextColor(WHITE, BLACK);
357 M5.Lcd.setCursor(10, 90);
358 M5.Lcd.setTextSize(2);
359 M5.Lcd.println(
"\nStarting \nOTA Update \nPlease Wait\n2-5 minutes");
364void setupTextPosition(TextPositionStruct textP)
367 setupTextPositionOverrideTextColor(textP, textP);
372void printTextAtTextPositionOverrideTextColor(String text, TextPositionStruct textPosition, TextPositionStruct textColor)
374 setupTextPositionOverrideTextColor(textPosition, textColor);
381void printTextAtTextPosition(String text, TextPositionStruct textPosition)
383 setupTextPosition(textPosition);
397 if (screenColor >= MAX_ACTION_TEXT_HOME_COLORS)
404 SerialCall.printf(
"incrementScreenColor_displayModule = %d\n", screenColor);
408int getScreenColor_displayModule()
412 if (screenColor < 0 || screenColor >= MAX_ACTION_TEXT_HOME_COLORS)
415 screenColor = screenColor % MAX_ACTION_TEXT_HOME_COLORS;
418 SerialLots.printf(
"getScreenColor_displayModule = %d\n", screenColor);
427 if (screenColor < 0 || screenColor >= MAX_ACTION_TEXT_HOME_COLORS)
430 screenColor = screenColor % MAX_ACTION_TEXT_HOME_COLORS;
433 SerialCall.printf(
"setScreenColor_displayModule = %d\n", screenColor);
444void incrementLoopTimer()
446 _loopTimer = (_loopTimer+1) % 100;
469String createSemanticAddress()
475 SerialTemp.print(
"createDynamicSemanticAddress: ");
479 _currentSemanticMarkerAddress = String((*_getStatusFunc)()) +
"&t=" + String(_loopTimer);
484 SerialCall.print(
"createSemanticAddress: ");
485 _currentSemanticMarkerAddress = _currentSemanticMarkerAddressBase;
489#ifdef TEST_LONGER_ADDRESS
497 _currentSemanticMarkerAddress +=
"&n=";
500 if (_currentSemanticMarkerAddress.length() < 130)
502 for (
int i= _currentSemanticMarkerAddress.length(); i< 130; i++)
504 _currentSemanticMarkerAddress +=
"_";
507 for (
int i=0; i< _loopTimer; i++)
509 _currentSemanticMarkerAddress += String(_loopTimer);
512 SerialTemp.printf(
"Length = %d\n", _currentSemanticMarkerAddress.length());
516 if (_loopTimer == 15)
519 if (_currentSemanticMarkerAddress.length() > 154)
521 SerialTemp.println(
" Truncating to 154 chartacters...");
523 _currentSemanticMarkerAddress = _currentSemanticMarkerAddress.substring(0,154);
528 if (_currentSemanticMarkerAddress.length() > 154)
530 SerialTemp.println(
" Truncating to 154 chartacters...");
532 _currentSemanticMarkerAddress = _currentSemanticMarkerAddress.substring(0,154);
535 SerialLots.println(_currentSemanticMarkerAddress);
536 return _currentSemanticMarkerAddress;
545unsigned long _delayStart;
547boolean _delayRunning =
false;
551void startDelay(
int seconds)
553 SerialCall.printf(
"startDelay_displayModule: %d\n", seconds);
555 _delayStart = millis();
556 _delayRunning =
true;
557 _delaySeconds = seconds;
561boolean delayFinished()
563 if (_delayRunning && ((millis() - _delayStart) >= (_delaySeconds * 1000)))
565 _delayRunning =
false;
566 SerialCall.println(
"delayFinished..");
575 SerialCall.println(
"stopDelay _delayRunning=false");
577 _delayRunning =
false;
587#define BLK_PWM_CHANNEL 7
588void setBrightness_displayModule(
int brightness)
591 ledcWrite(BLK_PWM_CHANNEL, brightness);
598 SerialCall.println(
"blankScreen_displayModule");
605 _semanticMarkerShown =
false;
608 M5.Lcd.fillScreen(BLACK);
620 printTextAtTextPosition(
" CLICKER",_connectedStatusTextPositionZoomed);
624#define TRY_DEVICES_AND_PAIRED
625#ifdef TRY_DEVICES_AND_PAIRED
627 char infoString[150];
628 boolean multilineScreenType;
633 multilineScreenType =
true;
657 SerialCall.println(infoString);
660 setupTextPosition(multilineScreenType?_multilineStatusTextPositionZoomed:_sensorStatusTextPositionZoomed);
663 printText(infoString,multilineScreenType?_multilineStatusTextPosition.maxLen:_sensorStatusTextPosition.maxLen);
669 setupTextPosition(_sensorStatusTextPositionZoomed);
685 SerialCall.println(
"wakeupScreen_displayModule");
695 SerialCall.println(
"clearScreen_displayModule");
702 M5.Lcd.setRotation(0);
703 M5.Lcd.fillScreen(BLACK);
710 SerialLots.print(
"isBlankScreen_displayModule:");
711 SerialLots.println(!_delayRunning?
"BLANK":
"NOT BLANK");
714 return !_delayRunning;
719boolean displayOnBlankScreen()
725int currentScreenTimeout()
735 SerialCall.println(
"setupESP_M5");
742 M5.Lcd.setTextColor(WHITE);
746 M5.Lcd.setRotation(0);
751 M5.Lcd.setTextSize(2);
755 M5.Lcd.printf(
"%s", VERSION);
760 M5.Lcd.qrcode(
"https://iDogWatch.com/bot/help",0,100,135);
762 printTextAtTextPosition(
"SM",_zoomedTextPositions[QRAVATAR_ACTION]);
791 SerialCall.println(
"loop_displayModule: delayFinished");
804#define LOOP_COUNTER_MICROSECONDS 20
806 if (_markerTimer > LOOP_COUNTER_MICROSECONDS)
811#define TRY_BLANKSCREEN_IN_LOOP
812#ifdef TRY_BLANKSCREEN_IN_LOOP
816 SerialCall.println(
"loop_displayModule: isBlankScreen");
821 if (_semanticMarkerShown)
823 SerialCall.println(
"loop_displayModule: redrawSemanticMarker(KEEP_SAME)");
834void printText(String text,
int maxLen)
837 if (text.length() < maxLen)
843 M5.Lcd.print(text.substring(0,maxLen));
849void printTextPadSpaces(String text, TextPositionStruct textColor)
853 int maxLen = textColor.maxLen;
854 printText(text, maxLen);
858 M5.Lcd.setTextColor(textColor.textColor, textColor.textColorBackground);
859 for (
int i=text.length(); i< maxLen; i++)
867void drawAction(String title,
int screenType)
870 SerialCall.print(
"drawAction: ");
871 SerialCall.print(title);
872 SerialCall.printf(
" screenType=%d\n",screenType);
876 && (screenType != SCREEN_TYPE_HELP))
879 title.replace(
" ",
"\r\n");
883 int colorIndex = getScreenColor_displayModule();
888 case SCREEN_TYPE_HOME_SIMPLE:
892 case SCREEN_TYPE_HOME_SIMPLE_1:
893 case SCREEN_TYPE_HOME_SIMPLE_2:
898 setupTextPosition(_actionTextHomeSimpleColor[colorIndex]);
899 printText(
" MINI CLICKER", _actionTextHomeSimplePositionZoomed.maxLen);
902 case SCREEN_TYPE_HOME_SIMPLE_3:
905 setupTextPosition(_actionTextHomeSimpleColor[colorIndex]);
906 printText(
"CLICKER MENU ", _actionTextHomeSimplePositionZoomed.maxLen);
910 case SCREEN_TYPE_HOME:
913 setupTextPosition(_actionTextHomeSimpleColor[colorIndex]);
914 printText(
" SMART CLICKER", _actionTextHomeSimplePositionZoomed.maxLen); }
917 case SCREEN_TYPE_PAIRED_DEV:
920 setupTextPosition(_actionTextHomeSimpleColor[colorIndex]);
923 printText(
"PAIR DEVICE ", _actionTextPositionZoomed.maxLen);
929 setupTextPosition(_actionTextHomeSimpleColor[colorIndex]);
930 printText(title, _actionTextPositionZoomed.maxLen);
936 if (screenType == SCREEN_TYPE_PAIRED_DEV)
939 setupTextPosition(_actionTextPosition);
941 printTextPadSpaces(
"PAIRDEV", _actionTextPosition);
946 setupTextPosition(_actionTextPosition);
949 printTextPadSpaces(title, _actionTextPosition);
956void drawSensorStatus(
int screenType)
958 char infoString[150];
959 boolean multilineScreenType =
false;
969 boolean isConnectedBLE =
970#ifdef USE_BLE_CLIENT_NETWORKING
977 String gStatus =
"g";
978 String gStatusHome =
"";
979 if (isConnectedBLE && gatewayOn)
993 case SCREEN_TYPE_HELP:
994 multilineScreenType =
true;
996 sprintf(infoString,
"Scan Image\nFor Help");
999 case SCREEN_TYPE_WIFI:
1000 multilineScreenType =
true;
1003#ifdef USE_MQTT_NETWORKING
1006 sprintf(infoString,
"Swap WIFI");
1008 sprintf(infoString,
"Swap/Retry\nWIFI");
1014 sprintf(infoString,
"Scan to\nShare WIFI");
1017 case SCREEN_TYPE_AP:
1018 multilineScreenType =
true;
1020 sprintf(infoString,
"Enter AP\n192.168.4.1");
1022 sprintf(infoString,
"In AP\n192.168.4.1");
1024 case SCREEN_TYPE_GUEST_PAGE:
1025 multilineScreenType =
true;
1026 sprintf(infoString,
"Share WIFI with Feeder");
1029 case SCREEN_TYPE_TIMER:
1039 case SCREEN_TYPE_TIMER:
1040 case SCREEN_TYPE_DOC_FOLLOW:
1042 case SCREEN_TYPE_HOME_SIMPLE_2:
1043 case SCREEN_TYPE_HOME_SIMPLE_3:
1044 case SCREEN_TYPE_PAIRED_DEV:
1045 case SCREEN_TYPE_REBOOT:
1050 multilineScreenType =
true;
1076 case SCREEN_TYPE_FEED_GUEST:
1077 multilineScreenType =
true;
1078 sprintf(infoString,
"Feed Guest");
1082 case SCREEN_TYPE_HOME:
1083 case SCREEN_TYPE_HOME_SIMPLE:
1084 case SCREEN_TYPE_HOME_SIMPLE_1:
1090 case SCREEN_TYPE_STATUS:
1100 && !(screenType == SCREEN_TYPE_HELP))
1103 setupTextPosition(multilineScreenType?_multilineStatusTextPositionZoomed:_sensorStatusTextPositionZoomed);
1107 setupTextPosition(multilineScreenType?_multilineStatusTextPosition:_sensorStatusTextPosition);
1111 printText(infoString,multilineScreenType?_multilineStatusTextPosition.maxLen:_sensorStatusTextPosition.maxLen);
1115void drawStatusText(String text,
boolean isOn)
1119 M5.Lcd.setTextColor(BLUE, YELLOW);
1121 M5.Lcd.setTextColor(WHITE, BLACK);
1127boolean containsMode(
char *modesDesired,
char mode)
1131 else return index(modesDesired,mode) != NULL;
1135void drawModuleStatus(
char *modesDesired)
1141 setupTextPosition(_moduleStatusTextPositionZoomed);
1146 setupTextPosition(_moduleStatusTextPosition);
1150#ifdef USE_MQTT_NETWORKING
1151 if (containsMode(modesDesired,
'W'))
1153 if (containsMode(modesDesired,
'M'))
1156#ifdef USE_BLE_CLIENT_NETWORKING
1158 if (containsMode(modesDesired,
'B'))
1161 if (containsMode(modesDesired,
'C'))
1164#ifdef USE_WIFI_AP_MODULE
1166 if (containsMode(modesDesired,
'A'))
1169 if (containsMode(modesDesired,
'T'))
1172#ifdef USE_BLE_SERVER_NETWORKING
1173 if (containsMode(modesDesired,
'S'))
1177 drawStatusText(
"S",
true);
1181 if (containsMode(modesDesired,
'Z'))
1185 if (containsMode(modesDesired,
'R'))
1186 drawStatusText(
"R",
true);
1188 if (containsMode(modesDesired,
'X'))
1189 drawStatusText(
"X",
true);
1191 if (containsMode(modesDesired,
'H'))
1192 drawStatusText(
"H",
true);
1195 if (containsMode(modesDesired,
'P'))
1203void displaySimpleStatus()
1206 boolean isConnectedBLE =
1207#ifdef USE_BLE_CLIENT_NETWORKING
1215 boolean isConnectedWIFI =
1216#ifdef USE_MQTT_NETWORKING
1222 String gStatus =
" ";
1223 if (isConnectedBLE && gatewayOn)
1227 else if (isConnectedBLE)
1234 printTextAtTextPosition(label,_connectedStatusTextPositionZoomed);
1238void displayZoomedSemanticMarker(
int screenType)
1240 SerialCall.print(
"displayZoomedSemanticMarker: ");
1241 SerialCall.println(_semanticTitle);
1251 case SCREEN_TYPE_WIFI:
1265 SerialTemp.println(wifi1);
1266 SerialTemp.println(wifi2);
1267 boolean wifi1Current = strcmp(json,wifi1)==0;
1269 SerialTemp.printf(
"wifi1Current == %d\n", wifi1Current);
1273 char *json1 = strstr(wifi1,
":");
1275 if (json1 && strlen(json1) > 3)
1283 char *comma = strchr(json1,
'\'');
1284 json1Len = comma?((int)(comma - json1)):strlen(json1);
1286 SerialTemp.println(json1);
1288 char *json2 = strstr(wifi2,
":");
1290 if (json2 && strlen(json2) > 3)
1298 char *comma = strchr(json2,
'\'');
1299 json2Len = comma?((int)(comma - json2)):strlen(json2);
1301 SerialTemp.println(json2);
1304 strncat(buffer, wifi1Current?json1:json2, wifi1Current?json1Len:json2Len );
1305 strcat(buffer,
"\n\r");
1306 printTextAtTextPosition(buffer,_zoomedTextPositions[SM_ACTION_SMALL]);
1309 strncat(buffer, !wifi1Current?json1:json2, !wifi1Current?json1Len:json2Len );
1311 M5.Lcd.setTextColor(WHITE, BLUE);
1312 M5.Lcd.print(buffer);
1314 SerialCall.println(buffer);
1319 case SCREEN_TYPE_HOME_SIMPLE:
1326 printTextAtTextPositionOverrideTextColor(
"TiltOn",_zoomedTextPositions[BIG_ACTION],_zoomedTextPositions[SM_ACTION] );
1328 printTextAtTextPositionOverrideTextColor(
"TiltOff",_zoomedTextPositions[BIG_ACTION], _zoomedTextPositions[SM_ACTION]);
1332 printTextAtTextPositionOverrideTextColor(
"BuzzOn",_zoomedTextPositions[SM_ACTION],_zoomedTextPositions[BIG_ACTION] );
1334 printTextAtTextPositionOverrideTextColor(
"BuzzOff",_zoomedTextPositions[SM_ACTION], _zoomedTextPositions[BIG_ACTION]);
1336 displaySimpleStatus();
1339 case SCREEN_TYPE_HOME_SIMPLE_1:
1347 printTextAtTextPosition(
"TiltOn",_zoomedTextPositions[BIG_ACTION]);
1349 printTextAtTextPosition(
"TiltOff",_zoomedTextPositions[BIG_ACTION]);
1352 printTextAtTextPosition(
"BuzzOn",_zoomedTextPositions[SM_ACTION]);
1354 printTextAtTextPosition(
"BuzzOff",_zoomedTextPositions[SM_ACTION]);
1356 displaySimpleStatus();
1359 case SCREEN_TYPE_HOME_SIMPLE_2:
1367 printTextAtTextPositionOverrideTextColor(tmpString,_zoomedTextPositions[BIG_ACTION], _zoomedTextPositions[SM_ACTION]);
1370 printTextAtTextPositionOverrideTextColor(tmpString,_zoomedTextPositions[SM_ACTION],_zoomedTextPositions[BIG_ACTION]);
1372 displaySimpleStatus();
1376 case SCREEN_TYPE_AP:
1380 printTextAtTextPositionOverrideTextColor(
"AP",_zoomedTextPositions[BIG_ACTION], _zoomedTextPositions[SM_ACTION]);
1381 printTextAtTextPositionOverrideTextColor(
"Mode...",_zoomedTextPositions[SM_ACTION],_zoomedTextPositions[SM_ACTION]);
1383 displaySimpleStatus();
1386 case SCREEN_TYPE_TIMER:
1387 case SCREEN_TYPE_HOME_SIMPLE_3:
1388 case SCREEN_TYPE_PAIRED_DEV:
1389 case SCREEN_TYPE_REBOOT:
1392 if (screenType == SCREEN_TYPE_REBOOT)
1394 else if (screenType == SCREEN_TYPE_PAIRED_DEV)
1396 else if (screenType == SCREEN_TYPE_HOME_SIMPLE_3)
1398 else if (screenType == SCREEN_TYPE_TIMER)
1401 SerialMin.println(
" *** INVALID screenType ***");
1414 M5.Lcd.fillRect(0, 80, 135, 130, BLACK);
1419 int textLength = 10;
1429 printTextAtTextPosition(buffer, (windowSize <= 4)?_menuTextPositionZoomed_4less:_menuTextPositionZoomed_4plus);
1439 if (currentItem >= windowSize)
1445 startItem = currentItem - windowSize + 1;
1447 maxItems = startItem + windowSize;
1448 for (
int i=startItem; i < maxItems; i++)
1454 M5.Lcd.setTextColor(WHITE, BLUE);
1458 M5.Lcd.setTextColor(ORANGE, BLACK);
1461 sprintf(buffer,
"-%.*s\n\r", textLength, menu);
1462 M5.Lcd.print(buffer);
1467 displaySimpleStatus();
1474 printTextAtTextPosition(
"+FEED",_zoomedTextPositions[BIG_ACTION]);
1476 String title =
"-" + _semanticTitle;
1477 title.replace(
" ",
"\r\n");
1481 case SCREEN_TYPE_HOME:
1482 printTextAtTextPosition(title,_zoomedTextPositions[SM_ACTION]);
1486 case SCREEN_TYPE_PAIRED_DEV:
1488 case SCREEN_TYPE_HELP:
1491 String title =
"-MINI\r\nCLICKER";
1492 printTextAtTextPosition(title,_zoomedTextPositions[SM_ACTION]);
1495 case SCREEN_TYPE_GUEST_PAGE:
1499 String title =
"-SHARE\r\nWIFI";
1500 printTextAtTextPosition(title,_zoomedTextPositions[SM_ACTION]);
1504 printTextAtTextPosition(title,_zoomedTextPositions[SM_ACTION]);
1514 int screenType = screenTypeForTitle_displayModule(_semanticTitle);
1516 SerialLots.printf(
"redrawSemanticMarker_displayModule(startNew:%d, ScreenType = %d)\n", startNew, screenType);;
1523 case SCREEN_TYPE_HOME_SIMPLE:
1529 case SCREEN_TYPE_HOME_SIMPLE_1:
1530 case SCREEN_TYPE_HOME_SIMPLE_2:
1531 case SCREEN_TYPE_HOME_SIMPLE_3:
1541#define TRY_CLEAR_WITH_RESET_TIMER
1543#ifdef TRY_CLEAR_WITH_RESET_TIMER
1551 _lastSemanticMarkerAddress = String(
"");
1556 incrementLoopTimer();
1561 if (screenType == SCREEN_TYPE_REBOOT)
1564 else if (screenType == SCREEN_TYPE_PAIRED_DEV)
1566 else if (screenType == SCREEN_TYPE_HOME_SIMPLE_3)
1568 else if (screenType == SCREEN_TYPE_TIMER)
1572 _semanticMarkerShown =
true;
1575 _currentSemanticMarkerAddress = createSemanticAddress();
1579 && (screenType != SCREEN_TYPE_HELP))
1581 displayZoomedSemanticMarker(screenType);
1583 else if (screenType == SCREEN_TYPE_DOC_FOLLOW)
1588 M5.Lcd.setRotation(0);
1593 setBrightness_displayModule(0);
1594#ifdef USE_MQTT_NETWORKING
1597 M5.Lcd.qrcode(
"https://SemanticMarker.org",0,100,135);
1602 printTextAtTextPosition(
"SM",_zoomedTextPositions[QRAVATAR_ACTION]);
1609 M5.Lcd.setRotation(0);
1610 SerialLots.print(
"last vs current: ");
1611 SerialLots.print(_lastSemanticMarkerAddress);
1612 SerialLots.println(
" vs ");
1613 SerialLots.println(_currentSemanticMarkerAddress);
1615 if (!_lastSemanticMarkerAddress.compareTo(_currentSemanticMarkerAddress)==0)
1617 SerialLots.println(_currentSemanticMarkerAddress);
1619 setBrightness_displayModule(0);
1624 M5.Lcd.qrcode(_currentSemanticMarkerAddress,0,100,135);
1627 String smChar = _semanticTitle.substring(0,1);
1628 printTextAtTextPosition(smChar,_zoomedTextPositions[QRAVATAR_ACTION]);
1634 _lastSemanticMarkerAddress = _currentSemanticMarkerAddress;
1638 drawAction(_semanticTitle, screenType);
1641 drawSensorStatus(screenType);
1646 case SCREEN_TYPE_HOME_SIMPLE_3:
1650 case SCREEN_TYPE_HOME_SIMPLE:
1651 case SCREEN_TYPE_HOME_SIMPLE_1:
1652 case SCREEN_TYPE_HOME_SIMPLE_2:
1653 case SCREEN_TYPE_AP:
1658 setupTextPosition(_homeSimpleStatusTextPositionZoomedRED);
1660 setupTextPosition(_homeSimpleStatusTextPositionZoomed);
1662 M5.Lcd.print(
"+FEED ");
1668 case SCREEN_TYPE_HOME:
1670 drawModuleStatus((
char*)
"WMCTZAS");
1672 case SCREEN_TYPE_TILT:
1674 drawModuleStatus((
char*)
"T");
1676 case SCREEN_TYPE_BUZZ:
1678 drawModuleStatus((
char*)
"Z");
1680 case SCREEN_TYPE_WIFI:
1681 drawModuleStatus((
char*)
"WM");
1686 case SCREEN_TYPE_HELP:
1689 setupTextPosition(_helpStatusTextPosition);
1692 printText((
char*)
"iDogWatch.com/bot/help",_helpStatusTextPosition.maxLen);
1695 case SCREEN_TYPE_RESET:
1696 drawModuleStatus((
char*)
"R");
1698 case SCREEN_TYPE_TIMER:
1700 case SCREEN_TYPE_REBOOT:
1702 case SCREEN_TYPE_PAIRED_DEV:
1705 case SCREEN_TYPE_GUEST_PAGE:
1706 drawModuleStatus((
char*)
"WMC");
1708 case SCREEN_TYPE_FEED_GUEST:
1709 drawModuleStatus((
char*)
"WMC");
1712 case SCREEN_TYPE_STATUS:
1716 drawModuleStatus((
char*)
"WMBCATS");
1725 startDelay(currentScreenTimeout());
1746 SerialTemp.print(
"showSemanticMarker(nulls func) ");
1747 SerialTemp.print(title);
1748 SerialTemp.print(
" SM=");
1749 SerialTemp.println(semanticMarkerAddress);
1753 _semanticTitle = title;
1756 _getStatusFunc = NULL;
1758 _currentSemanticMarkerAddressBase = semanticMarkerAddress;
1760 _lastSemanticMarkerAddress = String(
"");
1777 SerialCall.print(
"showSemanticMarkerFunc: ");
1778 SerialCall.print(title);
1779 SerialCall.print(
" SM=");
1780 SerialCall.println(semanticMarkerAddressBase);
1783 _getStatusFunc = getStatusFunc;
1784 _currentSemanticMarkerAddressBase = semanticMarkerAddressBase;
1785 _semanticTitle = title;
1786 _lastSemanticMarkerAddress = String(
"");
1801 drawAction(text, _currentScreenType);
1809 SerialLots.printf(
"addToTextMessages_displayModule:(%d)",displayOnBlankScreen());
1810 SerialLots.println(text);
1815 SerialLots.println(
"Not displaying since blank screen");
1821 switch (_currentScreenType)
1824 case SCREEN_TYPE_HOME_SIMPLE:
1825 case SCREEN_TYPE_HOME_SIMPLE_1:
1826 case SCREEN_TYPE_HOME_SIMPLE_2:
1827 case SCREEN_TYPE_AP:
1830 case SCREEN_TYPE_HOME_SIMPLE_3:
1834 setupTextPosition(_sensorStatusTextPositionZoomed);
1837 printText(text,_sensorStatusTextPosition.maxLen);
1840 drawAction(text, _currentScreenType);
1922 return (
char*)
"unused";
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
boolean useBLEClient()
returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect
void loop_displayModule()
called for the loop() of this plugin
void showSemanticMarkerFunc_displayModule(String semanticMarkerAddressBase, String title, const char *(*getStatusFunc)(void))
the function to call to get the 'status', return char*
void addToTextMessages_displayModule(String text)
void wakeupScreen_displayModule()
wakes up the screen
int _loopCounter_displayModule
void setup_displayModule()
for types: String, boolean ..
void clearScreen_displayModule()
clears the screen
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..
void setScreenColor_displayModule(int screenColor)
cache for getting the screen color 0..n. Will reset the cache as well
void showSemanticMarker_displayModule(String semanticMarkerAddress, String title)
displays the Semantic Marker (a super QR code) on the M5 screen (title = to display)
void blankScreen_displayModule()
blanks the screen
const char * currentSemanticMarkerAddress_displayModule()
returns the current semantic marker (eg. guest page)
int getLoopTimer_displayModule()
returns the loop timer (just a timer..)
void resetLoopTimer_displayModule()
reset the loop timer .. useful for testing,
void showOTAUpdatingMessage()
show an OTA message..
char * getLastDocFollowSemanticMarker_MQTTNetworking()
boolean isConnectedMQTT_MQTTState()
value of MQTT connected
boolean isConnectedWIFI_MQTTState()
value of WIFI connected
char * deviceName_mainModule()
gets the device name
int getFeedCount_mainModule()
feedcount info..
char * main_JSONStringForWIFICredentials()
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
int feedCountMax_mainModule()
returns the max for this feeder
char * getPairedDeviceOrAddress_mainModule()
returns if the paired device is not NONE .. returns address or device
void refreshDelayButtonTouched_MainModule()
called by the feed operation to say the device is still running.. and count it as a button click.
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
float getTemperature_mainModule()
retrieves the temperature .
boolean isValidPairedDevice_mainModule()
returns if the paired device is not NONE. Note, the paired Name might be an address now (see below)
float getBatPercentage_mainModule()
start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
void updateMenuState(ModelKindEnum modelKind)
updates the model for the menu state, this sets max etc
char * menuForState(ModelKindEnum modelKind, int item)
returns the menu string for the deviceState's item number (use woudl go 0..maxItems -1
ModelStateStruct * getModel(ModelKindEnum modelKind)
retrieves the state model for the modelKind
ModelKindEnum
a pseudo Class
@ pairedButNotConnectedEnum
@ notConnectedEnum
factory default but not connecte to anything..
@ pairableAndConnectedEnum
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int 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 setOnBootPreferences_mainModule()
set some defaults on boot - that override EPROM this can be called on the HOME screen to set back to ...
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...
#define PREFERENCE_SENSOR_TILT_VALUE
Sensor preferences.
#define PREFERENCE_ONLY_GEN3_CONNECT_SETTING
if true, only BLEClient connect to GEN3 feeders..
#define PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_WIFI_CREDENTIAL_2_SETTING
#define PREFERENCE_MAIN_BLE_SERVER_VALUE
#define PREFERENCE_STEPPER_BUZZER_VALUE
stepper preferences
#define PREFERENCE_WIFI_CREDENTIAL_1_SETTING
#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 PREFERENCE_SCREEN_COLOR_SETTING
ithe color of the screen 0..n
#define PREFERENCE_MAIN_GATEWAY_VALUE
boolean doneWIFI_APModule_Credentials()
called to see if the WIFIModule has finished bootstrapping..
the struct for the models. Since this isn't straight OO, we are overlaying information....
int currentItem
the current item
boolean perfersBigText
a preference to the View that big text is desired
PairedDeviceStateEnum pairedDeviceStateEnum
int delaySeconds
length of delay (changable..)
int maxItems
the number of items in the model