User-interaction Resources

torii.platform.resources.user.ButtonResources(name_or_number: str | int | None = None, number: int | None = None, *, pins: str | list[str] | dict[int, str], invert: bool = False, conn: tuple[str, str | int] | None = None, attrs: Attrs | None = None) list[Resource]

Turn a list of pins connected to switches into individual button resources.

Parameters:
  • name_or_number (str | int | None) –

    The common name for the button resources, or the explicit start index for the resources.

    If the name is not supplied, the resources will all have the common name of button.

  • number (int | None) – The explicit start index if name_or_number is the name of the button resources.

  • pins (str | list[str] | dict[int, str]) – The pins for each button.

  • invert (bool) – Invert the logic for the buttons.

  • conn (ResourceConn | None) – The connector these buttons are on if applicable.

  • attrs (Attrs | None) – The attributes to apply to the buttons if applicable.

Return type:

list[Resource]

Returns:

list[Resource] – The collection of expanded button resources.

torii.platform.resources.user.LEDResources(name_or_number: str | int | None = None, number: int | None = None, *, pins: str | list[str] | dict[int, str], invert: bool = False, conn: tuple[str, str | int] | None = None, attrs: Attrs | None = None) list[Resource]

Turn a list of pins connected to switches into individual LED resources.

Parameters:
  • name_or_number (str | int | None) –

    The common name for the LED resources, or the explicit start index for the resources.

    If the name is not supplied, the resources will all have the common name of led.

  • number (int | None) – The explicit start index if name_or_number is the name of the LED resources.

  • pins (str | list[str] | dict[int, str]) – The pins for each LED.

  • invert (bool) – Invert the logic for the LEDs.

  • conn (ResourceConn | None) – The connector these LEDs are on if applicable.

  • attrs (Attrs | None) – The attributes to apply to the LEDs if applicable.

Return type:

list[Resource]

Returns:

list[Resource] – The collection of expanded LED resources.

torii.platform.resources.user.RGBLEDResource(name_or_number: str | int, number: int | None = None, *, r: str, g: str, b: str, invert: bool = False, conn: tuple[str, str | int] | None = None, attrs: Attrs | None = None) Resource

Create an RGB LED resource.

This can be either common cathode or common anode, you simply need to set invert as appropriate.

Parameters:
  • name_or_number (str | int | None) –

    The name of this resource, or the explicit number to assign this resource.

    If no name is specified the default resource name of rgb_led is used.

  • number (int | None) – The explicit number to assign this resource.

  • r (str) – The LEDs red channel.

  • g (str) – The LEDs green channel.

  • b (str) – The LEDs blue channel.

  • invert (bool) – Invert the logic for the buttons.

  • conn (ResourceConn | None) – The connector these buttons are on if applicable.

  • attrs (Attrs | None) – The attributes to apply to the buttons if applicable.

Return type:

Resource

Returns:

Resource – The newly constructed RGB LED resource.

torii.platform.resources.user.SwitchResources(name_or_number: str | int | None = None, number: int | None = None, *, pins: str | list[str] | dict[int, str], invert: bool = False, conn: tuple[str, str | int] | None = None, attrs: Attrs | None = None) list[Resource]

Turn a list of pins connected to switches into individual switch resources.

Parameters:
  • name_or_number (str | int | None) –

    The common name for the switch resources, or the explicit start index for the resources.

    If the name is not supplied, the resources will all have the common name of switch.

  • number (int | None) – The explicit start index if name_or_number is the name of the switch resources.

  • pins (str | list[str] | dict[int, str]) – The pins for each switch.

  • invert (bool) – Invert the logic for the switches.

  • conn (ResourceConn | None) – The connector these switches are on if applicable.

  • attrs (Attrs | None) – The attributes to apply to the switches if applicable.

Return type:

list[Resource]

Returns:

list[Resource] – The collection of expanded switch resources.