mirror of
https://github.com/esphome/esphome.git
synced 2025-11-17 07:15:48 +00:00
[ESP32] ADC auto-range setting (#2541)
This commit is contained in:
committed by
GitHub
parent
bcc77c73e1
commit
e79f7ce290
@@ -21,6 +21,7 @@ ATTENUATION_MODES = {
|
||||
"2.5db": cg.global_ns.ADC_ATTEN_DB_2_5,
|
||||
"6db": cg.global_ns.ADC_ATTEN_DB_6,
|
||||
"11db": cg.global_ns.ADC_ATTEN_DB_11,
|
||||
"auto": "auto",
|
||||
}
|
||||
|
||||
|
||||
@@ -92,4 +93,7 @@ async def to_code(config):
|
||||
cg.add(var.set_pin(pin))
|
||||
|
||||
if CONF_ATTENUATION in config:
|
||||
cg.add(var.set_attenuation(config[CONF_ATTENUATION]))
|
||||
if config[CONF_ATTENUATION] == "auto":
|
||||
cg.add(var.set_autorange(cg.global_ns.true))
|
||||
else:
|
||||
cg.add(var.set_attenuation(config[CONF_ATTENUATION]))
|
||||
|
||||
Reference in New Issue
Block a user