LED-Clock/60LED_WS2812B_NTP_Clock.ino
2021-01-16 17:46:34 +01:00

444 lines
18 KiB
C++

#include <WiFi.h>
#include "time.h"
#include <TaskScheduler.h>
#include <NeoPixelBrightnessBus.h>
#include <IotWebConf.h>
#include <IotWebConfUsing.h>
// UpdateServer includes
#ifdef ESP8266
# include <ESP8266HTTPUpdateServer.h>
#elif defined(ESP32)
// For ESP32 IotWebConf provides a drop-in replacement for UpdateServer.
# include <IotWebConfESP32HTTPUpdateServer.h>
#endif
#define MOD(a,b) ((((a)%(b))+(b))%(b))
/* Model I
LDR (GL5516 ) is connected to GPIO 34 (Analog ADC1_CH6, 12bit resolution default
Light Resistance (at 10 Lux): 5-10 Kohm
Dark Resistance: 0.5 Mohm
over a 56k voltage divider . Dark (0.5MOhm) , 10Lux (5-10kOhm)
*/
#define LDR_PIN A6
#define NUM_LEDS 60
#define COLOR_ORDER GRB
#define DATA_PIN 17
#define SERIAL_BAUD 115200
//#define RGBW
volatile bool singleSecond = true; //show seconds
volatile bool allDotsOn = true; //lighten up all leds
volatile bool followingHour = true; //move hour like an analog one
volatile int hourOffset = 0;
void bootAnimCallback();
void clockTickCallback();
void ledRefreshCallback();
void brightnessAdjustmentCallback();
#ifdef RGBW
#define MINIMAL_BRIGHTNESS 5
#define LDR_SCALE 16
#define colorSaturation 255
//NeoPixelBrightnessBus<NeoGrbwFeature, Neo800KbpsMethod> strip(NUM_LEDS, DATA_PIN); //SK6812
NeoPixelBrightnessBus<NeoGrbwFeature, NeoEsp32I2s1800KbpsMethod> strip(NUM_LEDS, DATA_PIN);
RgbwColor red(colorSaturation, 0, 0, 0);
RgbwColor green(0, colorSaturation, 0, 0);
RgbwColor blue(0, 0, colorSaturation, 0);
RgbwColor realWhite(colorSaturation);
RgbwColor white(0, 0, 0, 40); //darkish dirt
RgbwColor whiter(0, 0, 0, 120); //darkish dirt
RgbwColor white12(0, 0, 0, 192); //darkish dirt
RgbwColor black(0);
RgbwColor gold(HtmlColor( 0xFFD700 ) );
RgbwColor orangered(HtmlColor( 0xFF4500 ) );
RgbwColor orange(HtmlColor( 0xFFA500 ) );
RgbwColor darkred(HtmlColor(0x800000));
RgbwColor temp;
#else
#define MINIMAL_BRIGHTNESS 20
#define LDR_SCALE 16
#define colorSaturation 192
//NeoPixelBrightnessBus<NeoGrbFeature, Neo800KbpsMethod> strip(NUM_LEDS, DATA_PIN); //ws2812B
NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32I2s1800KbpsMethod> strip(NUM_LEDS, DATA_PIN);
RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation);
RgbColor realWhite(colorSaturation);
RgbColor black(0);
RgbColor white(30, 40, 35); //darkish dirt
RgbColor whiter(120, 120, 120); //darkish dirt
RgbColor white12(255, 255, 255); //darkish dirt
RgbColor gold(HtmlColor( 0xFFD700 ) );
RgbColor orangered(HtmlColor( 0xFF4500 ) );
RgbColor orange(HtmlColor( 0xFFA500 ) );
RgbColor darkred(HtmlColor(0x800000));
RgbColor temp;
#endif
//NTP handler
//const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600; //ToDo changable from user
const int daylightOffset_sec = 3600;
struct tm timeinfo;
volatile int currentSec = 59;
volatile int currentMin = 1;
volatile int currentHour = 2;
// variable for storing the potentiometer value
volatile unsigned int ldrValue = 0;
volatile int MAX_BRIGHTNESS = 200;
// WebPortal
const char thingName[] = "NTP-Clock-RGBLED";
const char wifiInitialApPassword[] = "12345678";
//ToDo add internal LED and check visibility
#define STRING_LEN 63
#define NUMBER_LEN 4
// -- Configuration specific key. The value should be modified if config structure was changed.
#define CONFIG_VERSION "V1.0.0"
// -- Javascript block will be added to the header. 🔒 🔓
const char CUSTOMHTML_SCRIPT_INNER[] PROGMEM = "\n\
document.addEventListener('DOMContentLoaded', function(event) {\n\
let elements = document.querySelectorAll('input[type=\"password\"]');\n\
for (let p of elements) {\n\
let btn = document.createElement('INPUT'); btn.type = 'button'; btn.value = '🔓'; btn.style.width = 'auto'; p.style.width = '83%'; p.parentNode.insertBefore(btn,p.nextSibling);\n\
btn.onclick = function() { if (p.type === 'password') { p.type = 'text'; btn.value = '🔒'; } else { p.type = 'password'; btn.value = '🔓'; } }\n\
};\n\
});\n";
//const char CUSTOMHTML_BODY_INNER[] PROGMEM = " <link rel='icon' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAACPxJREFUeJztmm1sU+cVx3++vo7dGKdOQpp48ZQKJ3hCEFJYtBZSurUiDaWqSpKBWnUKe2Mkm8o+VWoEm8KglQpq12pSkSpIIdXUjQJS0pUkrTZtISoiiW0F1s1UfaFKyCBuAiN2HBz77MO1p7YJ1NfYGdL8k+4X+z73/M+5z31eznMgS5YsWbJkyfL/ijENz8iNXwJE0/C8ZMgBFqHpjyyQzTncA7wKeAE/0GcwGNrKyspKMmWwrKysxGAw7Ab64ja9cQ33ZMrmfKjAL4Fpo9EoDodDXK4lkp+fLwaDQVRVHalctuzBm7Q3AXagFLg7fpXGfzPdqFFlZeWDqqqOGAwGyc/PF5driTgcDjEajQJMxzWpqTijl83Ac8XFxZYdTz/Nfffdi8ViYWJigrff/hMdb7xR+nhDw8E33nzz3srKykvxNiXA94C1wArAAdi+YH8WuAaMAeeAfuDPwL8AhoeHi986evTgxx9/XPqDp57i0Uc3UlBQQDgc5v33T/PyK69YLl269BxwGfi9HmcMOp23An+3Wq1l7YcOsXRpxZwbpqamsFqtTExOvF5bW9cZjUZ/AjwAWE0mEwUFBSxevJiioiJyc3MBCIVCjI+PEwgEmJiYIBKJAASBvxmNxtd6e7sfK8gv2BoMBlm0aNEcm+fPn+eHP/oxwWDwArAMCGUqAA8Af9m0aZPh17/aNe8N0WiUvlOnePXVA7N+v1+MRqNp+fLlNDQ0sGbNGpYuXYrdbsdisaAoCgCxWIxwOMyVK1f48MMP6e/v5/jx45w9e5ZoNBpxu92G5ubt6v01NRiN84/bbbt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N1CGVj2amL+n0KpCL6AdcI6gVY7eCAPwGvAY8C10pMAywU1rfDNIouY4S5YsWbJkyZIlSyr8B2nXiKOP5kQtAAAAAElFTkSuQmCC'/>";
DNSServer dnsServer;
WebServer server(80);
#ifdef ESP8266
ESP8266HTTPUpdateServer httpUpdater;
#elif defined(ESP32)
HTTPUpdateServer httpUpdater;
#endif
char ntpServerParamValue[STRING_LEN];
char maxBrightnessParamValue[NUMBER_LEN];
char singleSecondParamValue[STRING_LEN];
char allDotsOnParamValue[STRING_LEN];
char followingHourParamValue[STRING_LEN];
IotWebConf iotWebConf(thingName, &dnsServer, &server, wifiInitialApPassword, CONFIG_VERSION);
IotWebConfParameterGroup timeGroup = IotWebConfParameterGroup("Time", "Time settings");
IotWebConfTextParameter ntpServerParam = IotWebConfTextParameter("NTP Server", "ntpServer", ntpServerParamValue, STRING_LEN, "pool.ntp.org");
IotWebConfParameterGroup ledGroup = IotWebConfParameterGroup("LED", "LED settings");
IotWebConfNumberParameter maxBrightnessParam = IotWebConfNumberParameter("Max BRIGHTNESS", "max brightness", maxBrightnessParamValue, NUMBER_LEN, "200", "20..254", "min='20' max='254' step='1'");
IotWebConfCheckboxParameter singleSecondParam = IotWebConfCheckboxParameter("Show Seconds", "singleSecond", singleSecondParamValue, STRING_LEN, true);
IotWebConfCheckboxParameter allDotsOnParam = IotWebConfCheckboxParameter("all Dots lighten on", "allDotsOn", allDotsOnParamValue, STRING_LEN, true);
IotWebConfCheckboxParameter followingHourParam = IotWebConfCheckboxParameter("following Hour", "followingHour", followingHourParamValue, STRING_LEN, true);
class CustomHtmlFormatProvider : public iotwebconf::HtmlFormatProvider
{
protected:
String getScriptInner() override
{
return
HtmlFormatProvider::getScriptInner() +
String(FPSTR(CUSTOMHTML_SCRIPT_INNER));
}
/*
String getBodyInner() override
{
return
String(FPSTR(CUSTOMHTML_BODY_INNER)) +
HtmlFormatProvider::getBodyInner();
}
*/
};
// -- An instance must be created from the class defined above.
CustomHtmlFormatProvider customHtmlFormatProvider;
//ToDo color Picker Second, 12Clock, Minute, Hour
Task bootAnim(200, TASK_FOREVER, &bootAnimCallback);
Task clockTick(1000, TASK_FOREVER, &clockTickCallback);
Task ledRefresh(200, TASK_FOREVER, &ledRefreshCallback);
Task brightness(10000, TASK_FOREVER, &brightnessAdjustmentCallback);
//Task iotwebconfLoop(200, TASK_FOREVER, &iotWebConf.doLoop);
Scheduler runner;
String printLocalTime() {
if (!getLocalTime(&timeinfo)) {
Serial.println("Failed to obtain time");
return "";
}
//Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
char timeStringBuff[50]; //50 chars should be enough
strftime(timeStringBuff, sizeof(timeStringBuff), "%A, %B %d %Y %H:%M:%S", &timeinfo);
//Serial.println(timeStringBuff);
return timeStringBuff;
}
/**
Handle web requests to "/" path.
*/
void iotWebConfHandleRoot() {
// -- Let IotWebConf test and handle captive portal requests.
if (iotWebConf.handleCaptivePortal())
{
// -- Captive portal request were already served.
return;
}
String s = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>";
s += "<meta http-equiv=\"refresh\" content=\"30\">";
//s += CUSTOMHTML_BODY_INNER;
s += "<title>RGB LED Clock</title></head><body>";
s += "RGB LED Clock";
s += "<p>";
s += "<table>";
s += "<tr><td>Current Time:</td><td>";
s += printLocalTime();
s += "</td></tr><tr></tr><tr><td>NTP Server:</td><td>";
s += ntpServerParamValue;
s += "</td><tr><tr><td>Current Brightness value: </td><td>";
s += String(strip.GetBrightness());
s += "</td><tr><tr><td>Max Brightness value: </td><td>";
s += atoi(maxBrightnessParamValue);
s += "</td></tr><tr><td>Show Seconds: </td><td>";
s += (singleSecond ? "Yes" : "No");
s += "</td></tr><tr><td>All Dots On: </td><td>";
s += (allDotsOn ? "Yes" : "No");
s += "</td></tr><tr><td>Following Hour: </td><td>";
s += (followingHour ? "Yes" : "No");
s += "<td></tr></table>";
s += "<p>";
s += "Go to <a href='config'>configure page</a> to change values.";
s += "</body></html>\n";
server.send(200, "text/html; charset=UTF-8", s);
}
void iotWebConfConfigSaved()
{
//ToDo ntpServerParamValue;
MAX_BRIGHTNESS = atoi(maxBrightnessParamValue);
singleSecond = singleSecondParam.isChecked() ? true : false;
//Serial.println(singleSecondParam.isChecked() ? "true" : "false");
allDotsOn = allDotsOnParam.isChecked() ? true : false;
//Serial.println(allDotsOnParam.isChecked() ? "true" : "false");
followingHour = followingHourParam.isChecked() ? true : false;
//Serial.println(followingHourParam.isChecked() ? "true" : "false");
Serial.println("Configuration was updated.");
}
/*
bool iotWebConfFormValidator(iotwebconf::WebRequestWrapper* webRequestWrapper)
{
Serial.println("Validating form.");
boolean valid = true;
int l = server.arg(ntpServerParam.getId()).length();
if (l < 3)
{
ntpServerParam.errorMessage = "Please provide at least 3 characters for this test!";
valid = false;
}
int b = atoi(maxBrightnessParamValue);
if (b < MINIMAL_BRIGHTNESS || b > 254)
{
valid = false;
}
return valid;
}
*/
void iotWebConf_Setup() {
timeGroup.addItem(&ntpServerParam);
ledGroup.addItem(&maxBrightnessParam);
ledGroup.addItem(&singleSecondParam);
ledGroup.addItem(&allDotsOnParam);
ledGroup.addItem(&followingHourParam);
iotWebConf.addParameterGroup(&timeGroup);
iotWebConf.addParameterGroup(&ledGroup);
iotWebConf.setConfigSavedCallback(&iotWebConfConfigSaved);
iotWebConf.setWifiConnectionCallback(&syncNTP); //NTP call after connection established
//iotWebConf.setFormValidator(&iotWebConfFormValidator);
iotWebConf.getApTimeoutParameter()->visible = true;
iotWebConf.setupUpdateServer(
[](const char* updatePath) {
httpUpdater.setup(&server, updatePath);
},
[](const char* userName, char* password) {
httpUpdater.updateCredentials(userName, password);
});
iotWebConf.setHtmlFormatProvider(&customHtmlFormatProvider);
// -- Initializing the configuration.
iotWebConf.init();
// -- Set up required URL handlers on the web server.
server.on("/", iotWebConfHandleRoot);
server.on("/config", [] { iotWebConf.handleConfig(); });
server.onNotFound([]() {
iotWebConf.handleNotFound();
});
Serial.println("Ready.");
Serial.flush();
}
void syncNTP() {
if (iotWebConf.getState() == 4) {
//init and get the time
configTime(gmtOffset_sec, daylightOffset_sec, ntpServerParamValue);
Serial.println(printLocalTime());
//inverted logic - remaining time
currentSec = 60 - timeinfo.tm_sec;
currentMin = 60 - timeinfo.tm_min;
currentHour = 12 - MOD(timeinfo.tm_hour, 12);
Serial.println("NTP mapped: " + String(currentHour) + ":" + String(currentMin) + ":" + String(currentSec));
bootAnim.disable();
ledRefresh.enable();
clockTick.enable();
brightness.enable();
}
}
void setup() {
pinMode(LDR_PIN, INPUT_PULLUP);
pinMode(DATA_PIN, OUTPUT);
Serial.begin(SERIAL_BAUD);
Serial.flush();
Serial.print("\n\n\nCPU Frequency is: ");
Serial.print(getCpuFrequencyMhz()); //Get CPU clock
Serial.println(" Mhz");
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress()); //Get CPU clock
Serial.println("-----------------------\nSettings\n-----------------------");
Serial.printf("Show single second: \t%s\n", singleSecond ? "yes" : "no");
Serial.printf("Lighten up all LEDs: \t%s\n", allDotsOn ? "yes" : "no");
Serial.printf("Following Hour: \t%s\n\n", followingHour ? "yes" : "no");
strip.Begin();
strip.SetBrightness( MINIMAL_BRIGHTNESS );
strip.ClearTo(white);
strip.Show();
runner.init();
runner.addTask(ledRefresh);
runner.addTask(clockTick);
runner.addTask(brightness);
runner.addTask(bootAnim);
bootAnim.enable();
iotWebConf_Setup();
//Serial.end();
}
void loop()
{
runner.execute();
iotWebConf.doLoop();
/*
while (Serial.available())
Serial.read();
*/
}
void ledRefreshCallback() {
temp = allDotsOn ? white : black;
strip.ClearTo(temp);
//1 dot hour marking
for (int dot = 0; dot < NUM_LEDS; dot++) {
if (MOD(dot, 5) == 0) {
strip.SetPixelColor(dot, whiter);
}
}
//3 dots hour
strip.SetPixelColor(MOD((currentHour * 5 - 1 + hourOffset), NUM_LEDS), gold);
strip.SetPixelColor(MOD((currentHour * 5 + 0 + hourOffset), NUM_LEDS), gold);
strip.SetPixelColor(MOD((currentHour * 5 + 1 + hourOffset), NUM_LEDS), gold);
strip.SetPixelColor(0, white12); //define high noon
if (singleSecond) {
strip.SetPixelColor(MOD((currentSec + 0), NUM_LEDS), (allDotsOn ? black : white));
}
strip.SetPixelColor(MOD((currentMin + 0), NUM_LEDS), darkred);
strip.Show();
}
// Scheduler
void clockTickCallback() {
ldrValue = (ldrValue + analogRead(LDR_PIN));
if (currentSec < 0) {
currentSec = 59;
currentMin--;
if (currentMin < 0) {
currentMin = 59;
currentHour--;
if (currentHour < 0) {
currentHour = 11;
syncNTP();
}
}
if (followingHour) {
hourOffset = 0 - ((60 - currentMin) / 12); //negative value
//Serial.println("hourOffset: " + String(hourOffset));
}
//Serial.println(String(interruptCounter) + " | Ring Index: " + String(currentHour * 5) + ":" + String(currentMin) + ":" + String(currentSec));
}
currentSec--;
}
void bootAnimCallback() {
strip.ClearTo(black);
currentSec--;
if (currentSec < 0) {
currentSec = 59;
}
if (iotWebConf.getState() == 3) {
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), white);
strip.SetPixelColor(MOD((currentSec - 1), NUM_LEDS), whiter);
strip.SetPixelColor(MOD((currentSec - 2), NUM_LEDS), white12);
}
if (iotWebConf.getState() == 2) {
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), orange);
strip.SetPixelColor(MOD((currentSec - 1), NUM_LEDS), orangered);
strip.SetPixelColor(MOD((currentSec - 2), NUM_LEDS), red);
}
if (iotWebConf.getState() == 0 || iotWebConf.getState() == 1) {
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), orangered);
strip.SetPixelColor(MOD((currentSec - 1), NUM_LEDS), red);
strip.SetPixelColor(MOD((currentSec - 2), NUM_LEDS), darkred);
}
strip.Show();
}
void brightnessAdjustmentCallback() {
//Serial.println(ldrValue);
//brigthness begin
ldrValue = ldrValue / 10;
int x;
if (ldrValue == 0) {
strip.SetBrightness( MAX_BRIGHTNESS );
}
else {
x = int(MINIMAL_BRIGHTNESS + (MAX_BRIGHTNESS - MINIMAL_BRIGHTNESS) / ((ldrValue / LDR_SCALE) + 1) );
strip.SetBrightness(x);
}
Serial.println("Brightness: " + String(strip.GetBrightness()) + "(" + String(ldrValue) + ")");
ldrValue = 0;
strip.Show();
}