diff --git a/esphome/components/max6956/max6956.cpp b/esphome/components/max6956/max6956.cpp index 7c684315d7..33b4e26c0a 100644 --- a/esphome/components/max6956/max6956.cpp +++ b/esphome/components/max6956/max6956.cpp @@ -70,7 +70,7 @@ bool MAX6956::digital_read_hw(uint8_t pin) { // Store in cache with proper alignment if (bank_index == 0) { // Special case for bank 0: pins 4-7 are in bits D0-D3, shift them to bits 4-7 - this->input_banks_[0] = value << 4; + this->input_banks_[0] = value << MAX6956_BANK0_SHIFT; } else { // Banks 1-3 map directly this->input_banks_[bank_index] = value; diff --git a/esphome/components/max6956/max6956.h b/esphome/components/max6956/max6956.h index 3bfed4c500..5d0760cab0 100644 --- a/esphome/components/max6956/max6956.h +++ b/esphome/components/max6956/max6956.h @@ -24,6 +24,8 @@ enum MAX6956GPIORange : uint8_t { /// Bank configuration for MAX6956 static constexpr uint8_t MAX6956_BANK_SIZE = 8; +static constexpr uint8_t MAX6956_TOTAL_PINS = 32; // Includes pins 0-3 (unused) for cache alignment +static constexpr uint8_t MAX6956_BANK0_SHIFT = 4; enum MAX6956GPIORegisters { MAX6956_GLOBAL_CURRENT = 0x02, @@ -44,7 +46,9 @@ enum MAX6956GPIOFlag { FLAG_LED = 0x20 }; enum MAX6956CURRENTMODE { GLOBAL = 0x00, SEGMENT = 0x01 }; -class MAX6956 : public Component, public i2c::I2CDevice, public gpio_expander::CachedGpioExpander { +class MAX6956 : public Component, + public i2c::I2CDevice, + public gpio_expander::CachedGpioExpander { public: MAX6956() = default;