-
Notifications
You must be signed in to change notification settings - Fork 1
/
ISKOClean.ino
executable file
·164 lines (148 loc) · 4.35 KB
/
ISKOClean.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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <Adafruit_WS2801.h>
#include <SPI.h>
#include "ISKOJsonClient.h"
#define USE_SERIAL Serial
#define BOX_NAME "ISKO-MONITOR"
ISKOJsonClient ISKOClient;
uint8_t dataPin = 4; // Red wire (other red is 5V - Be Careful!)
uint8_t clockPin = 5; // Green wire
Adafruit_WS2801 strip = Adafruit_WS2801(32, dataPin, clockPin);
void setup() {
USE_SERIAL.begin(115200);
USE_SERIAL.flush();
strip.begin();
strip.show();
WiFi.hostname(BOX_NAME);
WiFiManager wifiManager;
//wifiManager.resetSettings();
wifiManager.autoConnect(BOX_NAME, "iskomagic");
}
void loop() {
// is configuration portal requested?
USE_SERIAL.println("IP address: ");
USE_SERIAL.println(WiFi.localIP());
ISKOClient.parseISKOJson();
USE_SERIAL.println("Index v Libusi: ");
USE_SERIAL.println(ISKOClient.getIndex());
indexShow(ISKOClient.getIndex());
delay(120000);
}
void indexShow(int index) {
int i;
switch (index) {
case 0:
strip.setPixelColor(0, Color(255, 0, 0));
for (i=1; i < 11; i++) {
strip.setPixelColor(i, Color(0, 0, 255));
}
for (i=11; i < 21; i++) {
strip.setPixelColor(i, Color(255, 255, 255));
}
for (i=21; i < 31; i++) {
strip.setPixelColor(i, Color(0, 255, 0));
}
strip.setPixelColor(31, Color(255, 0, 0));
strip.show();
break;
case 1:
for (i=0; i < 10; i++) {
strip.setPixelColor(i, Color(40, 255, 185));
}
for (i=10; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Color(0, 0, 0));
}
strip.show();
break;
case 2:
for (i=0; i < 16; i++) {
strip.setPixelColor(i, Color(10, 2, 255));
}
for (i=16; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Color(0, 0, 0));
}
strip.show();
break;
case 3:
for (i=0; i < 22; i++) {
strip.setPixelColor(i, Color(255, 0, 245));
}
for (i=22; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Color(0, 0, 0));
}
strip.show();
break;
case 4:
for (i=0; i < 28; i++) {
strip.setPixelColor(i, Color(255, 0, 45));
}
for (i=28; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Color(0, 0, 0));
}
strip.show();
break;
case 5:
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Color(255, 0, 0));
}
strip.show();
break;
case 6:
for (i=0; i < 3; i++) {
strip.setPixelColor(i, Color(255, 0, 245));
}
for (i=3; i < 29; i++) {
strip.setPixelColor(i, Color(255, 0, 0));
}
for (i=29; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Color(255, 0, 245));
}
strip.show();
break;
case -1:
strip.setPixelColor(0, Color(255, 0, 0));
for (i=1; i < 11; i++) {
strip.setPixelColor(i, Color(15, 15, 15));
}
for (i=11; i < 21; i++) {
strip.setPixelColor(i, Color(7, 7, 7));
}
for (i=21; i < 31; i++) {
strip.setPixelColor(i, Color(1, 1, 1));
}
strip.setPixelColor(31, Color(255, 0, 0));
strip.show();
break;
case -2:
strip.setPixelColor(0, Color(255, 0, 0));
for (i=1; i < 31; i=i+2) {
strip.setPixelColor(i, Color(255, 75, 0));
strip.setPixelColor(i, Color(0, 0, 0));
}
strip.setPixelColor(31, Color(255, 0, 0));
strip.show();
break;
default:
strip.setPixelColor(0, Color(255, 0, 0));
for (i=1; i < strip.numPixels()-1; i++) {
strip.setPixelColor(i, Color(random(0, 256), random(0, 256), random(0, 256)));
}
strip.setPixelColor(31, Color(255, 0, 0));
strip.show();
break;
}
}
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}