[image] Restructure into a platform component (#17416)

This commit is contained in:
Jesse Hills
2026-07-09 07:38:58 +12:00
committed by GitHub
parent 26f48ee9ea
commit dd0d0942f5
39 changed files with 1827 additions and 883 deletions
+11 -8
View File
@@ -1,23 +1,26 @@
animation:
- id: rgb565_animation
image:
- platform: animation
id: rgb565_animation
file: $component_dir/anim.gif
type: RGB565
transparency: opaque
resize: 50x50
- id: rgb_animation
- platform: animation
id: rgb_animation
file: $component_dir/anim.apng
type: RGB
transparency: chroma_key
resize: 50x50
- id: grayscale_animation
- platform: animation
id: grayscale_animation
file: $component_dir/anim.apng
type: grayscale
display:
lambda: |-
id(rgb565_animation).next_frame();
id(rgb_animation1).next_frame();
id(grayscale_animation2).next_frame();
id(rgb_animation).next_frame();
id(grayscale_animation).next_frame();
it.image(0, 0, rgb565_animation);
it.image(120, 0, rgb_animation1);
it.image(240, 0, grayscale_animation2);
it.image(120, 0, rgb_animation);
it.image(240, 0, grayscale_animation);
@@ -0,0 +1,16 @@
# Legacy top-level `animation:` form (deprecated; migrates to
# `platform: animation`). Config-only test exercising the deprecation path.
display:
- platform: sdl
id: animation_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
animation:
- id: legacy_animation
file: $component_dir/anim.gif
type: RGB565
transparency: opaque
resize: 50x50
+17
View File
@@ -0,0 +1,17 @@
image:
- platform: file
id: file_binary_image
file: ../../pnglogo.png
type: BINARY
dither: FloydSteinberg
- platform: file
id: file_rgb565_image
file: ../../pnglogo.png
type: RGB565
transparency: alpha_channel
resize: 50x50
- platform: file
id: file_mdi_image
file: mdi:alert-circle-outline
type: BINARY
resize: 24x24
+14
View File
@@ -0,0 +1,14 @@
packages:
spi: !include ../../test_build_components/common/spi/esp32-idf.yaml
display:
- platform: ili9xxx
id: file_main_lcd
spi_id: spi_bus
model: ili9342
cs_pin: 15
dc_pin: 13
reset_pin: 21
invert_colors: true
<<: !include common.yaml
+9
View File
@@ -0,0 +1,9 @@
display:
- platform: sdl
id: file_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
<<: !include common.yaml
+38 -19
View File
@@ -1,85 +1,104 @@
image:
- id: binary_image
- platform: file
id: binary_image
file: ../../pnglogo.png
type: BINARY
dither: FloydSteinberg
- id: transparent_transparent_image
- platform: file
id: transparent_transparent_image
file: ../../pnglogo.png
type: BINARY
transparency: chroma_key
- id: rgba_image
- platform: file
id: rgba_image
file: ../../pnglogo.png
type: RGB
transparency: alpha_channel
resize: 50x50
- id: rgb24_image
- platform: file
id: rgb24_image
file: ../../pnglogo.png
type: RGB
transparency: chroma_key
- id: rgb_image
- platform: file
id: rgb_image
file: ../../pnglogo.png
type: RGB
transparency: opaque
- id: rgb565_image
- platform: file
id: rgb565_image
file: ../../pnglogo.png
type: RGB565
transparency: opaque
- id: rgb565_ck_image
- platform: file
id: rgb565_ck_image
file: ../../pnglogo.png
type: RGB565
transparency: chroma_key
- id: rgb565_alpha_image
- platform: file
id: rgb565_alpha_image
file: ../../pnglogo.png
type: RGB565
transparency: alpha_channel
- id: grayscale_alpha_image
- platform: file
id: grayscale_alpha_image
file: ../../pnglogo.png
type: grayscale
transparency: alpha_channel
resize: 50x50
- id: grayscale_ck_image
- platform: file
id: grayscale_ck_image
file: ../../pnglogo.png
type: grayscale
transparency: chroma_key
- id: grayscale_image
- platform: file
id: grayscale_image
file: ../../pnglogo.png
type: grayscale
transparency: opaque
- id: web_svg_image
- platform: file
id: web_svg_image
file: https://media.esphome.io/logo/logo.svg
resize: 256x48
type: BINARY
transparency: chroma_key
- id: web_tiff_image
- platform: file
id: web_tiff_image
file: https://media.esphome.io/tests/images/SIPI_Jelly_Beans_4.1.07.tiff
type: RGB
resize: 48x48
- id: web_redirect_image
- platform: file
id: web_redirect_image
file: https://media.esphome.io/logo/logo.png
type: RGB
resize: 48x48
- id: mdi_alert
- platform: file
id: mdi_alert
type: BINARY
file: mdi:alert-circle-outline
resize: 50x50
- id: another_alert_icon
- platform: file
id: another_alert_icon
file: mdi:alert-outline
type: BINARY
- file: mdil:arrange-bring-to-front
- platform: file
file: mdil:arrange-bring-to-front
id: mdil_id
resize: 50x50
type: binary
transparency: chroma_key
- file: mdi:beer
- platform: file
file: mdi:beer
id: mdi_id
resize: 50x50
type: binary
transparency: chroma_key
- file: memory:alert-octagon
- platform: file
file: memory:alert-octagon
id: memory_id
resize: 50x50
type: binary
+3 -4
View File
@@ -12,12 +12,11 @@ display:
invert_colors: true
image:
defaults:
- platform: file
id: test_image
file: ../../pnglogo.png
type: rgb565
transparency: opaque
byte_order: little_endian
resize: 50x50
dither: FloydSteinberg
images:
- id: test_image
file: ../../pnglogo.png
+57 -40
View File
@@ -7,43 +7,60 @@ display:
height: 480
image:
binary:
- id: binary_image
file: ../../pnglogo.png
dither: FloydSteinberg
- id: transparent_transparent_image
file: ../../pnglogo.png
transparency: chroma_key
rgb:
alpha_channel:
- id: rgba_image
file: ../../pnglogo.png
resize: 50x50
chroma_key:
- id: rgb24_image
file: ../../pnglogo.png
type: RGB
opaque:
- id: rgb_image
file: ../../pnglogo.png
rgb565:
- id: rgb565_image
file: ../../pnglogo.png
transparency: opaque
- id: rgb565_ck_image
file: ../../pnglogo.png
transparency: chroma_key
- id: rgb565_alpha_image
file: ../../pnglogo.png
transparency: alpha_channel
grayscale:
- id: grayscale_alpha_image
file: ../../pnglogo.png
transparency: alpha_channel
resize: 50x50
- id: grayscale_ck_image
file: ../../pnglogo.png
transparency: chroma_key
- id: grayscale_image
file: ../../pnglogo.png
transparency: opaque
- platform: file
id: binary_image
file: ../../pnglogo.png
type: binary
dither: FloydSteinberg
- platform: file
id: transparent_transparent_image
file: ../../pnglogo.png
type: binary
transparency: chroma_key
- platform: file
id: rgba_image
file: ../../pnglogo.png
type: rgb
transparency: alpha_channel
resize: 50x50
- platform: file
id: rgb24_image
file: ../../pnglogo.png
type: RGB
transparency: chroma_key
- platform: file
id: rgb_image
file: ../../pnglogo.png
type: rgb
transparency: opaque
- platform: file
id: rgb565_image
file: ../../pnglogo.png
type: rgb565
transparency: opaque
- platform: file
id: rgb565_ck_image
file: ../../pnglogo.png
type: rgb565
transparency: chroma_key
- platform: file
id: rgb565_alpha_image
file: ../../pnglogo.png
type: rgb565
transparency: alpha_channel
- platform: file
id: grayscale_alpha_image
file: ../../pnglogo.png
type: grayscale
transparency: alpha_channel
resize: 50x50
- platform: file
id: grayscale_ck_image
file: ../../pnglogo.png
type: grayscale
transparency: chroma_key
- platform: file
id: grayscale_image
file: ../../pnglogo.png
type: grayscale
transparency: opaque
@@ -0,0 +1,25 @@
# Legacy top-level `image:` defaults/images form (deprecated; migrates to
# `platform: file`). Config-only test exercising the deprecation/migration path,
# including the per-type byte_order drop when an entry overrides to a non-endian
# type (binary).
display:
- platform: sdl
id: image_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
image:
defaults:
type: rgb565
transparency: opaque
byte_order: little_endian
resize: 50x50
dither: FloydSteinberg
images:
- id: legacy_defaults_image
file: ../../pnglogo.png
- id: legacy_defaults_binary
file: ../../pnglogo.png
type: binary
@@ -0,0 +1,24 @@
# Legacy top-level `image:` structured form using single-dict (non-list) values
# for `images:`, a type group, and a transparency group -- the old `ensure_list`
# accepted a bare dict in each of these places. Deprecated; migrates to
# `platform: file`. Config-only test exercising the deprecation/migration path.
display:
- platform: sdl
id: image_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
image:
images:
id: legacy_images_single_dict
file: ../../pnglogo.png
type: rgb565
rgb565:
id: legacy_grouped_type_single_dict
file: ../../pnglogo.png
rgb:
alpha_channel:
id: legacy_grouped_transparency_single_dict
file: ../../pnglogo.png
@@ -0,0 +1,25 @@
# Legacy top-level `image:` type-grouped form (deprecated; migrates to
# `platform: file`). Config-only test exercising the deprecation/migration path.
display:
- platform: sdl
id: image_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
image:
binary:
- id: legacy_grouped_binary
file: ../../pnglogo.png
rgb:
alpha_channel:
- id: legacy_grouped_rgba
file: ../../pnglogo.png
opaque:
- id: legacy_grouped_rgb
file: ../../pnglogo.png
rgb565:
- id: legacy_grouped_rgb565
file: ../../pnglogo.png
transparency: chroma_key
@@ -0,0 +1,16 @@
# Legacy top-level `image:` single-dict form (a bare image dict instead of a
# list; deprecated, migrates to `platform: file`). Config-only test exercising
# the deprecation/migration path.
display:
- platform: sdl
id: image_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
image:
id: legacy_single_image
file: ../../pnglogo.png
type: RGB565
transparency: opaque
+18
View File
@@ -0,0 +1,18 @@
# Legacy top-level `image:` list form (deprecated; migrates to `platform: file`).
# Config-only test exercising the deprecation/migration path.
display:
- platform: sdl
id: image_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
image:
- id: legacy_list_binary
file: ../../pnglogo.png
type: BINARY
- id: legacy_list_rgb565
file: ../../pnglogo.png
type: RGB565
transparency: alpha_channel
+17 -12
View File
@@ -2,11 +2,9 @@ wifi:
ssid: MySSID
password: password1
# Purposely test that `online_image:` does auto-load `image:`
# Keep the `image:` undefined.
# image:
online_image:
- id: online_binary_image
image:
- platform: online_image
id: online_binary_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
format: PNG
type: BINARY
@@ -21,34 +19,41 @@ online_image:
} else {
ESP_LOGD("online_image", "Cache miss: fresh download");
}
- id: online_binary_transparent_image
- platform: online_image
id: online_binary_transparent_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
type: BINARY
transparency: chroma_key
format: png
- id: online_rgba_image
- platform: online_image
id: online_rgba_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
format: PNG
type: RGB
transparency: alpha_channel
- id: online_rgb24_image
- platform: online_image
id: online_rgb24_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
format: PNG
type: RGB
transparency: chroma_key
- id: online_binary_bmp
- platform: online_image
id: online_binary_bmp
url: https://samples-files.com/samples/images/bmp/480-360-sample.bmp
format: BMP
type: BINARY
- id: online_rgb_bmp_8bit
- platform: online_image
id: online_rgb_bmp_8bit
url: https://samples-files.com/samples/images/bmp/480-360-sample.bmp
format: BMP
type: RGB
- id: online_jpeg_image
- platform: online_image
id: online_jpeg_image
url: http://www.faqs.org/images/library.jpg
format: JPEG
type: RGB
- id: online_jpg_image
- platform: online_image
id: online_jpg_image
url: http://www.faqs.org/images/library.jpg
format: JPG
type: RGB565
@@ -0,0 +1,22 @@
# Legacy top-level `online_image:` form (deprecated; migrates to
# `platform: online_image`). Config-only test exercising the deprecation path.
wifi:
ssid: MySSID
password: password1
http_request:
display:
- platform: sdl
id: online_image_display
auto_clear_enabled: false
dimensions:
width: 480
height: 480
online_image:
- id: legacy_online_image
url: http://www.example.org/example.png
format: PNG
type: RGB565
resize: 50x50