Skip to content

Commit

Permalink
Fix fractional UTC offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncoon committed Nov 25, 2021
1 parent 0702b26 commit f5288e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion esp8266-fastled-webserver/Fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ uint8_t power = 1;
uint8_t brightness = brightnessMap[brightnessIndex];


float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

//String setPower(String value) {
// power = value.toInt();
Expand Down Expand Up @@ -160,7 +164,7 @@ String setUtcOffsetIndex(uint8_t value)
{
utcOffsetIndex = value;
if (utcOffsetIndex > 104) utcOffsetIndex = 104;
int utcOffsetInHours = map(utcOffsetIndex, 0, 104, -12, 14);
float utcOffsetInHours = mapfloat(utcOffsetIndex, 0, 104, -12, 14);
utcOffsetInSeconds = utcOffsetInHours * 60 * 60;
Serial.print(F("utcOffsetIndex: ")); Serial.println(utcOffsetIndex);
Serial.print(F("utcOffsetInHours: ")); Serial.println(utcOffsetInHours);
Expand Down

0 comments on commit f5288e1

Please sign in to comment.