FIx lighting maths
This commit is contained in:
parent
f383baae95
commit
1b18919543
1 changed files with 2 additions and 7 deletions
|
@ -182,18 +182,13 @@ float getIndexMultiplier(int now, int startTime, int endTime, bool swap){
|
|||
float indexMultiplier = 1;
|
||||
int a = swap ? endTime - now : now - startTime;
|
||||
int b = endTime - startTime;
|
||||
indexMultiplier = a > 0 ? b / a : 0;
|
||||
|
||||
if (indexMultiplier < 1)
|
||||
indexMultiplier = 1;
|
||||
|
||||
return indexMultiplier;
|
||||
return constrain(a / b, 0, 1);
|
||||
}
|
||||
|
||||
float getHeatIndex() {
|
||||
time_t now = time(nullptr);
|
||||
float indexMultiplier = now >= _lightsOffStartTime ? getIndexMultiplier(now, _lightsOffStartTime, _lightsOffEndTime, true) : getIndexMultiplier(now, _lightsOnStartTime, _lightsOnEndTime, false);
|
||||
return HEAT_INDEX_MAX / indexMultiplier;
|
||||
return HEAT_INDEX_MAX * indexMultiplier;
|
||||
}
|
||||
|
||||
void doLighting() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue