Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive Temperature scale in forecast (Feature request; where to find) #106

Open
LordSexy opened this issue Jun 5, 2024 · 2 comments
Open

Comments

@LordSexy
Copy link

LordSexy commented Jun 5, 2024

Hey guys,

its not a bug report or anything, just something I would like to adjust and I dont know where to look.

My Display (800 pixel Waveshare 3 color; hat 2.3 working fine btw!) shows the temperature and rain forecast for 36 hours (default:24).
The Y-axis for temperature starts at 5°C and ends at 30 °C and the forcast is between 12 °C and 21 °C for the next days.

Where is the code which draws that, so I can scale it to "draw Y-axis, so temp forecast is around 10% hight to 90 % hight of the graph"

I just want to use the space a bit more. I would also try to adapt the dotted grey lines, so they are not just at 5°C intervals, but scale to 2°C / 1°C if the graph is quiet flat for the day. If you dont have capacity to implement it, I would bodge it myself. No problems :D

But massive shoutouts to @lmarzen and anyone else involved. A dork like me could build it and change the first few things by myself. Cheers

@lmarzen
Copy link
Owner

lmarzen commented Jun 5, 2024

The interval scales automatically in 5-degree increments. So if there is a lot of temperature variation it will "zoom out" to 10 or 15 degree increments automatically etc.

Here is how to do what you are asking... (ps. I haven't tested this myself but this should hopefully be correct)

Changing 5 ->10 in these lines will change the minimum increment major tick distance from 5 to 10.

int yMajorTicks = 5;

int yTempMajorTicks = 5;

Changing 5 ->10 in these lines will change the default increment from 5 degrees to 10 degrees.

yTempMajorTicks += 5;

Changing the plus/minus 1's in these lines to 5 will make sure there is at least a distance of 5 from the top or bottom of the graph. You could do some math with some variables here to get the 10% that you desire every time.

int tempBoundMin = static_cast<int>(tempMin - 1)
- modulo(static_cast<int>(tempMin - 1), yTempMajorTicks);
int tempBoundMax = static_cast<int>(tempMax + 1)
+ (yTempMajorTicks - modulo(static_cast<int>(tempMax + 1), yTempMajorTicks));
// while we have to many major ticks then increase the step
while ((tempBoundMax - tempBoundMin) / yTempMajorTicks > yMajorTicks)
{
yTempMajorTicks += 5;
tempBoundMin = static_cast<int>(tempMin - 1)
- modulo(static_cast<int>(tempMin - 1), yTempMajorTicks);
tempBoundMax = static_cast<int>(tempMax + 1) + (yTempMajorTicks
- modulo(static_cast<int>(tempMax + 1), yTempMajorTicks));
}

@LordSexy
Copy link
Author

LordSexy commented Jun 6, 2024

signal-2024-06-06-134037
AAAAH. This makes sense.

I was wondering, because I had 10 °C to the bottom and top for a 5°C change on that day.

sure there is at least a distance of 5 from the top or bottom of the graph

That is a good idea, but yesterday it failed on me. For my taste its a bit too much and Ill see how I change it. Maybe I scale it to +-10% or Ill slap 5 °C on each side and leave the "at least" out of the equation.

Ill come back and report on my findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants