-
Notifications
You must be signed in to change notification settings - Fork 22
/
Jarvis.ino
67 lines (47 loc) · 1.18 KB
/
Jarvis.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
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include "local-config.h"
#include "src/JarvisDesk.h"
#include "src/Ota.h"
#include "src/TelnetLogger.h"
#include "AdafruitIO_WiFi.h"
const int LED_PIN = LED_BUILTIN;
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
AdafruitIO_Group *jarvis_sub = io.group("jarvis");
JarvisDesk Jarvis;
Ota ota;
// FIXME: Move to flasher.h
void flash(unsigned count = 0, float secs = 0.3);
void setup() {
pinMode(LED_PIN, OUTPUT);
io.connect();
Jarvis.begin();
jarvis_sub->onMessage("preset", handlePreset);
flash(0, 0.5);
while (io.status() < AIO_CONNECTED) {
delay(100);
}
flash(10, 0.1);
ota.begin();
LogServer.begin();
jarvis_sub->get();
}
void loop() {
// Run the AdafruitIO Service
io.run();
// run the Jarvis desk interface
Jarvis.run();
LogServer.run();
// Run the OTA Updater Service
ota.loop();
}
// Handle messages from AdafruitIO
void handlePreset(AdafruitIO_Data *data) {
Log.println(">MSG: ", data->feedName(), "=", data->toString());
auto preset = data->toInt();
flash(preset, 0.25);
// Press the button
Jarvis.goto_preset(preset);
}