-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESP32_TTGO_Smart-Traffic-Light.h
91 lines (77 loc) · 2.65 KB
/
ESP32_TTGO_Smart-Traffic-Light.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _ESP32_TTGO_Smart_Traffic_Light_H_
#define _ESP32_TTGO_Smart_Traffic_Light_H_
#define DEBUG 0
#define DEBUG_MQTT 1
#include "debug_print.h"
#include "wifi_mqtt_creds.h"
// "cycle through" modes FIXME: make proper state-machine implementation...
enum opModes: byte
{
TRAFFIC_AUTO = 0 // cycle through trafficLightModes at fixed intervalls
,TRAFFIC_MANUAL // cycle through trafficLightModes at manual button press
,TRAFFIC // manual toggle red/yellow/green on/off via buttons 1-3
,MOOD // toggle simileys via buttons 1-2
,STARTAMPEL // f1-like start signel, button1: start, button2: stop -> show time
,DISCO
,CLOCK
,APP_CONFIG
,_NUM_MODES_
};
// special modes
const byte MODE_SELECT = 0x10;
//const byte APP_CONFIG = 0x20;
// german menu ;)
const char* mode2str(opModes mode)
{
if (mode == TRAFFIC) return "AMPEL Farben";
if (mode == TRAFFIC_AUTO) return "AMPEL (Auto)";
if (mode == TRAFFIC_MANUAL) return "AMPEL (Manual)";
if (mode == MOOD) return "LAUNE";
if (mode == STARTAMPEL) return "START AMPEL";
if (mode == DISCO) return "DISCO";
if (mode == CLOCK) return "UHR (binary)";
if (mode == APP_CONFIG) return "CONFIG Menu";
return "INVALID";
}
const byte TRAFFIC_OFF = 255;
enum trafficLightModes: byte
{
// OFF
STOP // red
,GET_READY // red/yellow
,GO // green
,ATTN // yellow
,_NUM_TRAFFIC_LIGHT_MODES_
};
enum moodType: byte
{
HAPPY
,NEUTRAL
,SAD
,NO_MOOD
};
#define MATRIX_POS_TOP 1
#define MATRIX_POS_MIDDLE 2
#define MATRIX_POS_BOTTOM 4
#define MATRIX_POS_ALL (MATRIX_POS_TOP|MATRIX_POS_MIDDLE|MATRIX_POS_BOTTOM)
// tft-display-control prototypes
void drawTrafficLight(int mode, bool clear=true);
void drawModeSelectMenu();
void drawConfigMenu(bool update=false);
// led-matrix-control prototypes
void fillTopMatrix(const struct CRGB& color, bool ledShow=true);
void fillMiddleMatrix(const struct CRGB& color, bool ledShow=true);
void fillBottomMatrix(const struct CRGB& color, bool ledShow=true);
void fillTopRed(bool on=true);
void fillMiddleYellow(bool on=true);
void fillBottomGreen(bool on=true);
void drawBinClockSec(int sec, const struct CRGB& bgColor=CRGB::Blue,
const struct CRGB& fgColor=CRGB::Yellow);
void drawBinClockHourMin(const DateTime &dtNow,
const struct CRGB& bgColor=CRGB::Blue,
const struct CRGB& fgColor=CRGB::Yellow);
void drawBinClockDate(int day, int month,
const struct CRGB& bgColor=CRGB::Blue,
const struct CRGB& fgColor=CRGB::Yellow);
int mqttConnect(bool updateDisplay=true);
#endif