From 4c9eb4f71f4d872e2b333982c0e84ad299ba72a7 Mon Sep 17 00:00:00 2001 From: void Date: Mon, 7 Apr 2025 03:12:16 +0000 Subject: [PATCH] Add dev32 buzzer, neopixel, common anode rgb led, SPDT, boot button as a HA button --- dev32 | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 379 insertions(+) create mode 100644 dev32 diff --git a/dev32 b/dev32 new file mode 100644 index 0000000..00d63b8 --- /dev/null +++ b/dev32 @@ -0,0 +1,379 @@ +esphome: + name: dev32 + friendly_name: DEV32 + +esp32: + board: esp32dev + framework: + type: arduino + +logger: + +api: + +ota: + platform: esphome + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +esp32_ble_tracker: + scan_parameters: + active: true + +bluetooth_proxy: + active: true + +output: + - platform: ledc + pin: GPIO5 + id: output_red + inverted: true + - platform: ledc + pin: GPIO18 + id: output_green + inverted: true + - platform: ledc + pin: GPIO19 + inverted: true + id: output_blue + - platform: ledc + pin: GPIO33 + id: piezo_output + frequency: 1000 Hz + inverted: false + +light: + - platform: neopixelbus + type: GRB + variant: WS2812 + pin: GPIO25 + num_leds: 12 + name: "NeoPixel Light" + id: neopixelled + restore_mode: ALWAYS_OFF + gamma_correct: 2.8 + default_transition_length: 1s + flash_transition_length: 0s + effects: + - addressable_rainbow: + - addressable_rainbow: + name: Rainbow Effect With Custom Values + speed: 10 + width: 50 + - addressable_color_wipe: + - addressable_color_wipe: + name: Color Wipe Effect With Custom Values + colors: + - red: 100% + green: 100% + blue: 100% + num_leds: 5 + gradient: true + - red: 0% + green: 0% + blue: 0% + num_leds: 1 + add_led_interval: 100ms + reverse: false + - addressable_scan: + - addressable_scan: + name: Scan Effect With Custom Values + move_interval: 100ms + scan_width: 1 + - addressable_twinkle: + - addressable_twinkle: + name: Twinkle Effect With Custom Values + twinkle_probability: 5% + progress_interval: 4ms + - addressable_random_twinkle: + - addressable_random_twinkle: + name: Random Twinkle Effect With Custom Values + twinkle_probability: 5% + progress_interval: 32ms + - addressable_fireworks: + - addressable_fireworks: + name: Fireworks Effect With Custom Values + update_interval: 32ms + spark_probability: 10% + use_random_color: false + fade_out_rate: 120 + - addressable_flicker: + - addressable_flicker: + name: Flicker Effect With Custom Values + update_interval: 16ms + intensity: 5% + - pulse: + name: "Fast Pulse" + transition_length: 0.5s + update_interval: 0.5s + min_brightness: 0% + max_brightness: 100% + - pulse: + name: "Slow Pulse" + transition_length: 500ms + update_interval: 2s + - pulse: + name: "Asymmetrical Pulse" + transition_length: + on_length: 1s + off_length: 500ms + update_interval: 1.5s + - random: + name: Random Effect With Custom Values + transition_length: 5s + update_interval: 7s + - strobe: + name: Strobe Effect With Custom Values + colors: + - state: true + brightness: 100% + red: 100% + green: 90% + blue: 0% + duration: 500ms + - state: false + duration: 250ms + - state: true + brightness: 100% + red: 0% + green: 100% + blue: 0% + duration: 500ms + - flicker: + name: Flicker Effect With Custom Values1 + alpha: 95% + intensity: 3.3% + - lambda: + name: "Police Light Effect" + update_interval: 1s + lambda: |- + static bool is_red = true; + auto call = id(neopixelled).turn_on(); + call.set_transition_length(1000); + if (is_red) { + call.set_rgb(1.0, 0.0, 0.0); + } else { + call.set_rgb(0.0, 0.0, 1.0); + } + call.perform(); + is_red = !is_red; + - lambda: + name: "Slow Unique Color Cycle" + update_interval: 60s + lambda: |- + static std::vector> colors = { + {1.0, 0.0, 0.0}, + {0.0, 1.0, 0.0}, + {0.0, 0.0, 1.0}, + {1.0, 1.0, 0.0}, + {0.0, 1.0, 1.0}, + {1.0, 0.0, 1.0}, + {1.0, 1.0, 1.0}, + {1.0, 0.5, 0.0}, + {0.5, 0.0, 1.0}, + {0.0, 1.0, 0.5} + }; + static std::vector> color_queue; + static int index = 0; + if (color_queue.empty()) { + color_queue = colors; + ESP_LOGD("slow_color_cycle", "Shuffling color queue"); + std::random_shuffle(color_queue.begin(), color_queue.end()); + index = 0; + } + std::vector color = color_queue[index]; + float r = color[0]; + float g = color[1]; + float b = color[2]; + auto call = id(neopixelled).turn_on(); + call.set_transition_length(60000); + call.set_rgb(r, g, b); + call.perform(); + index++; + if (index >= color_queue.size()) { + color_queue.clear(); + } + + - platform: rgb + name: "Common Anode RGB LED" + id: common_anode_rgb_led + red: output_red + green: output_green + blue: output_blue + gamma_correct: 2.8 + default_transition_length: 1s + restore_mode: ALWAYS_OFF + effects: + - pulse: + - pulse: + name: "Fast Pulse" + transition_length: 0.5s + update_interval: 0.5s + min_brightness: 0% + max_brightness: 100% + - pulse: + name: "Slow Pulse" + transition_length: 500ms + update_interval: 2s + - pulse: + name: "Asymmetrical Pulse" + transition_length: + on_length: 1s + off_length: 500ms + update_interval: 1.5s + - random: + name: Random Effect With Custom Values + transition_length: 5s + update_interval: 7s + - strobe: + name: Strobe Effect With Custom Values + colors: + - state: true + brightness: 100% + red: 100% + green: 90% + blue: 0% + duration: 500ms + - state: false + duration: 250ms + - state: true + brightness: 100% + red: 0% + green: 100% + blue: 0% + duration: 500ms + - flicker: + name: Flicker Effect With Custom Values + alpha: 95% + intensity: 3.3% + - lambda: + name: "Police Light Effect" + update_interval: 1s + lambda: |- + static bool is_red = true; + auto call = id(common_anode_rgb_led).turn_on(); + call.set_transition_length(1000); + if (is_red) { + call.set_rgb(1.0, 0.0, 0.0); + } else { + call.set_rgb(0.0, 0.0, 1.0); + } + call.perform(); + is_red = !is_red; + - lambda: + name: "Slow Unique Color Cycle" + update_interval: 60s + lambda: |- + static std::vector> colors = { + {1.0, 0.0, 0.0}, + {0.0, 1.0, 0.0}, + {0.0, 0.0, 1.0}, + {1.0, 1.0, 0.0}, + {0.0, 1.0, 1.0}, + {1.0, 0.0, 1.0}, + {1.0, 1.0, 1.0}, + {1.0, 0.5, 0.0}, + {0.5, 0.0, 1.0}, + {0.0, 1.0, 0.5} + }; + static std::vector> color_queue; + static int index = 0; + if (color_queue.empty()) { + color_queue = colors; + ESP_LOGD("slow_color_cycle", "Shuffling color queue"); + std::random_shuffle(color_queue.begin(), color_queue.end()); + index = 0; + } + std::vector color = color_queue[index]; + float r = color[0]; + float g = color[1]; + float b = color[2]; + auto call = id(common_anode_rgb_led).turn_on(); + call.set_transition_length(60000); + call.set_rgb(r, g, b); + call.perform(); + index++; + if (index >= color_queue.size()) { + color_queue.clear(); + } + +rtttl: + output: piezo_output + id: piezo_rtttl + gain: 0.8 + +switch: + - platform: template + name: "Play Mario Melody" + id: play_mario_melody + turn_on_action: + - rtttl.play: "mario:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16d#6,8p,16d6,8p,16c6" + + - platform: template + name: "Play Funky Town" + id: play_funkytown + turn_on_action: + - rtttl.play: "Funky Town:d=8,o=4,b=125:c6,c6,a#5,c6,p,g5,p,g5,c6,f6,e6,c6,2p,c6,c6,a#5,c6,p,g5,p,g5,c6,f6,e6,c6" + + - platform: template + name: "march" + id: play_march + turn_on_action: + - rtttl.play: "DeathMarch:d=4,o=5,b=100:c,p,c,8c,2c,d#,8d,d,8c,c,8b4,2c" + + + - platform: template + name: "itchy" + id: play_itchy + turn_on_action: + - rtttl.play: "Itchy:d=8,o=5,b=160:c6,a,4p,c6,a6,4p,c6,a,c6,a,c6,a6,4p,p,c6,d6,e6,p,e6,f6,g6,4p,d6,c6,4d6,f6,4a#6,4a6,2c7" + + - platform: template + name: "trek" + id: play_trek + turn_on_action: + - rtttl.play: "TheNextG:d=4,o=5,b=100:8f#6,16a#6,16a#6,16d#7,8c#7,16p,16g#6,16g#7,16g#7,8f#7,8p,16g#6,8f#7,16p,8d#7,16p,8d#7,16p,16d#7,16a#6,16d#7,8c#7" + + - platform: template + name: "tonight" + id: play_tonight + turn_on_action: + - rtttl.play: "Tonight:d=4,o=5,b=160:2c#6,p,8c#.6,16p,c#6,16a#,16p,a#.,8g#,2a#,8p,8f#,8f#,a#,16g#.,16p,g#.,16f#,16p,f#.,p,16c#,16p,c#,p,f#.,16p,8f#,32p,g#,32p,a#,2f#" + + + + + + +binary_sensor: + - platform: gpio + pin: + number: 0 + mode: INPUT_PULLUP + inverted: true + name: "ESP32 Boot Button" + filters: + - delayed_on: 10ms + device_class: power + + - platform: gpio + pin: + number: GPIO26 + mode: INPUT_PULLUP + inverted: true + name: "Switch Position A" + filters: + - delayed_on: 10ms + + - platform: gpio + pin: + number: GPIO27 + mode: INPUT_PULLUP + inverted: true + name: "Switch Position B" + filters: + - delayed_on: 10ms + +captive_portal: