本页面介绍 Unit Joystick2 在 ESPHome 中的 I2C 摇杆组件。组件提供 X/Y 轴数值、Z 轴按键状态和板载 RGB 灯控制。
| 项目 | 信息 |
|---|---|
| 产品名称 | Unit Joystick2 |
| SKU | U024-V2 |
| 主要功能 | X/Y 轴摇杆输入、Z 轴按键和 RGB 灯光控制 |
| 通信接口 | I2C |
| 默认 I2C 地址 | 0x63 |
| ESPHome 组件 | i2c_joystick_2(外部组件) |
| ESPHome 版本要求 | / |
external_components:
- source: github://m5stack/esphome-yaml/components
components: [i2c_joystick_2]
refresh: 0s
i2c_joystick_2:
- id: joystick2
i2c_id: i2c_bus
address: 0x63 X、Y 轴使用 i2c_joystick_2 Sensor Platform。axis 可选 x 或 y,mode 可选 adc_16bit、adc_8bit、offset_12bit 或 offset_8bit。
sensor:
- platform: i2c_joystick_2
id: joystick2_x
i2c_joystick_2_id: joystick2
name: "Joystick2 X"
axis: x
mode: offset_12bit
update_interval: 100ms
- platform: i2c_joystick_2
id: joystick2_y
i2c_joystick_2_id: joystick2
name: "Joystick2 Y"
axis: y
mode: offset_12bit
update_interval: 100ms Z 轴按键使用 i2c_joystick_2 Binary Sensor Platform:
binary_sensor:
- platform: i2c_joystick_2
id: joystick2_button
i2c_joystick_2_id: joystick2
name: "Joystick2 Button" 通过三个 i2c_joystick_2 Output 通道组合 RGB 灯实体。通道值为 CHANNEL_R、CHANNEL_G 和 CHANNEL_B:
output:
- platform: i2c_joystick_2
id: joystick2_red
i2c_joystick_2_id: joystick2
channel: CHANNEL_R
- platform: i2c_joystick_2
id: joystick2_green
i2c_joystick_2_id: joystick2
channel: CHANNEL_G
- platform: i2c_joystick_2
id: joystick2_blue
i2c_joystick_2_id: joystick2
channel: CHANNEL_B
light:
- platform: rgb
name: "Joystick2 Light"
red: joystick2_red
green: joystick2_green
blue: joystick2_blue