diff --git a/biciClock.ino b/biciClock.ino index 36a6b59..7259c3c 100644 --- a/biciClock.ino +++ b/biciClock.ino @@ -6,11 +6,15 @@ #include #include #include +#include #define STATION_UID "93" // location id #define HOST "testing.lbsfilm.at" +#define REFRESH 1000 + +#define OFFSET 1 #define SEGLEN 5 // SegmentLength #define SEPLEN 2 // SeperatorLength @@ -46,9 +50,12 @@ String minutes = ""; void setup() { Serial.begin(115200); - + //WiFiManagerParameter custom_station_id)("server", "station id", mqtt_server, 40); + EEPROM.begin(512); WiFiManager wifiManager; wifiManager.autoConnect("ConfigureClock"); + //wifiManager.addParameter(&custom_station_id); + //Serial.println(custom_station_id).getValue()); clock.begin(); clock.show(); // Initialize all pixels to 'off' @@ -56,7 +63,6 @@ void setup() { delay(1000); colorWipe( clock.Color(0, 100, 150), 10); colorWipe( clock.Color(0, 0, 0), 5); - getData(); displayNumber("99:99", clock.Color(150, 150, 150)); } @@ -72,6 +78,12 @@ void displayNumber(String string, uint32_t color) { } +void noclock() { + for (int led = 0; led < clock.numPixels(); led++) { + clock.setPixelColor(led, 0); + } + clock.show(); +} void colon(uint32_t color) { @@ -114,37 +126,45 @@ void loop() // Main loop // Check motion sensor // get data and time - uint32_t c = clock.Color(0, 100, 150); - fillNumber(3, 0, c); - clock.show(); - delay(1000); - fillNumber(0, 1, c); - clock.show(); - delay(1000); - fillNumber(1, 2, c); - clock.show(); - delay(1000); - fillNumber(2, 3, c); - clock.show(); - delay(1000); - fillNumber(3, 4, c); - clock.show(); - delay(1000); - fillNumber(0, 5, c); - clock.show(); - delay(1000); - fillNumber(1, 6, c); - clock.show(); - delay(1000); - fillNumber(2, 7, c); - clock.show(); - delay(1000); - fillNumber(3, 8, c); - clock.show(); - delay(1000); - fillNumber(0, 9, c); - clock.show(); - delay(1000); + if (millis() - oldTime > REFRESH) { + uint32_t c = clock.Color(10, 10, 10); + getData(); + displayNumber(hours + ":" + minutes, c); + Serial.println(hours + ":" + minutes); + } + + /* + fillNumber(3, 0, c); + clock.show(); + delay(1000); + fillNumber(0, 1, c); + clock.show(); + delay(1000); + fillNumber(1, 2, c); + clock.show(); + delay(1000); + fillNumber(2, 3, c); + clock.show(); + delay(1000); + fillNumber(3, 4, c); + clock.show(); + delay(1000); + fillNumber(0, 5, c); + clock.show(); + delay(1000); + fillNumber(1, 6, c); + clock.show(); + delay(1000); + fillNumber(2, 7, c); + clock.show(); + delay(1000); + fillNumber(3, 8, c); + clock.show(); + delay(1000); + fillNumber(0, 9, c); + clock.show(); + delay(1000); + */ } void getData() { @@ -180,14 +200,23 @@ void getData() { const char* bicisChar = root["free_bikes"]; bicis = String(bicisChar); + const char* hoursChar = root["time"]["hours"]; + hours = String(hoursChar); + const char* minutesChar = root["time"]["minutes"]; + minutes = String(minutesChar); + + int offsetting = hours.toInt(); + offsetting = offsetting + OFFSET; + if (offsetting == 24) offsetting = 0; + if(offsetting<10) hours = "0" + String(offsetting, DEC); + else hours = String(offsetting, DEC); + } } else { Serial.printf("[HTTP] GET... failed, error: %s\n", https.errorToString(httpCode).c_str()); } https.end(); - - oldTime = millis(); }