IoT - Modular - Debugging.cpp

From The TinkerNet Wiki
Revision as of 22:35, 29 April 2021 by Tinker (talk | contribs) (Created page with "==#includes, Defines, etc...== <syntaxhighlight lang="cpp" line="1"> #include "libraries.h" #include "functions.h" #include "debug.h" </syntaxhighlight> ==debug_TitleScreen(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

#includes, Defines, etc...

1 #include "libraries.h"
2 #include "functions.h"
3 #include "debug.h"

debug_TitleScreen()

 1 void debug_TitleScreen()
 2 {
 3     Serial.printf("\n\n#================================================#\n");
 4     Serial.printf("# %-46s #\n", DeviceName);
 5     Serial.printf("# %-46s #\n", DeviceDesc);
 6     Serial.printf("+------------------------------------------------+\n");
 7     Serial.printf("# WiFi Enabled...                                #\n");
 8     Serial.printf("# Speaks fluent MQTT...                          #\n");
 9     Serial.printf("#================================================#\n");
10 }

debug_ReadyScreen()

1 void debug_ReadyScreen()
2 {
3     Serial.printf("#================================================#\n");
4     Serial.printf("#                 Ready To Run.                  #\n");
5     Serial.printf("#================================================#\n");
6 }

debug_Separator()

1 void debug_Separator()
2 {
3     Serial.printf("+------------------------------------------------+\n");
4 }

debug_SectionTitle()

1 void debug_SectionTitle(const char *Title)
2 {
3     Serial.printf("| %-46s |\n", Title);
4 }

debug_LineOut()

1 void debug_LineOut(const char *Line)
2 {
3     Serial.printf("|    %-43s |\n", Line);
4 }

debug_Action()

 1 void debug_Action(const char *Line)
 2 {
 3     {
 4         const char *SPACE = "                              ";
 5         char BUFFER[100];
 6         char BUFFER2[100];
 7 
 8         int BuffSize = (23 - (strlen(Line) / 2));
 9 
10         strcpy(BUFFER, SPACE);
11         BUFFER[BuffSize] = '\0';
12 
13         sprintf(BUFFER2, "%s%s", BUFFER, Line);
14         Serial.printf("| %-46s |\n", BUFFER2);
15     }
16 }

debug_Trouble()

1 void debug_Trouble(const char *Line)
2 {
3     Serial.printf("* %-46s *\n", Line);
4 }

debug_Success()

1 void debug_Success(const char *Line)
2 {
3     Serial.printf("+ %-46s +\n", Line);
4 }

debug_ProgressBar0()

1 void debug_ProgressBar0()
2 {
3     Serial.printf("| ");
4 }

debug_ProgressBar1()

1 void debug_ProgressBar1()
2 {
3     Serial.printf(".");
4 }

debug_ProgressBar2()

1 void debug_ProgressBar2(int dotcount)
2 {
3     for (int i = 0; i < (47 - dotcount); i++)
4     {
5         Serial.printf(" ");
6     }
7     Serial.printf("|\n");
8 }

debug_ESP_info()

 1 void debug_ESP_info()
 2 {
 3     char Line[46];
 4     // Check and report on the flash memory on this board
 5     debug_SectionTitle("Board flash memory Info");
 6     uint32_t realSize = ESP.getFlashChipRealSize();
 7     uint32_t ideSize = ESP.getFlashChipSize();
 8     FlashMode_t ideMode = ESP.getFlashChipMode();
 9     sprintf(Line, "Flash real id:   %08X", ESP.getFlashChipId());
10     debug_LineOut(Line);
11     sprintf(Line, "Flash real size: %u", realSize);
12     debug_LineOut(Line);
13     sprintf(Line, "Flash ide  size: %u", ideSize);
14     debug_LineOut(Line);
15     sprintf(Line, "Flash ide speed: %u", ESP.getFlashChipSpeed());
16     debug_LineOut(Line);
17     sprintf(Line, "Flash ide mode:  %s", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT"
18                                                                   : ideMode == FM_DIO    ? "DIO"
19                                                                   : ideMode == FM_DOUT   ? "DOUT"
20                                                                                          : "UNKNOWN"));
21     debug_LineOut(Line);
22     if (ideSize != realSize)
23     {
24         sprintf(Line, "Flash Chip configuration wrong!");
25     }
26     else
27     {
28         sprintf(Line, "Flash Chip configuration ok.");
29     }
30     debug_LineOut(Line);
31 }