1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 01:02:19 +01:00

[color][lvgl] Allow Color to be used for lv_color_t (#10016)

This commit is contained in:
Clyde Stubbs
2025-08-04 10:51:34 +10:00
committed by GitHub
parent d69e98e15d
commit 339c26c815
2 changed files with 11 additions and 1 deletions

View File

@@ -1,8 +1,13 @@
#pragma once
#include "defines.h"
#include "component.h"
#include "helpers.h"
#ifdef USE_LVGL
#include "esphome/components/lvgl/lvgl_proxy.h"
#endif // USE_LVGL
namespace esphome {
inline static constexpr uint8_t esp_scale8(uint8_t i, uint8_t scale) {
@@ -33,6 +38,11 @@ struct Color {
uint32_t raw_32;
};
#ifdef USE_LVGL
// convenience function for Color to get a lv_color_t representation
operator lv_color_t() const { return lv_color_make(this->r, this->g, this->b); }
#endif
inline constexpr Color() ESPHOME_ALWAYS_INLINE : raw_32(0) {} // NOLINT
inline constexpr Color(uint8_t red, uint8_t green, uint8_t blue) ESPHOME_ALWAYS_INLINE : r(red),
g(green),