piggz / harbour-amazfish

Amazfit Bip support for SailfishOS
GNU General Public License v3.0
103 stars 51 forks source link

Weather displays only 0 degrees #323

Closed vige closed 8 months ago

vige commented 8 months ago

Since the latest update (2.2.1) , weather only displays 0 degrees. Otherwise it seems to be working, e.g. it says that today it's clear sky and on Friday we have scattered clouds. But the temperature displays 0 for all days - in reality it's about -20 degrees here.

It worked previously, but I don't know which version broke it as I skipped some versions.

jmlich commented 8 months ago

Can you please tell us what device you have? In previous version, the temperature was clipped to integer right after its download from openweathermap. I have updated the interface to provide qreal. Maybe explicit conversion to int is needed.

piggz commented 8 months ago

He has an Amazfit Bip ... the temp on my GTR2 is working fine, and its the same code path, but the temp where vige is is currently -21 .. maybe something odd going on with casting a negative to char?

vige commented 8 months ago

Can you please tell us what device you have? In previous version, the temperature was clipped to integer right after its download from openweathermap. I have updated the interface to provide qreal. Maybe explicit conversion to int is needed.

I haven't figured out yet where the values get zeroed. But to me it seems the temperatures are still clipped to ints: https://github.com/piggz/harbour-amazfish/blob/d1e25b29347a373b13afaeef3d215aa3982f9d6e/lib/src/weather/currentweather.cpp#L171

vige commented 8 months ago
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.032 : Sending forecast
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.032 : 1704212972
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.032 : Forecast: 0 800 254 251
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.032 : Forecast: 1 800 254 251
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.032 : Forecast: 2 802 254 248
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.032 : Forecast: 3 800 255 248
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.033 : Forecast: 4 803 259 253
tammi 02 18:29:33 Xperia10III harbour-amazfishd[31765]: 2024-01-02 18:29:33.033 : Writing chunked:  "\x01\xEC""9\x94""e\x00\x06\x00\x00\x00\x00""clear sky\x00\x00\x00\x00\x00""clear sky\x00\x00\x00\x00\x00""clear sky\x00\x01\x01\x00\x00scattered clouds\x00\x00\x00\x00\x00""clear sky\x00\x01\x01\x00\x00""broken clouds\x00"

Here the values look correct:

https://github.com/piggz/harbour-amazfish/blob/d1e25b29347a373b13afaeef3d215aa3982f9d6e/daemon/src/services/mibandservice.cpp#L827

Here they are zero:

https://github.com/piggz/harbour-amazfish/blob/d1e25b29347a373b13afaeef3d215aa3982f9d6e/daemon/src/services/mibandservice.cpp#L833

So it seems that - 273.15 doesn't do what one would expect it to do.

piggz commented 8 months ago

I think the problem is the casting of negative floats to char, its definitely around the undefined sections of the c standard! :)

piggz commented 8 months ago

This is fixed in 2.2.2. I think the issue is that on Arm, char is unsigned, so changed the casts to explicitly be int8_t. Tested before and after on my GTR2 and seems ok there.