-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThrowReversi.ino
71 lines (61 loc) · 1.76 KB
/
ThrowReversi.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
66
67
68
69
70
71
#include "src/Control/CommandReader.h"
#include "src/Control/ControlServer.h"
#include "src/Output/RgbwLedOutput.h"
#include "src/Output/RgbwLedStripOutput.h"
#include "src/Engine.h"
#include "config.wiring.h"
#include "config.visual.h"
#include "config.net.h"
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <WiFiClient.h>
RgbwLedOutput status_led(STATUSLED_PIN, STATUSLED_FLAGS);
CommandReader command_reader;
RgbwLedStripOutput output_tilecolors(BOARD_WIDTH * BOARD_HEIGHT * 2, BOARDLEDS_PIN, BOARDLEDS_FLAGS);
Engine engine(command_reader, output_tilecolors, BOARD_WIDTH, BOARD_HEIGHT);
ControlServer control_server(command_reader, engine.getBoard());
IPAddress local_ip(NET_LOCAL_IP);
IPAddress local_ip_mask(NET_LOCAL_IP_MASK);
DNSServer dnsServer;
const char HTML[] =
#include "HTML.h"
;
void setup()
{
// LED to show "loading" status
status_led.setup();
status_led.setColor(rgbw(COLOR_STATUS_LOAD));
status_led.flush();
delay(1000);
// Set up components
engine.setup();
output_tilecolors.setup();
control_server.setup(HTML);
// Set up WiFi access point
if (!WiFi.mode(WIFI_AP)) fail();
if (!WiFi.softAPConfig(local_ip, local_ip, local_ip_mask)) fail();
if (!WiFi.softAP(NET_AP_NAME)) fail();
// Set up DNS server (captive portal)
dnsServer.setErrorReplyCode(DNSReplyCode::ServerFailure);
if (!dnsServer.start(53, NET_DNS_NAME, local_ip)) fail();
// LED to show "done" status
status_led.setColor(rgbw::black);
status_led.flush();
delay(100);
status_led.setColor(rgbw(COLOR_STATUS_DONE));
status_led.flush();
}
void loop()
{
dnsServer.processNextRequest();
control_server.loop();
command_reader.update();
engine.loop();
output_tilecolors.flush();
}
void fail()
{
status_led.setColor(rgbw(COLOR_STATUS_ERROR));
status_led.flush();
while (true) ;
}