Some debugging functions
Jump to navigation
Jump to search
I2C_functions.cpp
NOTE: The ESP version of the Arduino core has printf()
, The Atmel version does not. If you want to use these functions on an Atmel MCU, you'll have to re-write pretty much EVERY Serial.printf()
...
1 #include "libraries.h"
2 #include "functions.h"
3 #include "debug.h"
4
5 void debug_TitleScreen()
6 {
7 Serial.printf("\n\n#================================================#\n");
8 Serial.printf("# %-46s #\n", DeviceName);
9 Serial.printf("# %-46s #\n", DeviceDesc);
10 Serial.printf("+------------------------------------------------+\n");
11 Serial.printf("# WiFi Enabled... #\n");
12 Serial.printf("# Speaks fluent MQTT... #\n");
13 Serial.printf("#================================================#\n");
14 }
15
16 void debug_ReadyScreen()
17 {
18 Serial.printf("#================================================#\n");
19 Serial.printf("# Ready To Run. #\n");
20 Serial.printf("#================================================#\n");
21 }
22
23 void debug_Separator()
24 {
25 Serial.printf("+------------------------------------------------+\n");
26 }
27
28 void debug_SectionTitle(const char *Title)
29 {
30 Serial.printf("| %-46s |\n", Title);
31 }
32
33 void debug_LineOut(const char *Line)
34 {
35 Serial.printf("| %-43s |\n", Line);
36 }
37
38 void debug_Action(const char *Line)
39 {
40 {
41 const char *SPACE = " ";
42 char BUFFER[100];
43 char BUFFER2[100];
44
45 int BuffSize = (23 - (strlen(Line) / 2));
46
47 strcpy(BUFFER, SPACE);
48 BUFFER[BuffSize] = '\0';
49
50 sprintf(BUFFER2, "%s%s", BUFFER, Line);
51 Serial.printf("| %-46s |\n", BUFFER2);
52 }
53 }
54
55 void debug_Trouble(const char *Line)
56 {
57 Serial.printf("* %-46s *\n", Line);
58 }
59
60 void debug_Success(const char *Line)
61 {
62 Serial.printf("+ %-46s +\n", Line);
63 }
64
65 void debug_ProgressBar0()
66 {
67 Serial.printf("| ");
68 }
69
70 void debug_ProgressBar1()
71 {
72 Serial.printf(".");
73 }
74
75 void debug_ProgressBar2(int dotcount)
76 {
77 for (int i = 0; i < (47 - dotcount); i++)
78 {
79 Serial.printf(" ");
80 }
81 Serial.printf("|\n");
82 }
83
84 void debug_ESP_info()
85 {
86 char Line[46];
87 // Check and report on the flash memory on this board
88 debug_SectionTitle("Board flash memory Info");
89 uint32_t realSize = ESP.getFlashChipRealSize();
90 uint32_t ideSize = ESP.getFlashChipSize();
91 FlashMode_t ideMode = ESP.getFlashChipMode();
92 sprintf(Line, "Flash real id: %08X", ESP.getFlashChipId());
93 debug_LineOut(Line);
94 sprintf(Line, "Flash real size: %u", realSize);
95 debug_LineOut(Line);
96 sprintf(Line, "Flash ide size: %u", ideSize);
97 debug_LineOut(Line);
98 sprintf(Line, "Flash ide speed: %u", ESP.getFlashChipSpeed());
99 debug_LineOut(Line);
100 sprintf(Line, "Flash ide mode: %s", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT"
101 : ideMode == FM_DIO ? "DIO"
102 : ideMode == FM_DOUT ? "DOUT"
103 : "UNKNOWN"));
104 debug_LineOut(Line);
105 if (ideSize != realSize)
106 {
107 sprintf(Line, "Flash Chip configuration wrong!");
108 }
109 else
110 {
111 sprintf(Line, "Flash Chip configuration ok.");
112 }
113 debug_LineOut(Line);
114 }