nene1234

lilka lvgl norm color

Nov 15th, 2025
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.63 KB | None | 0 0
  1. esphome:
  2.   name: lilka
  3.   friendly_name: lilka
  4.   on_boot:
  5.     priority: 600
  6.     then:
  7.       - output.turn_on: display_power
  8.       - delay: 100ms
  9.  
  10. esp32:
  11.   board: esp32-s3-devkitc-1
  12.   framework:
  13.     type: esp-idf
  14.  
  15. logger:
  16. api:
  17.   encryption:
  18.     key: "Yw3yq8lxsaze+jdggjAwxKpV4GD6gNZptvw4d6OPfOc="
  19.  
  20. ota:
  21.   - platform: esphome
  22.     password: "bb198feb99159fdaefc8092f10039acd"
  23.  
  24. wifi:
  25.   ssid: !secret wifi_ssid
  26.   password: !secret wifi_password
  27.   ap:
  28.     ssid: "Lilka Fallback Hotspot"
  29.     password: "hnYImYM4O6I0"
  30.  
  31. captive_portal:
  32. # Веб-сервер
  33. web_server:
  34.   port: 80
  35.  
  36. # Увімкнення живлення дисплея
  37. output:
  38.   - platform: gpio
  39.     pin: 46
  40.     id: display_power
  41.     inverted: false
  42.  
  43. # Сенсор батареї
  44. sensor:
  45.   - platform: adc
  46.     pin: GPIO3
  47.     name: "Battery Voltage"
  48.     id: battery_voltage
  49.     update_interval: 10s
  50.     attenuation: 12db
  51.     filters:
  52.       - multiply: 1.33
  53.    
  54.   - platform: template
  55.     name: "Battery Level"
  56.     id: battery_level
  57.     unit_of_measurement: "%"
  58.     accuracy_decimals: 0
  59.     update_interval: 10s
  60.     lambda: |-
  61.       float voltage = id(battery_voltage).state;
  62.       float percent = (voltage - 3.0) / (4.2 - 3.0) * 100.0;
  63.       if (percent > 100) percent = 100;
  64.       if (percent < 0) percent = 0;
  65.       return percent;
  66.  
  67. # SPI шина
  68. spi:
  69.   clk_pin: 18
  70.   mosi_pin: 17
  71.  
  72. # Дисплей ST7789V
  73. display:
  74.   - platform: mipi_spi
  75.     model: ST7789V
  76.     id: my_display
  77.     dc_pin: 15
  78.     cs_pin: 7
  79.     update_interval: 1s
  80.     rotation: 270
  81.     invert_colors: true
  82.     color_order: BGR
  83.     pixel_mode: 16bit
  84.     dimensions:
  85.       width: 280
  86.       height: 240
  87.       offset_width: 20
  88.       offset_height: 0
  89.     auto_clear_enabled: false
  90.  
  91. # LVGL - з чорним фоном
  92. lvgl:
  93.   log_level: INFO
  94.  
  95.   style_definitions:
  96.     - id: default_style
  97.       bg_color: 0x000000
  98.       text_color: 0xFFFFFF
  99.  
  100.   pages:
  101.     - id: main_page
  102.       bg_color: 0x000000
  103.       widgets:
  104.        # Червона кнопка - Battery %
  105.         - button:
  106.             id: red_button
  107.             align: CENTER
  108.             y: -40
  109.             width: 180
  110.             height: 50
  111.             bg_color: 0xFF0000  # Червоний
  112.             widgets:
  113.               - label:
  114.                   id: battery_label
  115.                   text: "Battery: --"
  116.                   align: CENTER
  117.                   text_color: 0xFFFFFF
  118.        
  119.         # Зелена кнопка - Voltage
  120.         - button:
  121.             id: green_button
  122.             align: CENTER
  123.             y: 20
  124.             width: 180
  125.             height: 50
  126.             bg_color: 0x00FF00  # Зелений
  127.             widgets:
  128.               - label:
  129.                   id: voltage_label
  130.                   text: "Voltage: --"
  131.                   align: CENTER
  132.                   text_color: 0x000000
  133.        
  134.         # Синя кнопка - Lilka LVGL
  135.         - button:
  136.             id: blue_button
  137.             align: CENTER
  138.             y: 80
  139.             width: 180
  140.             height: 50
  141.             bg_color: 0x0000FF  # Синій
  142.             widgets:
  143.               - label:
  144.                   text: "Lilka LVGL"
  145.                   align: CENTER
  146.                   text_color: 0xFFFFFF
  147.  
  148. # Кнопки керування
  149. binary_sensor:
  150.   - platform: gpio
  151.     pin:
  152.       number: 38
  153.       mode: INPUT_PULLUP
  154.       inverted: true
  155.     name: "Button Up"
  156.     id: button_up
  157.     filters:
  158.       - delayed_on_off: 50ms
  159.    
  160.   - platform: gpio
  161.     pin:
  162.       number: 41
  163.       mode: INPUT_PULLUP
  164.       inverted: true
  165.     name: "Button Down"
  166.     id: button_down
  167.     filters:
  168.       - delayed_on_off: 50ms
  169.    
  170.   - platform: gpio
  171.     pin:
  172.       number: 39
  173.       mode: INPUT_PULLUP
  174.       inverted: true
  175.     name: "Button Left"
  176.     id: button_left
  177.     filters:
  178.       - delayed_on_off: 50ms
  179.    
  180.   - platform: gpio
  181.     pin:
  182.       number: 40
  183.       mode: INPUT_PULLUP
  184.       inverted: true
  185.     name: "Button Right"
  186.     id: button_right
  187.     filters:
  188.       - delayed_on_off: 50ms
  189.  
  190.   - platform: gpio
  191.     pin:
  192.       number: 5
  193.       mode: INPUT_PULLUP
  194.       inverted: true
  195.     name: "Button A"
  196.     id: button_a
  197.     filters:
  198.       - delayed_on_off: 50ms
  199.    
  200.   - platform: gpio
  201.     pin:
  202.       number: 6
  203.       mode: INPUT_PULLUP
  204.       inverted: true
  205.     name: "Button B"
  206.     id: button_b
  207.     filters:
  208.       - delayed_on_off: 50ms
  209.  
  210.   - platform: gpio
  211.     pin:
  212.       number: 10
  213.       mode: INPUT_PULLUP
  214.       inverted: true
  215.     name: "Button C"
  216.     id: button_c
  217.     filters:
  218.       - delayed_on_off: 50ms
  219.  
  220.   - platform: gpio
  221.     pin:
  222.       number: 9
  223.       mode: INPUT_PULLUP
  224.       inverted: true
  225.     name: "Button D"
  226.     id: button_d
  227.     filters:
  228.       - delayed_on_off: 50ms
  229.  
  230.   - platform: gpio
  231.     pin:
  232.       number: 4
  233.       mode: INPUT_PULLUP
  234.       inverted: true
  235.     name: "Button Start"
  236.     id: button_start
  237.     filters:
  238.       - delayed_on_off: 50ms
  239.  
  240.   - platform: gpio
  241.     pin:
  242.       number: 0
  243.       mode: INPUT_PULLUP
  244.       inverted: true
  245.     name: "Button Select"
  246.     id: button_select
  247.     filters:
  248.       - delayed_on_off: 50ms
  249.  
  250. # Оновлення даних на кнопках
  251. interval:
  252.   - interval: 5s
  253.     then:
  254.       - lvgl.label.update:
  255.           id: battery_label
  256.           text: !lambda |-
  257.             return std::string("Battery: ") + to_string((int)id(battery_level).state) + "%";
  258.       - lvgl.label.update:
  259.           id: voltage_label
  260.           text: !lambda |-
  261.             char buf[20];
  262.             snprintf(buf, sizeof(buf), "Voltage: %.2fV", id(battery_voltage).state);
  263.             return std::string(buf);
Advertisement
Add Comment
Please, Sign In to add comment