Skip to content

Conversation

@pgrawehr
Copy link
Contributor

@pgrawehr pgrawehr commented Dec 20, 2025

Add a new Binding for INA236 voltage and current sensor. It's similar to the existing binding INA219 in functionality, but the registers are quite different, so that a common base class is not useful. Could think of a common interface, though.

Alarm features are not implemented as the breakouts from most suppliers don't seem to have the ALRT pin wired out.

Microsoft Reviewers: Open in CodeFlow

@raffaeler
Copy link
Contributor

Could you please split the PRs by differentiating the tasks? I see changes to the lang versions along with other stuff not related to the binding.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a new device binding for the INA236 voltage and current sensor, along with significant improvements to the repository's testing infrastructure and language version standardization.

Key Changes:

  • New INA236 device binding with complete implementation including tests, samples, and documentation
  • Introduction of I2cSimulatedDeviceBase class to provide a reusable testing infrastructure for I2C devices
  • Standardization of C# language version to 12 across the entire repository
  • Refactoring of existing Tca955x tests to use the new simulated device infrastructure

Reviewed changes

Copilot reviewed 79 out of 79 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
src/devices/Ina236/Ina236.cs Main INA236 device implementation with voltage/current/power monitoring capabilities
src/devices/Ina236/Ina236OperatingMode.cs Operating mode enumeration for device configuration
src/devices/Ina236/Ina236Register.cs Register address definitions
src/devices/Ina236/README.md Device documentation and usage examples
src/devices/Ina236/samples/Program.cs Sample code demonstrating device usage
src/devices/Ina236/tests/Ina236Tests.cs Unit tests for INA236 device
src/devices/Ina236/tests/SimulatedIna236.cs Simulated device for testing
src/devices/Common/System/Device/I2c/I2cSimulatedDeviceBase.cs New base class for simulating I2C devices in tests
src/devices/Tca955x/tests/Tca955xSimulatedDevice.cs New simulated device using the base infrastructure
src/devices/Tca955x/tests/Tca9554Tests.cs Refactored tests using new infrastructure
src/devices/Tca955x/tests/Tca9555Tests.cs Refactored tests using new infrastructure
Directory.Build.props Updated default LangVersion to 12
samples/Directory.Build.props Updated default LangVersion to 12
Multiple .csproj files Removed explicit LangVersion settings to use default
src/devices/Gpio/README.md Fixed table formatting and typos
src/devices/Tca955x/README.md Fixed spelling errors
samples/README.md Updated .NET version requirements

Assert.Equal(PinValue.High, value);
pin8.Dispose();
pin0.Dispose();
Assert.False(tcaController.IsPinOpen(8));
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion checks if pin 8 is closed after closing pin 0. This appears to be a copy-paste error - it should check if pin 0 is closed instead.

Copilot uses AI. Check for mistakes.
@dotnet-policy-service dotnet-policy-service bot added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Jan 24, 2026
Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of comments, looks nice!

/// Type B has addresses 0x44 to 0x47, depending on the ADDR pin.
/// </summary>
public const int DefaultI2cAddress = 0x40;
private I2cDevice _i2cDevice;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private readonly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to nullable, so I can throw deterministic ObjectDisposedException's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants