mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 19:54:14 +01:00
f811b1157c
* Update CI matcher * Check Executable bit * Quicklint * Updates * Allow pm1.0 and pm10.0 for PMS5003ST Fixes https://github.com/esphome/feature-requests/issues/225 * PowerSupplyRequester * Lint * Include debug data in generated main.cpp * Updates * Auto-select bit_depth * Updates
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#include "fastled_light.h"
|
|
#include "esphome/core/log.h"
|
|
|
|
namespace esphome {
|
|
namespace fastled_base {
|
|
|
|
static const char *TAG = "fastled";
|
|
|
|
void FastLEDLightOutput::setup() {
|
|
ESP_LOGCONFIG(TAG, "Setting up FastLED light...");
|
|
this->controller_->init();
|
|
this->controller_->setLeds(this->leds_, this->num_leds_);
|
|
this->effect_data_ = new uint8_t[this->num_leds_];
|
|
if (!this->max_refresh_rate_.has_value()) {
|
|
this->set_max_refresh_rate(this->controller_->getMaxRefreshRate());
|
|
}
|
|
}
|
|
void FastLEDLightOutput::dump_config() {
|
|
ESP_LOGCONFIG(TAG, "FastLED light:");
|
|
ESP_LOGCONFIG(TAG, " Num LEDs: %u", this->num_leds_);
|
|
ESP_LOGCONFIG(TAG, " Max refresh rate: %u", *this->max_refresh_rate_);
|
|
}
|
|
void FastLEDLightOutput::loop() {
|
|
if (!this->should_show_())
|
|
return;
|
|
|
|
uint32_t now = micros();
|
|
// protect from refreshing too often
|
|
if (*this->max_refresh_rate_ != 0 && (now - this->last_refresh_) < *this->max_refresh_rate_) {
|
|
return;
|
|
}
|
|
this->last_refresh_ = now;
|
|
this->mark_shown_();
|
|
|
|
ESP_LOGVV(TAG, "Writing RGB values to bus...");
|
|
this->controller_->showLeds();
|
|
}
|
|
|
|
} // namespace fastled_base
|
|
} // namespace esphome
|