10static const char *
const TAG =
"tm1651.display";
12static const uint8_t MAX_INPUT_LEVEL_PERCENT = 100;
13static const uint8_t TM1651_MAX_LEVEL = 7;
15static const uint8_t TM1651_BRIGHTNESS_LOW_HW = 0;
16static const uint8_t TM1651_BRIGHTNESS_MEDIUM_HW = 2;
17static 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;
virtual uint8_t get_pin() const =0
std::unique_ptr< TM1651 > battery_display_
InternalGPIOPin * clk_pin_
void set_level_percent(uint8_t new_level)
uint8_t calculate_level_(uint8_t new_level)
void set_brightness(uint8_t new_brightness)
uint8_t calculate_brightness_(uint8_t new_brightness)
InternalGPIOPin * dio_pin_
void set_level(uint8_t new_level)
void dump_config() override
Providing packet encoding functions for exchanging data with a remote host.
std::unique_ptr< T > make_unique(Args &&...args)