First time display

This commit is contained in:
Lukas Bachschwell 2017-11-24 16:13:31 +01:00
parent 30bfe969d7
commit da491f3dca

View File

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