ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
mipi_spi_light.h
Go to the documentation of this file.
1#pragma once
2
7
9
10// Brightness-only light that sets the display brightness with an SPI command.
11// Brightness is scaled into [min_brightness, max_brightness]; off writes min_brightness.
12class MipiSpiLight final : public light::LightOutput, public Parented<MipiSpiBrightness> {
13 public:
14 MipiSpiLight(uint8_t min_brightness, uint8_t max_brightness)
15 : min_brightness_(min_brightness), max_brightness_(max_brightness) {}
16
18 auto traits = light::LightTraits();
19 traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
20 return traits;
21 }
22
24 float brightness;
25 state->current_values_as_brightness(&brightness);
26 this->parent_->set_brightness(
27 this->min_brightness_ +
28 static_cast<uint8_t>(roundf(brightness * (this->max_brightness_ - this->min_brightness_))));
29 }
30
31 protected:
34};
35
36} // namespace esphome::mipi_spi
Helper class to easily give an object a parent of type T.
Definition helpers.h:1997
Interface to write LightStates to hardware.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:68
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
light::LightTraits get_traits() override
MipiSpiLight(uint8_t min_brightness, uint8_t max_brightness)
void write_state(light::LightState *state) override
bool state
Definition fan.h:2
@ BRIGHTNESS
Dimmable light.