ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
max6956.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
7
8namespace esphome::max6956 {
9
17
19enum MAX6956GPIORange : uint8_t {
22};
23
29 MAX6956_PORT_CONFIG_START = 0x09, // Port Configuration P7, P6, P5, P4
30 MAX6956_CURRENT_START = 0x12, // Current054
31 MAX6956_1PORT_VALUE_START = 0x20, // Port 0 only (virtual port, no action)
32 MAX6956_8PORTS_VALUE_START = 0x44, // 8 ports 4-11 (data bits D0-D7)
33};
34
35enum MAX6956GPIOFlag { FLAG_LED = 0x20 };
36
37enum MAX6956CURRENTMODE { GLOBAL = 0x00, SEGMENT = 0x01 };
38
39class MAX6956 final : public Component, public i2c::I2CDevice {
40 public:
41 MAX6956() = default;
42
43 void setup() override;
44
45 bool digital_read(uint8_t pin);
46 void digital_write(uint8_t pin, bool value);
47 void pin_mode(uint8_t pin, gpio::Flags flags);
48 void pin_mode(uint8_t pin, max6956::MAX6956GPIOFlag flags);
49
50 float get_setup_priority() const override { return setup_priority::HARDWARE; }
51
52 void set_brightness_global(uint8_t current);
54 void set_pin_brightness(uint8_t pin, float brightness);
55
56 void dump_config() override;
57
60
61 protected:
62 // read a given register
63 bool read_reg_(uint8_t reg, uint8_t *value);
64 // write a value to a given register
65 bool write_reg_(uint8_t reg, uint8_t value);
68
69 private:
70 int8_t prev_bright_[28] = {0};
71};
72
74
75} // namespace esphome::max6956
76
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:164
float get_setup_priority() const override
Definition max6956.h:50
bool read_reg_(uint8_t reg, uint8_t *value)
Definition max6956.cpp:131
void digital_write(uint8_t pin, bool value)
Definition max6956.cpp:49
void set_brightness_global(uint8_t current)
Definition max6956.cpp:90
void dump_config() override
Definition max6956.cpp:145
bool digital_read(uint8_t pin)
Definition max6956.cpp:42
void set_pin_brightness(uint8_t pin, float brightness)
Definition max6956.cpp:112
max6956::MAX6956CURRENTMODE brightness_mode_
Definition max6956.h:66
void setup() override
Definition max6956.cpp:21
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition max6956.cpp:54
bool write_reg_(uint8_t reg, uint8_t value)
Definition max6956.cpp:138
void set_brightness_mode(max6956::MAX6956CURRENTMODE brightness_mode)
Definition max6956.cpp:100
uint16_t flags
ESPHOME_EXPANDER_PIN_SUMMARY_DECL(esphome::max6956::MAX6956)
@ MAX6956_8PORTS_VALUE_START
Definition max6956.h:32
@ MAX6956_TRANSITION_DETECT_MASK
Definition max6956.h:27
@ MAX6956_GLOBAL_CURRENT
Definition max6956.h:25
@ MAX6956_CONFIGURATION
Definition max6956.h:26
@ MAX6956_1PORT_VALUE_START
Definition max6956.h:31
@ MAX6956_PORT_CONFIG_START
Definition max6956.h:29
@ MAX6956_CURRENT_START
Definition max6956.h:30
MAX6956GPIORange
Range for MAX6956 pins.
Definition max6956.h:19
MAX6956GPIOMode
Modes for MAX6956 pins.
Definition max6956.h:11
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43