ESP_IOT v2.5
IOT ESP Coding
UI.cpp
Go to the documentation of this file.
1//! \link UIModule
2
3//
4//
5//
6//
7
8#include "UI.h"
9
10#ifdef ESP_M5
11#else
12
13#ifdef BOARD
14//!initialize the board layoud, which is different than default
15
17{
18 SerialDebug.println("XXXXXXXXXXXXXXXX BOARD Defined XXXXXXXXXXXXXXXXXXX");
19 boolean buzzStatus = getBuzzStatus_StepperModule();
20
21 pinMode(BLUE_LED, OUTPUT);
22 pinMode(GREEN_LED, OUTPUT);
23 pinMode(YELLOW_LED, OUTPUT);
24 pinMode(BUZZ, OUTPUT);
25
26 digitalWrite(BLUE_LED, LOW);
27 digitalWrite(GREEN_LED, HIGH); //turn the power light on
28
29 if (buzzStatus)
30 {
31 digitalWrite(YELLOW_LED, HIGH);
32 }
33 else
34 {
35 digitalWrite(YELLOW_LED, LOW);
36 }
37
38 pinMode(TOUCH_1, INPUT);
39 pinMode(TOUCH_2, INPUT);
40 pinMode(TOUCH_3, INPUT);
41
42 pinMode(POWER_PIN, OUTPUT);
43 digitalWrite(POWER_PIN, LOW); //nessesary to enable 6.3V circuit
44 SerialDebug.println("POWER_PIN set LOW");
45}
46//! the main loop()
48{
49 //nothing yet
50}
51#else
52
53#ifdef PROTO
54//!initialize the board layoud, same as BOARD
55
56void setup_UIModule()
57{
58 SerialDebug.println("----------------- PROTO Defined -----------------");
59 boolean buzzStatus = getBuzzStatus_StepperModule();
60
61 pinMode(BLUE_LED, OUTPUT);
62 pinMode(GREEN_LED, OUTPUT);
63 pinMode(YELLOW_LED, OUTPUT);
64 pinMode(BUZZ, OUTPUT);
65
66 digitalWrite(BLUE_LED, HIGH);
67 digitalWrite(GREEN_LED, LOW); //turn the power light on
68
69 if (buzzStatus)
70 {
71 digitalWrite(YELLOW_LED, LOW);
72 }
73 else
74 {
75 digitalWrite(YELLOW_LED, HIGH);
76 }
77
78 pinMode(TOUCH_1, INPUT);
79 pinMode(TOUCH_2, INPUT);
80 pinMode(TOUCH_3, INPUT);
81
82 pinMode(POWER_PIN, OUTPUT);
83 digitalWrite(POWER_PIN, LOW); //nessesary to enable 6.3V circuit
84 SerialDebug.println("POWER_PIN set LOW");
85}
86//! the main loop()
87void loop_UIModule()
88{
89 //nothing yet
90}
91
92#else
93void setup_UIModule()
94{
95 SerialDebug.println("OOOOOOOOOOOOOOOO No BOARD Defined OOOOOOOOOOOOOOOOOOO");
96 pinMode(BUZZ, OUTPUT);
97
98 digitalWrite(BUZZ, LOW);
99}
100
101//! the main loop()
102void loop_UIModule()
103{
104 //nothing yet
105}
106#endif //PROTO
107#endif //BOARD
108
109//!UI specific actions
110void setBuzzerLight_UIModule(boolean onFlag)
111{
112 SerialDebug.printf("setBuzzerLight %s\n",onFlag?"ON":"OFF");
113
114#ifdef BOARD
115 //set the buzzer light on
116 digitalWrite(YELLOW_LED, onFlag?HIGH:LOW);
117#endif
118
119#ifdef PROTO
120 //set the buzzer light on
121 digitalWrite(YELLOW_LED, onFlag?LOW:HIGH);
122#endif
123
124}
125
126//!callback for SOLID blinking led
127//void solidLight(char *message)
128void solidLightOnOff_UIModule(boolean onOff)
129{
130#ifdef ESP_32
131 SerialDebug.println("solidLight..");
132 digitalWrite(LED, onOff ? HIGH : LOW);
133#endif
134}
135
136//!blink the LED
138#ifdef ESP_32
139 // grab the buzzStatus right now
140 boolean buzzStatus = getBuzzStatus_StepperModule();
142 int stepperSteps = (int) (stepperAngle / 0.176);
143
144 SerialDebug.printf("BlinkLed LED=%d, HIGH=%d, LOW=%d, BUZZ=%d, buzzStatus=%d, StepperAngle=%d, Steps=%d\n", LED, HIGH, LOW, BUZZ, buzzStatus, stepperAngle, stepperSteps);
145#ifdef BOARD
146 digitalWrite(BLUE_LED, HIGH); // Flash the LED
147#else
148#ifdef PROTO
149 digitalWrite(BLUE_LED, LOW);
150#else
151 digitalWrite(LED, HIGH); // Flash the LED
152#endif //PROTO
153#endif //BOARD
154
155 if (buzzStatus)
156 {
157 digitalWrite(BUZZ, HIGH); // Buzz the Piezo
158 }
159 delay(150); // Was 300
160#ifdef BOARD
161 digitalWrite(BLUE_LED, LOW); // Flash the LED
162#else
163#ifdef PROTO
164 digitalWrite(BLUE_LED, HIGH);
165#else
166
167 digitalWrite(LED, LOW);
168#endif //PROTO
169#endif //BOARD
170
171
172 if (buzzStatus)
173 {
174 digitalWrite(BUZZ, LOW);
175 }
176 delay(30); // Kill time to detect double beep
177#endif //ESP_32
178}
179
180#endif //ESP_M5
float getPreferenceFloat_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
boolean getBuzzStatus_StepperModule()
returns the buzzer status
#define LED
Definition: StepperModule.h:54
void setup_UIModule()
UIModule
Definition: UI.cpp:16
void loop_UIModule()
the main loop()
Definition: UI.cpp:47
void setBuzzerLight_UIModule(boolean onFlag)
UI specific actions.
Definition: UI.cpp:110
void blinkLED_UIModule()
blink the LED
Definition: UI.cpp:137
void solidLightOnOff_UIModule(boolean onOff)
callback for SOLID blinking led
Definition: UI.cpp:128
#define GREEN_LED
Definition: UI.h:12
#define TOUCH_3
Definition: UI.h:18
#define TOUCH_1
Definition: UI.h:16
#define BLUE_LED
Definition: UI.h:11
#define BUZZ
Definition: UI.h:21
#define TOUCH_2
Definition: UI.h:17
#define YELLOW_LED
Definition: UI.h:13
#define POWER_PIN
Definition: UI.h:22