/*
Idea by Schuppeste@googlemail.com
Sources: https://github.com/schuppeste/Sofaleds
Space: http://www.hackaday.io/Schuppeste
*/
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include "FS.h"
#include "Time.h"
#include "TimeLib.h"
#include <SoftwareSerial.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 rtc;
int SS_TXPin = D5;
int BWM_Pin = D7;
SoftwareSerial Serial1t(SW_SERIAL_UNUSED_PIN, SS_TXPin);
ESP8266WebServer server(80);
int citycount = 0;
int myintervall = 60;
int mymethod = 0;
const char signMessage[] PROGMEM = { };
long mainconfig[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
String citys[20] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", ""
};
long gmt[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int dst[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
String ssid = "";
String key = "";
String ip = "";
int waiting = 1000;
String NTPurl = "";
String setRow1 = "";
String setRow2 = "";
String olddate = "";
int col = 0;
int steps = 0;
int cursor1 = -1;
int cursor2 = -2;
int cursor3 = -3;
boolean updated = false;
boolean startanim = false;
unsigned long lastupdate = millis();
byte helper1[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13
};
byte helper2[] = { 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D,
0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27
};
IPAddress local_IP(192, 168, 4, 22);
IPAddress gateway(192, 168, 4, 9);
IPAddress subnet(255, 255, 255, 0);
boolean startAP = false;
int tzoffset = 0;
void setup() {
pinMode(D7, INPUT);
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1)
;
}
int apstatus = HIGH;
Serial.begin(9600);
if (!SPIFFS.begin()) {
Serial.println("Failed to mount file system");
} else if (loadConfig()) {
}
WiFi.hostname("weltuhr");
Serial.println(ssid + key);
if (ssid == "" || key == "" || apstatus == LOW) {
WiFi.softAP("weltuhr", "weltuhr"); //Create Access Point
WiFi.softAPConfig(local_IP, gateway, subnet);
} else {
WiFi.begin((const char*) ssid.c_str(), (const char*) key.c_str());
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
}
server.on("/", handleRoot);
server.on("/index.html", handleRoot);
server.serveStatic("/config.json", SPIFFS, "/config.json");
server.serveStatic("/stylesheet.css", SPIFFS, "/stylesheet.css");
server.begin(); //Start the server
startAP = true;
waiting = mainconfig[0];
myintervall = mainconfig[1];
Serial1t.begin(9600);
Serial1t.write(0x1B);
Serial1t.write(0x05);
Serial1t.write(0x1B);
Serial1t.write(0x0A);
Serial1t.write(0x1B);
Serial1t.write(0x17);
Serial1t.write(mainconfig[6] + 1);
//WiFi.mode(WIFI_OFF);
if (myintervall == 0)
myintervall = 60 * 1000;
setSyncProvider (rtcsync);
setSyncInterval(500);
}
boolean first = true;
boolean waitprogress = false;
unsigned long lastwaitprogress = 0;
boolean updatewaitprogress = false;
unsigned long lastupdatewaitprogress = 0;
boolean cyclewaitprogress = false;
unsigned long lastcyclewaitprogress = 0;
boolean screensaver = false;
unsigned long lastscreensaver = 0;
int cycles = 0;
int cityscount = 0;
unsigned long speedupdate = 200;
boolean bwm_active = false;
void loop() {
unsigned long current Millis = millis();
int tempbwm = digitalRead(D7);
if ((tempbwm == HIGH && screensaver ) || (tempbwm == HIGH && cyclewaitprogress)) {
lastscreensaver = currentMillis;
screensaver = false;
cyclewaitprogress = false;
Serial1t.write(0x1B);
Serial1t.write(0x05);
Serial.println("BWM");
}
//Between Cities
if (currentMillis - lastwaitprogress >= (myintervall * 1000) || first) {
lastwaitprogress = currentMillis;
waitprogress = false;
}
//update
if (currentMillis - lastupdatewaitprogress >= speedupdate) {
lastupdatewaitprogress = currentMillis;
updatewaitprogress = false;
}
//Between Cycle Wait
if (currentMillis - lastcyclewaitprogress >= mainconfig[...
Read more »
There's a typo in the page title: "Webinterface Worldclcok" - I believe it should say *clock instead of clcok :D