mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
177bdcb3de | ||
|
|
523957d30d | ||
|
|
a0e216fcf1 | ||
|
|
775cf085fe | ||
|
|
c913af2814 | ||
|
|
faa4fe43f3 | ||
|
|
f8142505b7 | ||
|
|
16fde5016e | ||
|
|
885fc5a016 |
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,40 @@
|
||||
# Render a Pip-Boy green map (inverted OSM tiles) centred on home.
|
||||
# Map data (c) OpenStreetMap contributors, ODbL.
|
||||
# usage: make_map.py LAT LON ZOOM W H OUT
|
||||
import io, math, sys, urllib.request
|
||||
from PIL import Image, ImageDraw, ImageOps
|
||||
|
||||
GRID_STEP = 48
|
||||
|
||||
lat, lon, z, w, h, out = float(sys.argv[1]), float(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5]), sys.argv[6]
|
||||
|
||||
def world_px(lat, lon):
|
||||
n = 256 * 2**z
|
||||
x = (lon + 180) / 360 * n
|
||||
y = (1 - math.asinh(math.tan(math.radians(lat))) / math.pi) / 2 * n
|
||||
return x, y
|
||||
|
||||
cx, cy = world_px(lat, lon)
|
||||
x0, y0 = int(cx - w / 2), int(cy - h / 2)
|
||||
canvas = Image.new("RGB", (w, h))
|
||||
for ty in range(y0 // 256, (y0 + h) // 256 + 1):
|
||||
for tx in range(x0 // 256, (x0 + w) // 256 + 1):
|
||||
url = f"https://tile.openstreetmap.org/{z}/{tx}/{ty}.png"
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "esphome-map-render/1.0"})
|
||||
tile = Image.open(io.BytesIO(urllib.request.urlopen(req).read())).convert("RGB")
|
||||
canvas.paste(tile, (tx * 256 - x0, ty * 256 - y0))
|
||||
|
||||
g = ImageOps.autocontrast(ImageOps.invert(canvas.convert("L")), cutoff=1)
|
||||
g = g.point(lambda v: int(255 * (v / 255) ** 1.8)) # darker background, roads/edges stay bright
|
||||
# black -> Pip-Boy background, white -> a muted green so the markers stand out
|
||||
img = ImageOps.colorize(g, black=(10, 15, 11), white=(80, 170, 105))
|
||||
# grid and frame like the Pip-Boy local map
|
||||
draw = ImageDraw.Draw(img)
|
||||
GRID = (36, 67, 46)
|
||||
for x in range(GRID_STEP, w, GRID_STEP):
|
||||
draw.line([(x, 0), (x, h - 1)], fill=GRID)
|
||||
for y in range(GRID_STEP, h, GRID_STEP):
|
||||
draw.line([(0, y), (w - 1, y)], fill=GRID)
|
||||
draw.rectangle([0, 0, w - 1, h - 1], outline=GRID)
|
||||
img.save(out)
|
||||
print(f"saved {out}, centre world px {cx:.1f},{cy:.1f}")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
@@ -6,9 +6,7 @@
|
||||
# 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
|
||||
# pinned to be1f55d: the 2026-10-31 head breaks the IPv4-off build (IPV6_ROAM_SETTLE_MS defined under
|
||||
# USE_WIFI_LEASE_CACHE, used under USE_NETWORK_IPV6); back to github://pr#19750 once fixed
|
||||
- source: github://davidcoulson/esphome@be1f55d7d4f653a182980740b6d2549f22b2db87
|
||||
- source: github://pr#19750
|
||||
components: [network, wifi, ethernet]
|
||||
refresh: 1h
|
||||
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
#pragma once
|
||||
// Header-level decoding of captured ITS-G5 frames: 802.11 + LLC/SNAP, GeoNetworking (EN 302 636-4-1)
|
||||
// and BTP (EN 302 636-5-1). Gives the message type (from the BTP port) and the sender's position
|
||||
// vector, which GeoNetworking carries in every packet. The message bodies (CAM, DENM, SPATEM, ...)
|
||||
// are ASN.1 UPER and are not decoded here.
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace its_g5_decode {
|
||||
|
||||
struct Info {
|
||||
uint16_t port{0}; // BTP destination port, 0 = none
|
||||
uint8_t station_type{0}; // ETSI station type from the GN address
|
||||
bool secured{false}; // carried in an ETSI TS 103 097 signed packet (signature not verified)
|
||||
double lat{0}, lon{0}; // degrees
|
||||
float speed_kmh{0};
|
||||
float heading{0}; // degrees
|
||||
};
|
||||
|
||||
inline const char *port_name(uint16_t port) {
|
||||
switch (port) {
|
||||
case 2001: return "CAM";
|
||||
case 2002: return "DENM";
|
||||
case 2003: return "MAPEM";
|
||||
case 2004: return "SPATEM";
|
||||
case 2005: return "SAEM";
|
||||
case 2006: return "IVIM";
|
||||
case 2007: return "SREM";
|
||||
case 2008: return "SSEM";
|
||||
case 2009: return "CPM";
|
||||
case 2010: return "EVCSN";
|
||||
case 2011: return "TRM";
|
||||
case 2013: return "RTCMEM";
|
||||
case 2018: return "VAM";
|
||||
default: return "other";
|
||||
}
|
||||
}
|
||||
|
||||
inline const char *station_name(uint8_t type) {
|
||||
static const char *const NAMES[] = {"unknown", "pedestrian", "cyclist", "moped",
|
||||
"motorcycle", "passengerCar", "bus", "lightTruck",
|
||||
"heavyTruck", "trailer", "specialVehicle", "tram"};
|
||||
if (type < sizeof(NAMES) / sizeof(NAMES[0]))
|
||||
return NAMES[type];
|
||||
return type == 15 ? "roadSideUnit" : "other";
|
||||
}
|
||||
|
||||
inline uint16_t be16(const uint8_t *p) { return (p[0] << 8) | p[1]; }
|
||||
inline int32_t be32(const uint8_t *p) {
|
||||
return static_cast<int32_t>((uint32_t(p[0]) << 24) | (uint32_t(p[1]) << 16) | (uint32_t(p[2]) << 8) | p[3]);
|
||||
}
|
||||
|
||||
// Returns false for anything that is not a GeoNetworking packet it understands.
|
||||
inline bool parse(const std::vector<uint8_t> &frame, Info &out) {
|
||||
const uint8_t *f = frame.data();
|
||||
const size_t n = frame.size();
|
||||
if (n < 24 || ((f[0] >> 2) & 3) != 2) // data frames only
|
||||
return false;
|
||||
size_t i = 24;
|
||||
const bool qos = f[0] & 0x80;
|
||||
if (qos)
|
||||
i += 2;
|
||||
if ((f[1] & 3) == 3) // ToDS + FromDS: fourth address
|
||||
i += 6;
|
||||
if (qos && (f[1] & 0x80)) // +HTC
|
||||
i += 4;
|
||||
|
||||
static const uint8_t SNAP_GN[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x89, 0x47};
|
||||
if (i + 8 + 4 > n)
|
||||
return false;
|
||||
for (size_t k = 0; k < 8; k++) {
|
||||
if (f[i + k] != SNAP_GN[k])
|
||||
return false;
|
||||
}
|
||||
i += 8;
|
||||
|
||||
// GN basic header: version | next header, reserved, lifetime, remaining hop limit
|
||||
const uint8_t basic_nh = f[i] & 0x0F;
|
||||
i += 4;
|
||||
if (basic_nh == 2) {
|
||||
// ponytail: walks only the usual 1609.2 shape (signedData with an unsecuredData payload, no
|
||||
// external hash); anything else is skipped. A real OER decoder is needed for the rest.
|
||||
if (i + 7 > n || f[i] != 0x03 || f[i + 1] != 0x81 || !(f[i + 3] & 0x40) || f[i + 4] != 0x03 ||
|
||||
f[i + 5] != 0x80)
|
||||
return false;
|
||||
i += 6;
|
||||
if (f[i] & 0x80) {
|
||||
i += 1 + (f[i] & 0x7F);
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
out.secured = true;
|
||||
} else if (basic_nh != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// GN common header (8 bytes): next header | reserved, header type | subtype, ...
|
||||
if (i + 8 > n)
|
||||
return false;
|
||||
const uint8_t common_nh = f[i] >> 4;
|
||||
const uint8_t ht = f[i + 1] >> 4, hst = f[i + 1] & 0x0F;
|
||||
i += 8;
|
||||
|
||||
size_t pv, ext; // offset of the source position vector, length of the extended header
|
||||
switch (ht) {
|
||||
case 1: pv = i; ext = 24; break; // beacon
|
||||
case 2: pv = i + 4; ext = 48; break; // GUC
|
||||
case 3: case 4: pv = i + 4; ext = 44; break; // GAC, GBC
|
||||
case 5: pv = hst == 0 ? i : i + 4; ext = 28; break; // SHB, TSB
|
||||
default: return false; // location service, unknown
|
||||
}
|
||||
if (pv + 24 > n)
|
||||
return false;
|
||||
|
||||
// Long position vector: GN address (8), timestamp (4), lat, lon (1/10 µdeg), PAI | speed, heading
|
||||
out.station_type = (f[pv] >> 2) & 0x1F;
|
||||
out.lat = be32(f + pv + 12) / 1e7;
|
||||
out.lon = be32(f + pv + 16) / 1e7;
|
||||
int16_t speed = be16(f + pv + 20) & 0x7FFF;
|
||||
if (speed & 0x4000)
|
||||
speed -= 0x8000; // 15-bit signed, 0.01 m/s
|
||||
out.speed_kmh = speed * 0.036f;
|
||||
out.heading = be16(f + pv + 22) / 10.0f;
|
||||
|
||||
if ((common_nh == 1 || common_nh == 2) && i + ext + 2 <= n) // BTP-A / BTP-B
|
||||
out.port = be16(f + i + ext);
|
||||
return true;
|
||||
}
|
||||
|
||||
struct Stats {
|
||||
uint32_t cam{0}, denm{0}, spatem{0}, mapem{0}, other{0};
|
||||
Info last;
|
||||
};
|
||||
inline Stats stats;
|
||||
|
||||
// Parse, count and log one frame; returns false if it was not decoded.
|
||||
inline bool handle(const std::vector<uint8_t> &frame) {
|
||||
Info info;
|
||||
if (!parse(frame, info))
|
||||
return false;
|
||||
switch (info.port) {
|
||||
case 2001: stats.cam++; break;
|
||||
case 2002: stats.denm++; break;
|
||||
case 2004: stats.spatem++; break;
|
||||
case 2003: stats.mapem++; break;
|
||||
default: stats.other++; break;
|
||||
}
|
||||
stats.last = info;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace its_g5_decode
|
||||
@@ -0,0 +1,31 @@
|
||||
// Self-check for decode.h: one signed SHB CAM frame from a passenger car.
|
||||
// Build: g++ -std=c++20 decode_test.cpp -o /tmp/t && /tmp/t
|
||||
#include "decode.h"
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
using namespace its_g5_decode;
|
||||
int main() {
|
||||
std::vector<uint8_t> f = {0x88, 0x00, 0, 0, 0xff,0xff,0xff,0xff,0xff,0xff, 1,2,3,4,5,6, 0xff,0xff,0xff,0xff,0xff,0xff, 0,0, // QoS data hdr
|
||||
0x00, 0x00, // QoS ctrl
|
||||
0xAA,0xAA,0x03,0,0,0,0x89,0x47, // SNAP GN
|
||||
0x12, 0x00, 0x1a, 0x01, // basic, NH=2 secured
|
||||
0x03, 0x81, 0x00, 0x40, 0x03, 0x80, 0x30, // 1609.2 signedData/unsecuredData len
|
||||
0x20, 0x50, 0x02, 0x80, 0x00, 0x30, 0x01, 0x00}; // common: NH=BTP-B, HT=5 HST=0
|
||||
uint8_t pv[24] = {5 << 2, 0, 1,2,3,4,5,6, 0,0,0,0,
|
||||
0x1C,0xB3,0x8A,0x40, // lat 481528384 -> 48.1528384
|
||||
0x0A,0x34,0x5A,0x60, // lon 171203168 -> 17.1203168
|
||||
0x05,0x6E, // 1390 * 0.01 m/s = 50.04 km/h
|
||||
0x04,0xD2}; // 123.4 deg
|
||||
f.insert(f.end(), pv, pv + 24);
|
||||
uint8_t media[4] = {0}; f.insert(f.end(), media, media + 4);
|
||||
uint8_t btp[4] = {0x07, 0xD1, 0, 0}; f.insert(f.end(), btp, btp + 4); // port 2001
|
||||
Info i;
|
||||
assert(parse(f, i));
|
||||
assert(i.secured && i.port == 2001 && i.station_type == 5);
|
||||
assert(std::fabs(i.lat - 48.1528384) < 1e-7 && std::fabs(i.lon - 17.1203168) < 1e-7);
|
||||
assert(std::fabs(i.speed_kmh - 50.04f) < 0.01f && std::fabs(i.heading - 123.4f) < 0.01f);
|
||||
assert(handle(f) && stats.cam == 1);
|
||||
f[30] = 0x48; assert(!parse(f, i)); // not GeoNetworking
|
||||
std::puts("ok");
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
# Pip-Boy list row for mcu-lvgl's DATA tab: name left, value (id ${row}_val) right, select by touch
|
||||
# vars: row (widget id), name (left text), idx (row index for select_row)
|
||||
obj:
|
||||
id: ${row}
|
||||
width: 100%
|
||||
height: 44
|
||||
pad_left: 10
|
||||
pad_right: 10
|
||||
border_side: [BOTTOM]
|
||||
border_width: 1
|
||||
border_color: ${pip_line}
|
||||
bg_color: ${pip_panel}
|
||||
layout:
|
||||
type: flex
|
||||
flex_flow: row
|
||||
flex_align_cross: center
|
||||
pad_column: 12
|
||||
on_press:
|
||||
- script.execute:
|
||||
id: select_row
|
||||
row: ${idx}
|
||||
widgets:
|
||||
- obj:
|
||||
id: ${row}_mark
|
||||
width: 10
|
||||
height: 10
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
hidden: true
|
||||
- label:
|
||||
flex_grow: 1
|
||||
text: "${name}"
|
||||
- label:
|
||||
id: ${row}_val
|
||||
text: "--"
|
||||
@@ -0,0 +1,4 @@
|
||||
build/
|
||||
managed_components/
|
||||
sdkconfig
|
||||
sdkconfig.old
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(xiao_c6_spi)
|
||||
@@ -0,0 +1,28 @@
|
||||
= 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.
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,63 @@
|
||||
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
|
||||
@@ -0,0 +1,4 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES esp_hosted
|
||||
PRIV_REQUIRES nvs_flash esp_wifi)
|
||||
@@ -0,0 +1,5 @@
|
||||
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'
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# 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
|
||||
|
@@ -0,0 +1,25 @@
|
||||
# ── 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
|
||||
@@ -0,0 +1,112 @@
|
||||
# 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
|
||||
+1
-1
@@ -25,7 +25,7 @@ esphome:
|
||||
- component.suspend: car
|
||||
|
||||
esp32:
|
||||
board: m5stamp-pico
|
||||
variant: esp32
|
||||
framework:
|
||||
type: esp-idf
|
||||
advanced:
|
||||
|
||||
+4
-16
@@ -22,23 +22,15 @@ esphome:
|
||||
|
||||
esp32:
|
||||
variant: esp32
|
||||
toolchain: esp-idf
|
||||
framework:
|
||||
advanced:
|
||||
flash_chip: gd # ESP32-PICO-D4, like the other M5Stamp Pico (not read from the device)
|
||||
type: esp-idf
|
||||
advanced:
|
||||
flash_chip: gd
|
||||
sram1_as_iram: true
|
||||
|
||||
external_components:
|
||||
# - source: github://pr#3017
|
||||
# components: [hdmi_cec]
|
||||
# refresh: 1h
|
||||
# - source: github://Palakis/esphome-hdmi-cec
|
||||
# refresh: 1h
|
||||
- source: github://pr#9189
|
||||
components: [hdmi_cec]
|
||||
refresh: 0min
|
||||
packages:
|
||||
common: !include common/common.yaml
|
||||
ipv6_only: !include common/ipv6_only.yaml
|
||||
|
||||
debug:
|
||||
|
||||
@@ -133,10 +125,6 @@ hdmi_cec:
|
||||
address: 0x05 # Audio system
|
||||
# Promiscuous mode can be enabled to allow receiving messages not intended for us
|
||||
promiscuous_mode: false
|
||||
# Typically the physical address is discovered based on the point-to-point
|
||||
# topology of the HDMI connections using the DDC line. We don't have access
|
||||
# to that so we just hardcode a physical address.
|
||||
physical_address: 0x4000
|
||||
pin: 26
|
||||
on_message:
|
||||
- opcode: 0x36 # opcode for "Standby"
|
||||
|
||||
+31
-19
@@ -27,6 +27,7 @@ substitutions:
|
||||
comment: Klipper CNC pendant
|
||||
moonraker: http://klipper.local:7125
|
||||
max_feed: "3000" # mm/min, handwheel jog feed cap
|
||||
autolock: "60" # s without jogging or selecting until the handwheel locks
|
||||
|
||||
esphome:
|
||||
name: mcu-${device}
|
||||
@@ -69,13 +70,16 @@ http_request:
|
||||
globals:
|
||||
- id: axis
|
||||
type: int
|
||||
initial_value: "0" # 0 X, 1 Y, 2 Z
|
||||
initial_value: "-1" # -1 locked, 0 X, 1 Y, 2 Z
|
||||
- id: step
|
||||
type: int
|
||||
initial_value: "1" # index into steps[] in the jog interval
|
||||
- id: wheel_sent
|
||||
type: float
|
||||
initial_value: "0"
|
||||
- id: last_active
|
||||
type: uint32_t
|
||||
initial_value: "0" # millis() of the last jog or selection, drives the autolock
|
||||
|
||||
interval:
|
||||
# handwheel: send the counts since the last jog as one relative move
|
||||
@@ -83,9 +87,12 @@ interval:
|
||||
then:
|
||||
- lambda: |-
|
||||
static const float steps[] = {0.01f, 0.1f, 1.0f};
|
||||
if (id(axis) >= 0 && millis() - id(last_active) > ${autolock} * 1000) id(axis) = -1;
|
||||
float delta = id(handwheel).state - id(wheel_sent);
|
||||
if (delta == 0 || std::isnan(delta)) return;
|
||||
id(wheel_sent) = id(handwheel).state;
|
||||
if (id(axis) < 0) return; // locked: drop the counts
|
||||
id(last_active) = millis();
|
||||
float dist = delta * steps[id(step)];
|
||||
// feed so the move takes ~100 ms, i.e. about one interval
|
||||
// ponytail: capped feed lets fast spins queue moves that keep running after the wheel stops; drop excess counts if that bites
|
||||
@@ -111,9 +118,9 @@ sensor:
|
||||
number: 5
|
||||
mode: INPUT_PULLUP
|
||||
on_clockwise:
|
||||
- lambda: 'id(axis) = std::min(id(axis) + 1, 2);'
|
||||
- lambda: 'id(axis) = std::min(id(axis) + 1, 2); id(last_active) = millis();'
|
||||
on_anticlockwise:
|
||||
- lambda: 'id(axis) = std::max(id(axis) - 1, 0);'
|
||||
- lambda: 'id(axis) = std::max(id(axis) - 1, -1); id(last_active) = millis();'
|
||||
- platform: rotary_encoder
|
||||
id: step_encoder
|
||||
pin_a:
|
||||
@@ -123,9 +130,9 @@ sensor:
|
||||
number: 8
|
||||
mode: INPUT_PULLUP
|
||||
on_clockwise:
|
||||
- lambda: 'id(step) = std::min(id(step) + 1, 2);'
|
||||
- lambda: 'id(step) = std::min(id(step) + 1, 2); id(last_active) = millis();'
|
||||
on_anticlockwise:
|
||||
- lambda: 'id(step) = std::max(id(step) - 1, 0);'
|
||||
- lambda: 'id(step) = std::max(id(step) - 1, 0); id(last_active) = millis();'
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
@@ -134,7 +141,7 @@ binary_sensor:
|
||||
pin:
|
||||
number: 0
|
||||
inverted: true
|
||||
# axis push: zero the selected axis in work coordinates
|
||||
# axis push: zero the selected axis in work coordinates (nothing while locked)
|
||||
- platform: gpio
|
||||
id: axis_button
|
||||
name: Axis Button
|
||||
@@ -145,7 +152,7 @@ binary_sensor:
|
||||
filters:
|
||||
- delayed_on_off: 20ms
|
||||
on_press:
|
||||
- lambda: 'moonraker::client.gcode(str_sprintf("G92 %c0", "XYZ"[id(axis)]));'
|
||||
- lambda: 'if (id(axis) >= 0) moonraker::client.gcode(str_sprintf("G92 %c0", "XYZ"[id(axis)]));'
|
||||
- platform: gpio
|
||||
id: step_button
|
||||
name: Step Button
|
||||
@@ -196,11 +203,9 @@ binary_sensor:
|
||||
- lambda: 'moonraker::client.post("/printer/emergency_stop", "", true);'
|
||||
|
||||
font:
|
||||
# X11 misc-fixed bitmap fonts (as in u8g2 / Marlin), 6 px wide: axis letter + "-123.456" fits 64 px
|
||||
- file: assets/fonts/6x13.bdf
|
||||
id: font_big
|
||||
- file: assets/fonts/6x10.bdf
|
||||
id: font_small
|
||||
# Tiny5 Mono bitmap, 6x9 cell: axis letter + "-123.456" fits 64 px
|
||||
- file: assets/fonts/Tiny5Mono.bdf
|
||||
id: font_mono
|
||||
|
||||
spi:
|
||||
clk_pin: 13
|
||||
@@ -220,16 +225,23 @@ display:
|
||||
lambda: |-
|
||||
static const char *steps[] = {"0.01", "0.1", "1"};
|
||||
auto s = moonraker::client.status();
|
||||
it.printf(0, 0, id(font_small), "%s", s.state.c_str());
|
||||
it.printf(0, 10, id(font_small), "H:%s", s.homed.empty() ? "-" : s.homed.c_str());
|
||||
it.printf(0, 0, id(font_mono), "%s", s.state.c_str());
|
||||
it.printf(0, 10, id(font_mono), "H:%s", s.homed.empty() ? "-" : s.homed.c_str());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int y = 22 + i * 14;
|
||||
int y = 21 + i * 11;
|
||||
Color c = COLOR_ON;
|
||||
if (i == id(axis)) {
|
||||
it.filled_rectangle(0, y, 64, 13);
|
||||
it.filled_rectangle(0, y, 64, 10);
|
||||
c = COLOR_OFF;
|
||||
}
|
||||
it.printf(1, y + 1, id(font_big), c, "%c", "XYZ"[i]);
|
||||
it.printf(63, y + 1, id(font_big), c, TextAlign::TOP_RIGHT, "%.3f", s.pos[i]);
|
||||
it.printf(1, y + 1, id(font_mono), c, "%c", "XYZ"[i]);
|
||||
it.printf(63, y + 1, id(font_mono), c, TextAlign::TOP_RIGHT, "%.3f", s.pos[i]);
|
||||
}
|
||||
it.printf(0, 118, id(font_mono), "%s mm", steps[id(step)]);
|
||||
// corner: seconds until the handwheel locks, LCK once it has
|
||||
if (id(axis) < 0) {
|
||||
it.print(63, 118, id(font_mono), TextAlign::TOP_RIGHT, "LCK");
|
||||
} else {
|
||||
int left = ${autolock} - (int) ((millis() - id(last_active)) / 1000);
|
||||
it.printf(63, 118, id(font_mono), TextAlign::TOP_RIGHT, "%d", std::max(left, 0));
|
||||
}
|
||||
it.printf(0, 118, id(font_small), "%s mm", steps[id(step)]);
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
---
|
||||
# Hardware: Seeed Studio XIAO ESP32-C5 (host, its own radio in 802.11p for ITS-G5)
|
||||
# + Seeed Studio XIAO ESP32-C6 (esp32_hosted co-processor, Wi-Fi uplink over SPI)
|
||||
# Wi-Fi on the C6 needs esphome/esphome#22819 and hn/esphome-its-g5#3 (external components below)
|
||||
# and the co-processor firmware from hosted/xiao-c6-spi on the C6.
|
||||
# Pinout:
|
||||
# GPIO8 D8 -> esp32_hosted clk -> C6 D8 GPIO19
|
||||
# GPIO9 D9 <- esp32_hosted miso <- C6 D9 GPIO20
|
||||
# GPIO10 D10 -> esp32_hosted mosi -> C6 D10 GPIO18
|
||||
# GPIO7 D3 -> esp32_hosted cs -> C6 D3 GPIO21
|
||||
# GPIO1 D0 <- esp32_hosted handshake <- C6 D0 GPIO0
|
||||
# GPIO0 D1 <- esp32_hosted data_ready <- C6 D1 GPIO1
|
||||
# GPIO25 D2 -> esp32_hosted reset -> C6 D2 GPIO2 (CP firmware restarts itself on LOW)
|
||||
# GND, 3V3 shared
|
||||
substitutions:
|
||||
device: its-g5
|
||||
name: ITS-G5
|
||||
area: DEV
|
||||
comment: ITS-G5 receiver
|
||||
# OpenTrafficMap node ID (MQTT topics its/<node_id>/...): the reference firmware uses the MAC as
|
||||
# lowercase hex; replace it if opentrafficmap assigned a name (e.g. "node789")
|
||||
node_id: "3844bebe8638"
|
||||
|
||||
esphome:
|
||||
name: mcu-${device}
|
||||
friendly_name: ${name}
|
||||
area: ${area}
|
||||
comment: ${comment}
|
||||
includes:
|
||||
- common/its_g5/decode.h # its_g5_decode:: header decoding for the lambdas below
|
||||
|
||||
esp32:
|
||||
board: seeed_xiao_esp32c5
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
packages:
|
||||
common: !include common/common.yaml
|
||||
# ipv6_only off: eppp_link (pulled in by esp_wifi_remote) needs IPv4, fix belongs in esp-protocols
|
||||
# ipv6_only: !include common/ipv6_only.yaml
|
||||
|
||||
external_components:
|
||||
# Wi-Fi on the esp32_hosted co-processor of a host with its own radio
|
||||
- source: github://pr#22819
|
||||
components: [wifi]
|
||||
# its_g5_receiver allowing wifi on the co-processor
|
||||
- source: github://hn/esphome-its-g5@pull/3/head
|
||||
components: [its_g5_receiver]
|
||||
refresh: 1d
|
||||
|
||||
esp32_hosted:
|
||||
type: spi
|
||||
variant: ESP32C6
|
||||
clk_pin: GPIO8
|
||||
miso_pin: GPIO9
|
||||
mosi_pin: GPIO10
|
||||
cs_pin: GPIO7
|
||||
handshake_pin: GPIO1
|
||||
data_ready_pin: GPIO0
|
||||
reset_pin: GPIO25
|
||||
|
||||
wifi:
|
||||
use_coprocessor: true # Wi-Fi on the C6, the C5 radio is for 802.11p
|
||||
# car: ESP joins the tablet's hotspot as a client
|
||||
min_auth_mode: WPA2
|
||||
networks:
|
||||
- id: !remove wifi_iot
|
||||
- ssid: !secret wifi_ssid_0
|
||||
password: !secret wifi_password_0
|
||||
|
||||
# Raw 802.11 frames as UDP broadcasts; in Wireshark use the "UDP Listener"
|
||||
# (udpdump) interface on port 18511 with payload "wlan".
|
||||
udp:
|
||||
id: its_udp
|
||||
|
||||
# Raw frames to the OpenTrafficMap C-ITS server, as in hn's its-g5-opentrafficmap.yaml
|
||||
mqtt:
|
||||
id: mqtt_client
|
||||
broker: cits1.opentrafficmap.org
|
||||
port: 8883 # TLS is mandatory; publishing is anonymous
|
||||
discovery: false
|
||||
# *.opentrafficmap.org wildcard certificate, the hostname check fails with MbedTLS
|
||||
skip_cert_cn_check: true
|
||||
certificate_authority: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
||||
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
||||
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
||||
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
||||
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
||||
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
|
||||
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
|
||||
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
|
||||
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
|
||||
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
|
||||
B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
|
||||
KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
|
||||
OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
|
||||
jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
|
||||
qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
|
||||
rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
|
||||
HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
|
||||
hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
|
||||
ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
|
||||
3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
|
||||
NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
|
||||
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
|
||||
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
|
||||
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
|
||||
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
|
||||
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
||||
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
||||
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
||||
-----END CERTIFICATE-----
|
||||
# Empty prefix: no entity states, no command topics (the broker is anonymous) and no log topic;
|
||||
# only the OpenTrafficMap topics below
|
||||
topic_prefix: null
|
||||
log_topic: null
|
||||
birth_message:
|
||||
topic: its/${node_id}/status
|
||||
payload: online
|
||||
retain: true
|
||||
will_message:
|
||||
topic: its/${node_id}/status
|
||||
payload: offline
|
||||
retain: true
|
||||
on_connect:
|
||||
- delay: 3s
|
||||
- lambda: |-
|
||||
uint8_t mac[6];
|
||||
get_mac_address_raw(mac);
|
||||
char info[160];
|
||||
int n = snprintf(info, sizeof(info),
|
||||
"{\"emac\":\"%02x:%02x:%02x:%02x:%02x:%02x\",\"ver\":\"%s\",\"hwv\":\"esphome\"}",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], ESPHOME_VERSION);
|
||||
id(mqtt_client).publish("its/${node_id}/info", info, n, 0, false);
|
||||
|
||||
interval:
|
||||
- interval: 60s
|
||||
then:
|
||||
- lambda: |-
|
||||
char stats[48];
|
||||
int n = snprintf(stats, sizeof(stats), "{\"rbt\":%llu}", millis_64() / 1000ULL);
|
||||
id(mqtt_client).publish("its/${node_id}/stats", stats, n, 0, false);
|
||||
|
||||
its_g5_receiver:
|
||||
id: g5
|
||||
channel: 5900 # G5CC
|
||||
broadcast_only: true
|
||||
on_packet:
|
||||
- lambda: |-
|
||||
id(mqtt_client).publish("its/${node_id}/packet", (const char *) x.data(), x.size(), 0, false);
|
||||
- udp.write:
|
||||
id: its_udp
|
||||
data: !lambda return x;
|
||||
- lambda: |-
|
||||
if (!its_g5_decode::handle(x))
|
||||
return;
|
||||
const auto &i = its_g5_decode::stats.last;
|
||||
ESP_LOGD("its_g5", "%s from %s %.6f,%.6f %.0f km/h %.0f deg%s, rssi %.0f dBm",
|
||||
its_g5_decode::port_name(i.port), its_g5_decode::station_name(i.station_type),
|
||||
i.lat, i.lon, i.speed_kmh, i.heading, i.secured ? ", signed" : "", rssi);
|
||||
|
||||
sensor:
|
||||
- platform: its_g5_receiver
|
||||
its_g5_receiver_id: g5
|
||||
bytes_received:
|
||||
name: Bytes Received
|
||||
packets_received:
|
||||
name: Packets Received
|
||||
packets_dropped:
|
||||
name: Packets Dropped
|
||||
- platform: template
|
||||
name: CAM Received
|
||||
state_class: total_increasing
|
||||
accuracy_decimals: 0
|
||||
lambda: return its_g5_decode::stats.cam;
|
||||
- platform: template
|
||||
name: DENM Received
|
||||
state_class: total_increasing
|
||||
accuracy_decimals: 0
|
||||
lambda: return its_g5_decode::stats.denm;
|
||||
- platform: template
|
||||
name: SPATEM Received
|
||||
state_class: total_increasing
|
||||
accuracy_decimals: 0
|
||||
lambda: return its_g5_decode::stats.spatem;
|
||||
- platform: template
|
||||
name: MAPEM Received
|
||||
state_class: total_increasing
|
||||
accuracy_decimals: 0
|
||||
lambda: return its_g5_decode::stats.mapem;
|
||||
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
name: MQTT Connected
|
||||
device_class: connectivity
|
||||
entity_category: diagnostic
|
||||
lambda: return id(mqtt_client).is_connected();
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: Last Station
|
||||
update_interval: 10s
|
||||
lambda: |-
|
||||
const auto &i = its_g5_decode::stats.last;
|
||||
if (i.lat == 0 && i.lon == 0)
|
||||
return {};
|
||||
char buf[96];
|
||||
snprintf(buf, sizeof(buf), "%s %s %.6f,%.6f %.0f km/h %.0f°", its_g5_decode::port_name(i.port),
|
||||
its_g5_decode::station_name(i.station_type), i.lat, i.lon, i.speed_kmh, i.heading);
|
||||
return std::string(buf);
|
||||
+636
-60
@@ -88,12 +88,36 @@ substitutions:
|
||||
name: LVGL
|
||||
area: DEV
|
||||
comment: LVGL
|
||||
# Pip-Boy palette
|
||||
pip_green: "0x7DF59A"
|
||||
pip_dim: "0x3B7A4E"
|
||||
pip_line: "0x24432E"
|
||||
pip_panel: "0x12261A"
|
||||
pip_bg: "0x0A0F0B"
|
||||
# tab bar: 4 tabs, bracket follows the active one
|
||||
tab_w: "150"
|
||||
tab_step: "190"
|
||||
tab_x0: "44"
|
||||
tab_x1: "234"
|
||||
tab_x2: "424"
|
||||
tab_x3: "614"
|
||||
# MAP tab: centre and zoom of assets/images/pipboy_map.png, re-render it when changing:
|
||||
# python3 assets/images/make_map.py ${map_lat} ${map_lon} ${map_zoom} ${map_w} ${map_h} assets/images/pipboy_map.png
|
||||
map_lat: "48.0538401"
|
||||
map_lon: "17.3656273"
|
||||
map_zoom: "14"
|
||||
map_w: "768"
|
||||
map_h: "316"
|
||||
map_y: "104"
|
||||
map_name: "KVETOSLAVOV"
|
||||
|
||||
esphome:
|
||||
name: mcu-${device}
|
||||
friendly_name: ${name}
|
||||
area: ${area}
|
||||
comment: ${comment}
|
||||
includes:
|
||||
- common/nspanel_terminal/weather.h # weather_icon()
|
||||
on_boot:
|
||||
- priority: -100
|
||||
then:
|
||||
@@ -141,6 +165,10 @@ api:
|
||||
then:
|
||||
- lvgl.page.show: status_page
|
||||
|
||||
# the USB port on this board is a CH340 on UART0, not the S3 USB-JTAG
|
||||
logger:
|
||||
hardware_uart: UART0
|
||||
|
||||
i2c:
|
||||
- id: i2c_main
|
||||
sda: 19
|
||||
@@ -178,7 +206,182 @@ light:
|
||||
output: gpio_backlight_pwm
|
||||
restore_mode: ALWAYS_ON
|
||||
|
||||
# Pip-Boy look (after the Fallout 4 Pip-Boy: tab bar with a bracket on the active tab, status bar at the bottom)
|
||||
# STAT weekday, date, weather, name day, clock
|
||||
# DATA weather from Home Assistant as a list
|
||||
# MAP map around home with Home Assistant persons
|
||||
# SYS status page (shown until Home Assistant connects)
|
||||
# bottom bar: HP = WiFi signal, LEVEL = uptime days (bar: time of day), AP = free internal RAM
|
||||
sensor:
|
||||
- platform: homeassistant
|
||||
id: outside_temperature
|
||||
entity_id: sensor.zigbee_outside_temperature
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_data
|
||||
- platform: homeassistant
|
||||
id: outside_humidity
|
||||
entity_id: weather.outside
|
||||
attribute: humidity
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_data
|
||||
- platform: homeassistant
|
||||
id: outside_pressure
|
||||
entity_id: weather.outside
|
||||
attribute: pressure
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_data
|
||||
- platform: homeassistant
|
||||
id: outside_wind
|
||||
entity_id: weather.outside
|
||||
attribute: wind_speed
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_data
|
||||
# persons on the MAP tab
|
||||
- platform: homeassistant
|
||||
id: romanko_lat
|
||||
entity_id: person.romanko
|
||||
attribute: latitude
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_map
|
||||
- platform: homeassistant
|
||||
id: romanko_lon
|
||||
entity_id: person.romanko
|
||||
attribute: longitude
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_map
|
||||
- platform: homeassistant
|
||||
id: janko_lat
|
||||
entity_id: person.janko
|
||||
attribute: latitude
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_map
|
||||
- platform: homeassistant
|
||||
id: janko_lon
|
||||
entity_id: person.janko
|
||||
attribute: longitude
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_map
|
||||
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: weather_state
|
||||
entity_id: weather.outside
|
||||
internal: true
|
||||
on_value:
|
||||
- script.execute: update_data
|
||||
- platform: homeassistant
|
||||
id: nameday
|
||||
entity_id: sensor.nameday_sk
|
||||
internal: true
|
||||
on_value:
|
||||
- lvgl.label.update:
|
||||
id: nameday_label
|
||||
text: !lambda 'return "MENINY: " + x;'
|
||||
|
||||
script:
|
||||
- id: update_data
|
||||
then:
|
||||
- lambda: |-
|
||||
auto num = [](sensor::Sensor *s, const char *fmt) {
|
||||
return s->has_state() && !std::isnan(s->state) ? str_sprintf(fmt, s->state) : std::string("--");
|
||||
};
|
||||
const std::string cond = id(weather_state).has_state() ? id(weather_state).state : "";
|
||||
std::string cond_up = cond.empty() ? "--" : cond;
|
||||
for (auto &c : cond_up)
|
||||
c = c == '-' ? ' ' : toupper(c);
|
||||
const std::string temp = num(id(outside_temperature), "%.1f°C");
|
||||
// STAT
|
||||
lv_label_set_text(id(stat_icon), weather_icon(cond));
|
||||
lv_label_set_text(id(stat_temp), temp.c_str());
|
||||
// DATA
|
||||
lv_label_set_text(id(row_temp_val), temp.c_str());
|
||||
lv_label_set_text(id(row_cond_val), cond_up.c_str());
|
||||
lv_label_set_text(id(row_hum_val), num(id(outside_humidity), "%.0f %%").c_str());
|
||||
lv_label_set_text(id(row_press_val), num(id(outside_pressure), "%.0f hPa").c_str());
|
||||
lv_label_set_text(id(row_wind_val), num(id(outside_wind), "%.0f km/h").c_str());
|
||||
|
||||
# DATA: highlight the touched row like the Pip-Boy cursor
|
||||
- id: select_row
|
||||
parameters:
|
||||
row: int
|
||||
then:
|
||||
- lambda: |-
|
||||
lv_obj_t *const rows[] = {id(row_temp), id(row_cond), id(row_hum), id(row_press), id(row_wind)};
|
||||
lv_obj_t *const marks[] = {id(row_temp_mark), id(row_cond_mark), id(row_hum_mark), id(row_press_mark),
|
||||
id(row_wind_mark)};
|
||||
for (int i = 0; i < 5; i++) {
|
||||
lv_obj_set_style_bg_opa(rows[i], i == row ? LV_OPA_COVER : LV_OPA_TRANSP, LV_PART_MAIN);
|
||||
if (i == row)
|
||||
lv_obj_remove_flag(marks[i], LV_OBJ_FLAG_HIDDEN);
|
||||
else
|
||||
lv_obj_add_flag(marks[i], LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
- id: update_map
|
||||
then:
|
||||
- lambda: |-
|
||||
// Web Mercator, same projection as the map tiles
|
||||
static const double N = 256.0 * (1 << ${map_zoom});
|
||||
auto wx = [](double lon) { return (lon + 180) / 360 * N; };
|
||||
auto wy = [](double lat) { return (1 - std::asinh(std::tan(lat * M_PI / 180)) / M_PI) / 2 * N; };
|
||||
auto place = [&](lv_obj_t *marker, sensor::Sensor *lat, sensor::Sensor *lon) {
|
||||
if (lat->has_state() && lon->has_state() && !std::isnan(lat->state) && !std::isnan(lon->state)) {
|
||||
// map image is ${map_w}x${map_h} at 16,${map_y}; the marker ring (14x14) is at the container's edge
|
||||
const int x = ${map_w} / 2 + (int) (wx(lon->state) - wx(${map_lon}));
|
||||
const int y = ${map_h} / 2 + (int) (wy(lat->state) - wy(${map_lat}));
|
||||
if (x >= 0 && x < ${map_w} && y >= 0 && y < ${map_h}) {
|
||||
lv_obj_update_layout(marker);
|
||||
const bool right = lv_obj_get_style_flex_flow(marker, LV_PART_MAIN) == LV_FLEX_FLOW_ROW_REVERSE;
|
||||
lv_obj_set_pos(marker, 16 + (right ? x + 7 - lv_obj_get_width(marker) : x - 7),
|
||||
${map_y} + y - lv_obj_get_height(marker) / 2);
|
||||
lv_obj_remove_flag(marker, LV_OBJ_FLAG_HIDDEN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
lv_obj_add_flag(marker, LV_OBJ_FLAG_HIDDEN); // unknown or off the map
|
||||
};
|
||||
place(id(marker_romanko), id(romanko_lat), id(romanko_lon));
|
||||
place(id(marker_janko), id(janko_lat), id(janko_lon));
|
||||
|
||||
- id: update_stat
|
||||
then:
|
||||
- lambda: |-
|
||||
const bool wifi_ok = wifi::global_wifi_component->is_connected();
|
||||
const int rssi = wifi_ok ? wifi::global_wifi_component->wifi_rssi() : -100;
|
||||
const int hp = std::clamp(2 * (rssi + 100), 0, 100);
|
||||
lv_label_set_text(id(hp_label), str_sprintf("HP %d/100", hp).c_str());
|
||||
|
||||
const uint32_t up = millis() / 1000;
|
||||
lv_label_set_text(id(level_label), str_sprintf("LEVEL %u", up / 86400 + 1).c_str());
|
||||
lv_bar_set_value(id(xp_bar), (up % 86400) * 100 / 86400, LV_ANIM_OFF);
|
||||
|
||||
const size_t total = heap_caps_get_total_size(MALLOC_CAP_INTERNAL);
|
||||
const int ap = total ? heap_caps_get_free_size(MALLOC_CAP_INTERNAL) * 100 / total : 0;
|
||||
lv_label_set_text(id(ap_label), str_sprintf("AP %d/100", ap).c_str());
|
||||
|
||||
- id: update_clock
|
||||
then:
|
||||
- lambda: |-
|
||||
auto now = id(ha_time).now();
|
||||
if (!now.is_valid())
|
||||
return;
|
||||
auto upper = [](std::string s) {
|
||||
for (auto &c : s)
|
||||
c = toupper(c);
|
||||
return s;
|
||||
};
|
||||
lv_label_set_text(id(clock_label), now.strftime("%H\n%M").c_str());
|
||||
lv_label_set_text(id(weekday_label), upper(now.strftime("%A")).c_str());
|
||||
lv_label_set_text(id(date_label), upper(now.strftime("%b %d %Y")).c_str());
|
||||
|
||||
- id: update_status
|
||||
then:
|
||||
- lambda: |-
|
||||
@@ -226,35 +429,98 @@ script:
|
||||
lv_label_set_text(id(status_footer),
|
||||
str_sprintf("ESPHome %s · up %ud %02u:%02u:%02u", ESPHOME_VERSION, up / 86400,
|
||||
(up / 3600) % 24, (up / 60) % 60, up % 60).c_str());
|
||||
|
||||
# move the bracket to the active tab, dim the others; called from each page's on_load, so it also
|
||||
# follows pages shown from code (API connect/disconnect)
|
||||
- id: select_tab
|
||||
parameters:
|
||||
tab: int
|
||||
then:
|
||||
- lambda: |-
|
||||
lv_obj_t *const labels[] = {id(tab_stat_label), id(tab_data_label), id(tab_map_label), id(tab_sys_label)};
|
||||
for (int i = 0; i < 4; i++)
|
||||
lv_obj_set_style_text_color(labels[i], lv_color_hex(i == tab ? ${pip_green} : ${pip_dim}), LV_PART_MAIN);
|
||||
lv_obj_set_x(id(tab_bracket), ${tab_x0} + tab * ${tab_step});
|
||||
// no status bar on SYS, its page needs the room
|
||||
if (tab == 3)
|
||||
lv_obj_add_flag(id(bottom_bar), LV_OBJ_FLAG_HIDDEN);
|
||||
else
|
||||
lv_obj_remove_flag(id(bottom_bar), LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
interval:
|
||||
- interval: 1s
|
||||
then:
|
||||
- lvgl.label.update:
|
||||
id: clock_label
|
||||
text: !lambda |-
|
||||
auto now = id(ha_time).now();
|
||||
if (!now.is_valid())
|
||||
return std::string("--:--");
|
||||
return now.strftime("%H:%M");
|
||||
- if:
|
||||
condition:
|
||||
lvgl.page.is_showing: main_page
|
||||
then:
|
||||
- script.execute: update_clock
|
||||
- if:
|
||||
condition:
|
||||
lvgl.page.is_showing: status_page
|
||||
then:
|
||||
- script.execute: update_status
|
||||
else:
|
||||
- script.execute: update_stat
|
||||
|
||||
image:
|
||||
- platform: file
|
||||
file: assets/images/made-for-esphome-white-on-black.svg
|
||||
id: esphome_logo
|
||||
resize: 400x118
|
||||
resize: 300x88
|
||||
type: RGB565
|
||||
transparency: alpha_channel
|
||||
- platform: file
|
||||
file: assets/images/pipboy_map.png
|
||||
id: pipboy_map
|
||||
type: RGB565
|
||||
|
||||
font:
|
||||
- file: "gfonts://Roboto@500"
|
||||
- file: "gfonts://Roboto Mono@500"
|
||||
id: font_clock
|
||||
size: 200
|
||||
glyphs: "0123456789:-"
|
||||
size: 124
|
||||
glyphs: "0123456789-"
|
||||
- file: "gfonts://Roboto Mono@500"
|
||||
id: font_tab
|
||||
size: 30
|
||||
glyphs: "ADMPSTY"
|
||||
- file: "gfonts://Roboto Mono"
|
||||
id: font_big
|
||||
size: 40
|
||||
glyphs: "°-"
|
||||
glyphsets: [GF_Latin_Kernel]
|
||||
- file: "gfonts://Roboto Mono"
|
||||
id: font_pip
|
||||
size: 24
|
||||
glyphs: "°·"
|
||||
glyphsets: [GF_Latin_Core]
|
||||
ignore_missing_glyphs: true # only combining marks (U+0302…), Slovak uses precomposed letters
|
||||
- file: "gfonts://Roboto Mono"
|
||||
id: font_small
|
||||
size: 18
|
||||
glyphs: "©"
|
||||
glyphsets: [GF_Latin_Kernel]
|
||||
- file:
|
||||
type: web
|
||||
url: https://github.com/Templarian/MaterialDesign-Webfont/raw/v7.4.47/fonts/materialdesignicons-webfont.ttf
|
||||
id: font_weather
|
||||
size: 72
|
||||
glyphs:
|
||||
- "\U000F0594" # mdi:weather-night
|
||||
- "\U000F0599" # mdi:weather-sunny
|
||||
- "\U000F0595" # mdi:weather-partly-cloudy
|
||||
- "\U000F0590" # mdi:weather-cloudy
|
||||
- "\U000F0591" # mdi:weather-fog
|
||||
- "\U000F0597" # mdi:weather-rainy
|
||||
- "\U000F0596" # mdi:weather-pouring
|
||||
- "\U000F0598" # mdi:weather-snowy
|
||||
- "\U000F067F" # mdi:weather-snowy-rainy
|
||||
- "\U000F0592" # mdi:weather-hail
|
||||
- "\U000F0593" # mdi:weather-lightning
|
||||
- "\U000F067E" # mdi:weather-lightning-rainy
|
||||
- "\U000F059D" # mdi:weather-windy
|
||||
- "\U000F059E" # mdi:weather-windy-variant
|
||||
- "\U000F05D6" # mdi:alert-circle-outline
|
||||
- file: "gfonts://Roboto"
|
||||
id: font_title
|
||||
size: 40
|
||||
@@ -267,81 +533,391 @@ font:
|
||||
lvgl:
|
||||
log_level: WARN
|
||||
color_depth: 16
|
||||
bg_color: 0x000000
|
||||
text_color: 0xFFFFFF
|
||||
bg_color: ${pip_bg}
|
||||
text_color: ${pip_green}
|
||||
text_font: font_pip
|
||||
theme:
|
||||
buttonmatrix:
|
||||
# plain boxes: layout containers, markers and bars set only what they need
|
||||
obj:
|
||||
bg_opa: TRANSP
|
||||
border_width: 0
|
||||
items:
|
||||
bg_color: 0x2B2F36
|
||||
text_color: 0xFFFFFF
|
||||
radius: 12
|
||||
checked:
|
||||
bg_color: 0xE08A00
|
||||
radius: 0
|
||||
pad_all: 0
|
||||
text_color: ${pip_green} # the default theme sets a dark text color that labels inherit
|
||||
button:
|
||||
bg_opa: TRANSP
|
||||
border_width: 0
|
||||
shadow_width: 0
|
||||
radius: 0
|
||||
pressed:
|
||||
bg_opa: TRANSP
|
||||
top_layer:
|
||||
widgets:
|
||||
# same navigation bar as on mcu-lvgl-trainer
|
||||
- buttonmatrix:
|
||||
id: nav_bar
|
||||
align: bottom_mid
|
||||
width: 100%
|
||||
height: 64
|
||||
pad_all: 4
|
||||
pad_column: 6
|
||||
items:
|
||||
text_font: montserrat_28
|
||||
rows:
|
||||
- buttons:
|
||||
- id: page_prev
|
||||
text: "\uF053"
|
||||
on_press:
|
||||
then:
|
||||
lvgl.page.previous:
|
||||
- id: page_home
|
||||
text: "\uF015"
|
||||
on_press:
|
||||
then:
|
||||
lvgl.page.show: main_page
|
||||
- id: page_next
|
||||
text: "\uF054"
|
||||
on_press:
|
||||
then:
|
||||
lvgl.page.next:
|
||||
# tab bar: rule with end ticks, the bracket covers the rule under the active tab
|
||||
- obj:
|
||||
x: 16
|
||||
y: 56
|
||||
width: 768
|
||||
height: 2
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
- obj:
|
||||
x: 16
|
||||
y: 56
|
||||
width: 2
|
||||
height: 10
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
- obj:
|
||||
x: 782
|
||||
y: 56
|
||||
width: 2
|
||||
height: 10
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
- obj:
|
||||
id: tab_bracket
|
||||
x: ${tab_x0}
|
||||
y: 12
|
||||
width: ${tab_w}
|
||||
height: 46
|
||||
border_side: [LEFT, RIGHT]
|
||||
border_width: 2
|
||||
border_color: ${pip_green}
|
||||
bg_color: ${pip_bg}
|
||||
bg_opa: COVER
|
||||
widgets:
|
||||
- obj:
|
||||
align: TOP_LEFT
|
||||
width: 14
|
||||
height: 2
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
- obj:
|
||||
align: TOP_RIGHT
|
||||
width: 14
|
||||
height: 2
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
- button:
|
||||
x: ${tab_x0}
|
||||
y: 12
|
||||
width: ${tab_w}
|
||||
height: 44
|
||||
on_press:
|
||||
- lvgl.page.show: main_page
|
||||
widgets:
|
||||
- label:
|
||||
id: tab_stat_label
|
||||
align: CENTER
|
||||
text_font: font_tab
|
||||
text: "STAT"
|
||||
- button:
|
||||
x: ${tab_x1}
|
||||
y: 12
|
||||
width: ${tab_w}
|
||||
height: 44
|
||||
on_press:
|
||||
- lvgl.page.show: data_page
|
||||
widgets:
|
||||
- label:
|
||||
id: tab_data_label
|
||||
align: CENTER
|
||||
text_font: font_tab
|
||||
text_color: ${pip_dim}
|
||||
text: "DATA"
|
||||
- button:
|
||||
x: ${tab_x2}
|
||||
y: 12
|
||||
width: ${tab_w}
|
||||
height: 44
|
||||
on_press:
|
||||
- lvgl.page.show: map_page
|
||||
widgets:
|
||||
- label:
|
||||
id: tab_map_label
|
||||
align: CENTER
|
||||
text_font: font_tab
|
||||
text_color: ${pip_dim}
|
||||
text: "MAP"
|
||||
- button:
|
||||
x: ${tab_x3}
|
||||
y: 12
|
||||
width: ${tab_w}
|
||||
height: 44
|
||||
on_press:
|
||||
- lvgl.page.show: status_page
|
||||
widgets:
|
||||
- label:
|
||||
id: tab_sys_label
|
||||
align: CENTER
|
||||
text_font: font_tab
|
||||
text_color: ${pip_dim}
|
||||
text: "SYS"
|
||||
# status bar: HP | LEVEL [xp] | AP
|
||||
- obj:
|
||||
id: bottom_bar
|
||||
x: 16
|
||||
y: 432
|
||||
width: 768
|
||||
height: 40
|
||||
pad_left: 14
|
||||
pad_right: 14
|
||||
bg_color: ${pip_panel}
|
||||
bg_opa: COVER
|
||||
layout:
|
||||
type: flex
|
||||
flex_flow: row
|
||||
flex_align_main: SPACE_BETWEEN
|
||||
flex_align_cross: center
|
||||
widgets:
|
||||
- label:
|
||||
id: hp_label
|
||||
text: "HP"
|
||||
- obj:
|
||||
width: SIZE_CONTENT
|
||||
height: SIZE_CONTENT
|
||||
layout:
|
||||
type: flex
|
||||
flex_flow: row
|
||||
flex_align_cross: center
|
||||
pad_column: 14
|
||||
widgets:
|
||||
- label:
|
||||
id: level_label
|
||||
text: "LEVEL"
|
||||
- bar:
|
||||
id: xp_bar
|
||||
width: 140
|
||||
height: 18
|
||||
min_value: 0
|
||||
max_value: 100
|
||||
radius: 0
|
||||
pad_all: 3
|
||||
border_width: 2
|
||||
border_color: ${pip_green}
|
||||
bg_opa: TRANSP
|
||||
indicator:
|
||||
radius: 0
|
||||
bg_color: ${pip_green}
|
||||
- label:
|
||||
id: ap_label
|
||||
text: "AP"
|
||||
pages:
|
||||
# 1: clock
|
||||
# STAT: weekday, date, weather, name day | clock
|
||||
- id: main_page
|
||||
on_load:
|
||||
- script.execute:
|
||||
id: select_tab
|
||||
tab: 0
|
||||
- script.execute: update_clock
|
||||
- script.execute: update_data
|
||||
widgets:
|
||||
- label:
|
||||
id: clock_label
|
||||
align: CENTER
|
||||
y: -32
|
||||
text_font: font_clock
|
||||
text: "--:--"
|
||||
align: TOP_MID
|
||||
y: 68
|
||||
text: "STATUS"
|
||||
- label:
|
||||
id: weekday_label
|
||||
x: 40
|
||||
y: 108
|
||||
pad_left: 8
|
||||
pad_right: 8
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
text_color: ${pip_bg}
|
||||
text_font: font_big
|
||||
text: "--"
|
||||
- label:
|
||||
id: date_label
|
||||
x: 40
|
||||
y: 164
|
||||
text_font: font_big
|
||||
text: ""
|
||||
- label:
|
||||
id: stat_icon
|
||||
x: 36
|
||||
y: 222
|
||||
text_font: font_weather
|
||||
text: ""
|
||||
- label:
|
||||
id: stat_temp
|
||||
x: 124
|
||||
y: 236
|
||||
text_font: font_big
|
||||
text: "--"
|
||||
- label:
|
||||
id: nameday_label
|
||||
x: 40
|
||||
y: 320
|
||||
width: 380
|
||||
long_mode: WRAP
|
||||
text_color: ${pip_dim}
|
||||
text: ""
|
||||
- obj:
|
||||
x: 470
|
||||
y: 104
|
||||
width: 290
|
||||
height: 316
|
||||
border_width: 3
|
||||
border_color: ${pip_green}
|
||||
widgets:
|
||||
- label:
|
||||
id: clock_label
|
||||
align: CENTER
|
||||
text_font: font_clock
|
||||
text_align: CENTER
|
||||
text_line_space: -16
|
||||
text: "--\n--"
|
||||
|
||||
# 2: status (shown until Home Assistant connects)
|
||||
# DATA: weather from Home Assistant as a Pip-Boy list
|
||||
- id: data_page
|
||||
on_load:
|
||||
- script.execute:
|
||||
id: select_tab
|
||||
tab: 1
|
||||
- script.execute: update_data
|
||||
widgets:
|
||||
- label:
|
||||
align: TOP_MID
|
||||
y: 68
|
||||
text: "WEATHER"
|
||||
- label:
|
||||
x: 16
|
||||
y: 106
|
||||
width: 758
|
||||
text_align: RIGHT
|
||||
text_font: font_small
|
||||
text_color: ${pip_dim}
|
||||
text: "VALUE"
|
||||
- obj:
|
||||
x: 16
|
||||
y: 130
|
||||
width: 768
|
||||
height: SIZE_CONTENT
|
||||
layout:
|
||||
type: flex
|
||||
flex_flow: column
|
||||
widgets:
|
||||
- !include {file: common/pipboy_row.yaml, vars: {row: row_temp, name: TEMPERATURE, idx: 0}}
|
||||
- !include {file: common/pipboy_row.yaml, vars: {row: row_cond, name: CONDITIONS, idx: 1}}
|
||||
- !include {file: common/pipboy_row.yaml, vars: {row: row_hum, name: HUMIDITY, idx: 2}}
|
||||
- !include {file: common/pipboy_row.yaml, vars: {row: row_press, name: PRESSURE, idx: 3}}
|
||||
- !include {file: common/pipboy_row.yaml, vars: {row: row_wind, name: WIND, idx: 4}}
|
||||
|
||||
# MAP: baked map (no images over the native API), live person markers
|
||||
- id: map_page
|
||||
on_load:
|
||||
- script.execute:
|
||||
id: select_tab
|
||||
tab: 2
|
||||
- script.execute: update_map
|
||||
widgets:
|
||||
- label:
|
||||
align: TOP_MID
|
||||
y: 68
|
||||
text: "LOCAL MAP"
|
||||
- image:
|
||||
src: pipboy_map
|
||||
x: 16
|
||||
y: ${map_y}
|
||||
# home: square in a square, centre of the map
|
||||
- obj:
|
||||
x: 391 # 16 + map_w / 2 - 9
|
||||
y: 253 # map_y + map_h / 2 - 9
|
||||
width: 18
|
||||
height: 18
|
||||
border_width: 2
|
||||
border_color: ${pip_green}
|
||||
widgets:
|
||||
- obj:
|
||||
align: CENTER
|
||||
width: 6
|
||||
height: 6
|
||||
bg_color: ${pip_green}
|
||||
bg_opa: COVER
|
||||
# ring + name; the second one has the name on the left so both stay readable at home
|
||||
- obj:
|
||||
id: marker_romanko
|
||||
hidden: true
|
||||
width: SIZE_CONTENT
|
||||
height: SIZE_CONTENT
|
||||
layout:
|
||||
type: flex
|
||||
flex_flow: ROW
|
||||
flex_align_cross: center
|
||||
pad_column: 6
|
||||
widgets:
|
||||
- obj:
|
||||
width: 14
|
||||
height: 14
|
||||
radius: 7
|
||||
border_width: 2
|
||||
border_color: ${pip_green}
|
||||
- label:
|
||||
text_font: font_small
|
||||
text: "Romanko"
|
||||
- obj:
|
||||
id: marker_janko
|
||||
hidden: true
|
||||
width: SIZE_CONTENT
|
||||
height: SIZE_CONTENT
|
||||
layout:
|
||||
type: flex
|
||||
flex_flow: ROW_REVERSE
|
||||
flex_align_cross: center
|
||||
pad_column: 6
|
||||
widgets:
|
||||
- obj:
|
||||
width: 14
|
||||
height: 14
|
||||
radius: 7
|
||||
border_width: 2
|
||||
border_color: ${pip_green}
|
||||
- label:
|
||||
text_font: font_small
|
||||
text: "Janko"
|
||||
- label:
|
||||
x: 26
|
||||
y: 392 # map_y + map_h - 28
|
||||
text_font: font_small
|
||||
text_color: ${pip_dim}
|
||||
text: "© OpenStreetMap"
|
||||
- label:
|
||||
x: 16
|
||||
y: 388
|
||||
width: 758
|
||||
text_align: RIGHT
|
||||
text: "${map_name}"
|
||||
|
||||
# SYS: status (shown until Home Assistant connects)
|
||||
- id: status_page
|
||||
on_load:
|
||||
- script.execute:
|
||||
id: select_tab
|
||||
tab: 3
|
||||
- script.execute: update_status
|
||||
widgets:
|
||||
- label:
|
||||
align: TOP_MID
|
||||
y: 68
|
||||
text: "SYSTEM"
|
||||
- image:
|
||||
src: esphome_logo
|
||||
align: TOP_MID
|
||||
y: 16
|
||||
y: 104
|
||||
- label:
|
||||
align: TOP_MID
|
||||
y: 140
|
||||
y: 196
|
||||
text_font: font_title
|
||||
text_color: 0xFFFFFF
|
||||
text: "${name}"
|
||||
- obj:
|
||||
id: status_lines
|
||||
x: 60
|
||||
y: 196
|
||||
y: 252
|
||||
width: 700
|
||||
height: SIZE_CONTENT
|
||||
bg_opa: TRANSP
|
||||
border_width: 0
|
||||
pad_all: 0
|
||||
scrollbar_mode: "OFF"
|
||||
layout:
|
||||
type: flex
|
||||
|
||||
+2
-5
@@ -80,14 +80,11 @@ packages:
|
||||
|
||||
external_components:
|
||||
- source: github://m5stack/esphome-yaml
|
||||
components: [axp2101, aw88298, aw9523b, si12t, m5ioe1, ftservo, scs9009]
|
||||
components: [axp2101, aw88298, aw9523b, si12t, ftservo, scs9009]
|
||||
refresh: 0s
|
||||
- source: github://randybb/esphome-components
|
||||
components: [audio_spectrum]
|
||||
components: [audio_spectrum, m5ioe1]
|
||||
refresh: 1h
|
||||
# stop the microphone before the response with streaming STT (HA Cloud), drop once upstream
|
||||
- source: github://randybb/esphome@va-stop-mic-streaming-stt
|
||||
components: [voice_assistant]
|
||||
|
||||
globals:
|
||||
- id: in_love
|
||||
|
||||
@@ -507,3 +507,35 @@ interval:
|
||||
id(gnss_switch).turn_off();
|
||||
id(gnss_enable).turn_off();
|
||||
}
|
||||
|
||||
font:
|
||||
- file: "gfonts://Roboto"
|
||||
id: font_small
|
||||
size: 12
|
||||
|
||||
display:
|
||||
- platform: ssd1306_i2c
|
||||
model: "SSD1306 128x64"
|
||||
address: 0x3C
|
||||
i2c_id: system_i2c
|
||||
update_interval: 2s
|
||||
lambda: |-
|
||||
it.printf(0, 0, id(font_small), "%s %s", id(modem_network).has_state() ? id(modem_network).state.c_str() : "--",
|
||||
id(modem_operator).state.c_str());
|
||||
if (id(modem_rssi).has_state() && !std::isnan(id(modem_rssi).state))
|
||||
it.printf(127, 0, id(font_small), TextAlign::TOP_RIGHT, "%.0f dBm", id(modem_rssi).state);
|
||||
it.printf(0, 16, id(font_small), "PPP: %s", id(atmodem).is_connected() ? "OK" : "--");
|
||||
it.printf(127, 16, id(font_small), TextAlign::TOP_RIGHT, "MQTT: %s", id(mqtt_client)->is_connected() ? "OK" : "--");
|
||||
if (std::isnan(id(latitude).state))
|
||||
it.printf(0, 32, id(font_small), "GNSS: no fix");
|
||||
else
|
||||
it.printf(0, 32, id(font_small), "%.5f %.5f", id(latitude).state, id(longitude).state);
|
||||
auto now = id(sntp_time).now();
|
||||
if (now.is_valid())
|
||||
it.strftime(0, 48, id(font_small), "%H:%M", now);
|
||||
else
|
||||
it.printf(0, 48, id(font_small), "Up %.2f d", id(uptime_sensor).state);
|
||||
// The unrounded value; HA only gets 10 % steps
|
||||
float bat = std::isnan(id(battery_soc).state) ? id(battery_level).state : id(battery_soc).state;
|
||||
if (!std::isnan(bat))
|
||||
it.printf(127, 48, id(font_small), TextAlign::TOP_RIGHT, "Bat %.0f%%", bat);
|
||||
@@ -37,3 +37,5 @@ thread_tlv: "0E080000000000010000"
|
||||
|
||||
# ANT+ network key (8 bytes hex), from thisisant.com
|
||||
ant_plus_network_key: "0000000000000000"
|
||||
wifi_ssid_0: "ssid"
|
||||
wifi_password_0: "password"
|
||||
Reference in new issue
Block a user