private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts),
new Current(10, Current.UnitType.Amps)
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}