-
Notifications
You must be signed in to change notification settings - Fork 0
/
firework_esp32.ino
65 lines (54 loc) · 1.05 KB
/
firework_esp32.ino
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
#include <WiFi.h>
#include <Wire.h>
#include <WebServer.h>
#include "display.h"
#include "wireless.h"
#include "api.h"
#include "fire.h"
#include "beep.h"
bool armed = false;
Adafruit_SSD1305 display(128, 64, &Wire);
WebServer* _server;
int setArmed(bool arm){
if(arm && !armed){
announceArming();
outputEnable(true);
armed = true;
beep(200, 3, 200);
return 0;
}
else if(!arm && armed){
resetDisplayTimeout();
outputEnable(false);
armed = false;
beep(1000, 1);
return 0;
}
else{
// This shouldn't be possible
return 1;
}
}
int fireChannel(int channel){
if(!armed){
return 1;
}
return fire(channel);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
setupGraphics(&armed, &display);
pinMode(BEEP_PIN, OUTPUT);
beep(200, 1);
setupHardware();
setupWiFi();
_server = setupAPI(&setArmed, &fireChannel);
delay(500);
}
void loop() {
// put your main code here, to run repeatedly:
updateDisplay();
_server->handleClient();
//hardwareUpdate();
}