mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 17:06:52 +01:00
Compare commits
31
Commits
27cbbbe217
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3f3d90b2b | ||
|
|
a909041263 | ||
|
|
70d1079ccd | ||
|
|
0f1b32b1ed | ||
|
|
feaa161653 | ||
|
|
8aee65e697 | ||
|
|
0da0cd1544 | ||
|
|
6591b47c01 | ||
|
|
9a158bab19 | ||
|
|
bba78dbb17 | ||
|
|
3d5a77bd13 | ||
|
|
0f6e2350cc | ||
|
|
01fe45ce8d | ||
|
|
7c704fa55d | ||
|
|
8234220765 | ||
|
|
58a5176ed3 | ||
|
|
aa3e59bb0a | ||
|
|
71c31035e5 | ||
|
|
0c93059c78 | ||
|
|
6be43cb95e | ||
|
|
44b0601bf2 | ||
|
|
fdb9fd4796 | ||
|
|
dd88807a1b | ||
|
|
0ea4aaf685 | ||
|
|
64c25f6165 | ||
|
|
7d27f8a005 | ||
|
|
15242c38ee | ||
|
|
ae7035c597 | ||
|
|
c306d87acf | ||
|
|
c6b1cfd00d | ||
|
|
78644969ba |
No files matched your search
@@ -56,7 +56,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
for f in ${{ steps.changed.outputs.all_changed_files }}; do
|
for f in ${{ steps.changed.outputs.all_changed_files }}; do
|
||||||
# Zephyr RTOS platforms need the esphomeplatformzephyr fork, upstream doesn't know them yet
|
# Zephyr RTOS platforms need the esphomeplatformzephyr fork, upstream doesn't know them yet
|
||||||
if grep -qE '^(nrf|stm32|nxp|renesas|silabs):' "$f"; then echo "Skipping $f (zephyr fork)"; continue; fi
|
# (the platform key may also come from an !include'd package, e.g. common/xiao_stm32c5_canopen.yaml)
|
||||||
|
files="$f $(grep -oE '!include [^ ]+' "$f" | cut -d' ' -f2)"
|
||||||
|
if grep -qsE '^(nrf|stm32|nxp|renesas|silabs):' $files; then echo "Skipping $f (zephyr fork)"; continue; fi
|
||||||
echo "Validating $f..."
|
echo "Validating $f..."
|
||||||
esphome config "$f"
|
esphome config "$f"
|
||||||
done
|
done
|
||||||
@@ -7,3 +7,4 @@
|
|||||||
/archive/
|
/archive/
|
||||||
/trash/
|
/trash/
|
||||||
.device-builder.json
|
.device-builder.json
|
||||||
|
/.hosted/
|
||||||
@@ -4,19 +4,13 @@
|
|||||||
# common_eth: !include common/common_eth.yaml
|
# common_eth: !include common/common_eth.yaml
|
||||||
# ipv6_only: !include common/ipv6_only_eth.yaml
|
# ipv6_only: !include common/ipv6_only_eth.yaml
|
||||||
# WiFi devices use common/ipv6_only.yaml (this + the IPv6 SSID)
|
# WiFi devices use common/ipv6_only.yaml (this + the IPv6 SSID)
|
||||||
external_components:
|
|
||||||
# IPv6-only on wifi/ethernet with the IPv4 stack off (esphome/esphome#19750), drop once merged
|
|
||||||
- source: github://pr#19750
|
|
||||||
components: [network, wifi, ethernet]
|
|
||||||
refresh: 1h
|
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
framework:
|
framework:
|
||||||
components:
|
components:
|
||||||
# IDF v5.5.5 lwip + .local resolution over IPv6 (espressif/esp-lwip#94), drop once in IDF
|
# IDF v6.1.1 lwip + .local resolution over IPv6 (espressif/esp-lwip#94), drop once in IDF
|
||||||
- name: lwip
|
- name: lwip
|
||||||
source: https://github.com/randybb/esp-lwip.git
|
source: https://github.com/randybb/esp-lwip.git
|
||||||
ref: idf-v5.5.5-lwip-component
|
ref: idf-v6.1.1-lwip-component
|
||||||
path: lwip
|
path: lwip
|
||||||
|
|
||||||
network:
|
network:
|
||||||
|
|||||||
@@ -81,14 +81,9 @@ ota:
|
|||||||
|
|
||||||
api:
|
api:
|
||||||
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
||||||
on_client_connected:
|
# Home Assistant has subscribed and received every state
|
||||||
- delay: 2s
|
on_client_synced:
|
||||||
- if:
|
- lvgl.page.show: page_home
|
||||||
condition:
|
|
||||||
api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- lvgl.page.show: page_home
|
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
|
|||||||
+86
-83
@@ -1,14 +1,7 @@
|
|||||||
esp32:
|
# Vehicle iBeacon on an M5Stack ATOM Lite: BLE only, Wi-Fi + OTA by holding the button.
|
||||||
variant: esp32
|
# LED: short blue blink at boot, then dark; blue while the home beacon (mcu-gate) is seen;
|
||||||
toolchain: esp-idf
|
# green while Wi-Fi is on.
|
||||||
framework:
|
#
|
||||||
advanced:
|
|
||||||
flash_chip: gd # ESP32-PICO-D4, like every other ATOM Lite
|
|
||||||
type: esp-idf
|
|
||||||
|
|
||||||
external_components:
|
|
||||||
- source: components
|
|
||||||
|
|
||||||
# PINOUTS: M5ATOM
|
# PINOUTS: M5ATOM
|
||||||
# IR G12
|
# IR G12
|
||||||
# NEO G27
|
# NEO G27
|
||||||
@@ -24,85 +17,95 @@ external_components:
|
|||||||
# 1-WIRE G22
|
# 1-WIRE G22
|
||||||
# NC G19
|
# NC G19
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
variant: esp32
|
||||||
|
toolchain: esp-idf
|
||||||
|
framework:
|
||||||
|
advanced:
|
||||||
|
flash_chip: gd # ESP32-PICO-D4, like every other ATOM Lite
|
||||||
|
type: esp-idf
|
||||||
|
|
||||||
|
# iBeacon on air from boot without the empty standard advertisement every 10 s
|
||||||
|
packages:
|
||||||
|
wifi: !include wifi.yaml
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
on_loop:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
lambda: |-
|
- light.turn_on:
|
||||||
static uint32_t last_state = 0;
|
id: led
|
||||||
auto state = App.get_app_state();
|
red: 0%
|
||||||
if (state != last_state) {
|
green: 0%
|
||||||
if (state & STATUS_LED_ERROR) {
|
blue: 50%
|
||||||
auto call = id(led).turn_on();
|
transition_length: 0s
|
||||||
call.set_effect("ERROR");
|
- delay: 300ms
|
||||||
call.perform();
|
- light.turn_off:
|
||||||
} else if (state & STATUS_LED_WARNING) {
|
id: led
|
||||||
auto call = id(led).turn_on();
|
transition_length: 0s
|
||||||
call.set_effect("BOOT");
|
|
||||||
call.perform();
|
wifi:
|
||||||
} else {
|
enable_on_boot: false
|
||||||
auto call = id(led).turn_on();
|
|
||||||
call.set_effect("BEACON");
|
# flashed over USB straight to encrypted OTA, no password migration needed
|
||||||
call.perform();
|
ota:
|
||||||
}
|
- platform: esphome
|
||||||
last_state = state;
|
encryption:
|
||||||
}
|
key: !secret api_key
|
||||||
|
|
||||||
|
esp32_ble_tracker:
|
||||||
|
scan_parameters:
|
||||||
|
active: false
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
id: button
|
||||||
|
pin:
|
||||||
|
number: 39
|
||||||
|
inverted: true
|
||||||
|
on_press:
|
||||||
|
- delay: 3s
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
binary_sensor.is_on: button
|
||||||
|
then:
|
||||||
|
- wifi.enable:
|
||||||
|
- light.turn_on:
|
||||||
|
id: led
|
||||||
|
red: 0%
|
||||||
|
green: 50%
|
||||||
|
blue: 0%
|
||||||
|
transition_length: 0s
|
||||||
|
- platform: ble_presence
|
||||||
|
id: home
|
||||||
|
ibeacon_uuid: !secret ble_beacon_gate_uuid
|
||||||
|
timeout: 1min
|
||||||
|
on_press:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
not:
|
||||||
|
wifi.enabled:
|
||||||
|
then:
|
||||||
|
- light.turn_on:
|
||||||
|
id: led
|
||||||
|
red: 0%
|
||||||
|
green: 0%
|
||||||
|
blue: 50%
|
||||||
|
transition_length: 0s
|
||||||
|
on_release:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
not:
|
||||||
|
wifi.enabled:
|
||||||
|
then:
|
||||||
|
- light.turn_off:
|
||||||
|
id: led
|
||||||
|
transition_length: 0s
|
||||||
|
|
||||||
light:
|
light:
|
||||||
- platform: esp32_rmt_led_strip
|
- platform: esp32_rmt_led_strip
|
||||||
name: LED
|
|
||||||
id: led
|
id: led
|
||||||
rgb_order: GRB
|
channel_colors: GRB
|
||||||
pin: 27
|
pin: 27
|
||||||
num_leds: 1
|
num_leds: 1
|
||||||
chipset: ws2812
|
chipset: ws2812
|
||||||
restore_mode: ALWAYS_OFF
|
restore_mode: ALWAYS_OFF
|
||||||
effects:
|
|
||||||
- strobe:
|
|
||||||
name: "BEACON"
|
|
||||||
colors:
|
|
||||||
- state: true
|
|
||||||
red: 0%
|
|
||||||
green: 0%
|
|
||||||
blue: 50%
|
|
||||||
duration: 200ms
|
|
||||||
- state: false
|
|
||||||
duration: 200ms
|
|
||||||
- state: true
|
|
||||||
red: 0%
|
|
||||||
green: 0%
|
|
||||||
blue: 50%
|
|
||||||
duration: 200ms
|
|
||||||
- state: false
|
|
||||||
duration: 10s
|
|
||||||
- lambda:
|
|
||||||
name: "ERROR"
|
|
||||||
update_interval: 0.5s
|
|
||||||
lambda: |-
|
|
||||||
static bool state = false;
|
|
||||||
auto call = id(led).turn_on();
|
|
||||||
call.set_transition_length(500);
|
|
||||||
call.set_rgb(1, 0, 0);
|
|
||||||
if (!state) {
|
|
||||||
call.set_brightness(1);
|
|
||||||
} else {
|
|
||||||
// If using 0, it freaks Home Assistant UI.
|
|
||||||
call.set_brightness(0.01);
|
|
||||||
}
|
|
||||||
call.perform();
|
|
||||||
state = !state;
|
|
||||||
- lambda:
|
|
||||||
name: "BOOT"
|
|
||||||
update_interval: 0.5s
|
|
||||||
lambda: |-
|
|
||||||
static bool state = false;
|
|
||||||
auto call = id(led).turn_on();
|
|
||||||
call.set_transition_length(500);
|
|
||||||
call.set_rgb(0, 1, 0);
|
|
||||||
if (!state) {
|
|
||||||
call.set_brightness(1);
|
|
||||||
} else {
|
|
||||||
// If using 0, it freaks Home Assistant UI.
|
|
||||||
call.set_brightness(0.01);
|
|
||||||
}
|
|
||||||
call.perform();
|
|
||||||
state = !state;
|
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
---
|
||||||
|
# Seeed XIAO STM32C5 as a CANopen node (mrk's canopen hub + canopen_entities), MCUboot, OTA over CAN from can2mqtt
|
||||||
|
# (upload .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin).
|
||||||
|
# Needs: substitutions node_id; the esphomeplatformzephyr fork (esphome-zephyr).
|
||||||
|
# Pinout:
|
||||||
|
# PB12 user LED (active low) -> LED (light binary)
|
||||||
|
# PH2 BOOT0, left alone (a pull-up there sends software resets to ROM DFU)
|
||||||
|
# PB5/PB13 FDCAN2 RX/TX, PB14 CAN_STB -> on-board transceiver (board DTS)
|
||||||
|
# PB3/PB4 I2C2 SCL/SDA, LSM6DS3TR-C @0x6A -> on-board IMU (motion lsm6ds)
|
||||||
|
# First flash (TinyUF2 erased with mcu-stm32-xiao-c5-eraser.yaml), hold BOOT + press RESET for ROM DFU:
|
||||||
|
# dfu-util -a 0 -s 0x08000000 -D .esphome/build/<node>/.west_build/mcuboot/zephyr/zephyr.bin
|
||||||
|
# dfu-util -a 0 -s 0x08008000:leave -D .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin
|
||||||
|
|
||||||
|
external_components:
|
||||||
|
- source: github://mrk-its/esphome-canopen@dc6efff43e0076a5c2820800e6ff5ce28ee4c678 # canopen_entities; newer needs consts the zephyr fork lacks
|
||||||
|
components: [canopen, canopen_entities]
|
||||||
|
|
||||||
|
stm32:
|
||||||
|
variant: STM32C5
|
||||||
|
board: xiao_stm32c5
|
||||||
|
framework:
|
||||||
|
advanced:
|
||||||
|
bootloader: mcuboot
|
||||||
|
# required by the fork for MCUboot on the XIAO; the first flash is dfu-util by hand (see above)
|
||||||
|
runner: stm32cubeprogrammer
|
||||||
|
|
||||||
|
logger:
|
||||||
|
logs:
|
||||||
|
# canbus logs every frame at DEBUG; over USB CDC that stalls the loop and the RX queue overflows
|
||||||
|
canbus: INFO
|
||||||
|
# the same for pitch/roll every 200 ms
|
||||||
|
sensor: INFO
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
# pins come from the board DTS (i2c2: PB3/PB4), STM32C5 takes no sda:/scl:
|
||||||
|
- id: i2c_imu
|
||||||
|
dts_node_override: i2c2
|
||||||
|
|
||||||
|
motion:
|
||||||
|
- platform: lsm6ds
|
||||||
|
id: imu
|
||||||
|
i2c_id: i2c_imu
|
||||||
|
address: 0x6A
|
||||||
|
# a live inclinometer (maptool's dashboard / Terrain view) needs 100-200 ms
|
||||||
|
update_interval: 200ms
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: lsm6ds
|
||||||
|
id: imu_temp
|
||||||
|
name: IMU Temperature
|
||||||
|
# Levelled by the node itself (the mounting error belongs to the sensor, every reader of the bus gets it
|
||||||
|
# corrected): raw = state + offset, so levelling again adds to the offsets
|
||||||
|
- platform: motion
|
||||||
|
motion_id: imu
|
||||||
|
id: pitch
|
||||||
|
type: pitch
|
||||||
|
name: Pitch
|
||||||
|
filters:
|
||||||
|
- lambda: return x - id(pitch_offset).state;
|
||||||
|
- platform: motion
|
||||||
|
motion_id: imu
|
||||||
|
id: roll
|
||||||
|
type: roll
|
||||||
|
name: Roll
|
||||||
|
filters:
|
||||||
|
- lambda: return x - id(roll_offset).state;
|
||||||
|
|
||||||
|
number:
|
||||||
|
- platform: template
|
||||||
|
id: pitch_offset
|
||||||
|
name: Pitch Offset
|
||||||
|
entity_category: config
|
||||||
|
unit_of_measurement: "°"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true
|
||||||
|
initial_value: 0
|
||||||
|
min_value: -45
|
||||||
|
max_value: 45
|
||||||
|
step: 0.01
|
||||||
|
- platform: template
|
||||||
|
id: roll_offset
|
||||||
|
name: Roll Offset
|
||||||
|
entity_category: config
|
||||||
|
unit_of_measurement: "°"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true
|
||||||
|
initial_value: 0
|
||||||
|
min_value: -45
|
||||||
|
max_value: 45
|
||||||
|
step: 0.01
|
||||||
|
|
||||||
|
# canopen_entities has no button: a switch that turns itself back off. On uneven ground: level, turn the car
|
||||||
|
# 180° on the same spot, level again and take the mean (maptool writes the offsets for that)
|
||||||
|
switch:
|
||||||
|
- platform: template
|
||||||
|
id: level_imu
|
||||||
|
name: Level IMU
|
||||||
|
entity_category: config
|
||||||
|
lambda: return false;
|
||||||
|
turn_on_action:
|
||||||
|
- lambda: |-
|
||||||
|
if (std::isnan(id(pitch).state) || std::isnan(id(roll).state))
|
||||||
|
return;
|
||||||
|
id(pitch_offset).make_call().set_value(id(pitch_offset).state + id(pitch).state).perform();
|
||||||
|
id(roll_offset).make_call().set_value(id(roll_offset).state + id(roll).state).perform();
|
||||||
|
ESP_LOGI("level", "levelled: pitch offset %.2f, roll offset %.2f", id(pitch_offset).state, id(roll_offset).state);
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: gpio
|
||||||
|
id: led_out
|
||||||
|
pin:
|
||||||
|
number: PB12
|
||||||
|
inverted: true
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: binary
|
||||||
|
name: LED
|
||||||
|
id: led
|
||||||
|
output: led_out
|
||||||
|
|
||||||
|
# no button on PH2: it is BOOT0, and with BOOT_SEL on the pin (after tinyuf2_eraser) an internal pull-up there makes
|
||||||
|
# every software reset (OTA, reboot) start the ROM DFU bootloader instead of MCUboot
|
||||||
|
|
||||||
|
canbus:
|
||||||
|
- platform: zephyr_can
|
||||||
|
id: can_bus
|
||||||
|
can_id: 0
|
||||||
|
bit_rate: 500kbps
|
||||||
|
# an SDO block (16 frames) arrives back to back and must fit the RX queue (default 8)
|
||||||
|
rx_buffer_size: 32
|
||||||
|
|
||||||
|
# a list, so a node file can add a second local node (e.g. a PKP keypad emulation)
|
||||||
|
canopen:
|
||||||
|
- id: can_gate
|
||||||
|
canbus_id: can_bus
|
||||||
|
node_id: ${node_id}
|
||||||
|
heartbeat_interval: 5s
|
||||||
|
|
||||||
|
canopen_entities:
|
||||||
|
canopen_id: can_gate
|
||||||
|
entities:
|
||||||
|
- id: led
|
||||||
|
index: 1
|
||||||
|
tpdo: 0
|
||||||
|
# 2-byte encoding over min..max, so the three fit one TPDO
|
||||||
|
- id: pitch
|
||||||
|
index: 3
|
||||||
|
tpdo: 1
|
||||||
|
size: 2
|
||||||
|
min_value: -180
|
||||||
|
max_value: 180
|
||||||
|
- id: roll
|
||||||
|
index: 4
|
||||||
|
tpdo: 1
|
||||||
|
size: 2
|
||||||
|
min_value: -180
|
||||||
|
max_value: 180
|
||||||
|
- id: imu_temp
|
||||||
|
index: 5
|
||||||
|
tpdo: 1
|
||||||
|
size: 2
|
||||||
|
min_value: -40
|
||||||
|
max_value: 125
|
||||||
|
# levelling (maptool /can.html): Level IMU = SDO 0x2022:1 <- 1; offsets REAL32, state 0x2101 / 0x2111,
|
||||||
|
# command 0x2102:1 / 0x2112:1. 16/17: the nodes' own entities are 6..15
|
||||||
|
- id: level_imu
|
||||||
|
index: 2
|
||||||
|
- id: pitch_offset
|
||||||
|
index: 16
|
||||||
|
- id: roll_offset
|
||||||
|
index: 17
|
||||||
|
remote_logs:
|
||||||
|
level: INFO
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- platform: canopen_entities
|
||||||
|
canopen_id: can_gate
|
||||||
|
# the XIAO's board layout has slot0 one sector larger than slot1 (swap-move); with the fork's default
|
||||||
|
# (offset) MCUboot finds the slots incompatible and never installs the update
|
||||||
|
swap_method: move
|
||||||
|
|
||||||
|
# confirms the new MCUboot image after a good boot; without it MCUboot rolls back at the next reset
|
||||||
|
safe_mode:
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
build/
|
|
||||||
managed_components/
|
|
||||||
sdkconfig
|
|
||||||
sdkconfig.old
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
||||||
project(xiao_c6_spi)
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
= XIAO ESP32-C6 esp-hosted co-processor (SPI)
|
|
||||||
|
|
||||||
esp-hosted-mcu 3.1.0 co-processor firmware (`examples/wifi/sta/cp`) for a Seeed XIAO ESP32-C6 that gives a
|
|
||||||
XIAO ESP32-C5 its Wi-Fi over SPI (`mcu-its-g5.yaml`). The user LED (GPIO15) blinks while it runs.
|
|
||||||
|
|
||||||
Wiring, D-pin to the same D-pin on both boards, plus GND and 3V3:
|
|
||||||
|
|
||||||
[cols="1,1,1,1"]
|
|
||||||
|===
|
|
||||||
| Signal | XIAO pin | C5 GPIO | C6 GPIO
|
|
||||||
|
|
||||||
| CLK | D8 | 8 | 19
|
|
||||||
| MISO | D9 | 9 | 20
|
|
||||||
| MOSI | D10 | 10 | 18
|
|
||||||
| CS | D3 | 7 | 21
|
|
||||||
| handshake | D0 | 1 | 0
|
|
||||||
| data ready | D1 | 0 | 1
|
|
||||||
| reset | D2 | 25 | 2 (the XIAO has no EN pin)
|
|
||||||
|===
|
|
||||||
|
|
||||||
Build with the ESP-IDF that ESPHome already downloaded, and flash over USB:
|
|
||||||
|
|
||||||
----
|
|
||||||
./build.sh /dev/serial/by-id/usb-Espressif_USB_JTAG_serial_debug_unit_90:64:9B:AB:5F:DC-if00
|
|
||||||
----
|
|
||||||
|
|
||||||
Keep the esp_hosted version in `main/idf_component.yml` in step with the one ESPHome uses on the host.
|
|
||||||
ESPHome's `update: platform: esp32_hosted` only supports ESP32-P4 and ESP32-H2 hosts, so this one is flashed by hand.
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Build the co-processor firmware with the ESP-IDF that ESPHome already downloaded, and flash it
|
|
||||||
# when a port is given: ./build.sh [/dev/serial/by-id/usb-Espressif_...]
|
|
||||||
set -e
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
IDF=$(ls -d "$HOME"/.cache/esphome/idf/frameworks/5.5.* | sort -V | tail -1)
|
|
||||||
export IDF_PATH="$IDF" IDF_TOOLS_PATH="$HOME/.cache/esphome/idf"
|
|
||||||
export IDF_PYTHON_ENV_PATH="$HOME/.cache/esphome/idf/penvs/$(basename "$IDF")"
|
|
||||||
. "$IDF_PATH/export.sh" >/dev/null
|
|
||||||
[ -f sdkconfig ] || idf.py set-target esp32c6
|
|
||||||
idf.py build
|
|
||||||
[ -z "$1" ] || idf.py -p "$1" flash
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
espressif/esp_hosted:
|
|
||||||
component_hash: 22b08509494d4465f0e2f91ee16973d76fe90d5a930fa3910b7a43615db001bf
|
|
||||||
dependencies:
|
|
||||||
- name: cherry-embedded/cherryusb
|
|
||||||
registry_url: https://components.espressif.com
|
|
||||||
require: private
|
|
||||||
rules:
|
|
||||||
- if: target in [esp32p4]
|
|
||||||
- if: $CONFIG{ESP_HOSTED_HOST_USB_CHERRYUSB_MANIFEST} == 1
|
|
||||||
version: '>=1.6.0'
|
|
||||||
- name: espressif/esp_tinyusb
|
|
||||||
registry_url: https://components.espressif.com
|
|
||||||
require: private
|
|
||||||
rules:
|
|
||||||
- if: target in [esp32s2, esp32s3, esp32s31]
|
|
||||||
- if: $CONFIG{ESP_HOSTED_CP_TINYUSB_MANIFEST} == 1
|
|
||||||
version: '*'
|
|
||||||
- name: espressif/iot_usbh_rndis
|
|
||||||
registry_url: https://components.espressif.com
|
|
||||||
require: private
|
|
||||||
rules:
|
|
||||||
- if: target in [esp32p4]
|
|
||||||
- if: $CONFIG{ESP_HOSTED_HOST_USB_RNDIS_MANIFEST} == 1
|
|
||||||
version: ^0.5.2
|
|
||||||
- name: espressif/usb_host_cdc_acm
|
|
||||||
registry_url: https://components.espressif.com
|
|
||||||
require: private
|
|
||||||
rules:
|
|
||||||
- if: target in [esp32p4]
|
|
||||||
- if: $CONFIG{ESP_HOSTED_HOST_USB_CDC_ACM_MANIFEST} == 1
|
|
||||||
version: '*'
|
|
||||||
- name: idf
|
|
||||||
require: private
|
|
||||||
version: '>=5.5'
|
|
||||||
source:
|
|
||||||
registry_url: https://components.espressif.com/
|
|
||||||
type: service
|
|
||||||
targets:
|
|
||||||
- esp32
|
|
||||||
- esp32s2
|
|
||||||
- esp32s3
|
|
||||||
- esp32s31
|
|
||||||
- esp32c2
|
|
||||||
- esp32c3
|
|
||||||
- esp32c5
|
|
||||||
- esp32c6
|
|
||||||
- esp32c61
|
|
||||||
- esp32h2
|
|
||||||
- esp32h4
|
|
||||||
- esp32h21
|
|
||||||
- esp32p4
|
|
||||||
version: 3.1.0
|
|
||||||
idf:
|
|
||||||
source:
|
|
||||||
type: idf
|
|
||||||
version: 5.5.6
|
|
||||||
direct_dependencies:
|
|
||||||
- espressif/esp_hosted
|
|
||||||
- idf
|
|
||||||
manifest_hash: c37e626b03eed70cc211e75eb89460b788364cc18d9edb9dd97aec930c8ccc2c
|
|
||||||
target: esp32c6
|
|
||||||
version: 2.0.0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
idf_component_register(SRCS "main.c"
|
|
||||||
INCLUDE_DIRS "."
|
|
||||||
REQUIRES esp_hosted
|
|
||||||
PRIV_REQUIRES nvs_flash esp_wifi)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
espressif/esp_hosted:
|
|
||||||
version: '==3.1.0' # keep in step with the esp_hosted version ESPHome uses on the host
|
|
||||||
idf:
|
|
||||||
version: '>=5.5'
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "esp_event.h"
|
|
||||||
#include "nvs_flash.h"
|
|
||||||
|
|
||||||
#include "esp_check.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "freertos/FreeRTOS.h"
|
|
||||||
#include "freertos/task.h"
|
|
||||||
|
|
||||||
static const char *TAG = "wifi_mcu_example";
|
|
||||||
|
|
||||||
void app_main(void)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "ESP-Hosted MCU WiFi Example Starting...");
|
|
||||||
|
|
||||||
/* Initialize NVS */
|
|
||||||
esp_err_t ret = nvs_flash_init();
|
|
||||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
||||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
||||||
ret = nvs_flash_init();
|
|
||||||
}
|
|
||||||
ESP_ERROR_CHECK(ret);
|
|
||||||
|
|
||||||
/* create default event loop */
|
|
||||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
|
||||||
|
|
||||||
/* Heartbeat on the XIAO ESP32-C6 user LED (GPIO15, active low): shows the co-processor runs. */
|
|
||||||
gpio_set_direction(GPIO_NUM_15, GPIO_MODE_OUTPUT);
|
|
||||||
for (int on = 0;; on = !on) {
|
|
||||||
gpio_set_level(GPIO_NUM_15, !on);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(500));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# ESP-Hosted shared partition table — 4 MB flash, dual OTA (1.75 MB per slot)
|
|
||||||
# Name, Type, SubType, Offset, Size
|
|
||||||
nvs, data, nvs, 0x9000, 0x4000
|
|
||||||
otadata, data, ota, 0xd000, 0x2000
|
|
||||||
phy_init, data, phy, 0xf000, 0x1000
|
|
||||||
ota_0, app, ota_0, 0x10000, 0x1C0000
|
|
||||||
ota_1, app, ota_1, 0x1D0000, 0x1C0000
|
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
# ── Role: COPROCESSOR ────────────────────────────────────────────────
|
|
||||||
# ESP-Hosted coprocessor firmware (works with both MCU and Linux hosts
|
|
||||||
# via the unified MCU RPC v2 wire).
|
|
||||||
CONFIG_ESP_HOSTED=y
|
|
||||||
CONFIG_ESP_HOSTED_CP=y
|
|
||||||
CONFIG_ESP_HOSTED_CP_FOR_MCU=y
|
|
||||||
CONFIG_ESP_HOSTED_CP_RPC_V2=y
|
|
||||||
|
|
||||||
#Disable enterprise support by default
|
|
||||||
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=n
|
|
||||||
|
|
||||||
# BT Configuration
|
|
||||||
CONFIG_BT_ENABLED=n
|
|
||||||
#CONFIG_BT_CONTROLLER_ONLY=y
|
|
||||||
|
|
||||||
# OTA
|
|
||||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_eh_cp_ota_4m.csv"
|
|
||||||
|
|
||||||
# OS
|
|
||||||
CONFIG_FREERTOS_HZ=1000
|
|
||||||
CONFIG_ESP_WIFI_NVS_ENABLED=y
|
|
||||||
|
|
||||||
CONFIG_ESP_HOSTED_CP_FEAT_WIFI=y
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
# 1. CPU
|
|
||||||
#--------
|
|
||||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y
|
|
||||||
|
|
||||||
# 2. BT Configuration
|
|
||||||
#---------------------
|
|
||||||
CONFIG_BT_ENABLED=n
|
|
||||||
CONFIG_BT_CONTROLLER_ONLY=y
|
|
||||||
CONFIG_BT_BLUEDROID_ENABLED=
|
|
||||||
CONFIG_BT_LE_SLEEP_ENABLE=y
|
|
||||||
|
|
||||||
# 3.1 BLE over SPI/SDIO
|
|
||||||
#-----------------------
|
|
||||||
CONFIG_BT_LE_HCI_INTERFACE_USE_RAM=y
|
|
||||||
|
|
||||||
# 3.2 BLE over UART
|
|
||||||
#-------------------
|
|
||||||
# Enable below config, delete sdkconfig, build/ and rebuild
|
|
||||||
# CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y
|
|
||||||
# CONFIG_BT_LE_HCI_UART_TX_PIN=5
|
|
||||||
# CONFIG_BT_LE_HCI_UART_RX_PIN=12
|
|
||||||
# CONFIG_BT_LE_HCI_UART_FLOWCTRL=n
|
|
||||||
# # 4 pin solution is not working yet for c6
|
|
||||||
# #CONFIG_BT_LE_HCI_UART_RTS_PIN=9
|
|
||||||
# #CONFIG_BT_LE_HCI_UART_CTS_PIN=13
|
|
||||||
|
|
||||||
|
|
||||||
# 4. Partition Table
|
|
||||||
#--------------------
|
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_eh_cp_ota_4m.csv"
|
|
||||||
|
|
||||||
# 5. Mempool
|
|
||||||
#------------
|
|
||||||
CONFIG_ESP_CACHE_MALLOC=y
|
|
||||||
|
|
||||||
|
|
||||||
# # 6.1 LWIP split
|
|
||||||
# #---------------
|
|
||||||
#
|
|
||||||
# CONFIG_ESP_HOSTED_CP_FEAT_NW_SPLIT=y
|
|
||||||
# CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_START=61440
|
|
||||||
# CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_END=65535
|
|
||||||
# CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_START=61440
|
|
||||||
# CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_END=65535
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# # 6.2 LWIP split examples
|
|
||||||
# #-------------------------
|
|
||||||
|
|
||||||
|
|
||||||
# 7. Transport config
|
|
||||||
#---------------------
|
|
||||||
# ESP_HOSTED_TRANSPORT_CP_SDIO_NSEND_PSAMPLE=y
|
|
||||||
# ESP_HOSTED_TRANSPORT_CP_SDIO_DEFAULT_SPEED=y
|
|
||||||
#ESP_HOSTED_TRANSPORT_CP_SDIO_STREAMING_MODE=y
|
|
||||||
|
|
||||||
# For SPI Full duplex C6 on ESP32-P4-Function-EV-Board, please uncomment below
|
|
||||||
#CONFIG_ESP_HOST_DEV_BOARD_P4_FUNC_BOARD=y
|
|
||||||
#CONFIG_ESP_HOSTED_TRANSPORT_CP_SPI=y
|
|
||||||
|
|
||||||
|
|
||||||
# 8. Wifi config
|
|
||||||
#----------------
|
|
||||||
|
|
||||||
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=20
|
|
||||||
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64
|
|
||||||
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
|
|
||||||
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
|
|
||||||
CONFIG_ESP_WIFI_TX_BA_WIN=32
|
|
||||||
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
|
|
||||||
CONFIG_ESP_WIFI_RX_BA_WIN=32
|
|
||||||
|
|
||||||
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
|
|
||||||
CONFIG_ESP_WIFI_IRAM_OPT=y
|
|
||||||
|
|
||||||
# # 9. LWIP config
|
|
||||||
# #----------------
|
|
||||||
# CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65535
|
|
||||||
# CONFIG_LWIP_TCP_WND_DEFAULT=65535
|
|
||||||
# CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
|
|
||||||
# CONFIG_LWIP_UDP_RECVMBOX_SIZE=64
|
|
||||||
# CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64
|
|
||||||
# CONFIG_LWIP_TCP_SACK_OUT=y
|
|
||||||
# #CONFIG_LWIP_TCPIP_CORE_LOCKING=y
|
|
||||||
# #CONFIG_LWIP_TCPIP_CORE_LOCKING_INPUT=y
|
|
||||||
|
|
||||||
|
|
||||||
# 10. Optimizations
|
|
||||||
#-------------------
|
|
||||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
|
||||||
|
|
||||||
|
|
||||||
# 11. Stats
|
|
||||||
#-----------
|
|
||||||
#CONFIG_ESP_HOSTED_FUNCTION_PROFILING=y
|
|
||||||
#CONFIG_ESP_PKT_STATS=y
|
|
||||||
|
|
||||||
# # 12 iperf task
|
|
||||||
# #--------------
|
|
||||||
|
|
||||||
# Seeed XIAO ESP32-C6 as co-processor of a XIAO ESP32-C5 over SPI, wired D-pin to the same D-pin
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI=y
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_MODE_3=y
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_CLK=19
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_MISO=20
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_MOSI=18
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_CS=21
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_GPIO_HANDSHAKE=0
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_GPIO_DATA_READY=1
|
|
||||||
# The XIAO has no EN pin: the host's reset pin goes to GPIO2 (D2)
|
|
||||||
CONFIG_EH_TRANSPORT_CP_SPI_GPIO_RESET=2
|
|
||||||
@@ -30,6 +30,7 @@ esp32:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
status_led: !include
|
status_led: !include
|
||||||
file: common/status_led.yaml
|
file: common/status_led.yaml
|
||||||
vars:
|
vars:
|
||||||
|
|||||||
+191
-456
@@ -1,41 +1,67 @@
|
|||||||
---
|
---
|
||||||
# Hardware: M5Stack AtomS3
|
# Hardware: M5Stack AtomS3 + ATOMIC CAN base + CardKB on the Atom's Grove port
|
||||||
|
# CANopen keypad prototype (node 3): CardKB key code + press counter in TPDO 0 (canopen from ESPHome dev + canopen_entities)
|
||||||
|
# plus a Blink Marine PKP 2600SI (2x6) emulation as a second local node 0x15: keys 1-6 / q-y, LED RPDOs drawn on the display
|
||||||
# Pinout:
|
# Pinout:
|
||||||
# GPIO1 Grove SCL -> motor_in1 (output gpio)
|
# GPIO1 Grove SCL -> i2c_grove (i2c scl)
|
||||||
# GPIO2 Grove SDA -> motor_in2 (output gpio)
|
# GPIO2 Grove SDA -> i2c_grove (i2c sda)
|
||||||
# GPIO5 -> canbus/esp32_can (canbus esp32_can tx_pin)
|
# GPIO5 -> can_bus (canbus esp32_can tx_pin)
|
||||||
# GPIO6 -> canbus/esp32_can (canbus esp32_can rx_pin)
|
# GPIO6 -> can_bus (canbus esp32_can rx_pin)
|
||||||
# GPIO15 -> display_tft (display mipi_spi cs_pin)
|
# GPIO15 -> display_tft (display mipi_spi cs_pin)
|
||||||
# GPIO16 -> gpio_tft_backlight (output ledc)
|
# GPIO16 -> gpio_tft_backlight (output ledc)
|
||||||
# GPIO17 -> spi (spi clk_pin)
|
# GPIO17 -> spi (spi clk_pin)
|
||||||
# GPIO21 -> spi (spi mosi_pin)
|
# GPIO21 -> spi (spi mosi_pin)
|
||||||
# GPIO33 -> display_tft (display mipi_spi dc_pin)
|
# GPIO33 -> display_tft (display mipi_spi dc_pin)
|
||||||
# GPIO34 -> display_tft (display mipi_spi reset_pin)
|
# GPIO34 -> display_tft (display mipi_spi reset_pin)
|
||||||
# GPIO38 -> i2c_main (i2c sda)
|
|
||||||
# GPIO39 -> i2c_main (i2c scl)
|
|
||||||
# GPIO41 -> Button (binary_sensor gpio) (inverted)
|
# GPIO41 -> Button (binary_sensor gpio) (inverted)
|
||||||
# I2C:
|
# I2C:
|
||||||
# 0x21 pcf8574_hub (pcf8574)
|
# 0x5F cardkb (m5stack_keyboard), CardKB
|
||||||
# 0x26 m5stack_relay_1 (m5stack_4relay)
|
|
||||||
# 0x3C lcd (display ssd1306_i2c)
|
|
||||||
substitutions:
|
substitutions:
|
||||||
device: atoms3
|
device: atoms3
|
||||||
name: AtomS3
|
name: AtomS3
|
||||||
area: DEV
|
area: DEV
|
||||||
comment: --
|
comment: CANopen keypad
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
name: mcu-${device}
|
name: mcu-${device}
|
||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
# on_boot:
|
on_boot:
|
||||||
# - priority: 800
|
- lambda: |-
|
||||||
# then:
|
id(cardkb).add_on_key_callback([](uint8_t key) {
|
||||||
# - lambda: |-
|
id(key_code).publish_state(key);
|
||||||
# id(display_tft).enable();
|
float n = id(key_count).state; // NaN before the first key
|
||||||
# id(display_tft).transfer_byte(0x11);
|
uint32_t count = std::isnan(n) ? 1 : ((uint32_t) n + 1) % 65535;
|
||||||
# id(display_tft).disable();
|
id(key_count).publish_state(count);
|
||||||
|
id(key_event).publish_state((count % 255) * 256 + key); // one field: count (high byte) + key (low byte)
|
||||||
|
// PKP: keys 1-6 = top row, q w e r t y = bottom row (keys 7-12); CardKB has no release -> 200 ms press
|
||||||
|
static const char *const PKP_KEYS = "123456qwerty";
|
||||||
|
const char *p = key ? strchr(PKP_KEYS, key) : nullptr;
|
||||||
|
if (p != nullptr) {
|
||||||
|
id(pkp_keys) = 1u << (p - PKP_KEYS);
|
||||||
|
id(pkp_send_keys).execute();
|
||||||
|
}
|
||||||
|
id(display_tft).update();
|
||||||
|
});
|
||||||
|
// PKP RPDOs: 0x200 LED on, 0x300 LED blink (40 bits: R1-12, G1-12, B1-12), 0x400 brightness 0x00-0x3F
|
||||||
|
static canopen::FrameListener pkp_rx{0x015, 0x0FF, [](void *, uint32_t can_id, const uint8_t *d, uint8_t len) {
|
||||||
|
if (id(pkp).get_nmt_state() != canopen::NMTState::NMT_STATE_OPERATIONAL)
|
||||||
|
return;
|
||||||
|
uint64_t bits = 0;
|
||||||
|
for (uint8_t i = 0; i < len && i < 5; i++)
|
||||||
|
bits |= (uint64_t) d[i] << (8 * i);
|
||||||
|
if (can_id == 0x215)
|
||||||
|
id(pkp_led_on) = bits;
|
||||||
|
else if (can_id == 0x315)
|
||||||
|
id(pkp_led_blink) = bits;
|
||||||
|
else if (can_id == 0x415 && len > 0)
|
||||||
|
id(pkp_brightness) = d[0] > 0x3F ? 0x3F : d[0];
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
id(display_tft).update();
|
||||||
|
}, nullptr};
|
||||||
|
id(pkp).add_frame_listener(pkp_rx);
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
variant: esp32s3
|
variant: esp32s3
|
||||||
@@ -46,88 +72,17 @@ esp32:
|
|||||||
flash_chip: gd
|
flash_chip: gd
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
ota:
|
|
||||||
- platform: web_server
|
|
||||||
|
|
||||||
pcf8574:
|
|
||||||
- id: 'pcf8574_hub'
|
|
||||||
address: 0x21
|
|
||||||
pcf8575: true
|
|
||||||
|
|
||||||
image:
|
|
||||||
- platform: animation
|
|
||||||
file: "assets/images/blinky.gif"
|
|
||||||
id: blinky
|
|
||||||
resize: 128x128
|
|
||||||
type: RGB565
|
|
||||||
- platform: animation
|
|
||||||
file: "assets/images/vault_boy_walking.gif"
|
|
||||||
id: vaultboy
|
|
||||||
resize: 168x121
|
|
||||||
type: RGB565
|
|
||||||
|
|
||||||
logger:
|
|
||||||
logs:
|
|
||||||
component: ERROR
|
|
||||||
|
|
||||||
web_server:
|
|
||||||
port: 80
|
|
||||||
version: 3
|
|
||||||
|
|
||||||
# light:
|
|
||||||
# - platform: esp32_rmt_led_strip
|
|
||||||
# name: LED
|
|
||||||
# id: neo
|
|
||||||
# rgb_order: GRB
|
|
||||||
# pin: 2
|
|
||||||
# num_leds: 1
|
|
||||||
# # rmt_channel: 0
|
|
||||||
# chipset: ws2812
|
|
||||||
# restore_mode: ALWAYS_OFF
|
|
||||||
|
|
||||||
text:
|
|
||||||
- platform: template
|
|
||||||
name: Test Text
|
|
||||||
# id: "it_2"
|
|
||||||
icon: "mdi:text"
|
|
||||||
optimistic: true
|
|
||||||
internal: false
|
|
||||||
initial_value: "Welcome ESPHOME - #{name}"
|
|
||||||
restore_value: true
|
|
||||||
mode: text
|
|
||||||
# max_restore_data_length: 24
|
|
||||||
|
|
||||||
# logger:
|
|
||||||
# hardware_uart: USB_SERIAL_JTAG
|
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://pr#7234
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
components: m5stack_4relay
|
components: [canopen_entities]
|
||||||
refresh: 0s
|
refresh: 1h
|
||||||
# - source: github://pr#5586
|
- source: github://randybb/esphome-components
|
||||||
# components: [ http_request ]
|
components: [m5stack_keyboard]
|
||||||
# - source: github://mknjc/esphome@ds248x
|
refresh: 1h
|
||||||
# components: ds248x
|
# TEMP: esphome#23831 (OTA over CANopen, CiA 302-3); drop once merged
|
||||||
# - source: github://bekriebel/esphome@sh1107_fix
|
- source: github://pr#23831
|
||||||
# components:
|
components: [canopen]
|
||||||
# - ssd1306_base
|
refresh: 1h
|
||||||
# - ssd1306_i2c
|
|
||||||
# - ssd1306_spi
|
|
||||||
# - source: github://pr#5096
|
|
||||||
# refresh: 0s
|
|
||||||
# - source: github://pr#3500
|
|
||||||
# refresh: 0s
|
|
||||||
# components:
|
|
||||||
# - web_server
|
|
||||||
# - web_server_idf
|
|
||||||
# - web_server_base
|
|
||||||
# - captive_portal
|
|
||||||
|
|
||||||
# ota:
|
|
||||||
# - platform: http_request
|
|
||||||
|
|
||||||
# web_server:
|
|
||||||
# captive_portal:
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
@@ -136,106 +91,116 @@ packages:
|
|||||||
file: common/status_led.yaml
|
file: common/status_led.yaml
|
||||||
vars:
|
vars:
|
||||||
light_id: status_frame
|
light_id: status_frame
|
||||||
# common: !include common/common_wo_debug.yaml
|
|
||||||
# common: !include common/common_dev.yaml
|
logger:
|
||||||
|
logs:
|
||||||
|
# canbus logs every frame at DEBUG, which slows the loop during SDO block transfers
|
||||||
|
canbus: INFO
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
- id: i2c_grove
|
||||||
|
sda: 2
|
||||||
|
scl: 1
|
||||||
|
|
||||||
|
m5stack_keyboard:
|
||||||
|
- id: cardkb
|
||||||
|
i2c_id: i2c_grove
|
||||||
|
address: 0x5F
|
||||||
|
|
||||||
canbus:
|
canbus:
|
||||||
- platform: esp32_can
|
- platform: esp32_can
|
||||||
|
id: can_bus
|
||||||
rx_pin: 6
|
rx_pin: 6
|
||||||
tx_pin: 5
|
tx_pin: 5
|
||||||
can_id: 4
|
can_id: 3
|
||||||
# bit_rate: 500kbps
|
bit_rate: 500kbps
|
||||||
bit_rate: 1000KBPS
|
# IDF default is 5 frames; an SDO block (16 segments in ~8 ms) overflowed it (EMCY 0x8110, partial block acks)
|
||||||
use_extended_id: true
|
rx_queue_len: 32
|
||||||
on_frame:
|
|
||||||
- can_id: 0x123
|
|
||||||
use_extended_id: true
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
std::string b(x.begin(), x.end());
|
|
||||||
ESP_LOGD("can extended id 0x123", "%s", &b[0] );
|
|
||||||
- can_id: 0x123
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
std::string b(x.begin(), x.end());
|
|
||||||
ESP_LOGD("can standard id 0x123", "%s", &b[0] );
|
|
||||||
- can_id: 0x3f1
|
|
||||||
can_id_mask: 0x7ff
|
|
||||||
use_extended_id: false
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
std::string b(x.begin(), x.end());
|
|
||||||
ESP_LOGD("can id 0x03f1", "%s", &b[0] );
|
|
||||||
- can_id: 0x108
|
|
||||||
use_extended_id: false
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
std::string b(x.begin(), x.end());
|
|
||||||
ESP_LOGD("can id 0x108", "%s", &b[0] );
|
|
||||||
- can_id: 0x109
|
|
||||||
use_extended_id: false
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
std::string b(x.begin(), x.end());
|
|
||||||
ESP_LOGD("can id 0x109", "%s", &b[0] );
|
|
||||||
|
|
||||||
i2c:
|
canopen:
|
||||||
# - id: i2c_groove
|
- id: can_open
|
||||||
# sda: 2
|
canbus_id: can_bus
|
||||||
# scl: 1
|
node_id: 3
|
||||||
# scan: true
|
|
||||||
- id: i2c_main
|
|
||||||
sda: 38
|
|
||||||
scl: 39
|
|
||||||
scan: true
|
|
||||||
frequency: 800kHz
|
|
||||||
|
|
||||||
# mcp23017:
|
# Blink Marine PKP 2600SI emulation (docs: home-gitops canopen-nodes.adoc): like the real one, not active until NMT Start
|
||||||
# - id: mcp23017_hub
|
- id: pkp
|
||||||
# i2c_id: i2c_main
|
canbus_id: can_bus
|
||||||
# address: 0x20
|
node_id: 0x15
|
||||||
|
nmt_startup: pre_operational
|
||||||
|
device_name: PKP2600SI
|
||||||
|
|
||||||
# ds248x:
|
globals:
|
||||||
# i2c_id: i2c_main
|
- id: pkp_keys
|
||||||
# address: 0x18 # should be the default
|
type: uint16_t
|
||||||
# # sleep_pin: 32 # remove if not needed, if set the ds248x sleeps when no transaction is in progress
|
initial_value: '0'
|
||||||
# active_pullup: true # adds a active pullup which should improve signal integrity
|
- id: pkp_led_on
|
||||||
# strong_pullup: false # enables a strong pullup used to provide the needed current for temperature reading without vcc connected
|
type: uint64_t
|
||||||
# bus_sleep: true # power down the bus when no transaction is in progres
|
initial_value: '0'
|
||||||
|
- id: pkp_led_blink
|
||||||
|
type: uint64_t
|
||||||
|
initial_value: '0'
|
||||||
|
- id: pkp_brightness
|
||||||
|
type: uint8_t
|
||||||
|
initial_value: '0x3F'
|
||||||
|
|
||||||
# one_wire:
|
script:
|
||||||
# - platform: gpio
|
# keys state TPDO 0x195: bytes 0-1 keys 1-12, byte 4 tick (+1 per 100 ms); pressed now, released 200 ms later
|
||||||
# pin: 1
|
- id: pkp_send_keys
|
||||||
# id: hub_1
|
mode: restart
|
||||||
# - platform: gpio
|
then:
|
||||||
# pin: 2
|
- lambda: |-
|
||||||
# id: hub_2
|
if (id(pkp).get_nmt_state() != canopen::NMTState::NMT_STATE_OPERATIONAL)
|
||||||
|
return;
|
||||||
|
uint8_t d[5] = {(uint8_t) id(pkp_keys), (uint8_t) (id(pkp_keys) >> 8), 0, 0, (uint8_t) (millis() / 100)};
|
||||||
|
id(pkp).send_frame(0x195, d, sizeof(d));
|
||||||
|
- delay: 200ms
|
||||||
|
- lambda: |-
|
||||||
|
id(pkp_keys) = 0;
|
||||||
|
if (id(pkp).get_nmt_state() != canopen::NMTState::NMT_STATE_OPERATIONAL)
|
||||||
|
return;
|
||||||
|
uint8_t d[5] = {0, 0, 0, 0, (uint8_t) (millis() / 100)};
|
||||||
|
id(pkp).send_frame(0x195, d, sizeof(d));
|
||||||
|
|
||||||
m5stack_4relay:
|
ota:
|
||||||
id: m5stack_relay_1
|
- platform: canopen
|
||||||
i2c_id: i2c_main
|
canopen_id: can_open
|
||||||
|
|
||||||
# mqtt:
|
# CardKB sends only the press (Shift/Sym/Fn resolved in the CardKB): a consumer reacts to a change of key_count
|
||||||
# id: mqtt_client
|
# and reads the key from key_code (both in the same frame), or watches key_event alone (count % 255 << 8 | key)
|
||||||
# broker: !secret mqtt_ip
|
canopen_entities:
|
||||||
# # broker: 10.10.10.10
|
canopen_id: can_open
|
||||||
# username: !secret mqtt_username
|
entities:
|
||||||
# password: !secret mqtt_password
|
- {id: key_code, index: 1, tpdo: 0, size: 1}
|
||||||
# discovery: true
|
- {id: key_count, index: 2, tpdo: 0, size: 2}
|
||||||
|
- {id: side_button, index: 3, tpdo: 0}
|
||||||
|
- {id: key_event, index: 4, tpdo: 0, size: 2}
|
||||||
|
|
||||||
# mdns:
|
sensor:
|
||||||
# disabled: false
|
- platform: template
|
||||||
|
id: key_code
|
||||||
|
name: Key Code
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
- platform: template
|
||||||
|
id: key_count
|
||||||
|
name: Key Count
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
- platform: template
|
||||||
|
id: key_event
|
||||||
|
name: Key Event
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
|
||||||
# wifi:
|
binary_sensor:
|
||||||
# use_address: 10.17.240.52
|
- platform: gpio
|
||||||
|
id: side_button
|
||||||
|
name: Button
|
||||||
|
pin:
|
||||||
|
number: 41
|
||||||
|
inverted: true
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: gpio
|
|
||||||
id: motor_in1
|
|
||||||
pin: 1
|
|
||||||
- platform: gpio
|
|
||||||
id: motor_in2
|
|
||||||
pin: 2
|
|
||||||
- platform: ledc
|
- platform: ledc
|
||||||
pin: 16
|
pin: 16
|
||||||
id: gpio_tft_backlight
|
id: gpio_tft_backlight
|
||||||
@@ -266,155 +231,14 @@ light:
|
|||||||
blue: status_frame_b
|
blue: status_frame_b
|
||||||
restore_mode: ALWAYS_OFF
|
restore_mode: ALWAYS_OFF
|
||||||
|
|
||||||
switch:
|
|
||||||
- platform: template
|
|
||||||
name: "Motor Forward"
|
|
||||||
optimistic: true
|
|
||||||
turn_on_action:
|
|
||||||
- output.turn_on: motor_in1
|
|
||||||
- output.turn_off: motor_in2
|
|
||||||
turn_off_action:
|
|
||||||
- output.turn_off: motor_in1
|
|
||||||
- output.turn_off: motor_in2
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Motor Back"
|
|
||||||
optimistic: true
|
|
||||||
turn_on_action:
|
|
||||||
- output.turn_off: motor_in1
|
|
||||||
- output.turn_on: motor_in2
|
|
||||||
turn_off_action:
|
|
||||||
- output.turn_off: motor_in1
|
|
||||||
- output.turn_off: motor_in2
|
|
||||||
|
|
||||||
# switch:
|
|
||||||
- platform: m5stack_4relay
|
|
||||||
name: Relay 1
|
|
||||||
id: relay_1
|
|
||||||
channel: 1
|
|
||||||
# interlock: &interlock_group_1 [relay_1, relay_2]
|
|
||||||
# interlock_wait_time: 1s
|
|
||||||
m5stack_4relay_id: m5stack_relay_1
|
|
||||||
- platform: m5stack_4relay
|
|
||||||
name: Relay 2
|
|
||||||
id: relay_2
|
|
||||||
channel: 2
|
|
||||||
# interlock: *interlock_group_1
|
|
||||||
# interlock_wait_time: 1s
|
|
||||||
m5stack_4relay_id: m5stack_relay_1
|
|
||||||
- platform: m5stack_4relay
|
|
||||||
name: Relay 3
|
|
||||||
id: relay_3
|
|
||||||
channel: 3
|
|
||||||
# interlock: &interlock_group_2 [relay_3, relay_4]
|
|
||||||
m5stack_4relay_id: m5stack_relay_1
|
|
||||||
- platform: m5stack_4relay
|
|
||||||
name: Relay 4
|
|
||||||
id: relay_4
|
|
||||||
channel: 4
|
|
||||||
# interlock: *interlock_group_2
|
|
||||||
m5stack_4relay_id: m5stack_relay_1
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #8"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 9
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode:
|
|
||||||
output: true
|
|
||||||
inverted: false
|
|
||||||
spi:
|
spi:
|
||||||
clk_pin: 17
|
clk_pin: 17
|
||||||
mosi_pin: 21
|
mosi_pin: 21
|
||||||
|
|
||||||
binary_sensor:
|
|
||||||
- platform: gpio
|
|
||||||
name: Button
|
|
||||||
pin:
|
|
||||||
number: 41
|
|
||||||
inverted: true
|
|
||||||
- platform: status
|
|
||||||
id: system_status
|
|
||||||
# - platform: gpio
|
|
||||||
# id: test_sensor_1
|
|
||||||
# pin:
|
|
||||||
# mcp23xxx: mcp23017_hub
|
|
||||||
# number: 4
|
|
||||||
# mode:
|
|
||||||
# input: true
|
|
||||||
# pullup: true
|
|
||||||
# inverted: false
|
|
||||||
# filters:
|
|
||||||
# - delayed_on_off: 50ms #Debounce
|
|
||||||
# - platform: gpio
|
|
||||||
# id: test_sensor_2
|
|
||||||
# pin:
|
|
||||||
# mcp23xxx: mcp23017_hub
|
|
||||||
# number: 5
|
|
||||||
# mode:
|
|
||||||
# input: true
|
|
||||||
# pullup: true
|
|
||||||
# inverted: false
|
|
||||||
# filters:
|
|
||||||
# - delayed_on_off: 50ms #Debounce
|
|
||||||
# - platform: gpio
|
|
||||||
# id: test_sensor_3
|
|
||||||
# pin:
|
|
||||||
# mcp23xxx: mcp23017_hub
|
|
||||||
# number: 6
|
|
||||||
# mode:
|
|
||||||
# input: true
|
|
||||||
# pullup: true
|
|
||||||
# inverted: false
|
|
||||||
# filters:
|
|
||||||
# - delayed_on_off: 50ms #Debounce
|
|
||||||
# - platform: gpio
|
|
||||||
# id: test_sensor_4
|
|
||||||
# pin:
|
|
||||||
# mcp23xxx: mcp23017_hub
|
|
||||||
# number: 7
|
|
||||||
# mode:
|
|
||||||
# input: true
|
|
||||||
# pullup: true
|
|
||||||
# inverted: false
|
|
||||||
# filters:
|
|
||||||
# - delayed_on_off: 50ms #Debounce
|
|
||||||
|
|
||||||
color:
|
|
||||||
- id: my_red
|
|
||||||
red: 100%
|
|
||||||
green: 0%
|
|
||||||
blue: 0%
|
|
||||||
- id: my_yellow
|
|
||||||
red: 100%
|
|
||||||
green: 100%
|
|
||||||
blue: 0%
|
|
||||||
- id: my_green
|
|
||||||
red: 0%
|
|
||||||
green: 100%
|
|
||||||
blue: 0%
|
|
||||||
- id: my_blue
|
|
||||||
red: 0%
|
|
||||||
green: 0%
|
|
||||||
blue: 100%
|
|
||||||
- id: my_gray
|
|
||||||
red: 50%
|
|
||||||
green: 50%
|
|
||||||
blue: 50%
|
|
||||||
|
|
||||||
font:
|
font:
|
||||||
- file: "gfonts://Roboto"
|
- file: "gfonts://Roboto"
|
||||||
id: font_default
|
id: font_key
|
||||||
size: 20
|
size: 48
|
||||||
- file: "gfonts://Roboto"
|
|
||||||
id: roboto_32
|
|
||||||
size: 32
|
|
||||||
- file: "gfonts://Roboto"
|
|
||||||
id: roboto_24
|
|
||||||
size: 24
|
|
||||||
- file: "gfonts://Roboto"
|
|
||||||
id: roboto_12
|
|
||||||
size: 12
|
|
||||||
|
|
||||||
display:
|
display:
|
||||||
- platform: mipi_spi
|
- platform: mipi_spi
|
||||||
@@ -426,12 +250,10 @@ display:
|
|||||||
width: 128
|
width: 128
|
||||||
offset_height: 2
|
offset_height: 2
|
||||||
offset_width: 1
|
offset_width: 1
|
||||||
# backlight_pin: 16
|
|
||||||
cs_pin: 15
|
cs_pin: 15
|
||||||
dc_pin: 33
|
dc_pin: 33
|
||||||
reset_pin: 34
|
reset_pin: 34
|
||||||
# eightbitcolor: true
|
update_interval: 250ms # PKP LED blink
|
||||||
update_interval: 1s
|
|
||||||
lambda: |-
|
lambda: |-
|
||||||
// status screen (common/status_led.yaml): the whole display in the status colour
|
// status screen (common/status_led.yaml): the whole display in the status colour
|
||||||
auto &sv = id(status_frame)->current_values;
|
auto &sv = id(status_frame)->current_values;
|
||||||
@@ -439,129 +261,42 @@ display:
|
|||||||
it.fill(Color(sv.get_red() * 255, sv.get_green() * 255, sv.get_blue() * 255));
|
it.fill(Color(sv.get_red() * 255, sv.get_green() * 255, sv.get_blue() * 255));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Ingress shown animation Frame.
|
// PKP LEDs, 2x6 like the keypad: on colour; with blink, alternating with the blink colour (off if not on)
|
||||||
id(blinky).next_frame();
|
bool phase = (millis() / 500) & 1;
|
||||||
// Draw the animation my_animation at position [x=0,y=0]
|
uint8_t lvl = 255 * id(pkp_brightness) / 0x3F;
|
||||||
it.image(0, 0, id(blinky), COLOR_ON, COLOR_OFF);
|
for (int i = 0; i < 12; i++) {
|
||||||
|
auto rgb = [i](uint64_t b) { return (b >> i & 1) | (b >> (i + 12) & 1) << 1 | (b >> (i + 24) & 1) << 2; };
|
||||||
|
int on = rgb(id(pkp_led_on)), bl = rgb(id(pkp_led_blink));
|
||||||
// // it.print(0, 0, id(font_default), "Hello World!");
|
int c = phase && bl ? bl : (bl && !on ? 0 : on);
|
||||||
// // it.strftime(0, 0, id(font_default), TextAlign::TOP_LEFT, "%H:%M", id(ha_time).now());
|
int x = (i % 6) * 21 + 1, y = (i / 6) * 32;
|
||||||
// it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
it.filled_rectangle(x, y + 1, 19, 30, Color(c & 1 ? lvl : 0, c & 2 ? lvl : 0, c & 4 ? lvl : 0));
|
||||||
// it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
|
it.rectangle(x, y + 1, 19, 30, Color(64, 64, 64));
|
||||||
|
}
|
||||||
// it.strftime((128 / 2), (128 / 3) * 1 + 5, id(roboto_24), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(ha_time).now());
|
// last key
|
||||||
// it.strftime((128 / 2), (128 / 3) * 2 + 5, id(roboto_32), id(my_gray), TextAlign::CENTER, "%H:%M:%S", id(ha_time).now());
|
if (std::isnan(id(key_code).state))
|
||||||
// it.print(5, 5, id(roboto_12), id(my_yellow), TextAlign::TOP_LEFT, "ESPHome");
|
return;
|
||||||
|
uint8_t k = id(key_code).state;
|
||||||
// // Comment out the above lines to see the image without text overlaid
|
// CardKB: Shift/Sym come as plain characters, Fn and the specials as codes; unknown ones as hex
|
||||||
// // it.image(0, 0, id(my_image));
|
const char *s = nullptr;
|
||||||
|
char c[5];
|
||||||
// if (id(system_status).state) {
|
switch (k) {
|
||||||
// it.print(115, 5, id(roboto_12), id(my_green), TextAlign::TOP_RIGHT, "Online");
|
case 0x08: s = "BS"; break;
|
||||||
// }
|
case 0x09: s = "Tab"; break;
|
||||||
// else {
|
case 0x0D: s = "Ent"; break;
|
||||||
// it.print(115, 5, id(roboto_12), id(my_red), TextAlign::TOP_RIGHT, "Offline");
|
case 0x1B: s = "Esc"; break;
|
||||||
// }
|
case 0x20: s = "Spc"; break;
|
||||||
|
case 0x7F: s = "Del"; break;
|
||||||
- platform: ssd1306_i2c
|
case 0xB4: s = "Lt"; break;
|
||||||
model: "SH1107 128x64"
|
case 0xB5: s = "Up"; break;
|
||||||
# model: "SSD1306 128x64"
|
case 0xB6: s = "Dn"; break;
|
||||||
id: "lcd"
|
case 0xB7: s = "Rt"; break;
|
||||||
address: 0x3C
|
default:
|
||||||
i2c_id: i2c_main
|
if (k > 0x20 && k < 0x7F) {
|
||||||
rotation: 90
|
c[0] = (char) k;
|
||||||
flip_x: false
|
c[1] = 0;
|
||||||
flip_y: false
|
} else {
|
||||||
offset_y: 0
|
snprintf(c, sizeof(c), "%02X", k);
|
||||||
offset_x: 0
|
}
|
||||||
# lambda: |-
|
s = c;
|
||||||
# it.line(0, 0, 128, 64);
|
}
|
||||||
# it.rectangle(5, 5, 10, 10);
|
it.print(64, 96, id(font_key), TextAlign::CENTER, s);
|
||||||
# it.circle(118, 54, 5);
|
|
||||||
# it.rectangle(0, 0, 128, 64);
|
|
||||||
|
|
||||||
sensor:
|
|
||||||
# - platform: sht3xd
|
|
||||||
# i2c_id: i2c_main
|
|
||||||
# address: 0x44
|
|
||||||
# temperature:
|
|
||||||
# name: TEST Temperature
|
|
||||||
# humidity:
|
|
||||||
# name: TEST Humidity
|
|
||||||
# update_interval: 10s
|
|
||||||
# - platform: mpu6886
|
|
||||||
# address: 0x68
|
|
||||||
# i2c_id: i2c_main
|
|
||||||
# # accel_x:
|
|
||||||
# # name: "${name} MPU6886 Accel X"
|
|
||||||
# # accel_y:
|
|
||||||
# # name: "${name} MPU6886 Accel Y"
|
|
||||||
# # accel_z:
|
|
||||||
# # name: "${name} MPU6886 Accel z"
|
|
||||||
# # gyro_x:
|
|
||||||
# # name: "${name} MPU6886 Gyro X"
|
|
||||||
# # gyro_y:
|
|
||||||
# # name: "${name} MPU6886 Gyro Y"
|
|
||||||
# # gyro_z:
|
|
||||||
# # name: "${name} MPU6886 Gyro z"
|
|
||||||
# temperature:
|
|
||||||
# name: Temperature
|
|
||||||
# id: blabla
|
|
||||||
- platform: homeassistant
|
|
||||||
id: test_humidity_ha
|
|
||||||
entity_id: sensor.humidity_158d0001c2a1d1
|
|
||||||
# - platform: ds248x
|
|
||||||
# address: 0x8b0516b39804ff28
|
|
||||||
# name: "${name} Dallas Temp 1"
|
|
||||||
# resolution: 12
|
|
||||||
# - platform: ds248x
|
|
||||||
# address: 0xa50516b3d32aff28
|
|
||||||
# name: "${name} Dallas Temp 2"
|
|
||||||
# resolution: 12
|
|
||||||
# - platform: ds248x
|
|
||||||
# address: 0x8f0516b39d87ff28
|
|
||||||
# name: "${name} Dallas Temp 3"
|
|
||||||
# resolution: 12
|
|
||||||
# - platform: ds248x
|
|
||||||
# address: 0x810516b3c69fff28
|
|
||||||
# name: "${name} Dallas Temp 4"
|
|
||||||
# resolution: 12
|
|
||||||
# - platform: dallas_temp
|
|
||||||
# address: 0xdb041750eae2ff28
|
|
||||||
# name: Dallas Temp 1
|
|
||||||
# one_wire_id: hub_1
|
|
||||||
# update_interval: 10s
|
|
||||||
# - platform: dallas_temp
|
|
||||||
# address: 0xb2041750cf1aff28
|
|
||||||
# name: Dallas Temp 2
|
|
||||||
# one_wire_id: hub_1
|
|
||||||
# update_interval: 30s
|
|
||||||
# - platform: dallas_temp
|
|
||||||
# address: 0xcd01191eb8b07128
|
|
||||||
# name: Dallas Temp 3
|
|
||||||
# one_wire_id: hub_1
|
|
||||||
# update_interval: 45s
|
|
||||||
# - platform: dallas_temp
|
|
||||||
# address: 0x5a01191ef3375b28
|
|
||||||
# name: Dallas Temp 4
|
|
||||||
# one_wire_id: hub_1
|
|
||||||
|
|
||||||
# time:
|
|
||||||
# - platform: sntp
|
|
||||||
# id: sntp_time
|
|
||||||
# timezone: Europe/Bratislava
|
|
||||||
# servers:
|
|
||||||
# - 0.pool.ntp.org
|
|
||||||
# - 1.pool.ntp.org
|
|
||||||
# - 2.pool.ntp.org
|
|
||||||
|
|
||||||
# esp32_ble_tracker:
|
|
||||||
# scan_parameters:
|
|
||||||
# active: true
|
|
||||||
|
|
||||||
# bluetooth_proxy:
|
|
||||||
# active: true
|
|
||||||
|
|
||||||
# esp32_improv:
|
|
||||||
# authorizer: none
|
|
||||||
+36
-53
@@ -24,14 +24,18 @@ esp32:
|
|||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://mrk-its/esphome-canopen@dev
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
refresh: 1h
|
components: [canopen_entities]
|
||||||
- source: github://mrk-its/esphome-canbus-udp-multicast@dev
|
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
|
logger:
|
||||||
|
logs:
|
||||||
|
# canbus logs every frame at DEBUG, which slows the loop during SDO block transfers
|
||||||
|
canbus: INFO
|
||||||
|
|
||||||
canbus:
|
canbus:
|
||||||
- platform: esp32_can
|
- platform: esp32_can
|
||||||
id: can_bus
|
id: can_bus
|
||||||
@@ -39,57 +43,29 @@ canbus:
|
|||||||
tx_pin: 23
|
tx_pin: 23
|
||||||
can_id: 1
|
can_id: 1
|
||||||
bit_rate: 500kbps
|
bit_rate: 500kbps
|
||||||
|
# IDF default is 5 frames; an SDO block (16 segments in ~8 ms) overflowed it (EMCY 0x8110, partial block acks)
|
||||||
|
rx_queue_len: 32
|
||||||
|
|
||||||
canopen:
|
canopen:
|
||||||
id: can_open
|
id: can_open
|
||||||
canbus_id: can_bus
|
canbus_id: can_bus
|
||||||
node_id: 1
|
node_id: 1
|
||||||
entities:
|
|
||||||
- index: 1
|
|
||||||
id: light1_state
|
|
||||||
rpdo:
|
|
||||||
- node_id: 2
|
|
||||||
tpdo: 0
|
|
||||||
offset: 0
|
|
||||||
cmd: 0
|
|
||||||
|
|
||||||
- index: 2
|
canopen_entities:
|
||||||
id: light1_brightness
|
remote_nodes:
|
||||||
size: 1
|
node2: mcu-can-node-2.yaml
|
||||||
min_value: 0.0
|
|
||||||
max_value: 1.0
|
|
||||||
rpdo:
|
|
||||||
- node_id: 2
|
|
||||||
tpdo: 0
|
|
||||||
offset: 1
|
|
||||||
cmd: 0
|
|
||||||
|
|
||||||
- index: 3
|
|
||||||
id: light2_state
|
|
||||||
rpdo:
|
|
||||||
- node_id: 2
|
|
||||||
tpdo: 0
|
|
||||||
offset: 3
|
|
||||||
cmd: 0
|
|
||||||
|
|
||||||
- index: 4
|
|
||||||
id: light2_brightness
|
|
||||||
size: 1
|
|
||||||
min_value: 0.0
|
|
||||||
max_value: 1.0
|
|
||||||
rpdo:
|
|
||||||
- node_id: 2
|
|
||||||
tpdo: 0
|
|
||||||
offset: 4
|
|
||||||
cmd: 0
|
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: template
|
- platform: canopen_entities
|
||||||
id: light1_state
|
id: light1_state
|
||||||
name: Light 1 State
|
name: Light 1 State
|
||||||
- platform: template
|
node: node2
|
||||||
|
entity: light1
|
||||||
|
- platform: canopen_entities
|
||||||
id: light2_state
|
id: light2_state
|
||||||
name: Light 2 State
|
name: Light 2 State
|
||||||
|
node: node2
|
||||||
|
entity: light2
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: light1_state_cmd
|
id: light1_state_cmd
|
||||||
@@ -105,26 +81,33 @@ binary_sensor:
|
|||||||
pullup: true
|
pullup: true
|
||||||
on_press:
|
on_press:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
# both lights on node 2 off if either is on, otherwise both on
|
||||||
bool state = id(light1_state).state || id(light2_state).state;
|
- if:
|
||||||
|
condition:
|
||||||
// send command to entity #1 (light) on node #2
|
lambda: return id(light1_state).state || id(light2_state).state;
|
||||||
id(can_open).send_entity_cmd(2, 1, !state);
|
then:
|
||||||
|
- canopen_entities.light.turn_off: {node: node2, entity: light1}
|
||||||
// send command to entity #2 (light2) on node #2
|
- canopen_entities.light.turn_off: {node: node2, entity: light2}
|
||||||
id(can_open).send_entity_cmd(2, 2, !state);
|
else:
|
||||||
|
- canopen_entities.light.turn_on: {node: node2, entity: light1}
|
||||||
|
- canopen_entities.light.turn_on: {node: node2, entity: light2}
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: template
|
- platform: canopen_entities
|
||||||
id: light1_brightness
|
id: light1_brightness
|
||||||
name: Light 1 Brightness
|
name: Light 1 Brightness
|
||||||
- platform: template
|
node: node2
|
||||||
|
entity: light1
|
||||||
|
state: brightness
|
||||||
|
- platform: canopen_entities
|
||||||
id: light2_brightness
|
id: light2_brightness
|
||||||
name: Light 2 Brightness
|
name: Light 2 Brightness
|
||||||
|
node: node2
|
||||||
|
entity: light2
|
||||||
|
state: brightness
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: LED
|
name: LED
|
||||||
id: blue_led
|
id: blue_led
|
||||||
internal: true
|
|
||||||
pin: 2
|
pin: 2
|
||||||
+18
-3
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
# Hardware: ESP32 DevKit
|
# Hardware: ESP32 DevKit
|
||||||
# Pinout:
|
# Pinout:
|
||||||
|
# GPIO2 -> LED (switch gpio, on-board blue LED)
|
||||||
# GPIO17 -> i2c (i2c sda)
|
# GPIO17 -> i2c (i2c sda)
|
||||||
# GPIO18 -> i2c (i2c scl)
|
# GPIO18 -> i2c (i2c scl)
|
||||||
# GPIO19 -> as3935_i2c (as3935_i2c irq_pin)
|
# GPIO19 -> as3935_i2c (as3935_i2c irq_pin)
|
||||||
@@ -27,14 +28,18 @@ esp32:
|
|||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://mrk-its/esphome-canopen@dev
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
refresh: 1h
|
components: [canopen_entities]
|
||||||
- source: github://mrk-its/esphome-canbus-udp-multicast@dev
|
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
|
logger:
|
||||||
|
logs:
|
||||||
|
# canbus logs every frame at DEBUG, which slows the loop during SDO block transfers
|
||||||
|
canbus: INFO
|
||||||
|
|
||||||
canbus:
|
canbus:
|
||||||
- platform: esp32_can
|
- platform: esp32_can
|
||||||
id: can_bus
|
id: can_bus
|
||||||
@@ -42,11 +47,15 @@ canbus:
|
|||||||
tx_pin: 23
|
tx_pin: 23
|
||||||
can_id: 2
|
can_id: 2
|
||||||
bit_rate: 500kbps
|
bit_rate: 500kbps
|
||||||
|
# IDF default is 5 frames; an SDO block (16 segments in ~8 ms) overflowed it (EMCY 0x8110, partial block acks)
|
||||||
|
rx_queue_len: 32
|
||||||
|
|
||||||
canopen:
|
canopen:
|
||||||
id: can_open
|
id: can_open
|
||||||
canbus_id: can_bus
|
canbus_id: can_bus
|
||||||
node_id: 2
|
node_id: 2
|
||||||
|
|
||||||
|
canopen_entities:
|
||||||
entities:
|
entities:
|
||||||
- index: 1
|
- index: 1
|
||||||
id: light1
|
id: light1
|
||||||
@@ -145,3 +154,9 @@ sensor:
|
|||||||
# canopen: DEBUG
|
# canopen: DEBUG
|
||||||
# can_driver: DEBUG
|
# can_driver: DEBUG
|
||||||
# timer_driver: DEBUG
|
# timer_driver: DEBUG
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: LED
|
||||||
|
id: blue_led
|
||||||
|
pin: 2
|
||||||
+4
-5
@@ -48,7 +48,7 @@ logger:
|
|||||||
globals:
|
globals:
|
||||||
# CAN ID -> frames seen and the last data
|
# CAN ID -> frames seen and the last data
|
||||||
- id: frames_per_id
|
- id: frames_per_id
|
||||||
type: std::map<uint32_t, std::pair<uint32_t, std::vector<uint8_t>>>
|
type: std::map<uint32_t, std::pair<uint32_t, canbus::CanPayload>>
|
||||||
- id: ecm_last_seen
|
- id: ecm_last_seen
|
||||||
type: uint32_t
|
type: uint32_t
|
||||||
initial_value: '0'
|
initial_value: '0'
|
||||||
@@ -80,13 +80,12 @@ canbus:
|
|||||||
0x262, 0x263, 0x266, 0x2C1, 0x2C3, 0x3A0, 0x3D3, 0x4AC,
|
0x262, 0x263, 0x266, 0x2C1, 0x2C3, 0x3A0, 0x3D3, 0x4AC,
|
||||||
0x440, 0x442, 0x443, 0x44D, 0x640};
|
0x440, 0x442, 0x443, 0x44D, 0x640};
|
||||||
bool watch = std::find(std::begin(noisy), std::end(noisy), can_id) == std::end(noisy);
|
bool watch = std::find(std::begin(noisy), std::end(noisy), can_id) == std::end(noisy);
|
||||||
bool changed = e.second != x;
|
bool changed = !std::equal(x.begin(), x.end(), e.second.begin(), e.second.end());
|
||||||
// 0x224 (brake): byte 5 counts, compare the rest
|
// 0x224 (brake): byte 5 counts, compare the rest
|
||||||
if (can_id == 0x224 && x.size() > 5 && e.second.size() == x.size()) {
|
if (can_id == 0x224 && x.size() > 5 && e.second.size() == x.size()) {
|
||||||
watch = true;
|
watch = true;
|
||||||
auto a = x, b = e.second;
|
changed = !std::equal(x.begin(), x.begin() + 5, e.second.begin()) ||
|
||||||
a[5] = b[5] = 0;
|
!std::equal(x.begin() + 6, x.end(), e.second.begin() + 6);
|
||||||
changed = a != b;
|
|
||||||
}
|
}
|
||||||
if (watch && e.first > 1 && changed) {
|
if (watch && e.first > 1 && changed) {
|
||||||
char hex[format_hex_pretty_size(8)];
|
char hex[format_hex_pretty_size(8)];
|
||||||
|
|||||||
@@ -51,60 +51,6 @@ api:
|
|||||||
- rtttl.play:
|
- rtttl.play:
|
||||||
rtttl: !lambda 'return song;'
|
rtttl: !lambda 'return song;'
|
||||||
|
|
||||||
# light:
|
|
||||||
# - platform: neopixelbus
|
|
||||||
# type: GRB
|
|
||||||
# pin: 2
|
|
||||||
# variant: WS2812
|
|
||||||
# method: ESP8266_UART1
|
|
||||||
# num_leds: 1
|
|
||||||
# name: "${name} Light"
|
|
||||||
# id: neo
|
|
||||||
# effects:
|
|
||||||
# # Use default parameters:
|
|
||||||
# - random:
|
|
||||||
# # Customize parameters
|
|
||||||
# - random:
|
|
||||||
# name: "My Slow Random Effect"
|
|
||||||
# transition_length: 30s
|
|
||||||
# update_interval: 30s
|
|
||||||
# - random:
|
|
||||||
# name: "My Fast Random Effect"
|
|
||||||
# transition_length: 4s
|
|
||||||
# update_interval: 5s
|
|
||||||
# - strobe:
|
|
||||||
# - 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:
|
|
||||||
# - flicker:
|
|
||||||
# name: Flicker Effect With Custom Values
|
|
||||||
# alpha: 95%
|
|
||||||
# intensity: 1.5%
|
|
||||||
# - addressable_rainbow:
|
|
||||||
# - addressable_rainbow:
|
|
||||||
# name: Rainbow Effect With Custom Values
|
|
||||||
# speed: 10
|
|
||||||
# width: 50
|
|
||||||
# - addressable_scan:
|
|
||||||
# - addressable_scan:
|
|
||||||
# name: Scan Effect With Custom Values
|
|
||||||
# move_interval: 100ms
|
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: alarm_id
|
- id: alarm_id
|
||||||
type: bool
|
type: bool
|
||||||
|
|||||||
@@ -77,13 +77,6 @@ binary_sensor:
|
|||||||
id: media_out
|
id: media_out
|
||||||
|
|
||||||
light:
|
light:
|
||||||
# - platform: neopixelbus
|
|
||||||
# type: GRB
|
|
||||||
# pin: 27
|
|
||||||
# variant: WS2812
|
|
||||||
# num_leds: 1
|
|
||||||
# name: On-Board LED"
|
|
||||||
# id: neo_buildin
|
|
||||||
- platform: rgb
|
- platform: rgb
|
||||||
name: Light
|
name: Light
|
||||||
id: led_light
|
id: led_light
|
||||||
|
|||||||
+173
-240
@@ -1,22 +1,16 @@
|
|||||||
---
|
---
|
||||||
# Hardware: M5Stack M5Stamp C3
|
# Hardware: M5Stack M5Stamp C3, GNSS test bench with two receivers
|
||||||
# Pinout:
|
# Pinout:
|
||||||
# GPIO0 I2C SCL -> i2c_grove (i2c scl)
|
# GPIO0 Grove A pin 4, UART TX -> uart_m10 (uart tx_pin)
|
||||||
# GPIO1 I2C SDA, BUTTON -> i2c_grove (i2c sda)
|
# GPIO1 Grove A pin 3, UART RX -> uart_m10 (uart rx_pin)
|
||||||
# GPIO2 RGB
|
# GPIO18 Grove B pin 4 (USB D-), UART TX -> uart_at6668 (uart tx_pin)
|
||||||
# GPIO4 GPIO
|
# GPIO19 Grove B pin 3 (USB D+), UART RX -> uart_at6668 (uart rx_pin)
|
||||||
# GPIO5 GPIO
|
# GPIO20 UART0 RX (on-board USB to UART), unused: logger is API only
|
||||||
# GPIO6 GPIO
|
# GPIO21 UART0 TX (on-board USB to UART), unused: logger is API only
|
||||||
# GPIO7 GPIO
|
# Grove pin order: GND, 5V, signal, signal
|
||||||
# GPIO8 GPIO
|
# Receivers:
|
||||||
# GPIO9 GPIO
|
# Grove A XYZ GNSS YM-250, u-blox M10 (ROM SPG 5.10, PROTVER 34.10), 38400 baud -> gnss_m10 (ubx)
|
||||||
# GPIO10 GPIO
|
# Grove B M5Stack Cap LoRa-1262 GNSS, AT6668 (CASIC), 115200 baud -> gnss_at6668 (casic)
|
||||||
# GPIO18 UART RX -> uart_hdmi_switch (uart rx_pin)
|
|
||||||
# GPIO19 UART TX -> uart_hdmi_switch (uart tx_pin)
|
|
||||||
# GPIO20 UART RX, LOGGER -> uart_log (uart rx_pin)
|
|
||||||
# GPIO21 UART TX, LOGGER -> uart_log (uart tx_pin)
|
|
||||||
# I2C:
|
|
||||||
# 0x20 pcf8574_hub (pcf8574)
|
|
||||||
substitutions:
|
substitutions:
|
||||||
device: eworkbench
|
device: eworkbench
|
||||||
name: Electronics Workbench
|
name: Electronics Workbench
|
||||||
@@ -36,237 +30,176 @@ esp32:
|
|||||||
toolchain: esp-idf
|
toolchain: esp-idf
|
||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
advanced:
|
||||||
|
flash_chip: generic
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
|
|
||||||
i2c:
|
external_components:
|
||||||
- id: i2c_grove
|
# geolocation hub + nmea, ubx and casic platforms: esphome/esphome#23301 (stacked on #23293) + casic, not upstream yet
|
||||||
sda: 1
|
- source: github://randybb/esphome@geolocation-casic
|
||||||
scl: 0
|
components: [geolocation, nmea, ubx, casic]
|
||||||
scan: true
|
|
||||||
# - id: i2c_grove_2
|
logger:
|
||||||
# sda: 19
|
# The C3 has two UARTs and both receivers need one; logs go over the API only
|
||||||
# scl: 18
|
baud_rate: 0
|
||||||
# scan: true
|
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
- id: uart_log
|
- id: uart_m10
|
||||||
rx_pin: 20
|
rx_pin: 1
|
||||||
tx_pin: 21
|
tx_pin: 0
|
||||||
|
baud_rate: 38400
|
||||||
|
# Test aid: decode the answers to the polls in interval below
|
||||||
|
debug:
|
||||||
|
direction: RX
|
||||||
|
after:
|
||||||
|
bytes: 1024
|
||||||
|
timeout: 50ms
|
||||||
|
sequence:
|
||||||
|
- lambda: |-
|
||||||
|
for (size_t i = 0; i + 8 <= bytes.size(); i++) {
|
||||||
|
if (bytes[i] != 0xB5 || bytes[i + 1] != 0x62)
|
||||||
|
continue;
|
||||||
|
const uint8_t cls = bytes[i + 2], id = bytes[i + 3];
|
||||||
|
const size_t len = bytes[i + 4] | (bytes[i + 5] << 8);
|
||||||
|
if (i + 6 + len > bytes.size())
|
||||||
|
break;
|
||||||
|
const uint8_t *p = bytes.data() + i + 6;
|
||||||
|
if (cls == 0x0A && id == 0x28 && len >= 8) {
|
||||||
|
ESP_LOGI("ubxdbg", "MON-GNSS supported 0x%02X default 0x%02X enabled 0x%02X (bit0 GPS 1 GLO 2 BDS 3 GAL), max %u at once",
|
||||||
|
p[1], p[2], p[3], p[4]);
|
||||||
|
} else if (cls == 0x01 && id == 0x35 && len >= 8) {
|
||||||
|
static const char *const NAMES[] = {"GPS", "SBAS", "GAL", "BDS", "IMES", "QZSS", "GLO", "NAVIC"};
|
||||||
|
int tracked[8] = {0}, used[8] = {0}, sbas_corr = 0;
|
||||||
|
std::string sbas;
|
||||||
|
const uint8_t num = p[5];
|
||||||
|
for (uint8_t k = 0; k < num && 8 + 12 * (k + 1) <= len; k++) {
|
||||||
|
const uint8_t *b = p + 8 + 12 * k;
|
||||||
|
const uint32_t flags = b[8] | (b[9] << 8) | (b[10] << 16) | ((uint32_t) b[11] << 24);
|
||||||
|
const uint8_t g = b[0] & 7;
|
||||||
|
if (b[2] > 0)
|
||||||
|
tracked[g]++;
|
||||||
|
if (flags & (1u << 3))
|
||||||
|
used[g]++;
|
||||||
|
if (flags & (1u << 16))
|
||||||
|
sbas_corr++;
|
||||||
|
if (b[0] == 1 && b[2] > 0) {
|
||||||
|
char buf[16];
|
||||||
|
snprintf(buf, sizeof(buf), " %u:%u", b[1], b[2]);
|
||||||
|
sbas += buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string summary;
|
||||||
|
for (int g = 0; g < 8; g++) {
|
||||||
|
if (tracked[g] == 0)
|
||||||
|
continue;
|
||||||
|
char buf[24];
|
||||||
|
snprintf(buf, sizeof(buf), " %s %d/%d", NAMES[g], used[g], tracked[g]);
|
||||||
|
summary += buf;
|
||||||
|
}
|
||||||
|
ESP_LOGI("ubxdbg", "NAV-SAT used/tracked:%s; SBAS-corrected %d; SBAS PRN:cno%s", summary.c_str(), sbas_corr,
|
||||||
|
sbas.c_str());
|
||||||
|
}
|
||||||
|
i += 5 + len;
|
||||||
|
}
|
||||||
|
- id: uart_at6668
|
||||||
|
rx_pin: 19
|
||||||
|
tx_pin: 18
|
||||||
baud_rate: 115200
|
baud_rate: 115200
|
||||||
- id: uart_hdmi_switch
|
|
||||||
rx_pin: 18
|
|
||||||
tx_pin: 19
|
|
||||||
baud_rate: 9600
|
|
||||||
|
|
||||||
pcf8574:
|
geolocation:
|
||||||
- id: 'pcf8574_hub'
|
- platform: ubx
|
||||||
address: 0x20
|
id: gnss_m10
|
||||||
pcf8575: true
|
uart_id: uart_m10
|
||||||
|
update_interval: 10s
|
||||||
|
- platform: casic
|
||||||
|
id: gnss_at6668
|
||||||
|
uart_id: uart_at6668
|
||||||
|
update_interval: 10s
|
||||||
|
|
||||||
switch:
|
sensor:
|
||||||
- platform: gpio
|
- platform: geolocation
|
||||||
name: "PCF8574 Pin #0"
|
geolocation_id: gnss_m10
|
||||||
pin:
|
type: latitude
|
||||||
pcf8574: pcf8574_hub
|
name: M10 Latitude
|
||||||
number: 0
|
- platform: geolocation
|
||||||
# One of INPUT or OUTPUT
|
geolocation_id: gnss_m10
|
||||||
mode:
|
type: longitude
|
||||||
output: true
|
name: M10 Longitude
|
||||||
inverted: false
|
- platform: geolocation
|
||||||
- platform: gpio
|
geolocation_id: gnss_m10
|
||||||
name: "PCF8574 Pin #1"
|
type: altitude
|
||||||
pin:
|
name: M10 Altitude
|
||||||
pcf8574: pcf8574_hub
|
- platform: geolocation
|
||||||
number: 1
|
geolocation_id: gnss_m10
|
||||||
# One of INPUT or OUTPUT
|
type: speed
|
||||||
mode:
|
name: M10 Speed
|
||||||
output: true
|
- platform: geolocation
|
||||||
inverted: false
|
geolocation_id: gnss_m10
|
||||||
- platform: gpio
|
type: course
|
||||||
name: "PCF8574 Pin #7"
|
name: M10 Course
|
||||||
pin:
|
- platform: geolocation
|
||||||
pcf8574: pcf8574_hub
|
geolocation_id: gnss_m10
|
||||||
number: 7
|
type: satellites
|
||||||
# One of INPUT or OUTPUT
|
name: M10 Satellites
|
||||||
mode:
|
- platform: geolocation
|
||||||
output: true
|
geolocation_id: gnss_m10
|
||||||
inverted: false
|
type: hdop
|
||||||
|
name: M10 HDOP
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_m10
|
||||||
|
type: horizontal_accuracy
|
||||||
|
name: M10 Horizontal Accuracy
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_m10
|
||||||
|
type: vertical_accuracy
|
||||||
|
name: M10 Vertical Accuracy
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: latitude
|
||||||
|
name: AT6668 Latitude
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: longitude
|
||||||
|
name: AT6668 Longitude
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: altitude
|
||||||
|
name: AT6668 Altitude
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: speed
|
||||||
|
name: AT6668 Speed
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: course
|
||||||
|
name: AT6668 Course
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: satellites
|
||||||
|
name: AT6668 Satellites
|
||||||
|
- platform: geolocation
|
||||||
|
geolocation_id: gnss_at6668
|
||||||
|
type: hdop
|
||||||
|
name: AT6668 HDOP
|
||||||
|
|
||||||
binary_sensor:
|
time:
|
||||||
- platform: gpio
|
- platform: geolocation
|
||||||
name: "PCF8574 Pin #10"
|
id: gnss_time
|
||||||
pin:
|
geolocation_id: gnss_m10
|
||||||
pcf8574: pcf8574_hub
|
on_time_sync:
|
||||||
number: 8
|
- logger.log: GNSS time synced
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #11"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 9
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #12"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 10
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #13"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 11
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #14"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 12
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #15"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 13
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #16"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 14
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
- platform: gpio
|
|
||||||
name: "PCF8574 Pin #17"
|
|
||||||
pin:
|
|
||||||
pcf8574: pcf8574_hub
|
|
||||||
number: 15
|
|
||||||
# One of INPUT or OUTPUT
|
|
||||||
mode: INPUT
|
|
||||||
inverted: false
|
|
||||||
|
|
||||||
# binary_sensor:
|
interval:
|
||||||
# - platform: gpio
|
# Test aid: constellations and satellites of the M10
|
||||||
# id: rotary_encoder_button
|
- interval: 60s
|
||||||
# pin:
|
then:
|
||||||
# number: 6
|
- uart.write:
|
||||||
# # mode: INPUT_PULLUP
|
id: uart_m10
|
||||||
# inverted: true
|
data: [0xB5, 0x62, 0x0A, 0x28, 0x00, 0x00, 0x32, 0xA0]
|
||||||
# filters:
|
- delay: 2s
|
||||||
# - delayed_on: 30ms
|
- uart.write:
|
||||||
# - delayed_off: 30ms
|
id: uart_m10
|
||||||
# on_press:
|
data: [0xB5, 0x62, 0x01, 0x35, 0x00, 0x00, 0x36, 0xA3]
|
||||||
# - display_menu.enter:
|
|
||||||
|
|
||||||
# display:
|
|
||||||
# - platform: lcd_pcf8574
|
|
||||||
# id: my_lcd
|
|
||||||
# i2c_id: i2c_grove
|
|
||||||
# dimensions: 20x4
|
|
||||||
# address: 0x27
|
|
||||||
# user_characters:
|
|
||||||
# - position: 0
|
|
||||||
# data: # mark_back symbol
|
|
||||||
# - 0b00100
|
|
||||||
# - 0b01000
|
|
||||||
# - 0b11110
|
|
||||||
# - 0b01001
|
|
||||||
# - 0b00101
|
|
||||||
# - 0b00001
|
|
||||||
# - 0b11110
|
|
||||||
# - 0b00000
|
|
||||||
# lambda: |-
|
|
||||||
# id(my_lcd_menu).draw();
|
|
||||||
# if (!id(my_lcd_menu).is_active())
|
|
||||||
# it.print("Menu is not active");
|
|
||||||
|
|
||||||
# lcd_menu:
|
|
||||||
# id: my_lcd_menu
|
|
||||||
# display_id: my_lcd
|
|
||||||
# active: true
|
|
||||||
# mode: rotary
|
|
||||||
# mark_back: 0x08
|
|
||||||
# mark_selected: 0x3e
|
|
||||||
# mark_editing: 0x2a
|
|
||||||
# mark_submenu: 0x7e
|
|
||||||
# items:
|
|
||||||
# - type: back
|
|
||||||
# text: 'Back'
|
|
||||||
# - type: label
|
|
||||||
# text: 'Label 1'
|
|
||||||
# - type: label
|
|
||||||
# text: !lambda |-
|
|
||||||
# return "Templated label";
|
|
||||||
|
|
||||||
# select:
|
|
||||||
# - platform: template
|
|
||||||
# id: hdmi_switch
|
|
||||||
# optimistic: true
|
|
||||||
# options:
|
|
||||||
# - PC1
|
|
||||||
# - PC2
|
|
||||||
# - PC3
|
|
||||||
# - PC4
|
|
||||||
# initial_option: PC1
|
|
||||||
# # set_action:
|
|
||||||
# # - logger.log:
|
|
||||||
# # format: "Chosen option: %s (index %d)"
|
|
||||||
# # args: ["x.c_str()", "i"]
|
|
||||||
# # - uart.write:
|
|
||||||
# # id: uart_hdmi_switch
|
|
||||||
# # data: [0x47, 0x30, 0x31, 0x67, 0x41, 0x00]
|
|
||||||
|
|
||||||
# sensor:
|
|
||||||
# - platform: rotary_encoder
|
|
||||||
# id: rotary_encoder_sensor
|
|
||||||
# pin_a: 4
|
|
||||||
# pin_b: 5
|
|
||||||
# filters:
|
|
||||||
# debounce: 30ms
|
|
||||||
# on_anticlockwise:
|
|
||||||
# - display_menu.up:
|
|
||||||
# on_clockwise:
|
|
||||||
# - display_menu.down:
|
|
||||||
|
|
||||||
# display:
|
|
||||||
# - platform: tm1637
|
|
||||||
# id: tm1637_display
|
|
||||||
# clk_pin: 4
|
|
||||||
# dio_pin: 5
|
|
||||||
# update_interval: 500ms
|
|
||||||
# # intensity: 0
|
|
||||||
# lambda: |-
|
|
||||||
# static int i = 0;
|
|
||||||
# i++;
|
|
||||||
# if (id(alarm_id)) {
|
|
||||||
# if ((i % 2) == 0)
|
|
||||||
# it.print("8 8 ");
|
|
||||||
# else
|
|
||||||
# it.print(" 8 8");
|
|
||||||
# } else {
|
|
||||||
# if (((i / 10) % 2) == 0) {
|
|
||||||
# //it.set_intensity(7);
|
|
||||||
# if ((i % 2) == 0)
|
|
||||||
# it.strftime("%H.%M", id(ha_time).now());
|
|
||||||
# else
|
|
||||||
# it.strftime("%H%M", id(ha_time).now());
|
|
||||||
# } else {
|
|
||||||
# //it.set_intensity(1);
|
|
||||||
# it.printf("%.0f~C", id(temperature).state);
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
@@ -34,6 +34,7 @@ esp32:
|
|||||||
flash_chip: gd
|
flash_chip: gd
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
|
# iBeacon on air from boot without the empty standard advertisement every 10 s
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
ipv6_only: !include common/ipv6_only.yaml
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
@@ -107,8 +108,20 @@ globals:
|
|||||||
|
|
||||||
esp32_ble_tracker:
|
esp32_ble_tracker:
|
||||||
id: ${device}_ble_tracker
|
id: ${device}_ble_tracker
|
||||||
|
# window 160/320 ms (default 30): hears the vehicle beacons sooner, half the airtime stays for Wi-Fi
|
||||||
scan_parameters:
|
scan_parameters:
|
||||||
duration: 1min
|
duration: 1min
|
||||||
|
interval: 320ms
|
||||||
|
window: 160ms
|
||||||
|
active: false
|
||||||
|
|
||||||
|
# home beacon: the vehicles light their LED while they see it
|
||||||
|
esp32_ble_beacon:
|
||||||
|
type: iBeacon
|
||||||
|
uuid: !secret ble_beacon_gate_uuid
|
||||||
|
min_interval: 1s
|
||||||
|
max_interval: 1s
|
||||||
|
tx_power: 9dBm
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ esp32:
|
|||||||
sram1_as_iram: true
|
sram1_as_iram: true
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
# Ethernet LLDP 802.1AB transmitter
|
|
||||||
# - source: github://pr#11760
|
|
||||||
# components: [ethernet]
|
|
||||||
# refresh: 1h
|
|
||||||
- source: github://pr#2112
|
- source: github://pr#2112
|
||||||
components: ["m5stack_4relay"]
|
components: ["m5stack_4relay"]
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
@@ -67,44 +63,6 @@ i2c:
|
|||||||
scl: 16
|
scl: 16
|
||||||
scan: true
|
scan: true
|
||||||
|
|
||||||
# ethernet:
|
|
||||||
# lldp:
|
|
||||||
# # Enable LLDP transmission
|
|
||||||
# #enabled: true
|
|
||||||
# # Optional: override default port
|
|
||||||
# port: eth
|
|
||||||
# # Optional: override default system name
|
|
||||||
# system_name: mcu-${device}
|
|
||||||
# # Optional: override default system description
|
|
||||||
# system_description: ${comment}
|
|
||||||
# # Optional: override default "fast mode" burst packet count
|
|
||||||
# tx_fast_count: 4
|
|
||||||
# # Optional: override default LLDP frame transmission interval
|
|
||||||
# tx_interval: 30
|
|
||||||
# # Optional: override default hold count, used in conjuction with tx_interval to calculate overall TTL
|
|
||||||
# tx_hold: 4
|
|
||||||
|
|
||||||
# ethernet:
|
|
||||||
# type: LAN8720
|
|
||||||
# mdc_pin: 23
|
|
||||||
# mdio_pin: 18
|
|
||||||
# clk_mode: GPIO17_OUT
|
|
||||||
# phy_addr: 0
|
|
||||||
# power_pin: 12
|
|
||||||
# use_address: 10.17.240.245
|
|
||||||
|
|
||||||
# # Optional manual IP
|
|
||||||
# manual_ip:
|
|
||||||
# static_ip: 10.17.240.254
|
|
||||||
# gateway: 10.17.240.1
|
|
||||||
# subnet: 255.255.255.0
|
|
||||||
|
|
||||||
|
|
||||||
# ethernet:
|
|
||||||
# use_address: 10.17.241.254
|
|
||||||
# use_address: 10.17.241.98
|
|
||||||
# use_address: mcu-gateway.local
|
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
id: uart_modbus
|
id: uart_modbus
|
||||||
tx_pin: 4
|
tx_pin: 4
|
||||||
|
|||||||
@@ -86,14 +86,9 @@ packages:
|
|||||||
|
|
||||||
api:
|
api:
|
||||||
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
||||||
on_client_connected:
|
# Home Assistant has subscribed and received every state
|
||||||
- delay: 2s
|
on_client_synced:
|
||||||
- if:
|
- lvgl.page.show: main_page
|
||||||
condition:
|
|
||||||
api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- lvgl.page.show: main_page
|
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
|
|||||||
+3
-8
@@ -148,14 +148,9 @@ packages:
|
|||||||
|
|
||||||
api:
|
api:
|
||||||
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
||||||
on_client_connected:
|
# Home Assistant has subscribed and received every state
|
||||||
- delay: 2s
|
on_client_synced:
|
||||||
- if:
|
- lvgl.page.show: main_page
|
||||||
condition:
|
|
||||||
api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- lvgl.page.show: main_page
|
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
|
|||||||
+19
-13
@@ -16,7 +16,7 @@
|
|||||||
# GPIO39 -> touch_lcd (touchscreen ft63x6 interrupt_pin)
|
# GPIO39 -> touch_lcd (touchscreen ft63x6 interrupt_pin)
|
||||||
# AXP192 GPIO4 -> LCD reset (on_boot)
|
# AXP192 GPIO4 -> LCD reset (on_boot)
|
||||||
# Grove (free):
|
# Grove (free):
|
||||||
# Port A red (Core2) I2C GPIO32 SDA, GPIO33 SCL
|
# Port A red (Core2) I2C GPIO32 SDA, GPIO33 SCL -> can_bus (esp32_can rx GPIO32, tx GPIO33), TJA1050 module
|
||||||
# Port B black (base) GPIO GPIO26 out/DAC, GPIO36 in/ADC (input only); GPIO26 taken by the LoRa868 RST
|
# Port B black (base) GPIO GPIO26 out/DAC, GPIO36 in/ADC (input only); GPIO26 taken by the LoRa868 RST
|
||||||
# Port C blue (base) UART GPIO13 RX, GPIO14 TX -> i2c_port_c (i2c scl GPIO13, sda GPIO14)
|
# Port C blue (base) UART GPIO13 RX, GPIO14 TX -> i2c_port_c (i2c scl GPIO13, sda GPIO14)
|
||||||
# Touch buttons (below the LCD, raw y 240-280): A prev page, B keyboard page, C next page
|
# Touch buttons (below the LCD, raw y 240-280): A prev page, B keyboard page, C next page
|
||||||
@@ -97,16 +97,14 @@ external_components:
|
|||||||
components: [axp192]
|
components: [axp192]
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
- source: github://randybb/esphome-components
|
- source: github://randybb/esphome-components
|
||||||
components: [m5stack_keyboard, m5stack_st7789v2, meshtastic]
|
components: [m5stack_keyboard, m5stack_st7789v2, meshtastic, mlx90640]
|
||||||
refresh: 0s
|
refresh: 0s
|
||||||
# MLX90640, camera entity in HA (its heatmap page at /thermal needs web_server_base only)
|
|
||||||
- source: github://randybb/esphome-mlx-90640@optional-web-server
|
|
||||||
components: [mlx90640]
|
|
||||||
|
|
||||||
# MLX90640 on Port C; settings changed at runtime are saved on the device
|
# MLX90640 on Port C; settings changed at runtime are saved on the device
|
||||||
mlx90640:
|
mlx90640:
|
||||||
id: thermal
|
id: thermal
|
||||||
i2c_id: i2c_port_c
|
i2c_id: i2c_port_c
|
||||||
|
web_ui: false # the heatmap page at /thermal would pull in web_server_base
|
||||||
refresh_rate: 4Hz
|
refresh_rate: 4Hz
|
||||||
update_interval: 10s
|
update_interval: 10s
|
||||||
min_temperature:
|
min_temperature:
|
||||||
@@ -129,14 +127,9 @@ mlx90640:
|
|||||||
|
|
||||||
api:
|
api:
|
||||||
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
||||||
on_client_connected:
|
# Home Assistant has subscribed and received every state
|
||||||
- delay: 2s
|
on_client_synced:
|
||||||
- if:
|
- lvgl.page.show: {id: main_page, lvgl_id: lvgl_main}
|
||||||
condition:
|
|
||||||
api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- lvgl.page.show: {id: main_page, lvgl_id: lvgl_main}
|
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -146,6 +139,19 @@ api:
|
|||||||
then:
|
then:
|
||||||
- lvgl.page.show: {id: status_page, lvgl_id: lvgl_main}
|
- lvgl.page.show: {id: status_page, lvgl_id: lvgl_main}
|
||||||
|
|
||||||
|
canbus:
|
||||||
|
- platform: esp32_can
|
||||||
|
id: can_bus
|
||||||
|
rx_pin: 32
|
||||||
|
tx_pin: 33
|
||||||
|
can_id: 5
|
||||||
|
bit_rate: 500kbps
|
||||||
|
|
||||||
|
canopen:
|
||||||
|
- id: can_open
|
||||||
|
canbus_id: can_bus
|
||||||
|
node_id: 5
|
||||||
|
|
||||||
i2c:
|
i2c:
|
||||||
- id: i2c_main
|
- id: i2c_main
|
||||||
sda: 21
|
sda: 21
|
||||||
|
|||||||
+4
-17
@@ -124,28 +124,15 @@ wifi:
|
|||||||
- component.update: m5paper_display
|
- component.update: m5paper_display
|
||||||
|
|
||||||
api:
|
api:
|
||||||
# status screen until Home Assistant connects (log viewers don't subscribe to states)
|
# status screen until Home Assistant has subscribed and received every state (log viewers don't subscribe)
|
||||||
on_client_connected:
|
on_client_synced:
|
||||||
- delay: 2s
|
- lambda: id(show_status) = false;
|
||||||
- if:
|
|
||||||
condition:
|
|
||||||
api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- lambda: id(show_status) = false;
|
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: return !id(calendar_page);
|
lambda: return !id(calendar_page);
|
||||||
then:
|
then:
|
||||||
- component.update: m5paper_display
|
- component.update: m5paper_display
|
||||||
# outside the battery cycle (power button, USB) WiFi is up anyway: always refresh
|
# outside the battery cycle (power button, USB) WiFi is up anyway: always refresh
|
||||||
- if:
|
|
||||||
condition:
|
|
||||||
and:
|
|
||||||
- lambda: return !id(calendar_page);
|
|
||||||
- api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- script.execute: fetch_events
|
- script.execute: fetch_events
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
|
|||||||
@@ -0,0 +1,340 @@
|
|||||||
|
---
|
||||||
|
# Hardware: M5StickC Plus + Hat CardKB + Hat Mini JoyC on the hat header, TJA1050 CAN module on Grove
|
||||||
|
# CANopen keypad + joystick (node 4), canopen from ESPHome dev + canopen_entities
|
||||||
|
# Pinout:
|
||||||
|
# GPIO0 hat SDA -> i2c_hat (i2c sda)
|
||||||
|
# GPIO26 hat SCL -> i2c_hat (i2c scl)
|
||||||
|
# GPIO32 Grove -> can_bus (canbus esp32_can rx_pin), TJA1050 module RX
|
||||||
|
# GPIO33 Grove -> can_bus (canbus esp32_can tx_pin), TJA1050 module TX
|
||||||
|
# GPIO21 internal SDA -> i2c_axp (i2c sda)
|
||||||
|
# GPIO22 internal SCL -> i2c_axp (i2c scl)
|
||||||
|
# GPIO10 red LED (active low) -> LED (light binary)
|
||||||
|
# GPIO37 button A -> Button A (binary_sensor gpio) (inverted)
|
||||||
|
# GPIO39 button B -> Button B (binary_sensor gpio) (inverted)
|
||||||
|
# I2C:
|
||||||
|
# 0x34 pmu_axp (axp192)
|
||||||
|
# 0x51 rtc_time (time bm8563)
|
||||||
|
# 0x68 imu (sensor mpu6886)
|
||||||
|
# 0x54 joyc (m5stack_mini_joyc), Hat Mini JoyC
|
||||||
|
# 0x5F cardkb (m5stack_keyboard), Hat CardKB
|
||||||
|
# Hat CardKB: its SDA/SCL pull-ups are on 5 V (measured, the ATmega itself takes 3V3 from the hat header, bridged
|
||||||
|
# to 5 V), so G0/G26 sit at 5 V, above the ESP32's VDD + 0.3 V; works, a level shifter or removing those pull-ups
|
||||||
|
# would fix it. Mini JoyC (STM32F030 PA9/PA10) is 5 V tolerant.
|
||||||
|
# GPIO13/15 LCD CLK/MOSI, GPIO5 CS, GPIO23 DC, GPIO18 RST -> display_tft (ST7789V2 135x240)
|
||||||
|
# AXP192: LDO2 LCD backlight, LDO3 LCD logic, EXTEN 5 V for the hat header and Grove
|
||||||
|
substitutions:
|
||||||
|
device: m5stickc-plus
|
||||||
|
name: M5StickC Plus
|
||||||
|
area: DEV
|
||||||
|
comment: CANopen keypad + joystick
|
||||||
|
|
||||||
|
esphome:
|
||||||
|
name: mcu-${device}
|
||||||
|
friendly_name: ${name}
|
||||||
|
area: ${area}
|
||||||
|
comment: ${comment}
|
||||||
|
on_boot:
|
||||||
|
# AXP192 EXTEN (reg 0x10 bit 2) = 5 V for the hat header and Grove (CardKB, CAN unit)
|
||||||
|
- priority: 800
|
||||||
|
then:
|
||||||
|
- lambda: id(set_exten)->execute(true);
|
||||||
|
- then:
|
||||||
|
- output.turn_on: lcd_logic
|
||||||
|
- lambda: |-
|
||||||
|
id(cardkb).add_on_key_callback([](uint8_t key) {
|
||||||
|
id(key_code).publish_state(key);
|
||||||
|
float n = id(key_count).state; // NaN before the first key
|
||||||
|
uint32_t count = std::isnan(n) ? 1 : ((uint32_t) n + 1) % 65535;
|
||||||
|
id(key_count).publish_state(count);
|
||||||
|
id(key_event).publish_state((count % 255) * 256 + key); // one field: count (high byte) + key (low byte)
|
||||||
|
id(display_tft).update();
|
||||||
|
});
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
board: m5stick-c
|
||||||
|
toolchain: esp-idf
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
|
||||||
|
external_components:
|
||||||
|
- source: github://m5stack/esphome-yaml
|
||||||
|
components: [axp192]
|
||||||
|
refresh: 1h
|
||||||
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
|
components: [canopen_entities]
|
||||||
|
refresh: 1h
|
||||||
|
- source: github://randybb/esphome-components
|
||||||
|
components: [m5stack_keyboard, m5stack_mini_joyc]
|
||||||
|
refresh: 1h
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common/common.yaml
|
||||||
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
- id: i2c_axp
|
||||||
|
sda: 21
|
||||||
|
scl: 22
|
||||||
|
- id: i2c_hat
|
||||||
|
sda: 0
|
||||||
|
scl: 26
|
||||||
|
|
||||||
|
axp192:
|
||||||
|
id: pmu_axp
|
||||||
|
i2c_id: i2c_axp
|
||||||
|
|
||||||
|
m5stack_keyboard:
|
||||||
|
- id: cardkb
|
||||||
|
i2c_id: i2c_hat
|
||||||
|
address: 0x5F
|
||||||
|
|
||||||
|
m5stack_mini_joyc:
|
||||||
|
- id: joyc
|
||||||
|
i2c_id: i2c_hat
|
||||||
|
# hat mounted turned 90° right of the display: X = hat Y, Y = -hat X
|
||||||
|
x:
|
||||||
|
id: joy_y
|
||||||
|
name: Joystick Y
|
||||||
|
filters:
|
||||||
|
- multiply: -1
|
||||||
|
- delta: 8
|
||||||
|
y:
|
||||||
|
id: joy_x
|
||||||
|
name: Joystick X
|
||||||
|
filters:
|
||||||
|
- delta: 8
|
||||||
|
button:
|
||||||
|
id: joy_button
|
||||||
|
name: Joystick Button
|
||||||
|
|
||||||
|
logger:
|
||||||
|
logs:
|
||||||
|
# canbus logs every frame at DEBUG, which slows the loop during SDO block transfers
|
||||||
|
canbus: INFO
|
||||||
|
|
||||||
|
canbus:
|
||||||
|
- platform: esp32_can
|
||||||
|
id: can_bus
|
||||||
|
tx_pin: 33
|
||||||
|
rx_pin: 32
|
||||||
|
can_id: 4
|
||||||
|
bit_rate: 500kbps
|
||||||
|
mode: LISTENONLY # TEMP: the node does not see the bus on RX (GPIO32), keep it off the bus
|
||||||
|
# IDF default is 5 frames; an SDO block (16 segments in ~8 ms) overflowed it (EMCY 0x8110, partial block acks)
|
||||||
|
rx_queue_len: 32
|
||||||
|
|
||||||
|
canopen:
|
||||||
|
- id: can_open
|
||||||
|
canbus_id: can_bus
|
||||||
|
node_id: 4
|
||||||
|
|
||||||
|
# CardKB sends only the press: a consumer reacts to a change of key_count and reads the key from key_code (same
|
||||||
|
# frame), or watches key_event alone (count % 255 << 8 | key). Joystick -512..511 as UINT16 = value + 512.
|
||||||
|
canopen_entities:
|
||||||
|
canopen_id: can_open
|
||||||
|
entities:
|
||||||
|
- {id: key_code, index: 1, tpdo: 0, size: 1}
|
||||||
|
- {id: key_count, index: 2, tpdo: 0, size: 2}
|
||||||
|
- {id: key_event, index: 3, tpdo: 0, size: 2}
|
||||||
|
- {id: joy_button, index: 4, tpdo: 0}
|
||||||
|
- {id: button_a, index: 5, tpdo: 0}
|
||||||
|
- {id: button_b, index: 6, tpdo: 0}
|
||||||
|
- {id: joy_x, index: 7, tpdo: 1, size: 2, min_value: -512, max_value: 65022}
|
||||||
|
- {id: joy_y, index: 8, tpdo: 1, size: 2, min_value: -512, max_value: 65022}
|
||||||
|
- {id: led, index: 9, tpdo: 1}
|
||||||
|
- {id: joy_led, index: 10, tpdo: 1, caps: [on_off, brightness]}
|
||||||
|
|
||||||
|
time:
|
||||||
|
- platform: bm8563
|
||||||
|
id: rtc_time
|
||||||
|
i2c_id: i2c_axp
|
||||||
|
# keep the RTC in sync with Home Assistant, for the time without Wi-Fi
|
||||||
|
- id: !extend ha_time
|
||||||
|
on_time_sync:
|
||||||
|
- bm8563.write_time: rtc_time
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: axp192
|
||||||
|
id: pmu_sensor
|
||||||
|
update_interval: 10s
|
||||||
|
battery_level:
|
||||||
|
id: battery_level
|
||||||
|
name: Battery Level
|
||||||
|
battery_voltage:
|
||||||
|
name: Battery Voltage
|
||||||
|
battery_charging:
|
||||||
|
id: battery_charging
|
||||||
|
name: Battery Charging
|
||||||
|
internal_temperature:
|
||||||
|
name: PMU Temperature
|
||||||
|
- platform: mpu6886
|
||||||
|
id: imu
|
||||||
|
i2c_id: i2c_axp
|
||||||
|
address: 0x68
|
||||||
|
update_interval: 1s
|
||||||
|
accel_x:
|
||||||
|
name: Accel X
|
||||||
|
accel_y:
|
||||||
|
name: Accel Y
|
||||||
|
accel_z:
|
||||||
|
name: Accel Z
|
||||||
|
gyro_x:
|
||||||
|
name: Gyro X
|
||||||
|
gyro_y:
|
||||||
|
name: Gyro Y
|
||||||
|
gyro_z:
|
||||||
|
name: Gyro Z
|
||||||
|
temperature:
|
||||||
|
name: IMU Temperature
|
||||||
|
- platform: template
|
||||||
|
id: key_code
|
||||||
|
name: Key Code
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
- platform: template
|
||||||
|
id: key_count
|
||||||
|
name: Key Count
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
- platform: template
|
||||||
|
id: key_event
|
||||||
|
name: Key Event
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: never
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
id: button_a
|
||||||
|
name: Button A
|
||||||
|
pin:
|
||||||
|
number: 37
|
||||||
|
inverted: true
|
||||||
|
- platform: gpio
|
||||||
|
id: button_b
|
||||||
|
name: Button B
|
||||||
|
pin:
|
||||||
|
number: 39
|
||||||
|
inverted: true
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: axp192
|
||||||
|
type: range
|
||||||
|
channel: DLDO2
|
||||||
|
id: lcd_backlight_out
|
||||||
|
min_voltage: 2500
|
||||||
|
max_voltage: 3300
|
||||||
|
- platform: axp192
|
||||||
|
channel: DLDO3
|
||||||
|
id: lcd_logic
|
||||||
|
voltage: 3000
|
||||||
|
- platform: gpio
|
||||||
|
id: led_out
|
||||||
|
pin:
|
||||||
|
number: 10
|
||||||
|
inverted: true
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: monochromatic
|
||||||
|
id: lcd_backlight
|
||||||
|
name: LCD Backlight
|
||||||
|
entity_category: config
|
||||||
|
output: lcd_backlight_out
|
||||||
|
restore_mode: ALWAYS_ON
|
||||||
|
- platform: binary
|
||||||
|
id: led
|
||||||
|
name: LED
|
||||||
|
output: led_out
|
||||||
|
- platform: m5stack_mini_joyc
|
||||||
|
id: joy_led
|
||||||
|
name: Joystick LED
|
||||||
|
mini_joyc_id: joyc
|
||||||
|
|
||||||
|
|
||||||
|
script:
|
||||||
|
# AXP192 EXTEN (reg 0x10 bit 2): 5 V out on the hat header and Grove
|
||||||
|
- id: set_exten
|
||||||
|
parameters:
|
||||||
|
enable: bool
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
uint8_t reg = 0x10, v;
|
||||||
|
if (id(i2c_axp).write_readv(0x34, ®, 1, &v, 1) != i2c::ERROR_OK)
|
||||||
|
return;
|
||||||
|
uint8_t d[2] = {reg, (uint8_t) (enable ? v | 0x04 : v & ~0x04)};
|
||||||
|
id(i2c_axp).write(0x34, d, 2);
|
||||||
|
|
||||||
|
button:
|
||||||
|
# restarts what runs from the 5 V out (CardKB bridged to 5 V, the CAN unit); the Mini JoyC runs from 3V3
|
||||||
|
- platform: template
|
||||||
|
name: Peripheral Power Cycle
|
||||||
|
entity_category: config
|
||||||
|
on_press:
|
||||||
|
- script.execute: {id: set_exten, enable: false}
|
||||||
|
- delay: 500ms
|
||||||
|
- script.execute: {id: set_exten, enable: true}
|
||||||
|
|
||||||
|
spi:
|
||||||
|
clk_pin: 13
|
||||||
|
mosi_pin: 15
|
||||||
|
|
||||||
|
font:
|
||||||
|
- file: "gfonts://Roboto"
|
||||||
|
id: font_key
|
||||||
|
size: 48
|
||||||
|
- file: "gfonts://Roboto"
|
||||||
|
id: font_status
|
||||||
|
size: 14
|
||||||
|
|
||||||
|
display:
|
||||||
|
- platform: mipi_spi
|
||||||
|
model: ST7789V
|
||||||
|
id: display_tft
|
||||||
|
dimensions:
|
||||||
|
width: 135
|
||||||
|
height: 240
|
||||||
|
offset_width: 52
|
||||||
|
offset_height: 40
|
||||||
|
invert_colors: true
|
||||||
|
rotation: 270 # landscape, turned left
|
||||||
|
cs_pin: 5
|
||||||
|
dc_pin: 23
|
||||||
|
reset_pin: 18
|
||||||
|
update_interval: 200ms
|
||||||
|
lambda: |-
|
||||||
|
// status line top left: battery (+ = charging), Wi-Fi RSSI, API (green = a client is connected)
|
||||||
|
it.printf(0, 0, id(font_status), "%.0f%%%s", id(battery_level).state, id(battery_charging).state ? "+" : "");
|
||||||
|
it.printf(40, 0, id(font_status), "%.0f", id(wifi_signal_sensor).state);
|
||||||
|
it.print(75, 0, id(font_status), api::global_api_server->is_connected() ? Color(0, 255, 0) : Color(255, 0, 0), "API");
|
||||||
|
// landscape 240x135: joystick dot in a 135x135 square on the right
|
||||||
|
it.rectangle(105, 0, 135, 135, Color(64, 64, 64));
|
||||||
|
if (!std::isnan(id(joy_x).state) && !std::isnan(id(joy_y).state)) {
|
||||||
|
int x = 172 + id(joy_x).state * 60 / 512, y = 67 - id(joy_y).state * 60 / 512;
|
||||||
|
it.filled_circle(x, y, 6, id(joy_button).state ? Color(255, 0, 0) : Color(255, 255, 255));
|
||||||
|
}
|
||||||
|
// last key (CardKB: specials as names, unknown codes as hex)
|
||||||
|
if (std::isnan(id(key_code).state))
|
||||||
|
return;
|
||||||
|
uint8_t k = id(key_code).state;
|
||||||
|
const char *s = nullptr;
|
||||||
|
char c[5];
|
||||||
|
switch (k) {
|
||||||
|
case 0x08: s = "BS"; break;
|
||||||
|
case 0x09: s = "Tab"; break;
|
||||||
|
case 0x0D: s = "Ent"; break;
|
||||||
|
case 0x1B: s = "Esc"; break;
|
||||||
|
case 0x20: s = "Spc"; break;
|
||||||
|
case 0x7F: s = "Del"; break;
|
||||||
|
case 0xB4: s = "Lt"; break;
|
||||||
|
case 0xB5: s = "Up"; break;
|
||||||
|
case 0xB6: s = "Dn"; break;
|
||||||
|
case 0xB7: s = "Rt"; break;
|
||||||
|
default:
|
||||||
|
if (k > 0x20 && k < 0x7F) {
|
||||||
|
c[0] = (char) k;
|
||||||
|
c[1] = 0;
|
||||||
|
} else {
|
||||||
|
snprintf(c, sizeof(c), "%02X", k);
|
||||||
|
}
|
||||||
|
s = c;
|
||||||
|
}
|
||||||
|
it.print(52, 67, id(font_key), TextAlign::CENTER, s); // last key on the left
|
||||||
+22
-2
@@ -7,6 +7,7 @@
|
|||||||
# P0.06 UART0 TX -> logger (J-Link VCOM)
|
# P0.06 UART0 TX -> logger (J-Link VCOM)
|
||||||
# P0.13 LED 1 (active low) -> ANT+ Connected (a configured device is received)
|
# P0.13 LED 1 (active low) -> ANT+ Connected (a configured device is received)
|
||||||
# P0.14 LED 2 (active low) -> ANT+ Unknown Device (an unconfigured one is in range)
|
# P0.14 LED 2 (active low) -> ANT+ Unknown Device (an unconfigured one is in range)
|
||||||
|
# NFC1/2 NFC antenna connector -> nfc_tag (Type 2 tag, HA tag URL)
|
||||||
# P1.01 UART1 RX <- mcu-nrf-dk UART1 TX (P1.02), packet_transport
|
# P1.01 UART1 RX <- mcu-nrf-dk UART1 TX (P1.02), packet_transport
|
||||||
# P1.02 UART1 TX -> mcu-nrf-dk UART1 RX (P1.01), packet_transport; plus GND
|
# P1.02 UART1 TX -> mcu-nrf-dk UART1 RX (P1.01), packet_transport; plus GND
|
||||||
# Radio: ANT+ receiver (RadiANT), no network of its own; values go to mcu-nrf-dk
|
# Radio: ANT+ receiver (RadiANT), no network of its own; values go to mcu-nrf-dk
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
# 655730 Garmin HRM-Pro heart rate
|
# 655730 Garmin HRM-Pro heart rate
|
||||||
# 498521 Concept2 PM5 (rower) fitness equipment (FE-C)
|
# 498521 Concept2 PM5 (rower) fitness equipment (FE-C)
|
||||||
# 1044953 Garmin Tempe environment (temperature)
|
# 1044953 Garmin Tempe environment (temperature)
|
||||||
# 604693 Garmin Varia RTL515 bike radar, battery only
|
# 604693 Garmin Varia RTL515 bike radar: vehicles, nearest distance + closing speed, battery
|
||||||
# 136052 Garmin HRM-Dual heart rate (pain cave)
|
# 136052 Garmin HRM-Dual heart rate (pain cave)
|
||||||
# 334424 Garmin HRM-Tri heart rate (bike)
|
# 334424 Garmin HRM-Tri heart rate (bike)
|
||||||
# 886796 Garmin Rally RS200 power + cadence
|
# 886796 Garmin Rally RS200 power + cadence
|
||||||
@@ -37,7 +38,7 @@ logger:
|
|||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://randybb/esphome-components
|
- source: github://randybb/esphome-components
|
||||||
components: [ant_plus]
|
components: [ant_plus, nfc_tag]
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -47,6 +48,9 @@ output:
|
|||||||
id: led_unknown
|
id: led_unknown
|
||||||
pin: {number: P0.14, inverted: true}
|
pin: {number: P0.14, inverted: true}
|
||||||
|
|
||||||
|
nfc_tag:
|
||||||
|
url: https://www.home-assistant.io/tag/mcu-nrf-ant
|
||||||
|
|
||||||
ant_plus:
|
ant_plus:
|
||||||
network_key: !secret ant_plus_network_key
|
network_key: !secret ant_plus_network_key
|
||||||
connected:
|
connected:
|
||||||
@@ -104,6 +108,18 @@ ant_plus:
|
|||||||
battery_low:
|
battery_low:
|
||||||
id: varia_battery_low
|
id: varia_battery_low
|
||||||
name: Garmin Varia RTL515 Battery Low
|
name: Garmin Varia RTL515 Battery Low
|
||||||
|
targets:
|
||||||
|
id: varia_vehicles
|
||||||
|
name: Garmin Varia RTL515 Vehicles
|
||||||
|
distance:
|
||||||
|
id: varia_distance
|
||||||
|
name: Garmin Varia RTL515 Vehicle Distance
|
||||||
|
speed:
|
||||||
|
id: varia_speed
|
||||||
|
name: Garmin Varia RTL515 Closing Speed
|
||||||
|
fast_approach:
|
||||||
|
id: varia_fast
|
||||||
|
name: Garmin Varia RTL515 Fast Vehicle
|
||||||
- type: heart_rate # Garmin HRM-Dual
|
- type: heart_rate # Garmin HRM-Dual
|
||||||
device_number: 136052
|
device_number: 136052
|
||||||
heart_rate:
|
heart_rate:
|
||||||
@@ -189,6 +205,9 @@ packet_transport:
|
|||||||
- tempe_temperature_max
|
- tempe_temperature_max
|
||||||
- tempe_battery
|
- tempe_battery
|
||||||
- varia_battery
|
- varia_battery
|
||||||
|
- varia_vehicles
|
||||||
|
- varia_distance
|
||||||
|
- varia_speed
|
||||||
- hrm_dual_heart_rate
|
- hrm_dual_heart_rate
|
||||||
- hrm_dual_battery
|
- hrm_dual_battery
|
||||||
- hrm_tri_heart_rate
|
- hrm_tri_heart_rate
|
||||||
@@ -205,6 +224,7 @@ packet_transport:
|
|||||||
- pm5_in_use
|
- pm5_in_use
|
||||||
- tempe_battery_low
|
- tempe_battery_low
|
||||||
- varia_battery_low
|
- varia_battery_low
|
||||||
|
- varia_fast
|
||||||
- rally_battery_low
|
- rally_battery_low
|
||||||
- speed2_battery_low
|
- speed2_battery_low
|
||||||
- sram_battery_low
|
- sram_battery_low
|
||||||
|
|||||||
@@ -145,6 +145,29 @@ sensor:
|
|||||||
device_class: voltage
|
device_class: voltage
|
||||||
accuracy_decimals: 2
|
accuracy_decimals: 2
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
- platform: packet_transport
|
||||||
|
provider: mcu-nrf-ant
|
||||||
|
remote_id: varia_vehicles
|
||||||
|
name: Garmin Varia RTL515 Vehicles
|
||||||
|
internal: false
|
||||||
|
icon: mdi:car-multiple
|
||||||
|
accuracy_decimals: 0
|
||||||
|
- platform: packet_transport
|
||||||
|
provider: mcu-nrf-ant
|
||||||
|
remote_id: varia_distance
|
||||||
|
name: Garmin Varia RTL515 Vehicle Distance
|
||||||
|
internal: false
|
||||||
|
unit_of_measurement: m
|
||||||
|
device_class: distance
|
||||||
|
accuracy_decimals: 1
|
||||||
|
- platform: packet_transport
|
||||||
|
provider: mcu-nrf-ant
|
||||||
|
remote_id: varia_speed
|
||||||
|
name: Garmin Varia RTL515 Closing Speed
|
||||||
|
internal: false
|
||||||
|
unit_of_measurement: m/s
|
||||||
|
device_class: speed
|
||||||
|
accuracy_decimals: 2
|
||||||
- platform: packet_transport
|
- platform: packet_transport
|
||||||
provider: mcu-nrf-ant
|
provider: mcu-nrf-ant
|
||||||
remote_id: hrm_dual_heart_rate
|
remote_id: hrm_dual_heart_rate
|
||||||
@@ -289,6 +312,12 @@ binary_sensor:
|
|||||||
internal: false
|
internal: false
|
||||||
device_class: battery
|
device_class: battery
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
- platform: packet_transport
|
||||||
|
provider: mcu-nrf-ant
|
||||||
|
remote_id: varia_fast
|
||||||
|
name: Garmin Varia RTL515 Fast Vehicle
|
||||||
|
internal: false
|
||||||
|
icon: mdi:car-emergency
|
||||||
- platform: packet_transport
|
- platform: packet_transport
|
||||||
provider: mcu-nrf-ant
|
provider: mcu-nrf-ant
|
||||||
remote_id: rally_battery_low
|
remote_id: rally_battery_low
|
||||||
|
|||||||
+363
-115
@@ -35,8 +35,10 @@
|
|||||||
# 0x40 es7210_adc (audio_adc es7210)
|
# 0x40 es7210_adc (audio_adc es7210)
|
||||||
# 0x41 sensor ina226 (sensor ina226)
|
# 0x41 sensor ina226 (sensor ina226)
|
||||||
# 0x51 rtc_time (time bm8563)
|
# 0x51 rtc_time (time bm8563)
|
||||||
|
# 0x50 nfc_reader (st25r_i2c)
|
||||||
# 0x58 aw9523b_hub (aw9523b)
|
# 0x58 aw9523b_hub (aw9523b)
|
||||||
# 0x68 touch_hub (si12t)
|
# 0x68 touch_hub (si12t)
|
||||||
|
# 0x69 imu (motion bmi270)
|
||||||
# 0x6F m5ioe1_hub (m5ioe1)
|
# 0x6F m5ioe1_hub (m5ioe1)
|
||||||
substitutions:
|
substitutions:
|
||||||
device: stackchan
|
device: stackchan
|
||||||
@@ -50,6 +52,20 @@ esphome:
|
|||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
on_boot:
|
on_boot:
|
||||||
|
# the 5 V BUS after the expander parked its pins low (HARDWARE) and before si12t/st25r probe it (DATA)
|
||||||
|
- priority: 700
|
||||||
|
then:
|
||||||
|
- script.execute: bus_power_on
|
||||||
|
# pitch end stops into the servo's own angle limits (no EEPROM unlock: until the next power cycle)
|
||||||
|
- priority: -100
|
||||||
|
then:
|
||||||
|
- delay: 2s
|
||||||
|
- lambda: |-
|
||||||
|
auto *bus = id(y_servo).get_parent();
|
||||||
|
bus->write_word(2, SCSCL_MIN_ANGLE_LIMIT_L, 645);
|
||||||
|
bus->write_word(2, SCSCL_MAX_ANGLE_LIMIT_L, 912);
|
||||||
|
ESP_LOGI("pitch", "Angle limits %d..%d", bus->read_word(2, SCSCL_MIN_ANGLE_LIMIT_L),
|
||||||
|
bus->read_word(2, SCSCL_MAX_ANGLE_LIMIT_L));
|
||||||
- priority: -100
|
- priority: -100
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
@@ -69,6 +85,11 @@ esp32:
|
|||||||
advanced:
|
advanced:
|
||||||
flash_chip: generic
|
flash_chip: generic
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
sdkconfig_options:
|
||||||
|
# per-task CPU time for the task_stats interval
|
||||||
|
CONFIG_FREERTOS_USE_TRACE_FACILITY: y
|
||||||
|
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS: y
|
||||||
|
CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID: y
|
||||||
|
|
||||||
psram:
|
psram:
|
||||||
mode: quad
|
mode: quad
|
||||||
@@ -83,32 +104,23 @@ external_components:
|
|||||||
components: [axp2101, aw88298, aw9523b, si12t, ftservo, scs9009]
|
components: [axp2101, aw88298, aw9523b, si12t, ftservo, scs9009]
|
||||||
refresh: 0s
|
refresh: 0s
|
||||||
- source: github://randybb/esphome-components
|
- source: github://randybb/esphome-components
|
||||||
components: [audio_spectrum, m5ioe1]
|
components: [audio_spectrum, m5ioe1, robot_face]
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
# st25r upstream has SPI only, st25r_i2c is still on this branch
|
||||||
|
- source: github://m5stack/esphome@feat-st25r3916
|
||||||
|
components: [st25r, st25r_i2c]
|
||||||
|
refresh: 1d
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: in_love
|
|
||||||
type: bool
|
|
||||||
initial_value: 'false'
|
|
||||||
- id: show_status
|
- id: show_status
|
||||||
type: bool
|
type: bool
|
||||||
initial_value: 'true'
|
initial_value: 'true'
|
||||||
- id: mouth_open
|
|
||||||
type: float
|
|
||||||
initial_value: '0.0'
|
|
||||||
- id: eyes_open
|
|
||||||
type: bool
|
|
||||||
initial_value: 'true'
|
|
||||||
- id: speaking
|
|
||||||
type: bool
|
|
||||||
initial_value: 'false'
|
|
||||||
- id: listening
|
- id: listening
|
||||||
type: bool
|
type: bool
|
||||||
initial_value: 'false'
|
initial_value: 'false'
|
||||||
- id: gaze_x
|
- id: speech
|
||||||
type: int
|
type: std::string
|
||||||
initial_value: '0'
|
- id: spin_limits # yaw servo angle limits while spinning: max << 16 | min
|
||||||
- id: gaze_y
|
|
||||||
type: int
|
type: int
|
||||||
initial_value: '0'
|
initial_value: '0'
|
||||||
|
|
||||||
@@ -178,7 +190,7 @@ switch:
|
|||||||
pin:
|
pin:
|
||||||
aw9523b_id: aw9523b_hub
|
aw9523b_id: aw9523b_hub
|
||||||
number: 15
|
number: 15
|
||||||
restore_mode: RESTORE_DEFAULT_ON
|
restore_mode: ALWAYS_OFF # switched on by bus_power_on
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: usb_otg_en
|
id: usb_otg_en
|
||||||
name: USB OTG
|
name: USB OTG
|
||||||
@@ -194,7 +206,7 @@ switch:
|
|||||||
pin:
|
pin:
|
||||||
aw9523b_id: aw9523b_hub
|
aw9523b_id: aw9523b_hub
|
||||||
number: 1
|
number: 1
|
||||||
restore_mode: RESTORE_DEFAULT_ON
|
restore_mode: ALWAYS_OFF # switched on by bus_power_on
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: light_bar_en
|
id: light_bar_en
|
||||||
internal: true
|
internal: true
|
||||||
@@ -293,7 +305,6 @@ media_player:
|
|||||||
- platform: speaker
|
- platform: speaker
|
||||||
id: media_out
|
id: media_out
|
||||||
name: Player
|
name: Player
|
||||||
buffer_size: 14000
|
|
||||||
# AW88298 maps volume linearly to -96..0 dB, the lower half is inaudible
|
# AW88298 maps volume linearly to -96..0 dB, the lower half is inaudible
|
||||||
volume_min: 0.5
|
volume_min: 0.5
|
||||||
volume_max: 1.0
|
volume_max: 1.0
|
||||||
@@ -342,27 +353,33 @@ voice_assistant:
|
|||||||
- lambda: id(show_status) = true;
|
- lambda: id(show_status) = true;
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
on_listening:
|
on_listening:
|
||||||
|
# someone talks: a look with one eye, then with both
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(listening) = true;
|
id(listening) = true;
|
||||||
id(gaze_x) = 0;
|
id(face).peek(0);
|
||||||
id(gaze_y) = 0;
|
id(face).look(0, 0);
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
- light.turn_on: {id: light_bar, brightness: 60%, red: 0%, green: 60%, blue: 100%}
|
- light.turn_on: {id: light_bar, brightness: 60%, red: 0%, green: 60%, blue: 100%}
|
||||||
on_stt_end:
|
on_stt_end:
|
||||||
- lambda: id(listening) = false;
|
# thinking: looks up to the side
|
||||||
|
- lambda: |-
|
||||||
|
id(listening) = false;
|
||||||
|
id(face).look(0.6f, -0.8f);
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
- light.turn_on: {id: light_bar, brightness: 40%, red: 80%, green: 50%, blue: 0%}
|
- light.turn_on: {id: light_bar, brightness: 40%, red: 80%, green: 50%, blue: 0%}
|
||||||
on_tts_start:
|
on_tts_start:
|
||||||
- lambda: id(speaking) = true;
|
- lambda: |-
|
||||||
|
id(face).look(0, 0);
|
||||||
|
id(face).set_speaking(true);
|
||||||
- light.turn_on: {id: light_bar, brightness: 60%, red: 0%, green: 100%, blue: 20%}
|
- light.turn_on: {id: light_bar, brightness: 60%, red: 0%, green: 100%, blue: 20%}
|
||||||
on_end:
|
on_end:
|
||||||
- wait_until:
|
- wait_until:
|
||||||
not:
|
not:
|
||||||
media_player.is_announcing: media_out
|
media_player.is_announcing: media_out
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(speaking) = false;
|
|
||||||
id(listening) = false;
|
id(listening) = false;
|
||||||
id(mouth_open) = 0.0f;
|
id(face).set_speaking(false);
|
||||||
|
id(face).set_idle(true);
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
- light.turn_on: {id: light_bar, brightness: 20%, red: 0%, green: 0%, blue: 100%}
|
- light.turn_on: {id: light_bar, brightness: 20%, red: 0%, green: 0%, blue: 100%}
|
||||||
- wait_until:
|
- wait_until:
|
||||||
@@ -370,25 +387,93 @@ voice_assistant:
|
|||||||
- micro_wake_word.start:
|
- micro_wake_word.start:
|
||||||
on_error:
|
on_error:
|
||||||
- light.turn_on: {id: light_bar, brightness: 60%, red: 100%, green: 0%, blue: 0%}
|
- light.turn_on: {id: light_bar, brightness: 60%, red: 100%, green: 0%, blue: 0%}
|
||||||
|
- script.execute:
|
||||||
|
id: show_mood
|
||||||
|
mood: sad
|
||||||
|
seconds: 3
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# short tap on the head starts the assistant
|
# Powers the 5 V BUS from the battery (as in m5stack/esphome-yaml stackchan base).
|
||||||
- id: head_tap
|
# The BUS is a capacitive load: switched on at once it pulls a converter under its
|
||||||
|
# UVP threshold and the AXP2101 powers itself off (red LED, off on battery only).
|
||||||
|
- id: bus_power_on
|
||||||
then:
|
then:
|
||||||
- if:
|
- lambda: |-
|
||||||
condition:
|
// REG 23H bits 4:0: DCDC1-5 under-voltage power-off, POR value all set
|
||||||
not: voice_assistant.is_running
|
uint8_t reg;
|
||||||
then:
|
if (id(axp2101_pmu)->read_byte(0x23, ®))
|
||||||
- voice_assistant.start:
|
id(axp2101_pmu)->write_byte(0x23, reg & ~0x1F);
|
||||||
# stroking the head shows the in-love face for a while
|
id(boost_en).turn_on();
|
||||||
- id: head_stroke
|
delay(50);
|
||||||
|
// eight pulses of growing on-time bring the cold BUS up to a few volts
|
||||||
|
for (int pulse = 0; pulse < 8; ++pulse) {
|
||||||
|
id(bus_out_en).turn_on();
|
||||||
|
delayMicroseconds(pulse * 16);
|
||||||
|
id(bus_out_en).turn_off();
|
||||||
|
delayMicroseconds(1000);
|
||||||
|
}
|
||||||
|
id(bus_out_en).turn_on();
|
||||||
|
delay(100);
|
||||||
|
# a mood for a while, then back to neutral (stroke: love, shake: dizzy, card: surprised)
|
||||||
|
- id: show_mood
|
||||||
mode: restart
|
mode: restart
|
||||||
|
parameters:
|
||||||
|
mood: string
|
||||||
|
seconds: int
|
||||||
then:
|
then:
|
||||||
- lambda: id(in_love) = true;
|
- lambda: |-
|
||||||
- component.update: display_tft
|
if (id(face).is_sleeping())
|
||||||
- delay: 5s
|
id(face).peek(0);
|
||||||
- lambda: id(in_love) = false;
|
id(face).set_mood(mood);
|
||||||
- component.update: display_tft
|
- delay: !lambda return seconds * 1000;
|
||||||
|
- lambda: id(face).set_mood(robot_face::MOOD_NEUTRAL);
|
||||||
|
# spins the head around (yaw servo, address 1) in wheel mode: angle limits 0/0 turn the SCS9009
|
||||||
|
# into a motor driven by PWM. The limits are written without unlocking the EEPROM, so they are
|
||||||
|
# only changed until the next power cycle, and they are put back once the spin is over.
|
||||||
|
- id: spin
|
||||||
|
mode: single
|
||||||
|
parameters:
|
||||||
|
seconds: float
|
||||||
|
power: int # -1000..1000, the sign is the direction
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
auto *bus = id(x_servo).get_parent();
|
||||||
|
const int min = bus->read_word(1, SCSCL_MIN_ANGLE_LIMIT_L);
|
||||||
|
const int max = bus->read_word(1, SCSCL_MAX_ANGLE_LIMIT_L);
|
||||||
|
if (min < 0 || max <= 0) {
|
||||||
|
ESP_LOGW("spin", "Angle limits not readable (%d/%d), not spinning", min, max);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
id(spin_limits) = (max << 16) | min;
|
||||||
|
ESP_LOGI("spin", "Spinning %.1f s at %d, limits %d..%d", seconds, power, min, max);
|
||||||
|
bus->enable_torque(1, 1);
|
||||||
|
bus->pwm_mode(1);
|
||||||
|
bus->write_pwm(1, clamp(power, -1000, 1000));
|
||||||
|
id(face).set_mood(robot_face::MOOD_DIZZY);
|
||||||
|
- delay: !lambda return (uint32_t) (seconds * 1000);
|
||||||
|
- lambda: |-
|
||||||
|
auto *bus = id(x_servo).get_parent();
|
||||||
|
bus->write_pwm(1, 0);
|
||||||
|
bus->enable_torque(1, 0);
|
||||||
|
// position mode again; torque is off, so the old goal position does not pull the head back
|
||||||
|
bus->write_word(1, SCSCL_MIN_ANGLE_LIMIT_L, id(spin_limits) & 0xFFFF);
|
||||||
|
bus->write_word(1, SCSCL_MAX_ANGLE_LIMIT_L, id(spin_limits) >> 16);
|
||||||
|
ESP_LOGI("spin", "Stopped, limits back to %d..%d", id(spin_limits) & 0xFFFF, id(spin_limits) >> 16);
|
||||||
|
- delay: 2s
|
||||||
|
- lambda: id(face).set_mood(robot_face::MOOD_NEUTRAL);
|
||||||
|
# text under the face with the mouth moving
|
||||||
|
- id: say
|
||||||
|
mode: restart
|
||||||
|
parameters:
|
||||||
|
message: string
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(speech) = message;
|
||||||
|
id(face).set_speaking(true);
|
||||||
|
- delay: 8s
|
||||||
|
- lambda: |-
|
||||||
|
id(speech).clear();
|
||||||
|
id(face).set_speaking(false);
|
||||||
# mic and speaker share one I2S bus - the mic must be released before playback
|
# mic and speaker share one I2S bus - the mic must be released before playback
|
||||||
- id: release_i2s_bus
|
- id: release_i2s_bus
|
||||||
mode: single
|
mode: single
|
||||||
@@ -411,6 +496,41 @@ script:
|
|||||||
timeout: 2s
|
timeout: 2s
|
||||||
|
|
||||||
interval:
|
interval:
|
||||||
|
# CPU time of every task over the last 10 s (100 % = one core), busiest first
|
||||||
|
- interval: 10s
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
struct Prev { std::string name; uint64_t run; };
|
||||||
|
static std::vector<Prev> prev;
|
||||||
|
static uint64_t prev_total = 0;
|
||||||
|
std::vector<TaskStatus_t> tasks(uxTaskGetNumberOfTasks() + 4);
|
||||||
|
configRUN_TIME_COUNTER_TYPE total;
|
||||||
|
tasks.resize(uxTaskGetSystemState(tasks.data(), tasks.size(), &total));
|
||||||
|
const uint64_t span = total - prev_total;
|
||||||
|
struct Row { const TaskStatus_t *t; uint64_t delta; };
|
||||||
|
std::vector<Row> rows;
|
||||||
|
std::vector<Prev> now;
|
||||||
|
for (auto &t : tasks) {
|
||||||
|
uint64_t before = 0;
|
||||||
|
for (auto &p : prev)
|
||||||
|
if (p.name == t.pcTaskName)
|
||||||
|
before = p.run;
|
||||||
|
rows.push_back({&t, t.ulRunTimeCounter - before});
|
||||||
|
now.push_back({t.pcTaskName, t.ulRunTimeCounter});
|
||||||
|
}
|
||||||
|
const bool first = prev_total == 0;
|
||||||
|
prev = std::move(now);
|
||||||
|
prev_total = total;
|
||||||
|
if (first || span == 0)
|
||||||
|
return;
|
||||||
|
std::sort(rows.begin(), rows.end(), [](const Row &a, const Row &b) { return a.delta > b.delta; });
|
||||||
|
for (auto &r : rows) {
|
||||||
|
const float pct = 100.0f * r.delta / span;
|
||||||
|
if (pct < 0.5f)
|
||||||
|
break;
|
||||||
|
ESP_LOGI("task_stats", "%-16s core %2d prio %2u %5.1f %%", r.t->pcTaskName,
|
||||||
|
r.t->xCoreID == tskNO_AFFINITY ? -1 : (int) r.t->xCoreID, (unsigned) r.t->uxCurrentPriority, pct);
|
||||||
|
}
|
||||||
- interval: 80ms # spectrum analyzer frame rate while music plays
|
- interval: 80ms # spectrum analyzer frame rate while music plays
|
||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
@@ -421,21 +541,37 @@ interval:
|
|||||||
then:
|
then:
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
# head touch gestures: a touch episode ends after 250 ms without contact;
|
# head touch gestures: a touch episode ends after 250 ms without contact;
|
||||||
# tap = short episode, stroke = longer episode that reaches the pads one after another
|
# stroke = longer episode that reaches the pads one after another (taps do nothing).
|
||||||
|
# Each ST25R scan switches its RF field on and the pads report a 50-350 ms phantom touch, at any
|
||||||
|
# si12t sensitivity, so the NFC reader is scanned from here: every 2 s between episodes, with the
|
||||||
|
# pads ignored for 400 ms afterwards, and at once when an episode starts (a card being laid on).
|
||||||
- interval: 50ms
|
- interval: 50ms
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
static bool active = false;
|
static bool active = false;
|
||||||
static uint32_t start = 0, last_on = 0;
|
static uint32_t start = 0, last_on = 0, last_scan = 0;
|
||||||
static uint32_t first_on[3];
|
static uint32_t first_on[3];
|
||||||
|
const uint32_t now = millis();
|
||||||
|
if (!active) {
|
||||||
|
if (now - last_scan >= 2000 && id(nfc_reader).is_ready()) {
|
||||||
|
last_scan = now;
|
||||||
|
id(nfc_reader).update();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (now - last_scan < 400)
|
||||||
|
return;
|
||||||
|
}
|
||||||
const bool on[3] = {id(head_touch_1).state != "No touch", id(head_touch_2).state != "No touch",
|
const bool on[3] = {id(head_touch_1).state != "No touch", id(head_touch_2).state != "No touch",
|
||||||
id(head_touch_3).state != "No touch"};
|
id(head_touch_3).state != "No touch"};
|
||||||
const uint32_t now = millis();
|
|
||||||
|
|
||||||
if (on[0] || on[1] || on[2]) {
|
if (on[0] || on[1] || on[2]) {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
active = true;
|
active = true;
|
||||||
start = now;
|
start = now;
|
||||||
|
if (id(nfc_reader).is_ready()) {
|
||||||
|
last_scan = now;
|
||||||
|
id(nfc_reader).update();
|
||||||
|
}
|
||||||
first_on[0] = first_on[1] = first_on[2] = 0;
|
first_on[0] = first_on[1] = first_on[2] = 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@@ -464,9 +600,7 @@ interval:
|
|||||||
first_on[1] ? (int) (first_on[1] - earliest) : -1, first_on[2] ? (int) (first_on[2] - earliest) : -1);
|
first_on[1] ? (int) (first_on[1] - earliest) : -1, first_on[2] ? (int) (first_on[2] - earliest) : -1);
|
||||||
|
|
||||||
if (pads >= 2 && spread >= 150 && duration >= 400) {
|
if (pads >= 2 && spread >= 150 && duration >= 400) {
|
||||||
id(head_stroke).execute();
|
id(show_mood).execute(std::string("love"), 5);
|
||||||
} else if (duration <= 600) {
|
|
||||||
id(head_tap).execute();
|
|
||||||
}
|
}
|
||||||
- interval: 1s # status screen refresh until Home Assistant connects
|
- interval: 1s # status screen refresh until Home Assistant connects
|
||||||
then:
|
then:
|
||||||
@@ -475,32 +609,6 @@ interval:
|
|||||||
lambda: return id(show_status);
|
lambda: return id(show_status);
|
||||||
then:
|
then:
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
- interval: 90ms
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
if (id(speaking)) {
|
|
||||||
id(mouth_open) = 0.15f + (esp_random() % 85) / 100.0f;
|
|
||||||
id(display_tft).update();
|
|
||||||
} else if (id(mouth_open) > 0) {
|
|
||||||
id(mouth_open) = 0;
|
|
||||||
id(display_tft).update();
|
|
||||||
}
|
|
||||||
- interval: 3s # blinking
|
|
||||||
then:
|
|
||||||
- delay: !lambda return esp_random() % 3000;
|
|
||||||
- lambda: id(eyes_open) = false;
|
|
||||||
- component.update: display_tft
|
|
||||||
- delay: 150ms
|
|
||||||
- lambda: id(eyes_open) = true;
|
|
||||||
- component.update: display_tft
|
|
||||||
- interval: 7s # looking around while idle
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
if (!id(speaking) && !id(listening)) {
|
|
||||||
id(gaze_x) = (int) (esp_random() % 21) - 10;
|
|
||||||
id(gaze_y) = (int) (esp_random() % 11) - 5;
|
|
||||||
id(display_tft).update();
|
|
||||||
}
|
|
||||||
|
|
||||||
spi:
|
spi:
|
||||||
- id: spi_bus
|
- id: spi_bus
|
||||||
@@ -628,29 +736,26 @@ display:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stack-chan face: 2 eyes + mouth, 320x240
|
// stack-chan face (robot_face), 320x240
|
||||||
// the whole screen is cleared only once, then just the face areas, so that only the
|
// the whole screen is cleared only once, then just the face areas, so that only the
|
||||||
// changed region is sent over SPI instead of the whole 150 kB buffer
|
// changed region is sent over SPI instead of the whole 150 kB buffer
|
||||||
const bool love = id(in_love);
|
|
||||||
const bool music = id(media_out).state == media_player::MEDIA_PLAYER_STATE_PLAYING && !id(va).is_running();
|
const bool music = id(media_out).state == media_player::MEDIA_PLAYER_STATE_PLAYING && !id(va).is_running();
|
||||||
// switching between face, in-love face and spectrum repaints everything
|
// switching between face and spectrum repaints everything
|
||||||
static int last_mode = -1;
|
static bool last_music = false;
|
||||||
const int mode = music ? 2 : love ? 1 : 0;
|
if (music != last_music) {
|
||||||
if (mode != last_mode) {
|
last_music = music;
|
||||||
last_mode = mode;
|
|
||||||
first_draw = true;
|
first_draw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the in-love face is drawn outside the partially cleared areas, so it always repaints everything
|
|
||||||
static bool spectrum_reset = true;
|
static bool spectrum_reset = true;
|
||||||
if (first_draw || love) {
|
if (first_draw) {
|
||||||
it.fill(id(face_bg));
|
it.fill(id(face_bg));
|
||||||
|
id(face).invalidate();
|
||||||
first_draw = false;
|
first_draw = false;
|
||||||
bar_drawn = false;
|
bar_drawn = false;
|
||||||
spectrum_reset = true;
|
spectrum_reset = true;
|
||||||
} else if (!music) {
|
} else if (!music) {
|
||||||
it.filled_rectangle(70, 78, 181, 31, id(face_bg)); // eyes including gaze range
|
it.filled_rectangle(0, 216, 320, 22, id(face_bg)); // speech text
|
||||||
it.filled_rectangle(105, 130, 111, 38, id(face_bg)); // mouth
|
|
||||||
if (dot_shown && !id(listening)) {
|
if (dot_shown && !id(listening)) {
|
||||||
it.filled_rectangle(254, 2, 28, 28, id(face_bg));
|
it.filled_rectangle(254, 2, 28, 28, id(face_bg));
|
||||||
}
|
}
|
||||||
@@ -743,42 +848,140 @@ display:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int ex = id(gaze_x), ey = id(gaze_y);
|
id(face).draw(it);
|
||||||
const int eye_y = 93 + ey, eye_r = 8;
|
|
||||||
const int lx = 90 + ex, rx = 230 + ex;
|
|
||||||
|
|
||||||
if (love) {
|
if (!id(speech).empty()) {
|
||||||
// heart eyes, blush and a wide smile
|
it.print(160, 218, id(font_status), id(face_fg), TextAlign::TOP_CENTER, id(speech).c_str());
|
||||||
for (int cx : {lx, rx}) {
|
|
||||||
it.filled_circle(cx - 6, eye_y - 3, 7, id(love_red));
|
|
||||||
it.filled_circle(cx + 6, eye_y - 3, 7, id(love_red));
|
|
||||||
it.filled_triangle(cx - 13, eye_y - 1, cx + 13, eye_y - 1, cx, eye_y + 14, id(love_red));
|
|
||||||
}
|
|
||||||
it.filled_circle(60 + ex, 130 + ey, 12, Color(90, 20, 40));
|
|
||||||
it.filled_circle(260 + ex, 130 + ey, 12, Color(90, 20, 40));
|
|
||||||
if (!id(speaking)) {
|
|
||||||
it.filled_circle(160 + ex / 2, 132 + ey / 2, 30, id(face_fg));
|
|
||||||
it.filled_circle(160 + ex / 2, 122 + ey / 2, 30, id(face_bg));
|
|
||||||
}
|
|
||||||
} else if (id(eyes_open)) {
|
|
||||||
it.filled_circle(lx, eye_y, eye_r, id(face_fg));
|
|
||||||
it.filled_circle(rx, eye_y, eye_r, id(face_fg));
|
|
||||||
} else {
|
|
||||||
it.filled_rectangle(lx - eye_r, eye_y - 2, eye_r * 2, 4, id(face_fg));
|
|
||||||
it.filled_rectangle(rx - eye_r, eye_y - 2, eye_r * 2, 4, id(face_fg));
|
|
||||||
}
|
|
||||||
|
|
||||||
const float m = id(mouth_open);
|
|
||||||
if (!love || id(speaking)) {
|
|
||||||
const int mw = 90 - (int) (40 * m);
|
|
||||||
const int mh = 4 + (int) (26 * m);
|
|
||||||
it.filled_rectangle(160 - mw / 2 + ex / 2, 148 - mh / 2 + ey / 2, mw, mh, id(face_fg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id(listening)) {
|
if (id(listening)) {
|
||||||
it.image(254, 2, id(icon_listening), id(face_fg), id(face_bg)); // left of the wifi bars
|
it.image(254, 2, id(icon_listening), id(face_fg), id(face_bg)); // left of the wifi bars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
robot_face:
|
||||||
|
id: face
|
||||||
|
display_id: display_tft
|
||||||
|
foreground: face_fg
|
||||||
|
background: face_bg
|
||||||
|
love_color: love_red
|
||||||
|
devil_color: status_low
|
||||||
|
# eyes only, centered between the status bar and the speech line
|
||||||
|
eyes_y: 120
|
||||||
|
eye_width: 72
|
||||||
|
eye_height: 84
|
||||||
|
eye_radius: 20
|
||||||
|
eye_spacing: 50
|
||||||
|
gaze_x: 34
|
||||||
|
gaze_y: 22
|
||||||
|
sleep_after: 5min
|
||||||
|
|
||||||
|
motion:
|
||||||
|
- platform: bmi270
|
||||||
|
id: imu
|
||||||
|
i2c_id: i2c_bsp
|
||||||
|
address: 0x69
|
||||||
|
update_interval: 50ms
|
||||||
|
accelerometer_range: 4G
|
||||||
|
accelerometer_odr: 100HZ
|
||||||
|
|
||||||
|
event:
|
||||||
|
- platform: motion
|
||||||
|
id: imu_shake
|
||||||
|
name: Shake
|
||||||
|
threshold: 1.5
|
||||||
|
cooldown: 500ms
|
||||||
|
on_event:
|
||||||
|
- script.execute:
|
||||||
|
id: show_mood
|
||||||
|
mood: dizzy
|
||||||
|
seconds: 3
|
||||||
|
|
||||||
|
st25r_i2c:
|
||||||
|
id: nfc_reader
|
||||||
|
i2c_id: i2c_bsp
|
||||||
|
update_interval: never # polled from the head touch interval, see there
|
||||||
|
on_tag:
|
||||||
|
- lambda: id(speech) = x; // UID under the face while the card lies there
|
||||||
|
- script.execute:
|
||||||
|
id: show_mood
|
||||||
|
mood: surprised
|
||||||
|
seconds: 3
|
||||||
|
- text_sensor.template.publish:
|
||||||
|
id: nfc_tag
|
||||||
|
state: !lambda return x;
|
||||||
|
on_tag_removed:
|
||||||
|
- lambda: id(speech).clear();
|
||||||
|
- component.update: display_tft
|
||||||
|
- text_sensor.template.publish:
|
||||||
|
id: nfc_tag
|
||||||
|
state: ""
|
||||||
|
|
||||||
|
# an update needs the network to itself: playback, wake word and the assistant stop first
|
||||||
|
ota:
|
||||||
|
- id: !extend ota_esphome
|
||||||
|
on_begin:
|
||||||
|
- media_player.stop: media_out
|
||||||
|
- voice_assistant.stop:
|
||||||
|
- micro_wake_word.stop:
|
||||||
|
|
||||||
|
# the StackChan base right under the Core spoils the WiFi link (ping 160-250 ms, stuttering audio,
|
||||||
|
# m5stack/StackChan#119); 11 dB brings it to ~20 ms. A ~1 cm gap from the base fixes it fully.
|
||||||
|
wifi:
|
||||||
|
output_power: 11dB
|
||||||
|
|
||||||
|
api:
|
||||||
|
actions:
|
||||||
|
- action: stackchan_say
|
||||||
|
variables:
|
||||||
|
message: string
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: say
|
||||||
|
message: !lambda return message;
|
||||||
|
- action: stackchan_pet
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: show_mood
|
||||||
|
mood: love
|
||||||
|
seconds: 5
|
||||||
|
# spins the head around: seconds, power -1000..1000 (sign = direction)
|
||||||
|
- action: stackchan_spin
|
||||||
|
variables:
|
||||||
|
seconds: float
|
||||||
|
power: int
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: spin
|
||||||
|
seconds: !lambda return seconds;
|
||||||
|
power: !lambda return power;
|
||||||
|
- action: stackchan_shake
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: show_mood
|
||||||
|
mood: dizzy
|
||||||
|
seconds: 3
|
||||||
|
# neutral, happy, sad, angry, tired, surprised, love, dizzy, puppy, devil, curious, suspicious;
|
||||||
|
# laugh and confused are short animations, sleep/wake close and open the eyes, wink winks
|
||||||
|
- action: stackchan_set_emotion
|
||||||
|
variables:
|
||||||
|
emotion: string
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
if (emotion == "laugh")
|
||||||
|
id(face).laugh();
|
||||||
|
else if (emotion == "confused")
|
||||||
|
id(face).confused();
|
||||||
|
else if (emotion == "sleep")
|
||||||
|
id(face).set_eyes_open(false);
|
||||||
|
else if (emotion == "wake")
|
||||||
|
id(face).peek(0);
|
||||||
|
else if (emotion == "wink")
|
||||||
|
id(face).wink(1);
|
||||||
|
else {
|
||||||
|
id(show_mood).stop();
|
||||||
|
id(face).set_mood(emotion);
|
||||||
|
}
|
||||||
|
|
||||||
touchscreen:
|
touchscreen:
|
||||||
- platform: ft63x6
|
- platform: ft63x6
|
||||||
id: touch_lcd
|
id: touch_lcd
|
||||||
@@ -815,6 +1018,25 @@ esp32_camera:
|
|||||||
frame_buffer_location: PSRAM
|
frame_buffer_location: PSRAM
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
|
# raw servo positions, 1024 steps = 360 degrees (2.844 steps per degree, as in ftservo)
|
||||||
|
- platform: ftservo
|
||||||
|
id: servo_x_feedback
|
||||||
|
ftservo_id: x_servo
|
||||||
|
update_interval: 500ms
|
||||||
|
position:
|
||||||
|
name: Servo X Position
|
||||||
|
entity_category: diagnostic
|
||||||
|
filters:
|
||||||
|
- delta: 2
|
||||||
|
- platform: ftservo
|
||||||
|
id: servo_y_feedback
|
||||||
|
ftservo_id: y_servo
|
||||||
|
update_interval: 500ms
|
||||||
|
position:
|
||||||
|
name: Servo Y Position
|
||||||
|
entity_category: diagnostic
|
||||||
|
filters:
|
||||||
|
- delta: 2
|
||||||
- platform: axp2101
|
- platform: axp2101
|
||||||
id: axp2101_sensor
|
id: axp2101_sensor
|
||||||
battery_level:
|
battery_level:
|
||||||
@@ -861,6 +1083,10 @@ si12t:
|
|||||||
intr_level: OUTPUT_ALL
|
intr_level: OUTPUT_ALL
|
||||||
|
|
||||||
text_sensor:
|
text_sensor:
|
||||||
|
- platform: template
|
||||||
|
id: nfc_tag
|
||||||
|
name: NFC Tag
|
||||||
|
icon: mdi:nfc
|
||||||
- platform: si12t
|
- platform: si12t
|
||||||
id: head_touch_1
|
id: head_touch_1
|
||||||
name: Head Touch 1
|
name: Head Touch 1
|
||||||
@@ -904,16 +1130,38 @@ ftservo:
|
|||||||
id: y_servo
|
id: y_servo
|
||||||
address: 2
|
address: 2
|
||||||
|
|
||||||
|
button:
|
||||||
|
- platform: template
|
||||||
|
name: Spin
|
||||||
|
icon: mdi:rotate-360
|
||||||
|
on_press:
|
||||||
|
- script.execute:
|
||||||
|
id: spin
|
||||||
|
seconds: 3
|
||||||
|
power: 600
|
||||||
|
|
||||||
number:
|
number:
|
||||||
- platform: ftservo
|
- platform: ftservo
|
||||||
ftservo_id: x_servo
|
ftservo_id: x_servo
|
||||||
|
# yaw: 0 = straight ahead = raw 461 (measured), 2.844 steps per degree
|
||||||
angle:
|
angle:
|
||||||
id: servo_x_angle
|
id: servo_x_angle
|
||||||
name: Servo X Angle
|
name: Servo X Angle
|
||||||
min_value: -164
|
min_value: -160
|
||||||
max_value: 164
|
max_value: 160
|
||||||
use_raw_angle: false
|
use_raw_angle: false
|
||||||
angle_offset: 164
|
angle_offset: 162.1
|
||||||
|
step: 5
|
||||||
|
# pitch: 0 = all the way down = raw 642, the top stop is raw 928 (~100 degrees, measured)
|
||||||
|
- platform: ftservo
|
||||||
|
ftservo_id: y_servo
|
||||||
|
angle:
|
||||||
|
id: servo_y_angle
|
||||||
|
name: Servo Y Angle
|
||||||
|
min_value: 0
|
||||||
|
max_value: 95
|
||||||
|
use_raw_angle: false
|
||||||
|
angle_offset: 225.7
|
||||||
step: 5
|
step: 5
|
||||||
|
|
||||||
light:
|
light:
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
# One-shot for a Seeed XIAO STM32C5 still on TinyUF2: erases TinyUF2 5 s after boot (mrk's tinyuf2_eraser, LED on when
|
||||||
|
# done), then hold BOOT + press RESET (ROM DFU, 0483:df11) and flash the MCUboot build of the node:
|
||||||
|
# dfu-util -a 0 -s 0x08000000 -D .esphome/build/<node>/.west_build/mcuboot/zephyr/zephyr.bin
|
||||||
|
# dfu-util -a 0 -s 0x08008000:leave -D .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin
|
||||||
|
esphome:
|
||||||
|
name: mcu-stm32-xiao-c5-eraser
|
||||||
|
on_boot:
|
||||||
|
priority: -100
|
||||||
|
then:
|
||||||
|
- delay: 5s
|
||||||
|
- tinyuf2_eraser.erase: eraser
|
||||||
|
# LED on: erased, go to DFU (BOOT + RESET)
|
||||||
|
- output.turn_on: led_out
|
||||||
|
|
||||||
|
external_components:
|
||||||
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
|
components: [tinyuf2_eraser]
|
||||||
|
|
||||||
|
stm32:
|
||||||
|
variant: STM32C5
|
||||||
|
board: xiao_stm32c5
|
||||||
|
|
||||||
|
logger:
|
||||||
|
|
||||||
|
tinyuf2_eraser:
|
||||||
|
id: eraser
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: gpio
|
||||||
|
id: led_out
|
||||||
|
pin:
|
||||||
|
number: PB12
|
||||||
|
inverted: true
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
---
|
||||||
|
# Hardware: Seeed XIAO STM32C5 #1, CANopen node 0x20 (see common/xiao_stm32c5_canopen.yaml); its LED is light
|
||||||
|
# entity 1 (0x2011:1 / 0x2012:1), the server for mcu-stm32-xiao-c5-sdo-client.yaml (esphome#22410 test)
|
||||||
|
# USB serial: 3838333031365105001F005D (TinyUF2: 5D001F000551363130333838)
|
||||||
|
# Keypad prototype (Blink Marine PKP compatible) until the MCP23017 board exists, M5 units on Grove:
|
||||||
|
# D4/D5 (i2c1, PB7 SDA, PB6 SCL) -> i2c_grove; two i2c buses: esphomeplatformzephyr/esphome#247, merged in framework-zephyr
|
||||||
|
# I2C:
|
||||||
|
# 0x41 enc (m5stack_8encoder), Unit 8Encoder
|
||||||
|
# 0x47 byte_button (m5stack_byte), Unit ByteButton -> PKP 2400SI (2x4) emulation, node 0x14
|
||||||
|
substitutions:
|
||||||
|
node_id: "0x20"
|
||||||
|
|
||||||
|
esphome:
|
||||||
|
name: mcu-stm32-xiao-c5
|
||||||
|
friendly_name: XIAO STM32C5
|
||||||
|
on_boot:
|
||||||
|
- lambda: |-
|
||||||
|
// PKP RPDOs: 0x200 LED on, 0x300 LED blink (bytes 0-2: R, G, B masks of keys 1-8), 0x400 brightness 0-3F
|
||||||
|
static canopen::FrameListener pkp_rx{0x014, 0x0FF, [](void *, uint32_t can_id, const uint8_t *d, uint8_t len) {
|
||||||
|
if (id(pkp).get_nmt_state() != canopen::NMTState::NMT_STATE_OPERATIONAL || len == 0)
|
||||||
|
return;
|
||||||
|
uint32_t bits = d[0] | (len > 1 ? d[1] << 8 : 0) | (len > 2 ? d[2] << 16 : 0);
|
||||||
|
if (can_id == 0x214)
|
||||||
|
id(pkp_led_on) = bits;
|
||||||
|
else if (can_id == 0x314)
|
||||||
|
id(pkp_led_blink) = bits;
|
||||||
|
else if (can_id == 0x414)
|
||||||
|
id(pkp_brightness) = d[0] > 0x3F ? 0x3F : d[0];
|
||||||
|
}, nullptr};
|
||||||
|
id(pkp).add_frame_listener(pkp_rx);
|
||||||
|
|
||||||
|
packages:
|
||||||
|
node: !include common/xiao_stm32c5_canopen.yaml
|
||||||
|
|
||||||
|
external_components:
|
||||||
|
- source: github://randybb/esphome-components
|
||||||
|
components: [m5stack_byte, m5stack_8encoder]
|
||||||
|
refresh: 1h
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
- id: i2c_grove
|
||||||
|
dts_node_override: i2c1
|
||||||
|
|
||||||
|
# Blink Marine PKP 2400SI emulation (docs: home-gitops canopen-nodes.adoc): like the real one, not active until
|
||||||
|
# NMT Start (000#0114); 0x14, because the AtomS3 emulates a PKP 2600SI at 0x15
|
||||||
|
canopen:
|
||||||
|
- id: pkp
|
||||||
|
canbus_id: can_bus
|
||||||
|
node_id: 0x14
|
||||||
|
nmt_startup: pre_operational
|
||||||
|
device_name: PKP2400SI
|
||||||
|
|
||||||
|
m5stack_byte:
|
||||||
|
- id: byte_button
|
||||||
|
i2c_id: i2c_grove
|
||||||
|
address: 0x47
|
||||||
|
|
||||||
|
# encoders: position 0..8 (min/max here) or free turning (bit set in Encoder Relative Modes, for the map and menus);
|
||||||
|
# both go to CAN as one byte: the position, or the counter mod 256 (the consumer takes the difference)
|
||||||
|
m5stack_8encoder:
|
||||||
|
- id: enc
|
||||||
|
i2c_id: i2c_grove
|
||||||
|
encoders:
|
||||||
|
- id: encoder_1
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: &enc_filters
|
||||||
|
- lambda: return (int32_t) x & 0xFF;
|
||||||
|
- id: encoder_2
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
- id: encoder_3
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
- id: encoder_4
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
- id: encoder_5
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
- id: encoder_6
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
- id: encoder_7
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
- id: encoder_8
|
||||||
|
min_value: 0
|
||||||
|
max_value: 8
|
||||||
|
filters: *enc_filters
|
||||||
|
buttons:
|
||||||
|
- id: encoder_button_1
|
||||||
|
- id: encoder_button_2
|
||||||
|
- id: encoder_button_3
|
||||||
|
- id: encoder_button_4
|
||||||
|
- id: encoder_button_5
|
||||||
|
- id: encoder_button_6
|
||||||
|
- id: encoder_button_7
|
||||||
|
- id: encoder_button_8
|
||||||
|
switch:
|
||||||
|
id: encoder_switch
|
||||||
|
|
||||||
|
number:
|
||||||
|
# 8Encoder LED colours 0xRRGGBB (1-8 at the encoders, 9 at the switch), set over CAN (SDO), kept over reboots
|
||||||
|
- &led_color
|
||||||
|
platform: template
|
||||||
|
id: led_color_1
|
||||||
|
name: LED 1 Color
|
||||||
|
entity_category: config
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true
|
||||||
|
initial_value: 0
|
||||||
|
min_value: 0
|
||||||
|
max_value: 0xFFFFFF
|
||||||
|
step: 1
|
||||||
|
- {<<: *led_color, id: led_color_2, name: LED 2 Color}
|
||||||
|
- {<<: *led_color, id: led_color_3, name: LED 3 Color}
|
||||||
|
- {<<: *led_color, id: led_color_4, name: LED 4 Color}
|
||||||
|
- {<<: *led_color, id: led_color_5, name: LED 5 Color}
|
||||||
|
- {<<: *led_color, id: led_color_6, name: LED 6 Color}
|
||||||
|
- {<<: *led_color, id: led_color_7, name: LED 7 Color}
|
||||||
|
- {<<: *led_color, id: led_color_8, name: LED 8 Color}
|
||||||
|
- {<<: *led_color, id: led_color_9, name: LED 9 Color}
|
||||||
|
# bit i = encoder i turns freely (navigation), else a position 0..8; set over CAN by the consumer (SDO)
|
||||||
|
- platform: template
|
||||||
|
id: encoder_relative_modes
|
||||||
|
name: Encoder Relative Modes
|
||||||
|
entity_category: config
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true
|
||||||
|
initial_value: 0
|
||||||
|
min_value: 0
|
||||||
|
max_value: 255
|
||||||
|
step: 1
|
||||||
|
on_value:
|
||||||
|
- lambda: |-
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
if ((int) x >> i & 1)
|
||||||
|
id(enc).set_range(i, INT32_MIN, INT32_MAX);
|
||||||
|
else
|
||||||
|
id(enc).set_range(i, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: pkp_keys_sent
|
||||||
|
type: uint8_t
|
||||||
|
initial_value: '0'
|
||||||
|
- id: pkp_led_on
|
||||||
|
type: uint32_t
|
||||||
|
initial_value: '0'
|
||||||
|
- id: pkp_led_blink
|
||||||
|
type: uint32_t
|
||||||
|
initial_value: '0'
|
||||||
|
- id: pkp_brightness
|
||||||
|
type: uint8_t
|
||||||
|
initial_value: '0x3F'
|
||||||
|
|
||||||
|
interval:
|
||||||
|
# keys TPDO 0x194 (byte 0: keys 1-8) on every change, as the real one (event-driven)
|
||||||
|
# TODO on arrival: ByteButton bit polarity is not documented; here a pressed key reads 0 (drop the ~ if not)
|
||||||
|
- interval: 20ms
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
uint8_t keys = ~id(byte_button).get_state();
|
||||||
|
if (keys == id(pkp_keys_sent) || id(pkp).get_nmt_state() != canopen::NMTState::NMT_STATE_OPERATIONAL)
|
||||||
|
return;
|
||||||
|
if (id(pkp).send_frame(0x194, &keys, 1))
|
||||||
|
id(pkp_keys_sent) = keys;
|
||||||
|
# LEDs: the on colour; with blink, alternating with the blink colour every 500 ms (off if not on)
|
||||||
|
- interval: 500ms
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
static bool phase = false;
|
||||||
|
phase = !phase;
|
||||||
|
uint8_t lvl = 255 * id(pkp_brightness) / 0x3F;
|
||||||
|
uint8_t rgb[8 * 3];
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
auto col = [i](uint32_t b) { return (b >> i & 1) | (b >> (i + 8) & 1) << 1 | (b >> (i + 16) & 1) << 2; };
|
||||||
|
int on = col(id(pkp_led_on)), bl = col(id(pkp_led_blink));
|
||||||
|
int c = phase && bl ? bl : (bl && !on ? 0 : on);
|
||||||
|
rgb[i * 3] = c & 1 ? lvl : 0;
|
||||||
|
rgb[i * 3 + 1] = c & 2 ? lvl : 0;
|
||||||
|
rgb[i * 3 + 2] = c & 4 ? lvl : 0;
|
||||||
|
}
|
||||||
|
id(byte_button).set_leds(rgb, 8);
|
||||||
|
|
||||||
|
# 8Encoder LEDs: the colours from led_color_1..9 (set remotely); turning an encoder shows its position 0..8 on the
|
||||||
|
# 8 encoder LEDs for ENC_SHOW_MS (bar on dark, none in free turning), its own LED blinks white, then the colours
|
||||||
|
# come back; the switch LED (9th) is green while the switch is on. Written only when something changed.
|
||||||
|
- interval: 50ms
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
static const uint32_t ENC_SHOW_MS = 3000;
|
||||||
|
static const uint8_t BAR[3] = {0, 64, 255}, ACTIVE[3] = {255, 255, 255}, SWITCH_ON[3] = {0, 255, 0};
|
||||||
|
sensor::Sensor *encs[8] = {id(encoder_1), id(encoder_2), id(encoder_3), id(encoder_4),
|
||||||
|
id(encoder_5), id(encoder_6), id(encoder_7), id(encoder_8)};
|
||||||
|
number::Number *colors[9] = {id(led_color_1), id(led_color_2), id(led_color_3), id(led_color_4), id(led_color_5),
|
||||||
|
id(led_color_6), id(led_color_7), id(led_color_8), id(led_color_9)};
|
||||||
|
static float last[8] = {NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN};
|
||||||
|
static int active = -1;
|
||||||
|
static uint32_t changed_at = 0;
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
float v = encs[i]->state;
|
||||||
|
if (std::isnan(v) || v == last[i])
|
||||||
|
continue;
|
||||||
|
if (!std::isnan(last[i])) { // not the first read after boot
|
||||||
|
active = i;
|
||||||
|
changed_at = millis();
|
||||||
|
}
|
||||||
|
last[i] = v;
|
||||||
|
}
|
||||||
|
uint8_t rgb[9 * 3];
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
uint32_t c = std::isnan(colors[i]->state) ? 0 : (uint32_t) colors[i]->state;
|
||||||
|
rgb[i * 3] = c >> 16;
|
||||||
|
rgb[i * 3 + 1] = c >> 8;
|
||||||
|
rgb[i * 3 + 2] = c;
|
||||||
|
}
|
||||||
|
if (active >= 0 && millis() - changed_at < ENC_SHOW_MS) {
|
||||||
|
// free turning: only its own LED
|
||||||
|
int pos = (int) id(encoder_relative_modes).state >> active & 1 ? 0 : encs[active]->state;
|
||||||
|
memset(rgb, 0, 8 * 3);
|
||||||
|
for (int led = 0; led < 8 && led < pos; led++)
|
||||||
|
memcpy(&rgb[led * 3], BAR, 3);
|
||||||
|
if (millis() / 250 & 1)
|
||||||
|
memcpy(&rgb[active * 3], ACTIVE, 3);
|
||||||
|
}
|
||||||
|
if (id(encoder_switch).state)
|
||||||
|
memcpy(&rgb[8 * 3], SWITCH_ON, 3);
|
||||||
|
static uint8_t sent[9 * 3];
|
||||||
|
static bool written = false;
|
||||||
|
if (written && memcmp(rgb, sent, sizeof(rgb)) == 0)
|
||||||
|
return; // no I2C traffic
|
||||||
|
if (id(enc).set_leds(rgb, 9)) {
|
||||||
|
memcpy(sent, rgb, sizeof(rgb));
|
||||||
|
written = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 8Encoder as entities of node 0x20 (the package uses 1-5, 16, 17); LED colours 50-58: command 0x2322:1 + 0x10 per LED (REAL32)
|
||||||
|
# encoders: one byte each, the position 0..8 (as the PKP3500-MT with its default TOP position 8) or the counter mod 256
|
||||||
|
canopen_entities:
|
||||||
|
entities:
|
||||||
|
- {id: encoder_switch, index: 6, tpdo: 1}
|
||||||
|
- {id: encoder_relative_modes, index: 7}
|
||||||
|
- {id: led_color_1, index: 50}
|
||||||
|
- {id: led_color_2, index: 51}
|
||||||
|
- {id: led_color_3, index: 52}
|
||||||
|
- {id: led_color_4, index: 53}
|
||||||
|
- {id: led_color_5, index: 54}
|
||||||
|
- {id: led_color_6, index: 55}
|
||||||
|
- {id: led_color_7, index: 56}
|
||||||
|
- {id: led_color_8, index: 57}
|
||||||
|
- {id: led_color_9, index: 58}
|
||||||
|
- {id: encoder_button_1, index: 30, tpdo: 3}
|
||||||
|
- {id: encoder_button_2, index: 31, tpdo: 3}
|
||||||
|
- {id: encoder_button_3, index: 32, tpdo: 3}
|
||||||
|
- {id: encoder_button_4, index: 33, tpdo: 3}
|
||||||
|
- {id: encoder_button_5, index: 34, tpdo: 3}
|
||||||
|
- {id: encoder_button_6, index: 35, tpdo: 3}
|
||||||
|
- {id: encoder_button_7, index: 36, tpdo: 3}
|
||||||
|
- {id: encoder_button_8, index: 37, tpdo: 3}
|
||||||
|
- {id: encoder_1, index: 40, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_2, index: 41, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_3, index: 42, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_4, index: 43, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_5, index: 44, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_6, index: 45, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_7, index: 46, tpdo: 4, size: 1}
|
||||||
|
- {id: encoder_8, index: 47, tpdo: 4, size: 1}
|
||||||
+230
@@ -0,0 +1,230 @@
|
|||||||
|
---
|
||||||
|
# Hardware: LilyGO T-Beam v1.1 (ESP32, AXP192), geolocation test receiver
|
||||||
|
# Pinout:
|
||||||
|
# GPIO12 GNSS RX -> uart_gnss (uart tx_pin)
|
||||||
|
# GPIO21 -> system_i2c (i2c sda)
|
||||||
|
# GPIO22 -> system_i2c (i2c scl)
|
||||||
|
# GPIO34 GNSS TX -> uart_gnss (uart rx_pin)
|
||||||
|
# GPIO38 User button (middle) -> user_button (binary_sensor gpio)
|
||||||
|
# I2C:
|
||||||
|
# 0x34 pmu_axp (axp192), LDO3 powers the GNSS, DCDC3 the ESP32
|
||||||
|
# 0x3C oled (display ssd1306_i2c)
|
||||||
|
# GNSS: u-blox NEO-6M (u-blox 6, fw 7.03), 9600 baud -> gnss (ubx), active antenna
|
||||||
|
# LoRa (SX1276) not set up yet
|
||||||
|
substitutions:
|
||||||
|
device: tbeam
|
||||||
|
name: T-Beam
|
||||||
|
area: DEV
|
||||||
|
comment: geolocation test receiver
|
||||||
|
|
||||||
|
esphome:
|
||||||
|
name: mcu-${device}
|
||||||
|
friendly_name: ${name}
|
||||||
|
area: ${area}
|
||||||
|
comment: ${comment}
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
board: ttgo-t-beam
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common/common.yaml
|
||||||
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
|
|
||||||
|
external_components:
|
||||||
|
- source: github://m5stack/esphome-yaml
|
||||||
|
components: [axp192]
|
||||||
|
refresh: 1h
|
||||||
|
# geolocation hub + nmea and ubx platforms, esphome/esphome#23301 (stacked on #23293)
|
||||||
|
- source: github://pr#23301
|
||||||
|
components: [geolocation, nmea, ubx]
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
id: system_i2c
|
||||||
|
sda: 21
|
||||||
|
scl: 22
|
||||||
|
|
||||||
|
axp192:
|
||||||
|
id: pmu_axp
|
||||||
|
address: 0x34
|
||||||
|
i2c_id: system_i2c
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: axp192
|
||||||
|
id: gnss_power
|
||||||
|
channel: DLDO3
|
||||||
|
voltage: 3300
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: output
|
||||||
|
id: gnss_enable
|
||||||
|
name: GNSS Power
|
||||||
|
output: gnss_power
|
||||||
|
restore_mode: ALWAYS_ON
|
||||||
|
|
||||||
|
uart:
|
||||||
|
id: uart_gnss
|
||||||
|
rx_pin: 34
|
||||||
|
tx_pin: 12
|
||||||
|
baud_rate: 9600
|
||||||
|
# Test aid: decode the NAV-SVINFO answers to the poll in interval below
|
||||||
|
debug:
|
||||||
|
direction: RX
|
||||||
|
after:
|
||||||
|
bytes: 512
|
||||||
|
timeout: 50ms
|
||||||
|
sequence:
|
||||||
|
- lambda: |-
|
||||||
|
for (size_t i = 0; i + 8 <= bytes.size(); i++) {
|
||||||
|
if (bytes[i] != 0xB5 || bytes[i + 1] != 0x62 || bytes[i + 2] != 0x01 || bytes[i + 3] != 0x30)
|
||||||
|
continue;
|
||||||
|
const size_t len = bytes[i + 4] | (bytes[i + 5] << 8);
|
||||||
|
if (i + 6 + len > bytes.size() || len < 8)
|
||||||
|
break;
|
||||||
|
const uint8_t *p = bytes.data() + i + 6;
|
||||||
|
const uint8_t num = p[4];
|
||||||
|
int tracked = 0, used = 0;
|
||||||
|
std::string sats;
|
||||||
|
for (uint8_t k = 0; k < num && 8 + 12 * (k + 1) <= len; k++) {
|
||||||
|
const uint8_t *c = p + 8 + 12 * k;
|
||||||
|
if (c[4] == 0)
|
||||||
|
continue;
|
||||||
|
tracked++;
|
||||||
|
if (c[2] & 0x01)
|
||||||
|
used++;
|
||||||
|
char buf[12];
|
||||||
|
snprintf(buf, sizeof(buf), " %u:%u", c[1], c[4]);
|
||||||
|
sats += buf;
|
||||||
|
}
|
||||||
|
ESP_LOGI("ubxdbg", "NAV-SVINFO used %d, tracked %d of %u channels, PRN:cno%s", used, tracked, num,
|
||||||
|
sats.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
geolocation:
|
||||||
|
- platform: ubx
|
||||||
|
id: gnss
|
||||||
|
update_interval: 10s
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: geolocation
|
||||||
|
type: latitude
|
||||||
|
id: latitude
|
||||||
|
name: Latitude
|
||||||
|
- platform: geolocation
|
||||||
|
type: longitude
|
||||||
|
id: longitude
|
||||||
|
name: Longitude
|
||||||
|
- platform: geolocation
|
||||||
|
type: altitude
|
||||||
|
id: altitude
|
||||||
|
name: Altitude
|
||||||
|
- platform: geolocation
|
||||||
|
type: speed
|
||||||
|
id: speed
|
||||||
|
name: Speed
|
||||||
|
- platform: geolocation
|
||||||
|
type: course
|
||||||
|
id: course
|
||||||
|
name: Course
|
||||||
|
- platform: geolocation
|
||||||
|
type: satellites
|
||||||
|
id: satellites
|
||||||
|
name: Satellites
|
||||||
|
- platform: geolocation
|
||||||
|
type: hdop
|
||||||
|
id: hdop
|
||||||
|
name: HDOP
|
||||||
|
- platform: geolocation
|
||||||
|
type: horizontal_accuracy
|
||||||
|
id: horizontal_accuracy
|
||||||
|
name: Horizontal Accuracy
|
||||||
|
- platform: geolocation
|
||||||
|
type: vertical_accuracy
|
||||||
|
name: Vertical Accuracy
|
||||||
|
- platform: axp192
|
||||||
|
id: pmu_sensors
|
||||||
|
axp192_id: pmu_axp
|
||||||
|
update_interval: 60s
|
||||||
|
battery_voltage:
|
||||||
|
id: battery_voltage
|
||||||
|
name: Battery Voltage
|
||||||
|
battery_level:
|
||||||
|
id: battery_level
|
||||||
|
name: Battery Level
|
||||||
|
battery_charge_current:
|
||||||
|
name: Battery Charge Current
|
||||||
|
entity_category: diagnostic
|
||||||
|
battery_discharge_current:
|
||||||
|
name: Battery Discharge Current
|
||||||
|
entity_category: diagnostic
|
||||||
|
vbus_voltage:
|
||||||
|
name: VBUS Voltage
|
||||||
|
entity_category: diagnostic
|
||||||
|
internal_temperature:
|
||||||
|
name: PMU Temperature
|
||||||
|
entity_category: diagnostic
|
||||||
|
battery_charging:
|
||||||
|
name: Battery Charging
|
||||||
|
battery_connected:
|
||||||
|
id: battery_connected
|
||||||
|
name: Battery Connected
|
||||||
|
vbus_present:
|
||||||
|
id: usb_power
|
||||||
|
name: USB Power
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
id: user_button
|
||||||
|
name: Button
|
||||||
|
pin:
|
||||||
|
number: 38
|
||||||
|
inverted: true
|
||||||
|
|
||||||
|
time:
|
||||||
|
- platform: geolocation
|
||||||
|
id: gnss_time
|
||||||
|
|
||||||
|
interval:
|
||||||
|
# Test aid: poll NAV-SVINFO (u-blox 6 has no NAV-SAT)
|
||||||
|
- interval: 10s
|
||||||
|
then:
|
||||||
|
- uart.write:
|
||||||
|
id: uart_gnss
|
||||||
|
data: [0xB5, 0x62, 0x01, 0x30, 0x00, 0x00, 0x31, 0x94]
|
||||||
|
|
||||||
|
font:
|
||||||
|
# Tiny5 Mono bitmap, 6x9 cell: 21 columns, 7 rows on 128x64
|
||||||
|
- file: assets/fonts/Tiny5Mono.bdf
|
||||||
|
id: font_mono
|
||||||
|
|
||||||
|
display:
|
||||||
|
- platform: ssd1306_i2c
|
||||||
|
id: oled
|
||||||
|
model: "SSD1306 128x64"
|
||||||
|
address: 0x3C
|
||||||
|
i2c_id: system_i2c
|
||||||
|
update_interval: 2s
|
||||||
|
lambda: |-
|
||||||
|
it.printf(0, 0, id(font_mono), "Sats %.0f", id(satellites).state);
|
||||||
|
if (!std::isnan(id(hdop).state))
|
||||||
|
it.printf(127, 0, id(font_mono), TextAlign::TOP_RIGHT, "HDOP %.1f", id(hdop).state);
|
||||||
|
if (std::isnan(id(latitude).state)) {
|
||||||
|
it.print(0, 9, id(font_mono), "No fix");
|
||||||
|
} else {
|
||||||
|
it.printf(0, 9, id(font_mono), "Lat %11.6f", id(latitude).state);
|
||||||
|
it.printf(0, 18, id(font_mono), "Lon %11.6f", id(longitude).state);
|
||||||
|
it.printf(0, 27, id(font_mono), "Alt %.0f m", id(altitude).state);
|
||||||
|
it.printf(127, 27, id(font_mono), TextAlign::TOP_RIGHT, "+-%.0f m", id(horizontal_accuracy).state);
|
||||||
|
it.printf(0, 36, id(font_mono), "%.1f km/h", id(speed).state);
|
||||||
|
if (!std::isnan(id(course).state))
|
||||||
|
it.printf(127, 36, id(font_mono), TextAlign::TOP_RIGHT, "%.0f deg", id(course).state);
|
||||||
|
}
|
||||||
|
auto now = id(gnss_time).now();
|
||||||
|
if (now.is_valid())
|
||||||
|
it.strftime(0, 46, id(font_mono), "%H:%M:%S", now);
|
||||||
|
if (id(battery_connected).state && !std::isnan(id(battery_level).state))
|
||||||
|
it.printf(127, 46, id(font_mono), TextAlign::TOP_RIGHT, "Bat %.0f%%", id(battery_level).state);
|
||||||
|
if (id(usb_power).state)
|
||||||
|
it.print(127, 55, id(font_mono), TextAlign::TOP_RIGHT, "USB");
|
||||||
+3
-8
@@ -38,14 +38,9 @@ packages:
|
|||||||
|
|
||||||
api:
|
api:
|
||||||
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
# status page until Home Assistant connects (log viewers don't subscribe to states)
|
||||||
on_client_connected:
|
# Home Assistant has subscribed and received every state
|
||||||
- delay: 2s
|
on_client_synced:
|
||||||
- if:
|
- lvgl.page.show: main_page
|
||||||
condition:
|
|
||||||
api.connected:
|
|
||||||
state_subscription_only: true
|
|
||||||
then:
|
|
||||||
- lvgl.page.show: main_page
|
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ modem:
|
|||||||
init_at:
|
init_at:
|
||||||
- AT+CPSI=60 # URC +CPSI every 60 s, for the operator
|
- AT+CPSI=60 # URC +CPSI every 60 s, for the operator
|
||||||
- AT+CGNSSINFO=30 # URC +CGNSSINFO every 30 s while GNSS runs; dev has no GNSS sensors
|
- AT+CGNSSINFO=30 # URC +CGNSSINFO every 30 s while GNSS runs; dev has no GNSS sensors
|
||||||
|
# GPS + GLONASS + Galileo (mask: 1 GLONASS, 2 BeiDou, 4 Galileo, 8 QZSS; GPS always on; was 15),
|
||||||
|
# DPO (power saving) kept. LE11B04SIM7600M21-A doesn't count Galileo in +CGNSSINFO
|
||||||
|
- AT+CGNSSMODE=5,1
|
||||||
|
# gpsOne XTRA: orbits from the net, kept in the modem's flash, so a fix in seconds after a power
|
||||||
|
# cycle (every ESP reset cycles the modem). Downloaded by the modem itself when expired (+CGPSXD: 0 = done)
|
||||||
|
- AT+CGPSXE=1
|
||||||
|
- AT+CGPSXDAUTO=1
|
||||||
on_connect:
|
on_connect:
|
||||||
# Survives an ESP reboot without a modem power cycle; the modem answers ERROR if GNSS already runs
|
# Survives an ESP reboot without a modem power cycle; the modem answers ERROR if GNSS already runs
|
||||||
- if:
|
- if:
|
||||||
|
|||||||
+25
-34
@@ -25,6 +25,9 @@ substitutions:
|
|||||||
light_workbench: light.mcu_basement_2_workbench_light
|
light_workbench: light.mcu_basement_2_workbench_light
|
||||||
light_exercise: light.exercise_room
|
light_exercise: light.exercise_room
|
||||||
fan: light.trainer_fan_exercise_room_fan
|
fan: light.trainer_fan_exercise_room_fan
|
||||||
|
# Home Assistant: the training state and the automation that runs the lights and the fan from it
|
||||||
|
training: input_boolean.training
|
||||||
|
training_automation: automation.training
|
||||||
|
|
||||||
# Pages (480x320, navigation bar at the bottom):
|
# Pages (480x320, navigation bar at the bottom):
|
||||||
# clock, lights, training, fan, stopwatch, status
|
# clock, lights, training, fan, stopwatch, status
|
||||||
@@ -145,6 +148,11 @@ packet_transport:
|
|||||||
- name: mcu-trainer-ant
|
- name: mcu-trainer-ant
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
|
- platform: homeassistant
|
||||||
|
id: training_on
|
||||||
|
entity_id: ${training}
|
||||||
|
on_state:
|
||||||
|
- script.execute: update_training_status
|
||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
id: basement_light
|
id: basement_light
|
||||||
entity_id: ${light_basement}
|
entity_id: ${light_basement}
|
||||||
@@ -456,14 +464,8 @@ text_sensor:
|
|||||||
value: !lambda return *parse_number<float>(x);
|
value: !lambda return *parse_number<float>(x);
|
||||||
# a running automation (e.g. its delay) has current > 0
|
# a running automation (e.g. its delay) has current > 0
|
||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
id: training_start_running
|
id: training_running
|
||||||
entity_id: automation.zwift_enable_fan
|
entity_id: ${training_automation}
|
||||||
attribute: current
|
|
||||||
on_value:
|
|
||||||
- script.execute: update_training_status
|
|
||||||
- platform: homeassistant
|
|
||||||
id: training_stop_running
|
|
||||||
entity_id: automation.zwift_disable_fan
|
|
||||||
attribute: current
|
attribute: current
|
||||||
on_value:
|
on_value:
|
||||||
- script.execute: update_training_status
|
- script.execute: update_training_status
|
||||||
@@ -518,14 +520,17 @@ script:
|
|||||||
|
|
||||||
- id: update_training_status
|
- id: update_training_status
|
||||||
then:
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
const bool on = id(training_on).state;
|
||||||
|
lv_label_set_text(id(training_btn_label), on ? "Stop" : "Štart");
|
||||||
|
lv_obj_set_style_bg_color(id(training_btn), lv_color_hex(on ? 0xB71C1C : 0x1E7D32), LV_PART_MAIN);
|
||||||
- lvgl.label.update:
|
- lvgl.label.update:
|
||||||
id: training_status_label
|
id: training_status_label
|
||||||
text: !lambda |-
|
text: !lambda |-
|
||||||
if (id(training_start_running).state != "0" && !id(training_start_running).state.empty())
|
const bool running = !id(training_running).state.empty() && id(training_running).state != "0";
|
||||||
return std::string("Tréning sa spúšťa, ventilátor sa zapne o 10 min");
|
if (id(training_on).state)
|
||||||
if (id(training_stop_running).state != "0" && !id(training_stop_running).state.empty())
|
return std::string(running ? "Tréning beží, ventilátor sa zapne o 10 min" : "Tréning beží");
|
||||||
return std::string("Tréning sa ukončuje, ventilátor sa vypne o 2 min");
|
return std::string(running ? "Tréning skončil, ventilátor sa vypne o 2 min" : "");
|
||||||
return std::string("");
|
|
||||||
|
|
||||||
- id: update_stopwatch
|
- id: update_stopwatch
|
||||||
then:
|
then:
|
||||||
@@ -814,42 +819,28 @@ lvgl:
|
|||||||
entity_id: ${light_exercise}
|
entity_id: ${light_exercise}
|
||||||
color_temp_kelvin: !lambda return (int) x;
|
color_temp_kelvin: !lambda return (int) x;
|
||||||
|
|
||||||
# 3: training start / stop
|
# 3: training start / stop, one toggle showing input_boolean.training
|
||||||
- id: training_page
|
- id: training_page
|
||||||
pad_all: 10
|
pad_all: 10
|
||||||
widgets:
|
widgets:
|
||||||
- button:
|
- button:
|
||||||
align: TOP_LEFT
|
id: training_btn
|
||||||
|
align: TOP_MID
|
||||||
y: 10
|
y: 10
|
||||||
width: 222
|
width: 460
|
||||||
height: 150
|
height: 150
|
||||||
bg_color: 0x1E7D32
|
bg_color: 0x1E7D32
|
||||||
widgets:
|
widgets:
|
||||||
- label:
|
- label:
|
||||||
|
id: training_btn_label
|
||||||
align: CENTER
|
align: CENTER
|
||||||
text_font: font_button
|
text_font: font_button
|
||||||
text: "Štart"
|
text: "Štart"
|
||||||
on_click:
|
on_click:
|
||||||
- homeassistant.action:
|
- homeassistant.action:
|
||||||
action: automation.trigger
|
action: input_boolean.toggle
|
||||||
data:
|
data:
|
||||||
entity_id: automation.zwift_enable_fan
|
entity_id: ${training}
|
||||||
- button:
|
|
||||||
align: TOP_RIGHT
|
|
||||||
y: 10
|
|
||||||
width: 222
|
|
||||||
height: 150
|
|
||||||
bg_color: 0xB71C1C
|
|
||||||
widgets:
|
|
||||||
- label:
|
|
||||||
align: CENTER
|
|
||||||
text_font: font_button
|
|
||||||
text: "Stop"
|
|
||||||
on_click:
|
|
||||||
- homeassistant.action:
|
|
||||||
action: automation.trigger
|
|
||||||
data:
|
|
||||||
entity_id: automation.zwift_disable_fan
|
|
||||||
- label:
|
- label:
|
||||||
id: training_status_label
|
id: training_status_label
|
||||||
align: TOP_MID
|
align: TOP_MID
|
||||||
|
|||||||
@@ -22,3 +22,4 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_honda_uuid
|
uuid: !secret ble_beacon_honda_uuid
|
||||||
major: !secret ble_beacon_honda_major
|
major: !secret ble_beacon_honda_major
|
||||||
minor: !secret ble_beacon_honda_minor
|
minor: !secret ble_beacon_honda_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -22,3 +22,4 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_suzuki_uuid
|
uuid: !secret ble_beacon_suzuki_uuid
|
||||||
major: !secret ble_beacon_suzuki_major
|
major: !secret ble_beacon_suzuki_major
|
||||||
minor: !secret ble_beacon_suzuki_minor
|
minor: !secret ble_beacon_suzuki_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -12,29 +12,14 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
on_boot:
|
|
||||||
then:
|
|
||||||
- if:
|
|
||||||
condition:
|
|
||||||
- binary_sensor.is_off: button
|
|
||||||
then:
|
|
||||||
- wifi.disable:
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
base: !include common/vehicle_base.yaml
|
base: !include common/vehicle_base.yaml
|
||||||
wifi: !include common/wifi.yaml
|
|
||||||
logger: !include common/logger.yaml
|
logger: !include common/logger.yaml
|
||||||
ota: !include common/ota.yaml
|
|
||||||
|
|
||||||
binary_sensor:
|
|
||||||
- platform: gpio
|
|
||||||
id: button
|
|
||||||
filters:
|
|
||||||
- invert:
|
|
||||||
pin: 39
|
|
||||||
|
|
||||||
esp32_ble_beacon:
|
esp32_ble_beacon:
|
||||||
type: iBeacon
|
type: iBeacon
|
||||||
uuid: !secret ble_beacon_toyota_auris_uuid
|
uuid: !secret ble_beacon_toyota_auris_uuid
|
||||||
major: !secret ble_beacon_toyota_auris_major
|
major: !secret ble_beacon_toyota_auris_major
|
||||||
minor: !secret ble_beacon_toyota_auris_minor
|
minor: !secret ble_beacon_toyota_auris_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -22,3 +22,4 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_toyota_yaris_uuid
|
uuid: !secret ble_beacon_toyota_yaris_uuid
|
||||||
major: !secret ble_beacon_toyota_yaris_major
|
major: !secret ble_beacon_toyota_yaris_major
|
||||||
minor: !secret ble_beacon_toyota_yaris_minor
|
minor: !secret ble_beacon_toyota_yaris_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -31,8 +31,9 @@ ble_beacon_toyota_auris_uuid: "00000000-0000-0000-0000-000000000000"
|
|||||||
ble_beacon_toyota_auris_major: 10167
|
ble_beacon_toyota_auris_major: 10167
|
||||||
ble_beacon_toyota_auris_minor: 61958
|
ble_beacon_toyota_auris_minor: 61958
|
||||||
ble_beacon_toyota_yaris_uuid: "00000000-0000-0000-0000-000000000000"
|
ble_beacon_toyota_yaris_uuid: "00000000-0000-0000-0000-000000000000"
|
||||||
ble_beacon_toyota_yaris_honda_major: 10167
|
ble_beacon_toyota_yaris_major: 10167
|
||||||
ble_beacon_toyota_yaris_honda_minor: 61958
|
ble_beacon_toyota_yaris_minor: 61958
|
||||||
|
ble_beacon_gate_uuid: "00000000-0000-0000-0000-000000000000"
|
||||||
|
|
||||||
# Thread active dataset (hex TLV) from Home Assistant
|
# Thread active dataset (hex TLV) from Home Assistant
|
||||||
thread_tlv: "0E080000000000010000"
|
thread_tlv: "0E080000000000010000"
|
||||||
|
|||||||
Reference in new issue
Block a user