Added support for air quality index value, animated preview now shows discharging battery
parent
b09c78a2a2
commit
f2cc221072
|
@ -5,7 +5,8 @@ namespace WatchFace.Parser.Elements.WeatherElements
|
|||
{
|
||||
public class AirPollution
|
||||
{
|
||||
// TODO: Looks like here should be Id 1 also
|
||||
[ParameterId(1)]
|
||||
public Number Index { get; set; }
|
||||
|
||||
[ParameterId(2)]
|
||||
public ImageSet Icon { get; set; }
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using System.Drawing;
|
||||
using WatchFace.Parser.Interfaces;
|
||||
|
||||
namespace WatchFace.Parser.Models.Elements
|
||||
{
|
||||
public class AirQualityIndexNumberElement : NumberElement, IDrawable
|
||||
{
|
||||
public AirQualityIndexNumberElement(Parameter parameter, Element parent = null, string name = null) :
|
||||
base(parameter, parent, name) { }
|
||||
|
||||
public void Draw(Graphics drawer, Bitmap[] resources, WatchState state)
|
||||
{
|
||||
if (state.AirQualityIndex != null)
|
||||
Draw(drawer, resources, state.AirQualityIndex.Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,12 +5,16 @@
|
|||
public AirPollutionElement(Parameter parameter, Element parent = null, string name = null) :
|
||||
base(parameter, parent, name) { }
|
||||
|
||||
public AirQualityIndexNumberElement Index { get; set; }
|
||||
public AirPollutionImageElement Current { get; set; }
|
||||
|
||||
protected override Element CreateChildForParameter(Parameter parameter)
|
||||
{
|
||||
switch (parameter.Id)
|
||||
{
|
||||
case 1:
|
||||
Index = new AirQualityIndexNumberElement(parameter, this);
|
||||
return Index;
|
||||
case 2:
|
||||
Current = new AirPollutionImageElement(parameter, this);
|
||||
return Current;
|
||||
|
|
|
@ -18,7 +18,10 @@ namespace WatchFace.Parser.Models
|
|||
public int? TomorrowDayTemperature { get; set; }
|
||||
public int? TomorrowNightTemperature { get; set; }
|
||||
public WeatherCondition CurrentWeather { get; set; } = WeatherCondition.Cloudy;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Air_quality_index#Mainland_China
|
||||
public AirCondition Air { get; set; } = AirCondition.Excellent;
|
||||
public int? AirQualityIndex { get; set; } = 15;
|
||||
|
||||
public int BatteryLevel { get; set; } = 67;
|
||||
public bool Bluetooth { get; set; } = true;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace WatchFace.Parser
|
|||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
var num = i + 1;
|
||||
watchState.BatteryLevel = num * 10;
|
||||
watchState.BatteryLevel = 100 - (num * 10);
|
||||
|
||||
watchState.Pulse = 60 + num * 2;
|
||||
watchState.Steps = num * 1000;
|
||||
|
@ -36,6 +36,17 @@ namespace WatchFace.Parser
|
|||
watchState.DayTemperature += 2;
|
||||
watchState.NightTemperature += 4;
|
||||
|
||||
if (num < 3)
|
||||
{
|
||||
watchState.Air = AirCondition.Unknown;
|
||||
watchState.AirQualityIndex = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
watchState.Air = (AirCondition) (num - 3);
|
||||
watchState.AirQualityIndex = (num - 2) * 50 - 25;
|
||||
}
|
||||
|
||||
if (num < 3)
|
||||
watchState.CurrentTemperature = null;
|
||||
else if (num == 3)
|
||||
|
|
|
@ -120,6 +120,7 @@
|
|||
<Compile Include="Models\Elements\TimeElement.cs" />
|
||||
<Compile Include="Models\Elements\Common\TwoDigitsElement.cs" />
|
||||
<Compile Include="Models\Elements\WatchFace.cs" />
|
||||
<Compile Include="Models\Elements\Weather\AirPollution\AirQualityIndexNumberElement.cs" />
|
||||
<Compile Include="Models\Elements\Weather\Temperature\Today\OnelineTemperatureElement.cs" />
|
||||
<Compile Include="Models\Elements\Weather\Temperature\CurrentTemperatureElement.cs" />
|
||||
<Compile Include="Models\Elements\Weather\AirPollution\AirPollutionImageElement.cs" />
|
||||
|
|
Loading…
Reference in New Issue