minor fixes
This commit is contained in:
parent
2453e9d74b
commit
a8d7c13c07
@ -41,7 +41,7 @@
|
||||
#define NUM_LEDS 60
|
||||
#define SERIAL_BAUD 115200
|
||||
|
||||
#define RGBW
|
||||
//#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
|
||||
@ -78,7 +78,7 @@ RgbwColor darkred(HtmlColor( 0x800000) );
|
||||
RgbwColor darkgreen(HtmlColor( 0x006400) );
|
||||
RgbwColor lightgreen(HtmlColor( 0x30ee30) );
|
||||
RgbwColor temp;
|
||||
RgbwColor secondsColor = white;
|
||||
RgbwColor secondsColor = black;
|
||||
RgbwColor minuteColor = darkred;
|
||||
RgbwColor hourColor = gold;
|
||||
RgbwColor highnoonColor = white12;
|
||||
@ -91,12 +91,12 @@ void transformtoHtmlColor (char* sOutput, RgbwColor* inputColor) {
|
||||
if (inputColor->IsMonotone())
|
||||
{
|
||||
//Serial.print("White: "); Serial.println(inputColor->W);
|
||||
Serial.print(HtmlColor(RgbColor(inputColor->W, inputColor->W, inputColor->W)).ToNumericalString(sOutput, 12));
|
||||
HtmlColor(RgbColor(inputColor->W, inputColor->W, inputColor->W)).ToNumericalString(sOutput, 12);
|
||||
//Serial.println((char*)sOutput);
|
||||
}
|
||||
else {
|
||||
//Serial.print("Color: "); Serial.print(inputColor->R); Serial.print(inputColor->G); Serial.println(inputColor->B);
|
||||
Serial.print(HtmlColor(RgbColor(inputColor->R, inputColor->G, inputColor->B)).ToNumericalString(sOutput, 12));
|
||||
HtmlColor(RgbColor(inputColor->R, inputColor->G, inputColor->B)).ToNumericalString(sOutput, 12);
|
||||
//Serial.println((char*)sOutput);
|
||||
}
|
||||
}
|
||||
@ -133,24 +133,24 @@ RgbColor darkred(HtmlColor( 0x800000 ));
|
||||
RgbColor darkgreen(HtmlColor( 0x006400 ));
|
||||
RgbColor lightgreen(HtmlColor( 0x90ee90 ));
|
||||
RgbColor temp;
|
||||
RgbColor secondsColor = white;
|
||||
RgbColor secondsColor = black;
|
||||
RgbColor minuteColor = darkred;
|
||||
RgbColor hourColor = gold;
|
||||
RgbColor highnoonColor = white12;
|
||||
RgbColor backlightColor = white;
|
||||
RgbColor hourMarkingColor = whiter;
|
||||
|
||||
void transformtoHtmlColor (char* sOutput, RgbColor inputColor) {
|
||||
HtmlColor(inputColor).ToNumericalString(sOutput, sizeof(sOutput) - 1);
|
||||
void transformtoHtmlColor (char* sOutput, RgbColor* inputColor) {
|
||||
HtmlColor(RgbColor(inputColor->R, inputColor->G, inputColor->B)).ToNumericalString(sOutput, 12);
|
||||
}
|
||||
|
||||
void transformHtmltoStrip(RgbColor outputColor, char* sInput) {
|
||||
void transformHtmltoStrip(RgbColor* outputColor, char* sInput) {
|
||||
HtmlColor htmlTemp;
|
||||
//Serial.print("HtmltoStrip ");
|
||||
htmlTemp.Parse<HtmlColorNames>( sInput );
|
||||
//Serial.println((char*)sInput);
|
||||
htmlTemp.Parse<HtmlColorNames>( sInput );
|
||||
RgbColor stripColor( htmlTemp );
|
||||
//Serial.printf("StripColor: R:%i G:%i B:%i\n", stripColor.R, stripColor.G, stripColor.B);
|
||||
//Serial.printf("StripColor: R:%i G:%i B:%i W:%i\n", stripColor.R, stripColor.G, stripColor.B, stripColor.W);
|
||||
memcpy(outputColor, &stripColor, sizeof(stripColor));
|
||||
}
|
||||
|
||||
@ -164,6 +164,7 @@ struct tm timeinfo;
|
||||
volatile int currentSec = 59;
|
||||
volatile int currentMin = 1;
|
||||
volatile int currentHour = 2;
|
||||
volatile bool NTPreachable = false;
|
||||
|
||||
#ifdef LDR_PIN
|
||||
// variable for storing the potentiometer value
|
||||
@ -179,7 +180,7 @@ const char wifiInitialApPassword[] = "12345678";
|
||||
// -- Maximal length the input-range attributes can have.
|
||||
#define COLOR_ATTR_LENGTH 60
|
||||
// -- Configuration specific key. The value should be modified if config structure was changed.
|
||||
#define CONFIG_VERSION "V1.1.3"
|
||||
#define CONFIG_VERSION "V1.1.4"
|
||||
|
||||
const char CUSTOMHTML_SCRIPT_INNER[] PROGMEM = "\n\
|
||||
function colorCh(id)\n\
|
||||
@ -294,8 +295,8 @@ IotWebConfCheckboxParameter allDotsOnParam = IotWebConfCheckboxParameter("all Do
|
||||
IotWebConfCheckboxParameter followingHourParam = IotWebConfCheckboxParameter("following Hour", "followingHour", followingHourParamValue, STRING_LEN, true);
|
||||
ColorWithValueParameter hourColorParam = ColorWithValueParameter("Stundenfarbe", "hourColorParam", hourColorParamValue, COLOR_ATTR_LENGTH, "#FFD700");
|
||||
ColorWithValueParameter minuteColorParam = ColorWithValueParameter("Minutenfarbe", "minuteColorParam", minuteColorParamValue, COLOR_ATTR_LENGTH, "#800000");
|
||||
ColorWithValueParameter secondsColorParam = ColorWithValueParameter("Sekundenfarbe", "secondsColorParam", secondsColorParamValue, COLOR_ATTR_LENGTH, "#ffffff");
|
||||
ColorWithValueParameter highnoonColorParam = ColorWithValueParameter("12Uhr Farbe", "highnoonColorParam", highnoonColorParamValue, COLOR_ATTR_LENGTH, "#1E2823");
|
||||
ColorWithValueParameter secondsColorParam = ColorWithValueParameter("Sekundenfarbe", "secondsColorParam", secondsColorParamValue, COLOR_ATTR_LENGTH, "#000000");
|
||||
ColorWithValueParameter highnoonColorParam = ColorWithValueParameter("12Uhr Farbe", "highnoonColorParam", highnoonColorParamValue, COLOR_ATTR_LENGTH, "#C0C0C0");
|
||||
ColorWithValueParameter backlightColorParam = ColorWithValueParameter("Hintergrundfarbe", "backlightColorParam", backlightColorParamValue, COLOR_ATTR_LENGTH, "#1E2823");
|
||||
ColorWithValueParameter hourMarkingColorParam = ColorWithValueParameter("Stundenmarkierung", "hourMarkingColorParam", hourMarkingColorParamValue, COLOR_ATTR_LENGTH, "#787878");
|
||||
|
||||
@ -332,6 +333,7 @@ bool getLocalTime(struct tm * info, uint32_t ms)
|
||||
String printLocalTime() {
|
||||
if (!getLocalTime(&timeinfo, 200)) {
|
||||
Serial.println("Failed to obtain time");
|
||||
NTPreachable = false;
|
||||
return "";
|
||||
}
|
||||
//Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
|
||||
@ -339,6 +341,7 @@ String printLocalTime() {
|
||||
char timeStringBuff[50]; //50 chars should be enough
|
||||
strftime(timeStringBuff, sizeof(timeStringBuff), "%A, %B %d %Y %H:%M:%S", &timeinfo);
|
||||
//Serial.println(timeStringBuff);
|
||||
NTPreachable = true;
|
||||
return timeStringBuff;
|
||||
|
||||
}
|
||||
@ -390,7 +393,7 @@ void iotWebConfHandleRoot() {
|
||||
s += sTemp;
|
||||
s += ";\"><td></tr>";
|
||||
if (singleSecond) {
|
||||
s += "<tr><td>Seconds Color: </td><td style=\"border: 1px solid #000000; background-color:";
|
||||
s += "<tr><td>Seconds color: </td><td style=\"border: 1px solid #000000; background-color:";
|
||||
transformtoHtmlColor ((char*)&sTemp, &secondsColor);
|
||||
s += sTemp;
|
||||
s += ";\"><td></tr>";
|
||||
@ -482,17 +485,19 @@ void syncNTP() {
|
||||
//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();
|
||||
if (NTPreachable) {
|
||||
//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();
|
||||
#ifdef LDR_PIN
|
||||
brightness.enable();
|
||||
brightness.enable();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,12 +519,6 @@ void setup() {
|
||||
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);
|
||||
@ -580,6 +579,9 @@ void clockTickCallback() {
|
||||
if (currentSec < 0) {
|
||||
currentSec = 59;
|
||||
currentMin--;
|
||||
if (!NTPreachable) {
|
||||
syncNTP();
|
||||
}
|
||||
if (currentMin < 0) {
|
||||
currentMin = 59;
|
||||
currentHour--;
|
||||
@ -603,6 +605,13 @@ void bootAnimCallback() {
|
||||
if (currentSec < 0) {
|
||||
currentSec = 59;
|
||||
}
|
||||
|
||||
if (iotWebConf.getState() == IOTWEBCONF_STATE_ONLINE && !NTPreachable) {
|
||||
strip.ClearTo(white);
|
||||
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), black);
|
||||
strip.SetPixelColor(MOD((currentSec - 1), NUM_LEDS), black);
|
||||
strip.SetPixelColor(MOD((currentSec - 2), NUM_LEDS), black);
|
||||
}
|
||||
if (iotWebConf.getState() == IOTWEBCONF_STATE_CONNECTING) {
|
||||
strip.SetPixelColor(MOD((currentSec - 0), NUM_LEDS), white);
|
||||
strip.SetPixelColor(MOD((currentSec - 1), NUM_LEDS), whiter);
|
||||
|
Loading…
Reference in New Issue
Block a user