mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-26 11:56:48 +01:00
BUGFIX: use newer weather icons, if firmware build is B41 or higher. The new firmware supports 24 icons, older ones have only 6.
This commit is contained in:
parent
8af6515df8
commit
c30ec7d407
@ -600,7 +600,7 @@ public class Weather {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte mapToZeTimeCondition(int openWeatherMapCondition) {
|
public static byte mapToZeTimeConditionOld(int openWeatherMapCondition) {
|
||||||
/* deducted values:
|
/* deducted values:
|
||||||
0 = partly cloudy
|
0 = partly cloudy
|
||||||
1 = cloudy
|
1 = cloudy
|
||||||
@ -709,4 +709,174 @@ public class Weather {
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte mapToZeTimeCondition(int openWeatherMapCondition) {
|
||||||
|
/* deducted values:
|
||||||
|
0 = tornado
|
||||||
|
1 = typhoon
|
||||||
|
2 = hurricane
|
||||||
|
3 = thunderstorm
|
||||||
|
4 = rain and snow
|
||||||
|
5 = unavailable
|
||||||
|
6 = freezing rain
|
||||||
|
7 = drizzle
|
||||||
|
8 = showers
|
||||||
|
9 = snow flurries
|
||||||
|
10 = blowing snow
|
||||||
|
11 = snow
|
||||||
|
12 = sleet
|
||||||
|
13 = foggy
|
||||||
|
14 = windy
|
||||||
|
15 = cloudy
|
||||||
|
16 = partly cloudy (night)
|
||||||
|
17 = partly cloudy (day)
|
||||||
|
18 = clear night
|
||||||
|
19 = sunny
|
||||||
|
20 = thundershower
|
||||||
|
21 = hot
|
||||||
|
22 = scattered thunders
|
||||||
|
23 = snow showers
|
||||||
|
24 = heavy snow
|
||||||
|
*/
|
||||||
|
switch (openWeatherMapCondition) {
|
||||||
|
//Group 2xx: Thunderstorm
|
||||||
|
case 210: //light thunderstorm:: //11d
|
||||||
|
return 22;
|
||||||
|
|
||||||
|
//Group 2xx: Thunderstorm
|
||||||
|
case 200: //thunderstorm with light rain: //11d
|
||||||
|
case 201: //thunderstorm with rain: //11d
|
||||||
|
case 202: //thunderstorm with heavy rain: //11d
|
||||||
|
case 230: //thunderstorm with light drizzle: //11d
|
||||||
|
case 231: //thunderstorm with drizzle: //11d
|
||||||
|
case 232: //thunderstorm with heavy drizzle: //11d
|
||||||
|
return 20;
|
||||||
|
|
||||||
|
//Group 2xx: Thunderstorm
|
||||||
|
case 211: //thunderstorm: //11d
|
||||||
|
case 212: //heavy thunderstorm: //11d
|
||||||
|
case 221: //ragged thunderstorm: //11d
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
//Group 7xx: Atmosphere
|
||||||
|
case 781: //tornado: //[[file:50d.png]]
|
||||||
|
//Group 90x: Extreme
|
||||||
|
case 900: //tornado
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
//Group 90x: Extreme
|
||||||
|
case 901: //tropical storm
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Group 7xx: Atmosphere
|
||||||
|
case 771: //squalls: //[[file:50d.png]]
|
||||||
|
//Group 9xx: Additional
|
||||||
|
case 960: //storm
|
||||||
|
case 961: //violent storm
|
||||||
|
case 902: //hurricane
|
||||||
|
case 962: //hurricane
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
//Group 3xx: Drizzle
|
||||||
|
case 300: //light intensity drizzle: //09d
|
||||||
|
case 301: //drizzle: //09d
|
||||||
|
case 302: //heavy intensity drizzle: //09d
|
||||||
|
case 310: //light intensity drizzle rain: //09d
|
||||||
|
case 311: //drizzle rain: //09d
|
||||||
|
case 312: //heavy intensity drizzle rain: //09d
|
||||||
|
case 313: //shower rain and drizzle: //09d
|
||||||
|
case 314: //heavy shower rain and drizzle: //09d
|
||||||
|
case 321: //shower drizzle: //09d
|
||||||
|
return 7;
|
||||||
|
|
||||||
|
//Group 5xx: Rain
|
||||||
|
case 500: //light rain: //10d
|
||||||
|
case 501: //moderate rain: //10d
|
||||||
|
case 502: //heavy intensity rain: //10d
|
||||||
|
case 503: //very heavy rain: //10d
|
||||||
|
case 504: //extreme rain: //10d
|
||||||
|
case 520: //light intensity shower rain: //09d
|
||||||
|
case 521: //shower rain: //09d
|
||||||
|
case 522: //heavy intensity shower rain: //09d
|
||||||
|
case 531: //ragged shower rain: //09d
|
||||||
|
//Group 90x: Extreme
|
||||||
|
case 906: //hail
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
//Group 5xx: Rain
|
||||||
|
case 511: //freezing rain: //13d
|
||||||
|
return 6;
|
||||||
|
|
||||||
|
//Group 6xx: Snow
|
||||||
|
case 620: //light shower snow: //[[file:13d.png]]
|
||||||
|
case 621: //shower snow: //[[file:13d.png]]
|
||||||
|
case 622: //heavy shower snow: //[[file:13d.png]]
|
||||||
|
return 23;
|
||||||
|
|
||||||
|
//Group 6xx: Snow
|
||||||
|
case 615: //light rain and snow: //[[file:13d.png]]
|
||||||
|
case 616: //rain and snow: //[[file:13d.png]]
|
||||||
|
return 4;
|
||||||
|
|
||||||
|
//Group 6xx: Snow
|
||||||
|
case 611: //sleet: //[[file:13d.png]]
|
||||||
|
case 612: //shower sleet: //[[file:13d.png]]
|
||||||
|
return 12;
|
||||||
|
|
||||||
|
//Group 6xx: Snow
|
||||||
|
case 600: //light snow: //[[file:13d.png]]
|
||||||
|
case 601: //snow: //[[file:13d.png]]
|
||||||
|
return 11;
|
||||||
|
//Group 6xx: Snow
|
||||||
|
case 602: //heavy snow: //[[file:13d.png]]
|
||||||
|
return 24;
|
||||||
|
|
||||||
|
//Group 7xx: Atmosphere
|
||||||
|
case 701: //mist: //[[file:50d.png]]
|
||||||
|
case 711: //smoke: //[[file:50d.png]]
|
||||||
|
case 721: //haze: //[[file:50d.png]]
|
||||||
|
case 731: //sandcase dust whirls: //[[file:50d.png]]
|
||||||
|
case 741: //fog: //[[file:50d.png]]
|
||||||
|
case 751: //sand: //[[file:50d.png]]
|
||||||
|
case 761: //dust: //[[file:50d.png]]
|
||||||
|
case 762: //volcanic ash: //[[file:50d.png]]
|
||||||
|
return 13;
|
||||||
|
|
||||||
|
//Group 800: Clear
|
||||||
|
case 800: //clear sky: //[[file:01d.png]] [[file:01n.png]]
|
||||||
|
return 19;
|
||||||
|
|
||||||
|
//Group 90x: Extreme
|
||||||
|
case 904: //hot
|
||||||
|
return 21;
|
||||||
|
|
||||||
|
//Group 80x: Clouds
|
||||||
|
case 801: //few clouds: //[[file:02d.png]] [[file:02n.png]]
|
||||||
|
case 802: //scattered clouds: //[[file:03d.png]] [[file:03d.png]]
|
||||||
|
case 803: //broken clouds: //[[file:04d.png]] [[file:03d.png]]
|
||||||
|
return 17;
|
||||||
|
|
||||||
|
//Group 80x: Clouds
|
||||||
|
case 804: //overcast clouds: //[[file:04d.png]] [[file:04d.png]]
|
||||||
|
return 15;
|
||||||
|
|
||||||
|
//Group 9xx: Additional
|
||||||
|
case 905: //windy
|
||||||
|
case 951: //calm
|
||||||
|
case 952: //light breeze
|
||||||
|
case 953: //gentle breeze
|
||||||
|
case 954: //moderate breeze
|
||||||
|
case 955: //fresh breeze
|
||||||
|
case 956: //strong breeze
|
||||||
|
case 957: //high windcase near gale
|
||||||
|
case 958: //gale
|
||||||
|
case 959: //severe gale
|
||||||
|
return 14;
|
||||||
|
|
||||||
|
default:
|
||||||
|
//Group 90x: Extreme
|
||||||
|
case 903: //cold
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,6 +412,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendWeather(WeatherSpec weatherSpec) {
|
public void onSendWeather(WeatherSpec weatherSpec) {
|
||||||
|
String buildnumber = versionCmd.fwVersion.substring(versionCmd.fwVersion.length() - 4);
|
||||||
byte[] weather = new byte[weatherSpec.location.getBytes(StandardCharsets.UTF_8).length + 26]; // 26 bytes for weatherdata and overhead
|
byte[] weather = new byte[weatherSpec.location.getBytes(StandardCharsets.UTF_8).length + 26]; // 26 bytes for weatherdata and overhead
|
||||||
weather[0] = ZeTimeConstants.CMD_PREAMBLE;
|
weather[0] = ZeTimeConstants.CMD_PREAMBLE;
|
||||||
weather[1] = ZeTimeConstants.CMD_PUSH_WEATHER_DATA;
|
weather[1] = ZeTimeConstants.CMD_PUSH_WEATHER_DATA;
|
||||||
@ -422,7 +423,14 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
weather[6] = (byte)(weatherSpec.currentTemp - 273);
|
weather[6] = (byte)(weatherSpec.currentTemp - 273);
|
||||||
weather[7] = (byte)(weatherSpec.todayMinTemp - 273);
|
weather[7] = (byte)(weatherSpec.todayMinTemp - 273);
|
||||||
weather[8] = (byte)(weatherSpec.todayMaxTemp - 273);
|
weather[8] = (byte)(weatherSpec.todayMaxTemp - 273);
|
||||||
|
|
||||||
|
if (buildnumber.compareTo("B4.1") >= 0) // if using firmware 1.7 Build 41 and above use newer icons
|
||||||
|
{
|
||||||
weather[9] = Weather.mapToZeTimeCondition(weatherSpec.currentConditionCode);
|
weather[9] = Weather.mapToZeTimeCondition(weatherSpec.currentConditionCode);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
weather[9] = Weather.mapToZeTimeConditionOld(weatherSpec.currentConditionCode);
|
||||||
|
}
|
||||||
for(int forecast = 0; forecast < 3; forecast++) {
|
for(int forecast = 0; forecast < 3; forecast++) {
|
||||||
weather[10+(forecast*5)] = 0; // celsius
|
weather[10+(forecast*5)] = 0; // celsius
|
||||||
weather[11+(forecast*5)] = (byte) 0xff;
|
weather[11+(forecast*5)] = (byte) 0xff;
|
||||||
|
Loading…
Reference in New Issue
Block a user