ByteSwitchUnit
Unit ByteSwitch is an 8-switch touch switch input unit equipped with 8 switch inputs and 9 WS2812C RGB LEDs. It uses the STM32 microcontroller and supports I2C communication. The board includes two Port A interfaces and supports cascading multiple Unit ByteSwitch modules, making it suitable for complex systems. It can achieve switch input detection and dynamic lighting feedback, ideal for smart home control, gaming devices, educational platforms, industrial status displays, and interactive exhibitions.
Support the following products:
class ByteSwitchUnit
Constructors
Methods
- ByteSwitchUnit.get_byte_switch_state() int
Get the status of all switchs as an integer, where each bit represents the state of each switch.
UIFLOW2:

- ByteSwitchUnit.get_switch_state(num) bool
Get the state of a specific switch.
- 参数:
num (int) – The index of the switch (0-7).
UIFLOW2:

- ByteSwitchUnit.set_led_show_mode(mode)
Set the LED show mode.
- 参数:
mode (int) –
The LED show mode to set.
- Options:
BYTEBUTTON_LED_USER_MODE: 0BYTEBUTTON_LED_SYS_MODE: 1
UIFLOW2:

- ByteSwitchUnit.set_led_brightness(num, brightness)
Set the brightness of a specific LED.
UIFLOW2:

- ByteSwitchUnit.get_led_brightness(num) int
Get the brightness of a specific LED.
- 参数:
num (int) – The index of the LED (0-7).
UIFLOW2:

- ByteSwitchUnit.set_led_color(num, color, led_show_mode, btn_is_pressed)
Set the color of a specific LED.
- 参数:
UIFLOW2:

- ByteSwitchUnit.get_led_color(num, led_show_mode, btn_is_pressed) int
Get the color of a specific LED.
- 参数:
UIFLOW2:

- ByteSwitchUnit.set_indicator_brightness(brightness)
Set the brightness of the indicator LED.
- 参数:
brightness (int) – The brightness level (0-255).
UIFLOW2:

- ByteSwitchUnit.set_indicator_color(color)
Set the color of the indicator LED in RGB888 format.
- 参数:
color (int) – The RGB888 color value to set.
UIFLOW2:

- ByteSwitchUnit.get_indicator_color() int
Get the color of the indicator LED in RGB888 format.
UIFLOW2:

- ByteSwitchUnit.rgb888_to_rgb233(color)
Convert an RGB888 color value to RGB233 format.
- 参数:
color (int) – The RGB888 color value as a 32-bit integer.
UIFLOW2:

- ByteSwitchUnit.set_rgb233(num, color)
Set the color of a specific LED in RGB233 format.
UIFLOW2:

- ByteSwitchUnit.get_rgb233(num)
Get the color of a specific LED in RGB233 format.
- 参数:
num (int) – The index of the LED (0-7).
UIFLOW2:

- ByteSwitchUnit.set_irq_enable(enable)
Enable or disable IRQ functionality.
- 参数:
enable (bool) – Whether to enable (True) or disable (False) IRQ.
UIFLOW2:

- ByteSwitchUnit.get_irq_enable()
Get the current IRQ enable status.
UIFLOW2:

- ByteSwitchUnit.save_to_flash()
Save the current user settings to flash.
UIFLOW2:







