From 49baaa50c7094d159c3c0192e32363fddd552d07 Mon Sep 17 00:00:00 2001 From: Jimmy Wennlund Date: Sun, 8 Sep 2024 23:09:28 +0200 Subject: [PATCH] More work on some feedback --- esphome/components/bl0910/bl0910.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/bl0910/bl0910.h b/esphome/components/bl0910/bl0910.h index 93f09f458b..4d9aa9309f 100644 --- a/esphome/components/bl0910/bl0910.h +++ b/esphome/components/bl0910/bl0910.h @@ -10,12 +10,14 @@ namespace bl0910 { // Mode 1 Trailing clock CPHA=1, Polarity low CPOL=0 -#define NUM_CHANNELS 11 +static const uint8_t NUM_CHANNELS = 11; class BL0910 : public PollingComponent, public spi::SPIDevice { public: + // Sensor index is 1-based to match the BL0910 documentation + // but the array is 0-based to save memory and simplify code void set_voltage_sensor(sensor::Sensor *voltage_sensor, int index, float voltage_reference) { this->voltage_sensor[index - 1] = voltage_sensor; this->voltage_reference[index - 1] = voltage_reference;