mirror of https://github.com/esphome/esphome.git
Compare commits
3 Commits
9fa19df2ff
...
ceb0564ebf
Author | SHA1 | Date |
---|---|---|
Oxan van Leeuwen | ceb0564ebf | |
Oxan van Leeuwen | 20f7eb7327 | |
Oxan van Leeuwen | 441d5bd44d |
|
@ -42,7 +42,7 @@ void AdalightLightEffect::reset_frame_(light::AddressableLight &it) {
|
|||
|
||||
void AdalightLightEffect::blank_all_leds_(light::AddressableLight &it) {
|
||||
for (int led = it.size(); led-- > 0;) {
|
||||
it[led].set(COLOR_BLACK);
|
||||
it[led].set(Color::BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,9 @@ class ClimateCall {
|
|||
* For climate devices with two point target temperature control
|
||||
*/
|
||||
ClimateCall &set_target_temperature_high(optional<float> target_temperature_high);
|
||||
ESPDEPRECATED("set_away() is deprecated, please use .set_preset(CLIMATE_PRESET_AWAY) instead")
|
||||
ESPDEPRECATED("set_away() is deprecated, please use .set_preset(CLIMATE_PRESET_AWAY) instead", "v1.20")
|
||||
ClimateCall &set_away(bool away);
|
||||
ESPDEPRECATED("set_away() is deprecated, please use .set_preset(CLIMATE_PRESET_AWAY) instead")
|
||||
ESPDEPRECATED("set_away() is deprecated, please use .set_preset(CLIMATE_PRESET_AWAY) instead", "v1.20")
|
||||
ClimateCall &set_away(optional<bool> away);
|
||||
/// Set the fan mode of the climate device.
|
||||
ClimateCall &set_fan_mode(ClimateFanMode fan_mode);
|
||||
|
@ -96,7 +96,7 @@ class ClimateCall {
|
|||
const optional<float> &get_target_temperature() const;
|
||||
const optional<float> &get_target_temperature_low() const;
|
||||
const optional<float> &get_target_temperature_high() const;
|
||||
ESPDEPRECATED("get_away() is deprecated, please use .get_preset() instead")
|
||||
ESPDEPRECATED("get_away() is deprecated, please use .get_preset() instead", "v1.20")
|
||||
optional<bool> get_away() const;
|
||||
const optional<ClimateFanMode> &get_fan_mode() const;
|
||||
const optional<ClimateSwingMode> &get_swing_mode() const;
|
||||
|
@ -193,7 +193,7 @@ class Climate : public Nameable {
|
|||
* Away allows climate devices to have two different target temperature configs:
|
||||
* one for normal mode and one for away mode.
|
||||
*/
|
||||
ESPDEPRECATED("away is deprecated, use preset instead")
|
||||
ESPDEPRECATED("away is deprecated, use preset instead", "v1.20")
|
||||
bool away{false};
|
||||
|
||||
/// The active fan mode of the climate device.
|
||||
|
|
|
@ -50,19 +50,19 @@ class ClimateTraits {
|
|||
}
|
||||
void set_supported_modes(std::set<ClimateMode> modes) { supported_modes_ = std::move(modes); }
|
||||
void add_supported_mode(ClimateMode mode) { supported_modes_.insert(mode); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
||||
void set_supports_auto_mode(bool supports_auto_mode) { set_mode_support_(CLIMATE_MODE_AUTO, supports_auto_mode); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
||||
void set_supports_cool_mode(bool supports_cool_mode) { set_mode_support_(CLIMATE_MODE_COOL, supports_cool_mode); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
||||
void set_supports_heat_mode(bool supports_heat_mode) { set_mode_support_(CLIMATE_MODE_HEAT, supports_heat_mode); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
||||
void set_supports_heat_cool_mode(bool supported) { set_mode_support_(CLIMATE_MODE_HEAT_COOL, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
||||
void set_supports_fan_only_mode(bool supports_fan_only_mode) {
|
||||
set_mode_support_(CLIMATE_MODE_FAN_ONLY, supports_fan_only_mode);
|
||||
}
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
||||
void set_supports_dry_mode(bool supports_dry_mode) { set_mode_support_(CLIMATE_MODE_DRY, supports_dry_mode); }
|
||||
bool supports_mode(ClimateMode mode) const { return supported_modes_.count(mode); }
|
||||
const std::set<ClimateMode> get_supported_modes() const { return supported_modes_; }
|
||||
|
@ -72,23 +72,23 @@ class ClimateTraits {
|
|||
|
||||
void set_supported_fan_modes(std::set<ClimateFanMode> modes) { supported_fan_modes_ = std::move(modes); }
|
||||
void add_supported_fan_mode(ClimateFanMode mode) { supported_fan_modes_.insert(mode); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_on(bool supported) { set_fan_mode_support_(CLIMATE_FAN_ON, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_off(bool supported) { set_fan_mode_support_(CLIMATE_FAN_OFF, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_auto(bool supported) { set_fan_mode_support_(CLIMATE_FAN_AUTO, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_low(bool supported) { set_fan_mode_support_(CLIMATE_FAN_LOW, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_medium(bool supported) { set_fan_mode_support_(CLIMATE_FAN_MEDIUM, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_high(bool supported) { set_fan_mode_support_(CLIMATE_FAN_HIGH, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_middle(bool supported) { set_fan_mode_support_(CLIMATE_FAN_MIDDLE, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_focus(bool supported) { set_fan_mode_support_(CLIMATE_FAN_FOCUS, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_fan_modes() instead", "v1.20")
|
||||
void set_supports_fan_mode_diffuse(bool supported) { set_fan_mode_support_(CLIMATE_FAN_DIFFUSE, supported); }
|
||||
bool supports_fan_mode(ClimateFanMode fan_mode) const { return supported_fan_modes_.count(fan_mode); }
|
||||
bool get_supports_fan_modes() const { return !supported_fan_modes_.empty() || !supported_custom_fan_modes_.empty(); }
|
||||
|
@ -115,25 +115,25 @@ class ClimateTraits {
|
|||
bool supports_custom_preset(const std::string &custom_preset) const {
|
||||
return supported_custom_presets_.count(custom_preset);
|
||||
}
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_presets() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_presets() instead", "v1.20")
|
||||
void set_supports_away(bool supports) {
|
||||
if (supports) {
|
||||
supported_presets_.insert(CLIMATE_PRESET_AWAY);
|
||||
supported_presets_.insert(CLIMATE_PRESET_HOME);
|
||||
}
|
||||
}
|
||||
ESPDEPRECATED("This method is deprecated, use supports_preset() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use supports_preset() instead", "v1.20")
|
||||
bool get_supports_away() const { return supports_preset(CLIMATE_PRESET_AWAY); }
|
||||
|
||||
void set_supported_swing_modes(std::set<ClimateSwingMode> modes) { supported_swing_modes_ = std::move(modes); }
|
||||
void add_supported_swing_mode(ClimateSwingMode mode) { supported_swing_modes_.insert(mode); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead", "v1.20")
|
||||
void set_supports_swing_mode_off(bool supported) { set_swing_mode_support_(CLIMATE_SWING_OFF, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead", "v1.20")
|
||||
void set_supports_swing_mode_both(bool supported) { set_swing_mode_support_(CLIMATE_SWING_BOTH, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead", "v1.20")
|
||||
void set_supports_swing_mode_vertical(bool supported) { set_swing_mode_support_(CLIMATE_SWING_VERTICAL, supported); }
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead")
|
||||
ESPDEPRECATED("This method is deprecated, use set_supported_swing_modes() instead", "v1.20")
|
||||
void set_supports_swing_mode_horizontal(bool supported) {
|
||||
set_swing_mode_support_(CLIMATE_SWING_HORIZONTAL, supported);
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ bool Image::get_pixel(int x, int y) const {
|
|||
}
|
||||
Color Image::get_color_pixel(int x, int y) const {
|
||||
if (x < 0 || x >= this->width_ || y < 0 || y >= this->height_)
|
||||
return 0;
|
||||
return Color::BLACK;
|
||||
const uint32_t pos = (x + y * this->width_) * 3;
|
||||
const uint32_t color32 = (pgm_read_byte(this->data_start_ + pos + 2) << 0) |
|
||||
(pgm_read_byte(this->data_start_ + pos + 1) << 8) |
|
||||
|
@ -470,7 +470,7 @@ Color Image::get_color_pixel(int x, int y) const {
|
|||
}
|
||||
Color Image::get_grayscale_pixel(int x, int y) const {
|
||||
if (x < 0 || x >= this->width_ || y < 0 || y >= this->height_)
|
||||
return 0;
|
||||
return Color::BLACK;
|
||||
const uint32_t pos = (x + y * this->width_);
|
||||
const uint8_t gray = pgm_read_byte(this->data_start_ + pos);
|
||||
return Color(gray | gray << 8 | gray << 16 | gray << 24);
|
||||
|
@ -493,10 +493,10 @@ bool Animation::get_pixel(int x, int y) const {
|
|||
}
|
||||
Color Animation::get_color_pixel(int x, int y) const {
|
||||
if (x < 0 || x >= this->width_ || y < 0 || y >= this->height_)
|
||||
return 0;
|
||||
return Color::BLACK;
|
||||
const uint32_t frame_index = this->width_ * this->height_ * this->current_frame_;
|
||||
if (frame_index >= this->width_ * this->height_ * this->animation_frame_count_)
|
||||
return 0;
|
||||
return Color::BLACK;
|
||||
const uint32_t pos = (x + y * this->width_ + frame_index) * 3;
|
||||
const uint32_t color32 = (pgm_read_byte(this->data_start_ + pos + 2) << 0) |
|
||||
(pgm_read_byte(this->data_start_ + pos + 1) << 8) |
|
||||
|
@ -505,10 +505,10 @@ Color Animation::get_color_pixel(int x, int y) const {
|
|||
}
|
||||
Color Animation::get_grayscale_pixel(int x, int y) const {
|
||||
if (x < 0 || x >= this->width_ || y < 0 || y >= this->height_)
|
||||
return 0;
|
||||
return Color::BLACK;
|
||||
const uint32_t frame_index = this->width_ * this->height_ * this->current_frame_;
|
||||
if (frame_index >= this->width_ * this->height_ * this->animation_frame_count_)
|
||||
return 0;
|
||||
return Color::BLACK;
|
||||
const uint32_t pos = (x + y * this->width_ + frame_index);
|
||||
const uint8_t gray = pgm_read_byte(this->data_start_ + pos);
|
||||
return Color(gray | gray << 8 | gray << 16 | gray << 24);
|
||||
|
|
|
@ -225,7 +225,7 @@ void ILI9341M5Stack::initialize() {
|
|||
this->width_ = 320;
|
||||
this->height_ = 240;
|
||||
this->invert_display_(true);
|
||||
this->fill_internal_(COLOR_BLACK);
|
||||
this->fill_internal_(Color::BLACK);
|
||||
}
|
||||
|
||||
// 24_TFT display
|
||||
|
@ -233,7 +233,7 @@ void ILI9341TFT24::initialize() {
|
|||
this->init_lcd_(INITCMD_TFT);
|
||||
this->width_ = 240;
|
||||
this->height_ = 320;
|
||||
this->fill_internal_(COLOR_BLACK);
|
||||
this->fill_internal_(Color::BLACK);
|
||||
}
|
||||
|
||||
} // namespace ili9341
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace esphome {
|
||||
namespace light {
|
||||
|
||||
using ESPColor = Color;
|
||||
using ESPColor ESPDEPRECATED("esphome::light::ESPColor is deprecated, use esphome::Color instead.", "v1.21") = Color;
|
||||
|
||||
class AddressableLight : public LightOutput, public Component {
|
||||
public:
|
||||
|
|
|
@ -151,7 +151,7 @@ class AddressableScanEffect : public AddressableLightEffect {
|
|||
void set_move_interval(uint32_t move_interval) { this->move_interval_ = move_interval; }
|
||||
void set_scan_width(uint32_t scan_width) { this->scan_width_ = scan_width; }
|
||||
void apply(AddressableLight &it, const Color ¤t_color) override {
|
||||
it.all() = COLOR_BLACK;
|
||||
it.all() = Color::BLACK;
|
||||
|
||||
for (auto i = 0; i < this->scan_width_; i++) {
|
||||
it[this->at_led_ + i] = current_color;
|
||||
|
@ -201,7 +201,7 @@ class AddressableTwinkleEffect : public AddressableLightEffect {
|
|||
else
|
||||
view.set_effect_data(new_pos);
|
||||
} else {
|
||||
view = COLOR_BLACK;
|
||||
view = Color::BLACK;
|
||||
}
|
||||
}
|
||||
while (random_float() < this->twinkle_probability_) {
|
||||
|
@ -272,7 +272,7 @@ class AddressableFireworksEffect : public AddressableLightEffect {
|
|||
explicit AddressableFireworksEffect(const std::string &name) : AddressableLightEffect(name) {}
|
||||
void start() override {
|
||||
auto &it = *this->get_addressable_();
|
||||
it.all() = COLOR_BLACK;
|
||||
it.all() = Color::BLACK;
|
||||
}
|
||||
void apply(AddressableLight &it, const Color ¤t_color) override {
|
||||
const uint32_t now = millis();
|
||||
|
|
|
@ -179,7 +179,7 @@ class LightColorValues {
|
|||
/// Convert these light color values to an CWWW representation with the given parameters.
|
||||
void as_cwww(float color_temperature_cw, float color_temperature_ww, float *cold_white, float *warm_white,
|
||||
float gamma = 0, bool constant_brightness = false) const {
|
||||
if (this->color_mode_ & ColorMode::COLD_WARM_WHITE) {
|
||||
if (this->color_mode_ & ColorCapability::COLD_WARM_WHITE) {
|
||||
const float cw_level = gamma_correct(this->cold_white_, gamma);
|
||||
const float ww_level = gamma_correct(this->warm_white_, gamma);
|
||||
const float white_level = gamma_correct(this->state_ * this->brightness_, gamma);
|
||||
|
|
|
@ -26,20 +26,20 @@ class LightTraits {
|
|||
return false;
|
||||
}
|
||||
|
||||
ESPDEPRECATED("get_supports_brightness() is deprecated, use color modes instead.")
|
||||
ESPDEPRECATED("get_supports_brightness() is deprecated, use color modes instead.", "v1.21")
|
||||
bool get_supports_brightness() const { return this->supports_color_capability(ColorCapability::BRIGHTNESS); }
|
||||
ESPDEPRECATED("get_supports_rgb() is deprecated, use color modes instead.")
|
||||
ESPDEPRECATED("get_supports_rgb() is deprecated, use color modes instead.", "v1.21")
|
||||
bool get_supports_rgb() const { return this->supports_color_capability(ColorCapability::RGB); }
|
||||
ESPDEPRECATED("get_supports_rgb_white_value() is deprecated, use color modes instead.")
|
||||
ESPDEPRECATED("get_supports_rgb_white_value() is deprecated, use color modes instead.", "v1.21")
|
||||
bool get_supports_rgb_white_value() const {
|
||||
return this->supports_color_mode(ColorMode::RGB_WHITE) ||
|
||||
this->supports_color_mode(ColorMode::RGB_COLOR_TEMPERATURE);
|
||||
}
|
||||
ESPDEPRECATED("get_supports_color_temperature() is deprecated, use color modes instead.")
|
||||
ESPDEPRECATED("get_supports_color_temperature() is deprecated, use color modes instead.", "v1.21")
|
||||
bool get_supports_color_temperature() const {
|
||||
return this->supports_color_capability(ColorCapability::COLOR_TEMPERATURE);
|
||||
}
|
||||
ESPDEPRECATED("get_supports_color_interlock() is deprecated, use color modes instead.")
|
||||
ESPDEPRECATED("get_supports_color_interlock() is deprecated, use color modes instead.", "v1.21")
|
||||
bool get_supports_color_interlock() const {
|
||||
return this->supports_color_mode(ColorMode::RGB) &&
|
||||
(this->supports_color_mode(ColorMode::WHITE) || this->supports_color_mode(ColorMode::COLD_WARM_WHITE) ||
|
||||
|
|
|
@ -1086,8 +1086,8 @@ void Nextion::add_addt_command_to_queue(NextionComponentBase *component) {
|
|||
|
||||
void Nextion::set_writer(const nextion_writer_t &writer) { this->writer_ = writer; }
|
||||
|
||||
ESPDEPRECATED("set_wait_for_ack(bool) is deprecated and has no effect")
|
||||
void Nextion::set_wait_for_ack(bool wait_for_ack) { ESP_LOGE(TAG, "This command is depreciated"); }
|
||||
ESPDEPRECATED("set_wait_for_ack(bool) is deprecated and has no effect", "v1.20")
|
||||
void Nextion::set_wait_for_ack(bool wait_for_ack) { ESP_LOGE(TAG, "This command is deprecated"); }
|
||||
|
||||
} // namespace nextion
|
||||
} // namespace esphome
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace ssd1306_base {
|
|||
|
||||
static const char *const TAG = "ssd1306";
|
||||
|
||||
static const uint8_t BLACK = 0;
|
||||
static const uint8_t WHITE = 1;
|
||||
static const uint8_t SSD1306_MAX_CONTRAST = 255;
|
||||
|
||||
static const uint8_t SSD1306_COMMAND_DISPLAY_OFF = 0xAE;
|
||||
|
@ -89,8 +87,8 @@ void SSD1306::setup() {
|
|||
|
||||
set_brightness(this->brightness_);
|
||||
|
||||
this->fill(BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->fill(Color::BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
|
||||
this->turn_on();
|
||||
}
|
||||
|
|
|
@ -106,9 +106,9 @@ void SSD1322::setup() {
|
|||
this->data(180);
|
||||
this->command(SSD1322_ENABLEGRAYSCALETABLE);
|
||||
set_brightness(this->brightness_);
|
||||
this->fill(COLOR_BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
this->fill(Color::BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
}
|
||||
void SSD1322::display() {
|
||||
this->command(SSD1322_SETCOLUMNADDRESS); // set column address
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace ssd1325_base {
|
|||
|
||||
static const char *const TAG = "ssd1325";
|
||||
|
||||
static const uint8_t BLACK = 0;
|
||||
static const uint8_t WHITE = 15;
|
||||
static const uint8_t SSD1325_MAX_CONTRAST = 127;
|
||||
static const uint8_t SSD1325_COLORMASK = 0x0f;
|
||||
static const uint8_t SSD1325_COLORSHIFT = 4;
|
||||
|
@ -114,9 +112,9 @@ void SSD1325::setup() {
|
|||
this->command(0x0D | 0x02);
|
||||
this->command(SSD1325_NORMALDISPLAY); // set display mode
|
||||
set_brightness(this->brightness_);
|
||||
this->fill(BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
this->fill(Color::BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
}
|
||||
void SSD1325::display() {
|
||||
this->command(SSD1325_SETCOLADDR); // set column address
|
||||
|
|
|
@ -78,9 +78,9 @@ void SSD1327::setup() {
|
|||
this->command(0x1C);
|
||||
this->command(SSD1327_NORMALDISPLAY); // set display mode
|
||||
set_brightness(this->brightness_);
|
||||
this->fill(COLOR_BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
this->fill(Color::BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
}
|
||||
void SSD1327::display() {
|
||||
this->command(SSD1327_SETCOLUMNADDRESS); // set column address
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace ssd1331_base {
|
|||
|
||||
static const char *const TAG = "ssd1331";
|
||||
|
||||
static const uint16_t BLACK = 0;
|
||||
static const uint16_t WHITE = 0xffff;
|
||||
static const uint16_t SSD1331_COLORMASK = 0xffff;
|
||||
static const uint8_t SSD1331_MAX_CONTRASTA = 0x91;
|
||||
static const uint8_t SSD1331_MAX_CONTRASTB = 0x50;
|
||||
|
@ -78,9 +76,9 @@ void SSD1331::setup() {
|
|||
this->command(SSD1331_MASTERCURRENT); // 0x87
|
||||
this->command(0x06);
|
||||
set_brightness(this->brightness_);
|
||||
this->fill(BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
this->fill(Color::BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
}
|
||||
void SSD1331::display() {
|
||||
this->command(SSD1331_SETCOLUMN); // set column address
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace ssd1351_base {
|
|||
|
||||
static const char *const TAG = "ssd1351";
|
||||
|
||||
static const uint16_t BLACK = 0;
|
||||
static const uint16_t WHITE = 0xffff;
|
||||
static const uint16_t SSD1351_COLORMASK = 0xffff;
|
||||
static const uint8_t SSD1351_MAX_CONTRAST = 15;
|
||||
static const uint8_t SSD1351_BYTESPERPIXEL = 2;
|
||||
|
@ -87,9 +85,9 @@ void SSD1351::setup() {
|
|||
this->data(0x80);
|
||||
this->data(0xC8);
|
||||
set_brightness(this->brightness_);
|
||||
this->fill(BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
this->fill(Color::BLACK); // clear display - ensures we do not see garbage at power-on
|
||||
this->display(); // ...write buffer, which actually clears the display's memory
|
||||
this->turn_on(); // display ON
|
||||
}
|
||||
void SSD1351::display() {
|
||||
this->command(SSD1351_SETCOLUMN); // set column address
|
||||
|
|
|
@ -40,7 +40,7 @@ void WLEDLightEffect::stop() {
|
|||
|
||||
void WLEDLightEffect::blank_all_leds_(light::AddressableLight &it) {
|
||||
for (int led = it.size(); led-- > 0;) {
|
||||
it[led].set(COLOR_BLACK);
|
||||
it[led].set(Color::BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#include "esphome/core/color.h"
|
||||
|
||||
namespace esphome {
|
||||
|
||||
const Color Color::BLACK(0, 0, 0, 0);
|
||||
const Color Color::WHITE(255, 255, 255, 255);
|
||||
|
||||
} // namespace esphome
|
|
@ -38,10 +38,10 @@ struct Color {
|
|||
g(green),
|
||||
b(blue),
|
||||
w(white) {}
|
||||
inline Color(uint32_t colorcode) ALWAYS_INLINE : r((colorcode >> 16) & 0xFF),
|
||||
g((colorcode >> 8) & 0xFF),
|
||||
b((colorcode >> 0) & 0xFF),
|
||||
w((colorcode >> 24) & 0xFF) {}
|
||||
inline explicit Color(uint32_t colorcode) ALWAYS_INLINE : r((colorcode >> 16) & 0xFF),
|
||||
g((colorcode >> 8) & 0xFF),
|
||||
b((colorcode >> 0) & 0xFF),
|
||||
w((colorcode >> 24) & 0xFF) {}
|
||||
|
||||
inline bool is_on() ALWAYS_INLINE { return this->raw_32 != 0; }
|
||||
inline Color &operator=(const Color &rhs) ALWAYS_INLINE { // NOLINT
|
||||
|
@ -143,8 +143,14 @@ struct Color {
|
|||
Color fade_to_black(uint8_t amnt) { return *this * amnt; }
|
||||
Color lighten(uint8_t delta) { return *this + delta; }
|
||||
Color darken(uint8_t delta) { return *this - delta; }
|
||||
|
||||
static const Color BLACK;
|
||||
static const Color WHITE;
|
||||
};
|
||||
|
||||
static const Color COLOR_BLACK(0, 0, 0);
|
||||
ESPDEPRECATED("Use Color::BLACK instead of COLOR_BLACK", "v1.21")
|
||||
static const Color COLOR_BLACK(0, 0, 0, 0);
|
||||
ESPDEPRECATED("Use Color::WHITE instead of COLOR_WHITE", "v1.21")
|
||||
static const Color COLOR_WHITE(255, 255, 255, 255);
|
||||
}; // namespace esphome
|
||||
|
||||
} // namespace esphome
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#endif
|
||||
|
||||
#define HOT __attribute__((hot))
|
||||
#define ESPDEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
#define ESPDEPRECATED(msg, when) __attribute__((deprecated(msg)))
|
||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
||||
#define PACKED __attribute__((packed))
|
||||
|
||||
|
|
Loading…
Reference in New Issue