Adding color markup

This commit is contained in:
Lukas Bachschwell 2017-12-14 17:12:33 +01:00
parent e3b7976781
commit cbdf93e7ee

View File

@ -13,6 +13,7 @@
#define HOST "bici.lbsfilm.at"
#define REFRESH 1000
#define CHANGE_MODE 10000
#define OFFSET 1
@ -38,7 +39,9 @@ byte digits[12][7] = {
{ 0, 0, 1, 1, 1, 1, 0 } // Digit C
};
long oldTime = 0;
long oldTime = 0; // for refresh
long oldModeTime = 0; // for mode
String bicislots = "";
String bicis = "";
@ -48,14 +51,20 @@ String minutes = "";
char stationId[6] = "93";
bool displayOn = false;
#define TIME 0
#define BICIS 1
unsigned int displayMode = TIME;
//flag for saving data
bool shouldSaveConfig = false;
//callback notifying us of the need to save config
/*
void saveConfigCallback () {
Serial.println("Should save config");
shouldSaveConfig = true;
}
*/
void setup() {
Serial.begin(115200);
@ -66,7 +75,7 @@ void setup() {
WiFiManagerParameter custom_station_id("server", "station id", stationId, 6);
WiFiManager wifiManager;
wifiManager.setSaveConfigCallback(saveConfigCallback);
//wifiManager.setSaveConfigCallback(saveConfigCallback);
wifiManager.autoConnect("ConfigureClock");
wifiManager.addParameter(&custom_station_id);
Serial.println(custom_station_id.getValue());
@ -90,12 +99,33 @@ void loop() // Main loop
{
// Check motion sensor
// get data and time
displayOn = digitalRead(D6);
displayOn = digitalRead(D7);
//displayOn = true;
if (millis() - oldModeTime > CHANGE_MODE) {
if (displayMode == TIME) displayMode = BICIS;
else displayMode = TIME;
oldModeTime = millis();
}
if (millis() - oldTime > REFRESH) {
uint32_t c = clock.Color(10, 10, 10);
getData();
switch (displayMode) {
case TIME: {
uint32_t c = clock.Color(100, 100, 130);
if (displayOn) displayNumber(hours + ":" + minutes, c);
else colorWipe( clock.Color(0, 0, 0), 1);
break;
}
case BICIS: {
uint32_t cSlots = clock.Color(100, 0, 0);
uint32_t cBicis = clock.Color(0, 100, 0);
if (displayOn) display2Numbers(bicislots, bicis, cSlots, cBicis );
else colorWipe( clock.Color(0, 0, 0), 1);
break;
}
}
Serial.println(hours + ":" + minutes);
}
}
@ -103,7 +133,8 @@ void loop() // Main loop
void getData() {
HTTPClient https;
String URL = "https://" + String(HOST) + "/stations?stationId=" + String(STATION_UID);
https.begin( URL, "1D:62:C5:06:5E:45:51:26:2F:56:A5:BD:E9:5E:F1:33:C8:6C:66:05"); //HTTPS
Serial.println(URL);
https.begin( URL, "20:0F:86:A4:96:D4:40:EF:28:03:C4:36:B7:B5:F2:C3:55:42:E7:51"); //HTTPS
int httpCode = https.GET();
if (httpCode > 0) {
@ -256,6 +287,19 @@ void displayNumber(String string, uint32_t color) {
}
void display2Numbers(String string, String string2, uint32_t color, uint32_t color2 ) {
for (int i = 0; i < 2; i++) {
fillNumber(i, string[i] - 48, color);
}
for (int i = 0; i < 2; i++) {
fillNumber(i + 2, string2[i] - 48, color2);
}
nocolon();
}
void noclock() {
for (int led = 0; led < clock.numPixels(); led++) {
clock.setPixelColor(led, 0);