WindVane windVane;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
windVane = new WindVane(Device.Pins.A00);
windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");
var observer = WindVane.CreateObserver(
handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
filter: null
);
windVane.Subscribe(observer);
return Task.CompletedTask;
}
public override async Task Run()
{
Azimuth azi = await windVane.Read();
Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");
windVane.StartUpdating(TimeSpan.FromSeconds(1));
}