Compile warnings eliminated.

Minor typo.
DEBUG_PRINTF fix for 8266
This commit is contained in:
Blaz Kristan 2021-08-24 21:35:47 +02:00
parent be7e2bed6f
commit 84d0c17c4b
5 changed files with 33 additions and 39 deletions

View File

@ -81,7 +81,9 @@ class UsermodTemperature : public Usermod {
temperature = readDallas(); temperature = readDallas();
lastMeasurement = millis(); lastMeasurement = millis();
waitingForConversion = false; waitingForConversion = false;
DEBUG_PRINTF("Read temperature %2.1f.\n", temperature); //DEBUG_PRINTF("Read temperature %2.1f.\n", temperature); // does not work properly on 8266
DEBUG_PRINT(F("Read temperature "));
DEBUG_PRINTLN(temperature);
} }
bool findSensor() { bool findSensor() {

View File

@ -49,54 +49,46 @@ void relativeChangeWhite(int8_t amount, byte lowerBoundary)
void colorHSVtoRGB(float hue, float saturation, float value, byte& red, byte& green, byte& blue) void colorHSVtoRGB(float hue, float saturation, float value, byte& red, byte& green, byte& blue)
{ {
float r, g, b; float r = red, g = green, b = blue;
auto i = static_cast<int>(hue * 6); uint8_t i = hue * 6.0;
auto f = hue * 6 - i; float f = hue * 6.0 - i;
auto p = value * (1 - saturation); value *= 255.0;
auto q = value * (1 - f * saturation); float p = value * (1.0 - saturation);
auto t = value * (1 - (1 - f) * saturation); float q = value * (1.0 - f * saturation);
float t = value * (1.0 - (1.0 - f) * saturation);
switch (i % 6) switch (i % 6) {
{ case 0: r = value, g = t, b = p; break;
case 0: r = value, g = t, b = p; case 1: r = q, g = value, b = p; break;
break; case 2: r = p, g = value, b = t; break;
case 1: r = q, g = value, b = p; case 3: r = p, g = q, b = value; break;
break; case 4: r = t, g = p, b = value; break;
case 2: r = p, g = value, b = t; case 5: r = value, g = p, b = q; break;
break;
case 3: r = p, g = q, b = value;
break;
case 4: r = t, g = p, b = value;
break;
case 5: r = value, g = p, b = q;
break;
} }
red = static_cast<uint8_t>(r * 255); red = r;
green = static_cast<uint8_t>(g * 255); green = g;
blue = static_cast<uint8_t>(b * 255); blue = b;
} }
void colorRGBtoHSV(byte red, byte green, byte blue, float& hue, float& saturation, float& value) void colorRGBtoHSV(byte red, byte green, byte blue, float& hue, float& saturation, float& value)
{ {
auto rd = static_cast<float>(red) / 255; float rd = red/255.0, gd = green/255.0, bd = blue/255.0;
auto gd = static_cast<float>(green) / 255; float max = std::max({ rd, gd, bd }), min = std::min({ rd, gd, bd });
auto bd = static_cast<float>(blue) / 255;
auto max = std::max({ rd, gd, bd }), min = std::min({ rd, gd, bd });
value = max; value = max;
auto d = max - min; float d = max - min;
saturation = max == 0 ? 0 : d / max; saturation = max == 0.0 ? 0.0 : d / max;
hue = 0; hue = 0;
if (max != min) if (max != min)
{ {
if (max == rd) hue = (gd - bd) / d + (gd < bd ? 6 : 0); if (max == rd) hue = (gd - bd) / d + (gd < bd ? 6.0 : 0.0);
else if (max == gd) hue = (bd - rd) / d + 2; else if (max == gd) hue = (bd - rd) / d + 2.0;
else if (max == bd) hue = (rd - gd) / d + 4; else if (max == bd) hue = (rd - gd) / d + 4.0;
hue /= 6; hue /= 6.0;
} }
} }

View File

@ -805,7 +805,7 @@ function populateEffects()
effects.unshift({ effects.unshift({
"id": 0, "id": 0,
"name": "Solid", "name": "Solid"
}); });
for (let i = 0; i < effects.length; i++) { for (let i = 0; i < effects.length; i++) {

View File

@ -169,16 +169,16 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
strip.fill(0); strip.fill(0);
} }
uint16_t start = 0, stop = 0; //uint16_t start = 0, stop = 0;
byte set = 0; //0 nothing set, 1 start set, 2 range set byte set = 0; //0 nothing set, 1 start set, 2 range set
for (uint16_t i = 0; i < iarr.size(); i++) { for (uint16_t i = 0; i < iarr.size(); i++) {
if(iarr[i].is<JsonInteger>()) { if(iarr[i].is<JsonInteger>()) {
if (!set) { if (!set) {
start = iarr[i]; //start = iarr[i];
set = 1; set = 1;
} else { } else {
stop = iarr[i]; //stop = iarr[i];
set = 2; set = 2;
} }
} else { //color } else { //color

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2108231 #define VERSION 2108241
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG