fix followingHour offset; fix single second color
This commit is contained in:
parent
fe2aa05b94
commit
825ee5ff50
@ -20,6 +20,7 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
// For ESP32 IotWebConf provides a drop-in replacement for UpdateServer.
|
// For ESP32 IotWebConf provides a drop-in replacement for UpdateServer.
|
||||||
# include <IotWebConfESP32HTTPUpdateServer.h>
|
# include <IotWebConfESP32HTTPUpdateServer.h>
|
||||||
|
#include <esp_task_wdt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ void transformHtmltoStrip(RgbColor* outputColor, char* sInput) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//const char* ntpServer = "pool.ntp.org";
|
const char* ntpServer = "pool.ntp.org";
|
||||||
const long gmtOffset_sec = 3600; //ToDo changable from user
|
const long gmtOffset_sec = 3600; //ToDo changable from user
|
||||||
const int daylightOffset_sec = 3600;
|
const int daylightOffset_sec = 3600;
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
@ -206,7 +207,7 @@ const char wifiInitialApPassword[] = "12345678";
|
|||||||
// -- Maximal length the input-range attributes can have.
|
// -- Maximal length the input-range attributes can have.
|
||||||
//#define COLOR_ATTR_LENGTH 60
|
//#define COLOR_ATTR_LENGTH 60
|
||||||
// -- Configuration specific key. The value should be modified if config structure was changed.
|
// -- Configuration specific key. The value should be modified if config structure was changed.
|
||||||
#define CONFIG_VERSION "V1.1.7"
|
#define CONFIG_VERSION "V1.1.8"
|
||||||
|
|
||||||
const char CUSTOMHTML_SCRIPT_INNER[] PROGMEM = "\n\
|
const char CUSTOMHTML_SCRIPT_INNER[] PROGMEM = "\n\
|
||||||
function colorCh(id)\n\
|
function colorCh(id)\n\
|
||||||
@ -439,6 +440,9 @@ void iotWebConfConfigSaved()
|
|||||||
//Serial.println(allDotsOnParam.isChecked() ? "true" : "false");
|
//Serial.println(allDotsOnParam.isChecked() ? "true" : "false");
|
||||||
#if NUM_LEDS == 60
|
#if NUM_LEDS == 60
|
||||||
followingHour = followingHourParam.isChecked() ? true : false;
|
followingHour = followingHourParam.isChecked() ? true : false;
|
||||||
|
if (!followingHour) {
|
||||||
|
hourOffset = 0 ;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
//Serial.println(followingHourParam.isChecked() ? "true" : "false");
|
//Serial.println(followingHourParam.isChecked() ? "true" : "false");
|
||||||
|
|
||||||
@ -472,6 +476,7 @@ void iotWebConf_Setup() {
|
|||||||
iotWebConf.addParameterGroup(&ledGroup);
|
iotWebConf.addParameterGroup(&ledGroup);
|
||||||
|
|
||||||
iotWebConf.setConfigSavedCallback(&iotWebConfConfigSaved);
|
iotWebConf.setConfigSavedCallback(&iotWebConfConfigSaved);
|
||||||
|
//iotWebConf.setWifiConnectionTimeoutMs(60000);
|
||||||
iotWebConf.setWifiConnectionCallback(&syncNTP); //NTP call after connection established
|
iotWebConf.setWifiConnectionCallback(&syncNTP); //NTP call after connection established
|
||||||
//iotWebConf.setFormValidator(&iotWebConfFormValidator);
|
//iotWebConf.setFormValidator(&iotWebConfFormValidator);
|
||||||
iotWebConf.getApTimeoutParameter()->visible = true;
|
iotWebConf.getApTimeoutParameter()->visible = true;
|
||||||
@ -535,6 +540,7 @@ void syncNTP() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
clockTick.enable(); //enable to check for ntp every 60 seconds
|
clockTick.enable(); //enable to check for ntp every 60 seconds
|
||||||
|
iotwebconfLoop.enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,13 +555,30 @@ void setup() {
|
|||||||
Serial.print("\n\n\nCPU Frequency is: ");
|
Serial.print("\n\n\nCPU Frequency is: ");
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
Serial.print(ESP.getCpuFreqMHz());
|
Serial.print(ESP.getCpuFreqMHz());
|
||||||
|
Serial.println(" Mhz");
|
||||||
|
Serial.print("Chip ID: ");
|
||||||
|
Serial.println(ESP.getFlashChipId());
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
Serial.print(getCpuFrequencyMhz()); //Get CPU clock
|
Serial.print(getCpuFrequencyMhz()); //Get CPU clock
|
||||||
#endif
|
|
||||||
Serial.println(" Mhz");
|
Serial.println(" Mhz");
|
||||||
|
uint32_t chipId = 0;
|
||||||
|
for (int i = 0; i < 17; i = i + 8) {
|
||||||
|
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
|
||||||
|
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
|
||||||
|
Serial.print("Chip ID: "); Serial.println(chipId);
|
||||||
|
#endif
|
||||||
Serial.print("MAC address: ");
|
Serial.print("MAC address: ");
|
||||||
Serial.println(WiFi.macAddress()); //Get CPU clock
|
Serial.println(WiFi.macAddress()); //Get CPU clock
|
||||||
|
|
||||||
|
#ifdef RGBW
|
||||||
|
Serial.println("RGBW");
|
||||||
|
#else
|
||||||
|
Serial.println("RGB");
|
||||||
|
#endif
|
||||||
|
|
||||||
strip.Begin();
|
strip.Begin();
|
||||||
strip.ClearTo(white);
|
strip.ClearTo(white);
|
||||||
strip.SetBrightness( MINIMAL_BRIGHTNESS );
|
strip.SetBrightness( MINIMAL_BRIGHTNESS );
|
||||||
@ -568,19 +591,25 @@ void setup() {
|
|||||||
runner.addTask(brightness);
|
runner.addTask(brightness);
|
||||||
#endif
|
#endif
|
||||||
runner.addTask(bootAnim);
|
runner.addTask(bootAnim);
|
||||||
//runner.addTask(iotWebConf.Loop);
|
runner.addTask(iotwebconfLoop);
|
||||||
bootAnim.enable();
|
bootAnim.enable();
|
||||||
|
|
||||||
iotWebConf_Setup();
|
iotWebConf_Setup();
|
||||||
//Serial.end();
|
//Serial.end();
|
||||||
|
#ifdef ESP8266
|
||||||
ESP.wdtDisable();
|
ESP.wdtDisable();
|
||||||
ESP.wdtEnable(2000);
|
ESP.wdtEnable(1000);
|
||||||
|
#endif
|
||||||
|
#if defined(ESP32)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
runner.execute();
|
runner.execute();
|
||||||
iotWebConf.doLoop(); //ToDo put in a task, measure the runtime
|
yield();
|
||||||
|
//iotWebConfLoopCallback();//ToDo put in a task, measure the runtime
|
||||||
|
ESP.wdtFeed();
|
||||||
/*
|
/*
|
||||||
while (Serial.available())
|
while (Serial.available())
|
||||||
Serial.read();
|
Serial.read();
|
||||||
@ -606,14 +635,14 @@ void ledRefreshCallback() {
|
|||||||
}
|
}
|
||||||
strip.SetPixelColor(0, highnoonColor); //define high noon
|
strip.SetPixelColor(0, highnoonColor); //define high noon
|
||||||
|
|
||||||
if (singleSecond) {
|
|
||||||
strip.SetPixelColor(MOD(int(currentSec * NUM_LEDS / 60 + 0), NUM_LEDS), secondsColor);
|
|
||||||
}
|
|
||||||
#if NUM_LEDS == 60
|
#if NUM_LEDS == 60
|
||||||
//3 dots hour
|
//3 dots hour
|
||||||
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 - 1 + hourOffset), NUM_LEDS), hourColor);
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 - 1 + hourOffset), NUM_LEDS), hourColor);
|
||||||
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 0 + hourOffset), NUM_LEDS), hourColor);
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 0 + hourOffset), NUM_LEDS), hourColor);
|
||||||
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 1 + hourOffset), NUM_LEDS), hourColor);
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 1 + hourOffset), NUM_LEDS), hourColor);
|
||||||
|
if (singleSecond) {
|
||||||
|
strip.SetPixelColor(MOD(int(currentSec * NUM_LEDS / 60 + 0), NUM_LEDS), allDotsOn ? secondsColor : backlightColor);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 0 + hourOffset), NUM_LEDS) , hourColor);
|
strip.SetPixelColor(MOD(int(currentHour * NUM_LEDS / 12 + 0 + hourOffset), NUM_LEDS) , hourColor);
|
||||||
#endif
|
#endif
|
||||||
@ -642,8 +671,8 @@ void clockTickCallback() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (followingHour) {
|
if (followingHour) {
|
||||||
hourOffset = int (currentMin * NUM_LEDS / 60 / 12); //negative value
|
hourOffset = int(currentMin * NUM_LEDS / 60 / 12);
|
||||||
//Serial.println("hourOffset: " + String(hourOffset));
|
//Serial.println("clockwise hourOffset: " + String(hourOffset));
|
||||||
}
|
}
|
||||||
//Serial.println(String(interruptCounter) + " | Ring Index: " + String(currentHour / (12 / NUM_LEDS)) + ":" + String(currentMin / (60 / NUM_LEDS)) + ":" + String(currentSec / (60 / NUM_LEDS)));
|
//Serial.println(String(interruptCounter) + " | Ring Index: " + String(currentHour / (12 / NUM_LEDS)) + ":" + String(currentMin / (60 / NUM_LEDS)) + ":" + String(currentSec / (60 / NUM_LEDS)));
|
||||||
}
|
}
|
||||||
@ -666,8 +695,8 @@ void clockTickCallback() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (followingHour) {
|
if (followingHour) {
|
||||||
hourOffset = 0 + int((60 - currentMin * NUM_LEDS / 60) / 12); //negative value
|
hourOffset = 0 - int((60 - currentMin * NUM_LEDS / 60) / 12); //negative value
|
||||||
//Serial.println("hourOffset: " + String(hourOffset));
|
//Serial.println("Anticlockwise hourOffset: " + String(hourOffset));
|
||||||
}
|
}
|
||||||
//Serial.println(String(interruptCounter) + " | Ring Index: " + String(currentHour / (12 / NUM_LEDS)) + ":" + String(currentMin / (60 / NUM_LEDS)) + ":" + String(currentSec / (60 / NUM_LEDS)));
|
//Serial.println(String(interruptCounter) + " | Ring Index: " + String(currentHour / (12 / NUM_LEDS)) + ":" + String(currentMin / (60 / NUM_LEDS)) + ":" + String(currentSec / (60 / NUM_LEDS)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user