MCP4461 组件
MCP4461 输出组件通过 I²C 启用使用 8 位外部四数字电位器/可变电阻。更多信息请参见 MCP4461 数据手册。
# Example configuration entrymcp4461: - id: mcp4461_output-
id (可选, ID): 用于此输出组件的 id。
-
address (可选, int): 手动指定数字电位器的 I2C 地址。 默认为
0x2C。 -
disable_wiper_0 (可选, bool): 禁用 wiper 0。默认为
false。 -
disable_wiper_1 (可选, bool): 禁用 wiper 1。默认为
false。 -
disable_wiper_2 (可选, bool): 禁用 wiper 2。默认为
false。 -
disable_wiper_3 (可选, bool): 禁用 wiper 3。默认为
false。
MCP4461 输出
Section titled “MCP4461 输出”MCP4461 输出组件将全局 MCP4461 的 8 个 MCP4461(wiper-)通道作为浮点输出暴露。
# Individual outputs# A-D are volatile wipers 0-3# E-H are nonvolatile wipers 0-3# (AE, BF, CG, DH belonging together)output:- platform: mcp4461 id: digipot_channel_0 mcp4461_id: mcp4461_output channel: A initial_value: 0.5 # always initialize volatile wiper 0 with wiper @ medium resistance range on start- platform: mcp4461 id: digipot_channel_1 mcp4461_id: mcp4461_output channel: B- platform: mcp4461 id: digipot_channel_2 mcp4461_id: mcp4461_output channel: C- platform: mcp4461 id: digipot_channel_3 mcp4461_id: mcp4461_output channel: D- platform: mcp4461 id: digipot_channel_4 mcp4461_id: mcp4461_output channel: E- platform: mcp4461 id: digipot_channel_5 mcp4461_id: mcp4461_output channel: F- platform: mcp4461 id: digipot_channel_6 mcp4461_id: mcp4461_output channel: G- platform: mcp4461 id: digipot_channel_7 mcp4461_id: mcp4461_output channel: H-
id (必需, ID): 用于此输出组件的 id。
-
mcp4461_id (可选, ID): 手动指定 MCP4461 的 ID。 如果你有多个 MCP4461 芯片并希望同时使用,请使用此选项。
-
channel (必需, string): 选择此 MCP4461 输出组件的通道。 可选值为
A、B、C、D、E、F、G或H。 -
initial_value (可选, float): 设置初始 wiper 值,有效范围为
0 - 1.0 -
terminal_a (可选, bool): 如果希望在启动时禁用端子 “A”,请设置为
false。默认为true -
terminal_b (可选, bool): 如果希望在启动时禁用端子 “B”,请设置为
false。默认为true -
terminal_w (可选, bool): 如果希望在启动时禁用端子 “W”,请设置为
false。默认为true -
所有其他选项请参见 输出。
对于 7 位和 8 位数字电位器/可变电阻设备,抽头数通常为 100/257。
对于 MCP4461,范围从 0 到 1.0 的有效输出状态将在内部乘以 256,以获得整数抽头数(范围 [0-256])。
NOTE
如果你不指定 initial_value 配置变量,可以在启动时使用 read_state() 和
update_state() 来获取当前状态。电位器(而非可变电阻)可以以同样的
方式处理。请参见下面的示例。
esphome: on_boot: priority: 100 then: - number.set: id: digipot_volatile_0 value: !lambda |- uint16_t wiper_level = id(digipot_wiper_0).read_state(); return wiper_level;
- lambda: |- id(digipot_wiper_0).update_state();