1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

Merge branch 'dev' into gsm

This commit is contained in:
oarcher
2024-08-07 22:46:09 +02:00
138 changed files with 5917 additions and 1042 deletions

2
tests/components/lvgl/.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
*.ttf -text

View File

@@ -8,3 +8,121 @@ touchscreen:
x_max: 240
y_max: 320
font:
- file: "$component_dir/roboto.ttf"
id: roboto20
size: 20
extras:
- file: '$component_dir/materialdesignicons-webfont.ttf'
glyphs: [
"\U000F004B",
"\U0000f0ed",
"\U000F006E",
"\U000F012C",
"\U000F179B",
"\U000F0748",
"\U000F1A1B",
"\U000F02DC",
"\U000F0A02",
"\U000F035F",
"\U000F0156",
"\U000F0C5F",
"\U000f0084",
"\U000f0091",
]
- file: "$component_dir/helvetica.ttf"
id: helvetica20
- file: "$component_dir/roboto.ttf"
id: roboto10
size: 10
bpp: 4
extras:
- file: '$component_dir/materialdesignicons-webfont.ttf'
glyphs: [
"\U000F004B",
"\U0000f0ed",
"\U000F006E",
"\U000F012C",
"\U000F179B",
"\U000F0748",
"\U000F1A1B",
"\U000F02DC",
"\U000F0A02",
"\U000F035F",
"\U000F0156",
"\U000F0C5F",
"\U000f0084",
"\U000f0091",
]
sensor:
- platform: lvgl
id: lvgl_sensor_id
name: "LVGL Arc Sensor"
widget: lv_arc
- platform: lvgl
widget: slider_id
name: LVGL Slider
- platform: lvgl
widget: bar_id
id: lvgl_bar_sensor
name: LVGL Bar
- platform: lvgl
widget: spinbox_id
name: LVGL Spinbox
number:
- platform: lvgl
widget: slider_id
name: LVGL Slider
- platform: lvgl
widget: lv_arc
id: lvgl_arc_number
name: LVGL Arc
- platform: lvgl
widget: bar_id
id: lvgl_bar_number
name: LVGL Bar
- platform: lvgl
widget: spinbox_id
id: lvgl_spinbox_number
name: LVGL Spinbox
light:
- platform: lvgl
name: LVGL LED
id: lv_light
led: lv_led
binary_sensor:
- platform: lvgl
id: lvgl_pressbutton
name: Pressbutton
widget: spin_up
publish_initial_state: true
- platform: lvgl
name: ButtonMatrix button
widget: button_a
- platform: lvgl
id: switch_d
name: Matrix switch D
widget: button_d
on_click:
then:
- lvgl.page.previous:
animation: move_right
time: 600ms
- platform: lvgl
id: button_checker
name: LVGL button
widget: spin_up
on_state:
then:
- lvgl.checkbox.update:
id: checkbox_id
state:
checked: !lambda return x;
text: Unchecked
- platform: lvgl
name: LVGL checkbox
widget: checkbox_id

Binary file not shown.

View File

@@ -1,149 +1,458 @@
lvgl:
log_level: TRACE
bg_color: light_blue
theme:
obj:
border_width: 1
style_definitions:
- id: style_test
bg_color: 0x2F8CD8
- id: header_footer
bg_color: 0x20214F
bg_grad_color: 0x005782
bg_grad_dir: VER
bg_opa: cover
border_width: 0
radius: 0
pad_all: 0
pad_row: 0
pad_column: 0
border_color: 0x0077b3
text_color: 0xFFFFFF
width: 100%
height: 30
border_side: [left, top]
text_decor: [underline, strikethrough]
- id: style_line
line_color: light_blue
line_width: 8
line_rounded: true
- id: date_style
text_font: roboto10
align: center
text_color: 0x000000
bg_opa: cover
radius: 4
pad_all: 2
- id: spin_button
height: 40
width: 40
- id: spin_label
align: center
text_align: center
text_font: space16
- id: bdr_style
border_color: 0x808080
border_width: 2
pad_all: 4
align: center
touchscreens:
- touchscreen_id: tft_touch
long_press_repeat_time: 200ms
long_press_time: 500ms
widgets:
- label:
id: hello_label
text: Hello world
text_color: 0xFF8000
align: center
text_font: montserrat_40
border_post: true
- label:
text: "Hello shiny day"
text_color: 0xFFFFFF
align: bottom_mid
text_font: space16
- obj:
align: center
arc_opa: COVER
arc_color: 0xFF0000
arc_rounded: false
arc_width: 3
anim_time: 1s
bg_color: light_blue
bg_grad_color: light_blue
bg_dither_mode: ordered
bg_grad_dir: hor
bg_grad_stop: 128
bg_image_opa: transp
bg_image_recolor: light_blue
bg_image_recolor_opa: 50%
bg_main_stop: 0
bg_opa: 20%
border_color: 0x00FF00
border_opa: cover
border_post: true
border_side: [bottom, left]
border_width: 4
clip_corner: false
height: 50%
image_recolor: light_blue
image_recolor_opa: cover
line_width: 10
line_dash_width: 10
line_dash_gap: 10
line_rounded: false
line_color: light_blue
opa: cover
opa_layered: cover
outline_color: light_blue
outline_opa: cover
outline_pad: 10px
outline_width: 10px
pad_all: 10px
pad_bottom: 10px
pad_column: 10px
pad_left: 10px
pad_right: 10px
pad_row: 10px
pad_top: 10px
shadow_color: light_blue
shadow_ofs_x: 5
shadow_ofs_y: 5
shadow_opa: cover
shadow_spread: 5
shadow_width: 10
text_align: auto
text_color: light_blue
text_decor: [underline, strikethrough]
text_font: montserrat_18
text_letter_space: 4
text_line_space: 4
text_opa: cover
transform_angle: 180
transform_height: 100
transform_pivot_x: 50%
transform_pivot_y: 50%
transform_zoom: 0.5
translate_x: 10
translate_y: 10
max_height: 100
max_width: 200
min_height: 20%
min_width: 20%
radius: circle
width: 10px
x: 100
y: 120
- button:
width: 20%
height: 10%
pressed:
bg_color: light_blue
checkable: true
checked:
bg_color: 0x000000
widgets:
- label:
text: Button
on_click:
lvgl.label.update:
pages:
- id: page1
skip: true
widgets:
- animimg:
height: 60
id: anim_img
src: [cat_image, dog_image]
repeat_count: 10
duration: 1s
auto_start: true
- label:
id: hello_label
bg_color: 0x123456
text: clicked
on_value:
logger.log:
format: "state now %d"
args: [x]
on_short_click:
lvgl.widget.hide: hello_label
on_long_press:
lvgl.widget.show: hello_label
on_cancel:
lvgl.widget.enable: hello_label
on_ready:
lvgl.widget.disable: hello_label
on_defocus:
lvgl.widget.hide: hello_label
on_focus:
logger.log: Button clicked
on_scroll:
logger.log: Button clicked
on_scroll_end:
logger.log: Button clicked
on_scroll_begin:
logger.log: Button clicked
on_release:
logger.log: Button clicked
on_long_press_repeat:
logger.log: Button clicked
text: Hello world
text_color: 0xFF8000
align: center
text_font: montserrat_40
border_post: true
on_click:
then:
- lvgl.animimg.stop: anim_img
- label:
text: "Hello shiny day"
text_color: 0xFFFFFF
align: bottom_mid
text_font: space16
- obj:
align: center
arc_opa: COVER
arc_color: 0xFF0000
arc_rounded: false
arc_width: 3
anim_time: 1s
bg_color: light_blue
bg_grad_color: light_blue
bg_dither_mode: ordered
bg_grad_dir: hor
bg_grad_stop: 128
bg_image_opa: transp
bg_image_recolor: light_blue
bg_image_recolor_opa: 50%
bg_main_stop: 0
bg_opa: 20%
border_color: 0x00FF00
border_opa: cover
border_post: true
border_side: [bottom, left]
border_width: 4
clip_corner: false
height: 50%
image_recolor: light_blue
image_recolor_opa: cover
line_width: 10
line_dash_width: 10
line_dash_gap: 10
line_rounded: false
line_color: light_blue
opa: cover
opa_layered: cover
outline_color: light_blue
outline_opa: cover
outline_pad: 10px
outline_width: 10px
pad_all: 10px
pad_bottom: 10px
pad_column: 10px
pad_left: 10px
pad_right: 10px
pad_row: 10px
pad_top: 10px
shadow_color: light_blue
shadow_ofs_x: 5
shadow_ofs_y: 5
shadow_opa: cover
shadow_spread: 5
shadow_width: 10
text_align: auto
text_color: light_blue
text_decor: [underline, strikethrough]
text_font: montserrat_18
text_letter_space: 4
text_line_space: 4
text_opa: cover
transform_angle: 180
transform_height: 100
transform_pivot_x: 50%
transform_pivot_y: 50%
transform_zoom: 0.5
translate_x: 10
translate_y: 10
max_height: 100
max_width: 200
min_height: 20%
min_width: 20%
radius: circle
width: 10px
x: 100
y: 120
- buttonmatrix:
on_press:
logger.log:
format: "matrix button pressed: %d"
args: ["x"]
on_long_press:
lvgl.matrix.button.update:
id: [button_a, button_e, button_c]
control:
disabled: true
on_click:
logger.log:
format: "matrix button clicked: %d, is button_a = %u"
args: ["x", "id(button_a) == x"]
items:
checked:
bg_color: 0xFFFF00
id: b_matrix
rows:
- buttons:
- id: button_a
text: home icon
width: 2
control:
checkable: true
on_value:
logger.log:
format: "button_a value %d"
args: [x]
- id: button_b
text: B
width: 1
on_value:
logger.log:
format: "button_b value %d"
args: [x]
on_click:
then:
- lvgl.page.previous:
control:
hidden: false
- buttons:
- id: button_c
text: C
control:
checkable: false
- id: button_d
text: menu left
on_long_press:
then:
logger.log: Long pressed
on_long_press_repeat:
then:
logger.log: Long pressed repeated
- buttons:
- id: button_e
- button:
id: button_button
width: 20%
height: 10%
pressed:
bg_color: light_blue
checkable: true
checked:
bg_color: 0x000000
widgets:
- label:
text: Button
on_click:
lvgl.label.update:
id: hello_label
bg_color: 0x123456
text: clicked
on_value:
logger.log:
format: "state now %d"
args: [x]
on_short_click:
lvgl.widget.hide: hello_label
on_long_press:
lvgl.widget.show: hello_label
on_cancel:
lvgl.widget.enable: hello_label
on_ready:
lvgl.widget.disable: hello_label
on_defocus:
lvgl.widget.hide: hello_label
on_focus:
logger.log: Button clicked
on_scroll:
logger.log: Button clicked
on_scroll_end:
logger.log: Button clicked
on_scroll_begin:
logger.log: Button clicked
on_release:
logger.log: Button clicked
on_long_press_repeat:
logger.log: Button clicked
- led:
id: lv_led
color: 0x00FF00
brightness: 50%
align: right_mid
- spinner:
arc_length: 120
spin_time: 2s
align: left_mid
- image:
src: cat_image
align: top_left
y: 50
- id: page2
widgets:
- button:
styles: spin_button
id: spin_up
on_click:
- lvgl.spinbox.increment: spinbox_id
widgets:
- label:
styles: spin_label
text: "+"
- spinbox:
text_font: space16
id: spinbox_id
align: center
width: 120
range_from: -10
range_to: 1000
step: 5.0
rollover: false
digits: 6
decimal_places: 2
value: 15
on_value:
then:
- logger.log:
format: "Spinbox value is %f"
args: [x]
- button:
styles: spin_button
id: spin_down
on_click:
- lvgl.spinbox.decrement: spinbox_id
widgets:
- label:
styles: spin_label
text: "-"
- arc:
align: left_mid
id: lv_arc
adjustable: true
on_value:
then:
- logger.log:
format: "Arc value is %f"
args: [x]
scroll_on_focus: true
value: 75
min_value: 1
max_value: 100
arc_color: 0xFF0000
indicator:
arc_color: 0xF000FF
pressed:
arc_color: 0xFFFF00
focused:
arc_color: 0x808080
- bar:
id: bar_id
align: top_mid
y: 20
value: 30
max_value: 100
min_value: 10
mode: range
on_click:
then:
- lvgl.bar.update:
id: bar_id
value: !lambda return (int)((float)rand() / RAND_MAX * 100);
- logger.log:
format: "bar value %f"
args: [x]
- line:
align: center
points:
- 5, 5
- 70, 70
- 120, 10
- 180, 60
- 240, 10
on_click:
lvgl.page.next:
- switch:
align: right_mid
- checkbox:
id: checkbox_id
text: Checkbox
align: bottom_right
- slider:
id: slider_id
align: top_mid
y: 40
value: 30
max_value: 100
min_value: 10
mode: normal
on_value:
then:
- logger.log:
format: "slider value %f"
args: [x]
on_click:
then:
- lvgl.slider.update:
id: slider_id
value: !lambda return (int)((float)rand() / RAND_MAX * 100);
- tabview:
id: tabview_id
width: 100%
height: 80%
position: top
on_value:
then:
- if:
condition:
lambda: return tab == id(tabview_tab_1);
then:
- logger.log: "Dog tab is now showing"
tabs:
- name: Dog
id: tabview_tab_1
border_width: 2
border_color: 0xff0000
width: 100%
pad_all: 8
layout:
type: grid
grid_row_align: end
grid_rows: [25px, fr(1), content]
grid_columns: [40, fr(1), fr(1)]
widgets:
- image:
grid_cell_row_pos: 0
grid_cell_column_pos: 0
src: dog_image
on_click:
then:
- lvgl.tabview.select:
id: tabview_id
index: 1
animated: true
- label:
styles: bdr_style
grid_cell_x_align: center
grid_cell_y_align: stretch
grid_cell_row_pos: 0
grid_cell_column_pos: 1
grid_cell_column_span: 1
text: "Grid cell 0/1"
- label:
grid_cell_x_align: end
styles: bdr_style
grid_cell_row_pos: 1
grid_cell_column_pos: 0
text: "Grid cell 1/0"
- label:
styles: bdr_style
grid_cell_row_pos: 1
grid_cell_column_pos: 1
text: "Grid cell 1/1"
- label:
id: cell_1_3
styles: bdr_style
grid_cell_row_pos: 1
grid_cell_column_pos: 2
text: "Grid cell 1/2"
- name: Cat
id: tabview_tab_2
widgets:
- image:
src: cat_image
on_click:
then:
- logger.log: Cat image clicked
- lvgl.tabview.select:
id: tabview_id
index: 0
animated: true
font:
- file: "gfonts://Roboto"
id: space16
bpp: 4
image:
- id: cat_img
- id: cat_image
resize: 256x48
file: $component_dir/logo-text.svg
- id: dog_img
- id: dog_image
file: $component_dir/logo-text.svg
resize: 256x48
type: TRANSPARENT_BINARY

Binary file not shown.

Binary file not shown.

View File

@@ -24,6 +24,33 @@ display:
invert_colors: false
update_interval: never
binary_sensor:
- platform: gpio
internal: true
id: up_button
pin:
number: GPIO38
inverted: true
- platform: gpio
internal: true
id: down_button
pin:
number: GPIO37
inverted: true
- platform: gpio
internal: true
id: select_button
pin:
number: GPIO39
inverted: true
lvgl:
encoders:
group: switches
enter_button: select_button
sensor:
left_button: up_button
right_button: down_button
packages:
lvgl: !include lvgl-package.yaml

View File

@@ -67,7 +67,7 @@ lvgl:
displays:
- tft_display
- second_display
rotary_encoders:
encoders:
sensor: encoder
enter_button: pushbutton
group: general

View File

@@ -426,3 +426,9 @@ valve:
} else {
return VALVE_CLOSED;
}
alarm_control_panel:
- platform: template
name: Alarm Control Panel
binary_sensors:
- input: some_binary_sensor

View File

@@ -0,0 +1,18 @@
<<: !include common.yaml
spi:
- id: spi_main_lcd
clk_pin: 16
mosi_pin: 17
miso_pin: 15
display:
- platform: ili9xxx
id: main_lcd
model: ili9342
cs_pin: 12
dc_pin: 13
reset_pin: 21
lambda: |-
it.fill(Color(0, 0, 0));
it.image(0, 0, id(online_rgba_image));

View File

@@ -0,0 +1,18 @@
<<: !include common.yaml
spi:
- id: spi_main_lcd
clk_pin: 14
mosi_pin: 13
miso_pin: 12
display:
- platform: ili9xxx
id: main_lcd
model: ili9342
cs_pin: 15
dc_pin: 3
reset_pin: 1
lambda: |-
it.fill(Color(0, 0, 0));
it.image(0, 0, id(online_rgba_image));

View File

@@ -0,0 +1,37 @@
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
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
format: PNG
type: BINARY
resize: 50x50
- id: online_binary_transparent_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
type: TRANSPARENT_BINARY
format: png
- id: online_rgba_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
format: PNG
type: RGBA
- id: online_rgb24_image
url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png
format: PNG
type: RGB24
use_transparency: true
# Check the set_url action
time:
- platform: sntp
on_time:
- at: "13:37:42"
then:
- online_image.set_url:
id: online_rgba_image
url: http://www.example.org/example.png

View File

@@ -0,0 +1,4 @@
<<: !include common-esp32.yaml
http_request:
verify_ssl: false

View File

@@ -0,0 +1,4 @@
<<: !include common-esp32.yaml
http_request: