10 static const char *
const TAG =
"tm1651.display";
12 static const uint8_t MAX_INPUT_LEVEL_PERCENT = 100;
13 static const uint8_t TM1651_MAX_LEVEL = 7;
15 static const uint8_t TM1651_BRIGHTNESS_LOW_HW = 0;
16 static const uint8_t TM1651_BRIGHTNESS_MEDIUM_HW = 2;
17 static const uint8_t TM1651_BRIGHTNESS_HIGH_HW = 7;
20 ESP_LOGCONFIG(TAG,
"Setting up TM1651...");
31 ESP_LOGCONFIG(TAG,
"TM1651 Battery Display");
75 float calculated_level = TM1651_MAX_LEVEL / (float) (MAX_INPUT_LEVEL_PERCENT / (
float) new_level);
76 return (uint8_t) roundf(calculated_level);
80 if (new_brightness <= 1) {
81 return TM1651_BRIGHTNESS_LOW_HW;
82 }
else if (new_brightness == 2) {
83 return TM1651_BRIGHTNESS_MEDIUM_HW;
84 }
else if (new_brightness >= 3) {
85 return TM1651_BRIGHTNESS_HIGH_HW;
88 return TM1651_BRIGHTNESS_LOW_HW;
void dump_config() override
InternalGPIOPin * clk_pin_
void set_level_percent(uint8_t new_level)
uint8_t calculate_level_(uint8_t new_level)
virtual uint8_t get_pin() const =0
InternalGPIOPin * dio_pin_
void set_brightness(uint8_t new_brightness)
uint8_t calculate_brightness_(uint8_t new_brightness)
Implementation of SPI Controller mode.
std::unique_ptr< TM1651 > battery_display_
void set_level(uint8_t new_level)