Skip to content

Conversation

@pgrawehr
Copy link
Contributor

@pgrawehr pgrawehr commented Oct 22, 2025

Microsoft Reviewers: Open in CodeFlow

@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 Oct 22, 2025
@joperezr joperezr requested a review from Copilot October 23, 2025 15:38
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 PR introduces a new VirtualGpioControllerWithDefault class to support physical-to-logical pin mapping for GPIO controllers, specifically addressing the need for Raspberry Pi physical pin numbering. The implementation allows dynamic pin mapping through a default controller and a mapping function, replacing previous approaches that lacked this capability.

  • Adds VirtualGpioControllerWithDefault class extending VirtualGpioController with default controller support
  • Implements physical-to-logical pin mapping for Raspberry Pi boards via ConvertPinNumberFromPhysicalToLogical
  • Updates VirtualGpioController.OpenPinCore documentation to guide users toward the new alternative

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/devices/Board/VirtualGpioControllerWithDefault.cs New class providing virtual GPIO controller with default controller and pin mapping function
src/devices/Board/VirtualGpioController.cs Updated documentation for OpenPinCore to reference new alternative implementation
src/devices/Board/RaspberryPiBoard.cs Added methods to create physical pin mapping and conversion logic from physical to logical numbering

throw new InvalidOperationException($"Virtual Pin Number {pinNumber} is in use already");
}
}

Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

The method MapToRealPin is public but lacks XML documentation comments. Public APIs should have comprehensive documentation explaining parameters, return values, and behavior, especially for methods that perform critical mapping operations.

Suggested change
/// <summary>
/// Maps a virtual pin number to the corresponding real pin number using the provided mapping function.
/// </summary>
/// <param name="virtualPin">The virtual pin number to map.</param>
/// <returns>
/// The real pin number corresponding to the virtual pin, or -1 if the mapping function does not recognize the pin.
/// </returns>

Copilot uses AI. Check for mistakes.


/// <summary>
/// Creates a derived GPIO controller that uses physical pin mapping for the Raspberry Pi.
/// </summary>
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

The method CreatePhysicalPinMapping() lacks a <returns> XML documentation tag describing what type of controller is returned and its behavior. This is important for API consumers to understand the returned controller's capabilities.

Suggested change
/// </summary>
/// </summary>
/// <returns>
/// A <see cref="VirtualGpioController"/> that uses physical board numbering for GPIO pins on the Raspberry Pi.
/// The returned controller maps physical pin numbers to the logical numbering scheme used by the underlying driver.
/// </returns>

Copilot uses AI. Check for mistakes.

/// <param name="defaultController">The controller to use. Must be for a Raspberry Pi.</param>
/// <returns>A controller that uses physical board numbering</returns>
/// <remarks>If the provided <paramref name="defaultController"/> is not for a Raspberry Pi, the behavior might be undefined.</remarks>
public static VirtualGpioController CreatePhysicalPinMapping(GpioController defaultController)
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

The static overload of CreatePhysicalPinMapping is missing a <returns> XML documentation tag. Public API methods should document their return values to clarify what the returned controller provides.

Copilot uses AI. Check for mistakes.

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.

1 participant