-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupport.h
More file actions
120 lines (96 loc) · 2.01 KB
/
Support.h
File metadata and controls
120 lines (96 loc) · 2.01 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
unsigned long int sec;
struct timeUnit {
int hour;
int min;
int sec;
int weekDay;
};
struct timeUnit timeReal;
struct timeUnit timeFetch;
unsigned long int timeLastFetch;
struct alarm {
int hour;
int min;
bool oneTime;
bool weekDay[7];
bool alreadyRinged;
};
String weekDayShort[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
struct alarm alarms[5];
byte existingAlarms = 0;
bool alarmsForToday = 1;
// Wifi things
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
String ssid = "Clock";
String password = "12345678";
bool wifiMode;
// NTP things
#include <NTPClient.h>
#include <WiFiUdp.h>
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
// NeoPixel things
#include <Adafruit_NeoPixel.h>
#define LED_PIN 12
#define LED_COUNT 60
byte brightness_sp = 50, brightness_pv = 0, brightness_default = 50, brightness_flashHigh = 150, brightness_flashLow = 20;
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800);
#define PIXEL_ROTATION_OFFSET 1
// IO things
#define BTN_PIN 0
#define PHR_PIN A0
#define PHR_LOWLIGHT_THRESHOLD 40
enum clockMode {
DARK,
NORMAL,
INITIALIZING,
TIMER,
RINGING,
NO_WIFI
};
enum stripMode {
MAN_OFF,
MAN_ON,
AUTO_OFF,
AUTO_ON,
FADING
};
enum ringType {
TIMER_RING,
ALARM_RING
};
byte clockMode, stripMode = AUTO_ON;
byte fadeStepDuration = 5;
bool inFade;
int lastTimeBTNPressed, lastFadeStep;
bool onTimer, timerRing;
long int timerCentSecLength, timerCentSecEnd, timerCentSecLeft;
int timerPixelCount;
float timerPixelCountFloat;
bool clockRinging;
bool ringCause;
byte alarmNumberRinging;
#include <EEPROM.h>
enum EEPROM_ADRESSES {
ADDR_WIFI_MODE = 0,
ADDR_WIFI_SSID = 1,
ADDR_WIFI_PSW = 30,
ADDR_ALARM_NUM = 50,
ADDR_ALARM_START = 51
};
enum ALARM_OFFEST {
OFFSET_HOUR,
OFFSET_MIN,
OFFSET_WEEKCODE,
OFFEST_ALREAYRINGED,
OFFSET_TOTAL = 10
};
enum wifiMode {
CREATE_NETWORK,
CONNETC_TO_NETWORK
};
#define TIME_CORRECTION_CONSTANT 200
bool APConfigured;