I am calculating the current temperature to RGB related to a maximum temperature:
val = round(temp / tempMax * 255, 0);
if (val > 255) val = 255;
In maths the function is v=temp/tempMax*255
.
This works for a temperature between 0 and tempMax.
I want to do the same but in an area between minTemp
and maxTemp-5
.
That means if the temp is exactly minTemp, val should be 0 and if it is maxTemp-5 it should be 255. all temperature that are lower than minTemp set val to zero and there will be special if statement for the area between maxTemp-5 and maxTemp. All the ifs are no problem but how do I need to modify my function that it calculating proportionally to the given borders?