From 51cb1381985dc83940326e12e39b256ce97b96c9 Mon Sep 17 00:00:00 2001 From: iggy Date: Fri, 18 Apr 2025 23:25:29 +0200 Subject: [PATCH] Add cyb2.yml --- cyb2.yml | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 cyb2.yml diff --git a/cyb2.yml b/cyb2.yml new file mode 100644 index 0000000..b7a2c9b --- /dev/null +++ b/cyb2.yml @@ -0,0 +1,347 @@ +esphome: + name: cyb2 + friendly_name: cyb2 + +esp32: + board: esp32dev + framework: + #type: arduino + type: esp-idf + +# Enable logging +logger: + +# Enable Home Assistant API +api: + encryption: + key: "j7XV9IcJRYR2ZmJCIwezbLl7xoF5cwhUB9LICXMwSvg=" + services: + - service: play_rtttl + variables: + song_str: string + then: + - rtttl.play: + rtttl: !lambda 'return song_str;' + +ota: + - platform: esphome + password: "dc303f89c909e0defe058ed4b0a03061" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot (captive portal) in case wifi connection fails + #ap: + # ssid: "Cyb2 Fallback Hotspot" + # password: "HEbDg1Ra9OzC" + +#captive_portal: + +# ============================================================ +# ESPHome Display related setup +# +# Create a font to use, add and remove glyphs as needed. +font: + - file: 'fonts/Arimo-Regular.ttf' + id: arimo20 + size: 20 + glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäö" + +# Create a Home Assistant blue color +color: + - id: ha_blue + hex: 51c0f2 + +# ============================================================ +# Home Assistant related setup +# +light: + - platform: monochromatic + output: backlight_pwm + name: Display Backlight + id: backlight + restore_mode: ALWAYS_ON + #on_state: + # - lvgl.slider.update: + # id: backlight_slider + # value: !lambda return x; + + +# ============================================================ +# Hardware related setup +# +# Setup SPI for the display. The ESP32-2432S028R uses separate SPI buses for display and touch +spi: + - id: tft + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + - id: touch + clk_pin: GPIO25 + mosi_pin: GPIO32 + miso_pin: GPIO39 + +# Setup a pin to control the backlight +output: + - platform: ledc + pin: GPIO21 + id: backlight_pwm + - platform: ledc + pin: GPIO26 + id: rtttl_out + +# Setup the ili9xxx platform +# +# Display is used as 240x320 by default so we rotate it to 90° +display: + - platform: ili9xxx + id: esp_display + model: ili9342 + spi_id: tft + cs_pin: GPIO15 + dc_pin: GPIO2 + #invert_display: true (changed to below with ESPhome 2023.12.0) + invert_colors: false + rotation: 90 + + +# Set up the xpt2046 touch platform +touchscreen: + platform: xpt2046 + spi_id: touch + cs_pin: GPIO33 + interrupt_pin: GPIO36 + update_interval: 50ms + threshold: 400 + calibration: + x_max: 3860 + x_min: 280 + y_min: 340 + y_max: 3860 + transform: + #swap_xy: true + mirror_x: true + #mirror_y: true +lvgl: + buffer_size: 25% + pages: + - id: simon + widgets: + - label: + x: 0 + y: 10 + width: 240 + height: 50 + text_align: CENTER + id: lbl_msg + text_font: montserrat_20 + text: "HELLO" + - led: + id: lvgl_led + x: 210 + y: 10 + #color: 0x0000FF + brightness: 70% + - buttonmatrix: + x: 0 + y: 50 + width: 240 + height: 270 + id: lvgl_keypad + rows: + - buttons: + - id: btn_1 + text: "1" + - id: btn_2 + text: "2" + - id: btn_3 + text: "3" + #height: 100 + - buttons: + - id: btn_4 + text: "4" + - id: btn_5 + text: "5" + - id: btn_6 + text: "6" + - buttons: + - id: btn_7 + text: "7" + - id: btn_8 + text: "8" + - id: btn_9 + text: "9" + - buttons: + - id: btn_a + text: "*" + - id: btn_0 + text: "0" + - id: btn_b + text: "#" + + #- buttons: + + #- id: btn_red + # key_code: "r" + # text: "Red" + #bg_color: 0xff0000 + #- id: btn_green + # key_code: "g" + # text: "Green" + + #bg_color: 0x00ff00 + #- buttons: + # - id: btn_yellow + # key_code: "y" + # text: "yellow" + + # - id: btn_blue + # key_code: "b" + # text: "blue" + + #bg_color: 0x0000ff + - id: main_page + widgets: + - slider: + id: backlight_slider + x: 20 + y: 50 + width: 30 + height: 100 + pad_all: 8 + min_value: 0 + max_value: 255 + on_release: + then: + - light.turn_on: + id: backlight + brightness: !lambda |- + return int(x) / 255.0; + + +text: + - platform: lvgl + widget: lbl_msg + name: "Message" + mode: TEXT + +key_collector: + - source_id: lvgl_keypad + min_length: 4 + max_length: 20 + end_keys: "#" + end_key_required: true + back_keys: "*" + allowed_keys: "0123456789*#" + timeout: 5s + on_progress: + - if: + condition: + lambda: return (0 != x.compare(std::string{""})); + then: + - lvgl.label.update: + id: lbl_msg + text: !lambda 'return x.c_str();' + else: + - lvgl.label.update: + id: lbl_msg + text: "ENTER CODE" + on_result: + - if: + condition: + lambda: return (0 == x.compare(std::string{"1234"})); + then: + - lvgl.led.update: + id: lvgl_led + color: 0x00FF00 + else: + - lvgl.led.update: + id: lvgl_led + color: 0xFF0000 + +binary_sensor: + - platform: lvgl + widget: btn_1 + name: 1 + - platform: lvgl + widget: btn_2 + name: 2 + - platform: lvgl + widget: btn_3 + name: 3 + - platform: lvgl + widget: btn_4 + name: 4 + - platform: lvgl + widget: btn_5 + name: 5 + - platform: lvgl + widget: btn_6 + name: 6 + - platform: lvgl + widget: btn_7 + name: 7 + - platform: lvgl + widget: btn_8 + name: 8 + - platform: lvgl + widget: btn_9 + name: 9 + - platform: lvgl + widget: btn_0 + name: 0 + - platform: lvgl + widget: btn_a + name: a + - platform: lvgl + widget: btn_b + name: b + + +#i2s_audio: + # - id: i2s_audio_bus + # i2s_lrclk_pin: GPIO22 + #i2s_bclk_pin: GPIO22 + +#i2s_audio: +# i2s_lrclk_pin: GPIO26 + #i2s_bclk_pin: GPIO26 +#media_player: +# - platform: i2s_audio +# name: ESPHome I2S Media Player +# dac_type: internal +# mode: left + +#i2s_audio: +# - id: i2s_audio_bus +# i2s_lrclk_pin: GPIO33 + # i2s_bclk_pin: GPIO19 + +#speaker: +# - platform: i2s_audio +# id: cyb_speaker + #i2s_dout_pin: GPIO22 +# sample_rate: 16000 +# dac_type: internal +# bits_per_sample: 16bit +# mode: left + #channel: left +# buffer_duration: 50ms + +#media_player: +# - platform: speaker +# name: None +# id: echo_media_player +# announcement_pipeline: +# speaker: cyb_speaker +# sample_rate: 16000 +# num_channels: 1 +# format: WAV +# codec_support_enabled: false +# buffer_size: 4000 + +rtttl: + output: rtttl_out + id: my_rtttl + gain: 10% \ No newline at end of file