-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnachtmensch.ino
80 lines (63 loc) · 1.3 KB
/
nachtmensch.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
72
73
74
75
76
77
78
79
#include <Arduino.h>
extern "C" {
#include <user_interface.h>
}
#include <OSCBundle.h>
#include <OSCData.h>
#include <OSCMatch.h>
#include <OSCMessage.h>
// NodeMCU Digital Pins
#define D0 16
#define D1 5 // I2C Bus SCL (clock) (save)
#define D2 4 // I2C Bus SDA (data) (save)
#define D3 0
#define D4 2 // Same as "LED_BUILTIN", but inverted logic
#define D5 14 // SPI Bus SCK (clock) (save)
#define D6 12 // SPI Bus MISO (save)
#define D7 13 // SPI Bus MOSI (save)
#define D8 15 // SPI Bus SS (CS)
#define D9 3 // RX0 (Serial console)
#define D10 1 // TX0 (Serial console)
// Nachtmensch Pins
#define LED_PIN D2
#define EL_WIRE_PIN D7
#define PIR_PIN D1
#define DEFAULT_LOOP_DELAY 10
const char *version = "1.0";
void setup() {
// setup all controllers
setupInfo();
// network related
setupNetwork();
setupOTA();
setupOSC();
// output & input
setupPIR();
setupWire();
// clean up led state
ledStopBlink();
ledOFF();
}
void loop() {
loopInfo();
loopPIR();
loopNetwork();
loopOTA();
}
void softReset() {
ESP.restart();
}
void wait()
{
wait(DEFAULT_LOOP_DELAY);
}
void wait(unsigned long waitTime)
{
unsigned long previousMillis = millis();
while (millis() - previousMillis <= waitTime)
{
ESP.wdtFeed();
loopInfo();
delay(DEFAULT_LOOP_DELAY);
}
}