[tm1637] Add set_brightness method (#15322)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run CodSpeed benchmarks (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04-arm) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04-arm) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
guillempages
2026-04-16 15:46:27 +02:00
committed by GitHub
parent 04a58159d0
commit ee70a4aa72
2 changed files with 10 additions and 0 deletions
+7
View File
@@ -347,6 +347,13 @@ uint8_t TM1637Display::print(uint8_t start_pos, const char *str) {
}
return pos - start_pos;
}
void TM1637Display::set_brightness(float brightness) {
auto intensity = clamp(brightness, 0.f, 1.f) * 7;
this->set_on(intensity > 0);
this->set_intensity(intensity);
}
uint8_t TM1637Display::print(const char *str) { return this->print(0, str); }
void TM1637Display::set_buffer(const uint8_t *data, uint8_t length) {
+3
View File
@@ -50,6 +50,9 @@ class TM1637Display : public PollingComponent {
/// Set raw buffer bytes from data array up to length bytes.
void set_buffer(const uint8_t *data, uint8_t length);
/// Set the display brightness. Accepts a value between 0.0 and 1.0; 0 will turn off
/// the display and 1.0 will set it to the maximum brightness.
void set_brightness(float brightness);
void set_intensity(uint8_t intensity) { this->intensity_ = intensity; }
void set_inverted(bool inverted) { this->inverted_ = inverted; }
void set_length(uint8_t length) { this->length_ = length; }