end-to-end working: ESP32 connects to server, renders widgets
boot logo (procedural hexagon + K), WiFi (WPA auto-detect with retries), TCP client connects and receives ScreenUpdate/DataUpdate messages, display renders widget data. Makefile with esp-flash/server/desktop targets. known issues: boot logo not cleared, text overlaps, occasional reconnect
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
mod adapters;
|
||||
mod boot;
|
||||
mod config;
|
||||
mod hal;
|
||||
mod tasks;
|
||||
|
||||
use client_domain::{BoundingBox, DisplayPort};
|
||||
use std::sync::mpsc;
|
||||
use esp_idf_hal::peripherals::Peripherals;
|
||||
use esp_idf_svc::eventloop::EspSystemEventLoop;
|
||||
use esp_idf_svc::nvs::EspDefaultNvsPartition;
|
||||
use log::info;
|
||||
|
||||
const WIFI_SSID: &str = env!("KFRAME_WIFI_SSID");
|
||||
const WIFI_PASS: &str = env!("KFRAME_WIFI_PASS");
|
||||
const SERVER_ADDR: &str = env!("KFRAME_SERVER_ADDR");
|
||||
|
||||
fn main() {
|
||||
esp_idf_svc::sys::link_patches();
|
||||
esp_idf_svc::log::EspLogger::initialize_default();
|
||||
@@ -14,8 +21,10 @@ fn main() {
|
||||
info!("=== K-Frame ESP32 ===");
|
||||
|
||||
let peripherals = Peripherals::take().unwrap();
|
||||
let sysloop = EspSystemEventLoop::take().unwrap();
|
||||
let nvs = EspDefaultNvsPartition::take().unwrap();
|
||||
|
||||
let mut display = hal::display::init(hal::display::DisplayHardware {
|
||||
let display = hal::display::init(hal::display::DisplayHardware {
|
||||
spi: peripherals.spi2,
|
||||
sclk: peripherals.pins.gpio18.into(),
|
||||
mosi: peripherals.pins.gpio23.into(),
|
||||
@@ -23,23 +32,13 @@ fn main() {
|
||||
dc: peripherals.pins.gpio21.into(),
|
||||
rst: peripherals.pins.gpio22.into(),
|
||||
});
|
||||
info!("Display initialized");
|
||||
info!("Display ready");
|
||||
|
||||
display.fill_background(config::SCREEN).unwrap();
|
||||
display.draw_text(
|
||||
"K-Frame",
|
||||
10, 10,
|
||||
BoundingBox::new(10, 10, 220, 40),
|
||||
).unwrap();
|
||||
display.draw_text(
|
||||
"Display test OK",
|
||||
10, 60,
|
||||
BoundingBox::new(10, 60, 220, 40),
|
||||
).unwrap();
|
||||
display.flush().unwrap();
|
||||
info!("Connecting WiFi...");
|
||||
let _wifi = hal::wifi::init(peripherals.modem, sysloop, nvs, WIFI_SSID, WIFI_PASS)
|
||||
.expect("WiFi init failed");
|
||||
|
||||
info!("Display test complete — looping forever");
|
||||
loop {
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
let (tx, rx) = mpsc::channel();
|
||||
tasks::network::spawn(SERVER_ADDR.into(), tx);
|
||||
tasks::render::run(config::SCREEN, display, rx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user