nene1234

lilka audio no memory

Nov 17th, 2025
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.11 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.     version: recommended
  15.  
  16. wifi:
  17.   ssid: !secret wifi_ssid
  18.   password: !secret wifi_password
  19.   ap:
  20.     ssid: "Lilka Fallback Hotspot"
  21.     password: "hnYImYM4O6I0"
  22.  
  23. captive_portal:
  24. web_server:
  25.   port: 80
  26.  
  27. api:
  28.   encryption:
  29.     key: "Yw3yq8lxsaze+jdggjAwxKpV4GD6gNZptvw4d6OPfOc="
  30.  
  31. logger:
  32. ota:
  33.   - platform: esphome
  34.     password: "bb198feb99159fdaefc8092f10039acd"
  35.  
  36. output:
  37.   - platform: gpio
  38.     pin: 46
  39.     id: display_power
  40.     inverted: false
  41.  
  42. i2s_audio:
  43.   - id: i2s_out
  44.     i2s_lrclk_pin: GPIO1 #LRC an MAX98357A
  45.     i2s_bclk_pin: GPIO42  #BCL an MAX98357A
  46.  
  47. speaker:
  48.   - platform: i2s_audio
  49.     id: lilka_speaker
  50.     dac_type: external
  51.     i2s_audio_id: i2s_out
  52.     i2s_dout_pin: GPIO2
  53.     channel: mono
  54.     sample_rate: 16000  #Defaults to 16000
  55.     bits_per_sample: 16bit #One of 8bit, 16bit, 24bit, or 32bit. Defaults to 16bit.
  56.  
  57. media_player:
  58.   - platform: speaker
  59.     name: "Lilka Media Player"
  60.     id: lilka_media_player
  61.     buffer_size: 4000 #Must be between 4000 and 4000000. Defaults to 100000
  62.     codec_support_enabled: true # set to flase to save and specify format to save recources
  63.     announcement_pipeline:
  64.         speaker: lilka_speaker
  65.   #      format: MP3 # One of FLAC, MP3, WAV, or NONE.
  66.         num_channels: 1
  67.  
  68.  
  69. # ---------------------------------------------------
  70. # СЕНСОРИ
  71. # ---------------------------------------------------
  72.  
  73. sensor:
  74.   - platform: adc
  75.     pin: GPIO3
  76.     id: battery_voltage
  77.     name: "Battery Voltage"
  78.     icon: "mdi:lightning-bolt"
  79.     update_interval: 10s
  80.     attenuation: 12db
  81.     filters:
  82.       - multiply: 1.33
  83.    
  84.   - platform: template
  85.     id: battery_level
  86.     name: "Battery Level"
  87.     icon: "mdi:battery"
  88.     unit_of_measurement: "%"
  89.     accuracy_decimals: 0
  90.     update_interval: 10s
  91.     lambda: |-
  92.       float voltage = id(battery_voltage).state;
  93.       float percent = (voltage - 3.0) / (4.2 - 3.0) * 100.0;
  94.       if (percent > 100) percent = 100;
  95.       if (percent < 0) percent = 0;
  96.       return percent;
  97.  
  98. # ---------------------------------------------------
  99. # ДИСПЛЕЙ ST7789V + LVGL
  100. # ---------------------------------------------------
  101.  
  102. spi:
  103.   clk_pin: 18
  104.   mosi_pin: 17
  105.  
  106. display:
  107.   - platform: mipi_spi
  108.     model: ST7789V
  109.     id: my_display
  110.     dc_pin: 15
  111.     cs_pin: 7
  112.     update_interval: 1s
  113.     rotation: 270
  114.     invert_colors: true
  115.     color_order: BGR
  116.     pixel_mode: 16bit
  117.     dimensions:
  118.       width: 280
  119.       height: 240
  120.       offset_width: 20
  121.       offset_height: 0
  122.     auto_clear_enabled: false
  123.  
  124. lvgl:
  125.   log_level: INFO
  126.   style_definitions:
  127.     - id: default_style
  128.       bg_color: 0x000000
  129.       text_color: 0xFFFFFF
  130.     - id: focused_style
  131.       border_color: 0xFFFFFF
  132.       border_width: 3
  133.  
  134.   pages:
  135.     - id: main_page
  136.       bg_color: 0x000000
  137.       widgets:
  138.         - button:
  139.             id: red_button
  140.             align: CENTER
  141.             y: -40
  142.             width: 180
  143.             height: 50
  144.             bg_color: 0xFF0000
  145.             widgets:
  146.               - label:
  147.                   id: battery_label
  148.                   text: "Battery: --"
  149.                   align: CENTER
  150.  
  151.         - button:
  152.             id: green_button
  153.             align: CENTER
  154.             y: 20
  155.             width: 180
  156.             height: 50
  157.             bg_color: 0x00FF00
  158.             widgets:
  159.               - label:
  160.                   id: voltage_label
  161.                   text: "Voltage: --"
  162.                   align: CENTER
  163.                   text_color: 0x000000
  164.  
  165.         - button:
  166.             id: blue_button
  167.             align: CENTER
  168.             y: 80
  169.             width: 180
  170.             height: 50
  171.             bg_color: 0x0000FF
  172.             widgets:
  173.               - label:
  174.                   text: "Lilka LVGL"
  175.                   align: CENTER
  176.                   text_color: 0xFFFFFF
  177.  
  178. # ---------------------------------------------------
  179. # ГЛОБАЛЬНІ ЗМІННІ ТА СКРИПТ ФОКУСУ
  180. # ---------------------------------------------------
  181.  
  182. globals:
  183.   - id: current_button_index
  184.     type: int
  185.     restore_value: no
  186.     initial_value: '0'
  187.  
  188. script:
  189.   - id: update_focus
  190.     then:
  191.       - lvgl.widget.update:
  192.           id: red_button
  193.           border_width: !lambda 'return id(current_button_index) == 0 ? 3 : 0;'
  194.       - lvgl.widget.update:
  195.           id: green_button
  196.           border_width: !lambda 'return id(current_button_index) == 1 ? 3 : 0;'
  197.       - lvgl.widget.update:
  198.           id: blue_button
  199.           border_width: !lambda 'return id(current_button_index) == 2 ? 3 : 0;'
  200.  
  201. # ---------------------------------------------------
  202. # КНОПКИ (ВСІ ВИДИМІ У HOME ASSISTANT)
  203. # ---------------------------------------------------
  204.  
  205. binary_sensor:
  206.  # D-Pad
  207.   - platform: gpio
  208.     pin:
  209.       number: 38
  210.       mode: INPUT_PULLUP
  211.       inverted: true
  212.     id: button_up
  213.     name: "Button Up"
  214.     icon: "mdi:arrow-up-circle"
  215.     filters:
  216.       - delayed_on_off: 50ms
  217.     on_press:
  218.       - lambda: |-
  219.           id(current_button_index)--;
  220.           if (id(current_button_index) < 0) id(current_button_index) = 2;
  221.       - script.execute: update_focus
  222.  
  223.   - platform: gpio
  224.     pin:
  225.       number: 41
  226.       mode: INPUT_PULLUP
  227.       inverted: true
  228.     id: button_down
  229.     name: "Button Down"
  230.     icon: "mdi:arrow-down-circle"
  231.     filters:
  232.       - delayed_on_off: 50ms
  233.     on_press:
  234.       - lambda: |-
  235.           id(current_button_index)++;
  236.           if (id(current_button_index) > 2) id(current_button_index) = 0;
  237.       - script.execute: update_focus
  238.  
  239.   - platform: gpio
  240.     pin:
  241.       number: 39
  242.       mode: INPUT_PULLUP
  243.       inverted: true
  244.     id: button_left
  245.     name: "Button Left"
  246.     icon: "mdi:arrow-left-circle"
  247.     filters:
  248.       - delayed_on_off: 50ms
  249.  
  250.   - platform: gpio
  251.     pin:
  252.       number: 40
  253.       mode: INPUT_PULLUP
  254.       inverted: true
  255.     id: button_right
  256.     name: "Button Right"
  257.     icon: "mdi:arrow-right-circle"
  258.     filters:
  259.       - delayed_on_off: 50ms
  260.  
  261.   # A B C D
  262.   - platform: gpio
  263.     pin:
  264.       number: 5
  265.       mode: INPUT_PULLUP
  266.       inverted: true
  267.     id: button_a
  268.     name: "Button A"
  269.     icon: "mdi:alpha-a-circle"
  270.     filters:
  271.       - delayed_on_off: 50ms
  272.  
  273.   - platform: gpio
  274.     pin:
  275.       number: 6
  276.       mode: INPUT_PULLUP
  277.       inverted: true
  278.     id: button_b
  279.     name: "Button B"
  280.     icon: "mdi:alpha-b-circle"
  281.     filters:
  282.       - delayed_on_off: 50ms
  283.  
  284.   - platform: gpio
  285.     pin:
  286.       number: 10
  287.       mode: INPUT_PULLUP
  288.       inverted: true
  289.     id: button_c
  290.     name: "Button C"
  291.     icon: "mdi:alpha-c-circle"
  292.     filters:
  293.       - delayed_on_off: 50ms
  294.  
  295.   - platform: gpio
  296.     pin:
  297.       number: 9
  298.       mode: INPUT_PULLUP
  299.       inverted: true
  300.     id: button_d
  301.     name: "Button D"
  302.     icon: "mdi:alpha-d-circle"
  303.     filters:
  304.       - delayed_on_off: 50ms
  305.  
  306.   # Start / Select
  307.   - platform: gpio
  308.     pin:
  309.       number: 4
  310.       mode: INPUT_PULLUP
  311.       inverted: true
  312.     id: button_start
  313.     name: "Button Start"
  314.     icon: "mdi:play-circle"
  315.     filters:
  316.       - delayed_on_off: 50ms
  317.  
  318.   - platform: gpio
  319.     pin:
  320.       number: 0
  321.       mode: INPUT_PULLUP
  322.       inverted: true
  323.     id: button_select
  324.     name: "Button Select"
  325.     icon: "mdi:checkbox-marked-circle"
  326.     filters:
  327.       - delayed_on_off: 50ms
  328.  
  329. # ---------------------------------------------------
  330. # ОНОВЛЕННЯ СТАТУСУ БАТАРЕЇ НА ЕКРАНІ
  331. # ---------------------------------------------------
  332.  
  333. interval:
  334.   - interval: 5s
  335.     then:
  336.       - lvgl.label.update:
  337.           id: battery_label
  338.           text: !lambda |-
  339.             return std::string("Battery: ") + to_string((int)id(battery_level).state) + "%";
  340.  
  341.       - lvgl.label.update:
  342.           id: voltage_label
  343.           text: !lambda |-
  344.             char buf[20];
  345.             snprintf(buf, sizeof(buf), "Voltage: %.2fV", id(battery_voltage).state);
  346.             return std::string(buf);
Advertisement
Add Comment
Please, Sign In to add comment