Extend mcp3204 to support 8 channels (mcp3208 variant) (#3332)

This commit is contained in:
RadekHvizdos 2022-04-10 22:44:11 +02:00 committed by GitHub
parent 3297267a16
commit 2b91c23bf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -20,7 +20,7 @@ void MCP3204::dump_config() {
} }
float MCP3204::read_data(uint8_t pin) { float MCP3204::read_data(uint8_t pin) {
uint8_t adc_primary_config = 0b00000110 & 0b00000111; uint8_t adc_primary_config = 0b00000110 | (pin >> 2);
uint8_t adc_secondary_config = pin << 6; uint8_t adc_secondary_config = pin << 6;
this->enable(); this->enable();
this->transfer_byte(adc_primary_config); this->transfer_byte(adc_primary_config);

View file

@ -17,7 +17,7 @@ CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend(
{ {
cv.GenerateID(): cv.declare_id(MCP3204Sensor), cv.GenerateID(): cv.declare_id(MCP3204Sensor),
cv.GenerateID(CONF_MCP3204_ID): cv.use_id(MCP3204), cv.GenerateID(CONF_MCP3204_ID): cv.use_id(MCP3204),
cv.Required(CONF_NUMBER): cv.int_range(min=0, max=3), cv.Required(CONF_NUMBER): cv.int_range(min=0, max=7),
} }
).extend(cv.polling_component_schema("60s")) ).extend(cv.polling_component_schema("60s"))