From 3a8931d52f07d27bd62544236ccc60d3dc0027d7 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Sun, 26 Apr 2026 14:45:04 +0800 Subject: [PATCH 01/15] feat: add new-screen feature for larger display support Add a `new-screen` feature flag to support a 320x170 display (vs original 284x78). This includes: - Display dimensions: 320x170 (new) vs 284x78 (old) - LCD gap adjustments: 0,36 (new) vs 18,82 (old) - Color inversion enabled for new screen - JPEG decoder dimensions updated - Backlight logic inverted (high vs low) Co-Authored-By: Claude Opus 4.5 --- Cargo.toml | 1 + src/lcd.rs | 39 +++++++++++++++++++++++++++++++-------- src/main.rs | 6 +++++- src/ws.rs | 6 +++++- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f6d24ff..73d4968 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ opt-level = "z" [features] default = [] +new-screen = [] experimental = ["esp-idf-svc/experimental"] diff --git a/src/lcd.rs b/src/lcd.rs index 70b92b2..86bebd3 100644 --- a/src/lcd.rs +++ b/src/lcd.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, fmt::Debug}; +use std::fmt::Debug; use embedded_graphics::{ framebuffer::{buffer_size, Framebuffer}, @@ -20,10 +20,16 @@ use esp_idf_svc::{ }; use u8g2_fonts::U8g2TextStyle; -use crate::protocol::ClientMessage; +#[cfg(feature = "new-screen")] +pub const DISPLAY_WIDTH: usize = 320; +#[cfg(feature = "new-screen")] +pub const DISPLAY_HEIGHT: usize = 170; +#[cfg(not(feature = "new-screen"))] pub const DISPLAY_WIDTH: usize = 284; +#[cfg(not(feature = "new-screen"))] pub const DISPLAY_HEIGHT: usize = 78; + static mut ESP_LCD_PANEL_HANDLE: esp_idf_svc::sys::esp_lcd_panel_handle_t = std::ptr::null_mut(); pub type ColorFormat = Rgb565; @@ -78,11 +84,18 @@ pub fn init_lcd(cs: Gpio12, dc: Gpio13, rst: Gpio14) -> Result<(), EspError> { const DISPLAY_MIRROR_X: bool = true; const DISPLAY_MIRROR_Y: bool = false; const DISPLAY_SWAP_XY: bool = true; + #[cfg(feature = "new-screen")] + const DISPLAY_INVERT_COLOR: bool = true; + #[cfg(not(feature = "new-screen"))] const DISPLAY_INVERT_COLOR: bool = false; ::log::info!("Reset LCD panel"); unsafe { - esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; + if cfg!(feature = "new-screen") { + esp!(esp_lcd_panel_set_gap(panel, 0, 36))?; + } else { + esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; + } esp!(esp_lcd_panel_reset(panel))?; esp!(esp_lcd_panel_init(panel))?; esp!(esp_lcd_panel_invert_color(panel, DISPLAY_INVERT_COLOR))?; @@ -427,7 +440,11 @@ mod new_jpg { pub fn flush_to_lcd(&self) -> i32 { let ptr = unsafe { std::slice::from_raw_parts(self.ptr.cast_const(), self.size) }; - super::flush_display(ptr, 0, 0, 288, 80) + if cfg!(feature = "new-screen") { + super::flush_display(ptr, 0, 0, 320, 168) + } else { + super::flush_display(ptr, 0, 0, 288, 80) + } } } @@ -448,8 +465,14 @@ mod new_jpg { // Generate default configuration let mut config = jpeg_dec_config_t::default(); config.output_type = jpeg_pixel_format_t_JPEG_PIXEL_FORMAT_RGB565_LE; - config.clipper.height = 80; - config.clipper.width = 288; + + if cfg!(feature = "new-screen") { + config.clipper.height = 168; + config.clipper.width = 320; + } else { + config.clipper.height = 80; + config.clipper.width = 288; + } // Create jpeg_dec handle let decoder = JpegDecoder::open(&config) @@ -476,10 +499,10 @@ mod new_jpg { // Calculate output length based on pixel format // Default to RGB565 (2 bytes per pixel) - let out_len = (*out_info).width * (*out_info).height * 2; + let out_len = (*out_info).width as usize * (*out_info).height as usize * 2; // Allocate aligned output buffer - let out_buf = JpegBuffer::new(out_len as usize, 16)?; + let out_buf = JpegBuffer::new(out_len, 16)?; jpeg_io.outbuf = out_buf.ptr; diff --git a/src/main.rs b/src/main.rs index 5519442..08d402e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,7 +88,11 @@ fn main() -> anyhow::Result<()> { let partition = esp_idf_svc::nvs::EspDefaultNvsPartition::take()?; let mut bl = esp_idf_svc::hal::gpio::PinDriver::output(peripherals.pins.gpio11)?; - bl.set_low()?; + if cfg!(feature = "new-screen") { + bl.set_high()?; + } else { + bl.set_low()?; + } // let mut backlight = lcd::backlight_init(peripherals.pins.gpio11.into())?; // lcd::set_backlight(&mut backlight, 40).unwrap(); diff --git a/src/ws.rs b/src/ws.rs index 75d5e7c..e3c8777 100644 --- a/src/ws.rs +++ b/src/ws.rs @@ -11,7 +11,11 @@ pub struct Server { impl Server { pub async fn new(uri: String) -> anyhow::Result { - let uri = format!("{}?pty=false&img=true&width=288&height=80", uri); + let uri = if cfg!(feature = "new-screen") { + format!("{}?pty=false&img=true&width=320&height=168", uri) + } else { + format!("{}?pty=false&img=true&width=288&height=80", uri) + }; let (ws, _resp) = tokio_websockets::ClientBuilder::new() .uri(&uri)? .connect() From 40fc34df16ccbc6ed2459543d395196dbc9f2ee1 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Tue, 5 May 2026 02:13:22 +0800 Subject: [PATCH 02/15] fix: remove rustls-rustcrypto because it is unstable --- Cargo.toml | 4 ++-- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 73d4968..43c0bb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,8 +71,8 @@ tokio-websockets = { version = "0.13", features = [ "rustls-webpki-roots" ] } -rustls-rustcrypto = { git = "https://github.com/RustCrypto/rustls-rustcrypto",rev="aecee37208823f6a4ffabeb7c0a1227015b131cb" } -elliptic-curve = { version = "=0.14.0-rc.29", default-features = false } +# rustls-rustcrypto = { git = "https://github.com/RustCrypto/rustls-rustcrypto",rev="aecee37208823f6a4ffabeb7c0a1227015b131cb" } +# elliptic-curve = { version = "=0.14.0-rc.29", default-features = false } http = "1.3" diff --git a/src/main.rs b/src/main.rs index 08d402e..1fd3af3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -392,7 +392,7 @@ fn main() -> anyhow::Result<()> { } if setting.server_url.starts_with("wss") { - _ = rustls_rustcrypto::provider().install_default(); + // _ = rustls_rustcrypto::provider().install_default(); lcd::display_text(&mut target, "Syncing time...", 0)?; let r = sync_time(&mut target); if r.is_err() { From 8029a9a9c9688e29d455c77f23ee08b60cc3f86c Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Tue, 5 May 2026 02:13:51 +0800 Subject: [PATCH 03/15] feat: ota support new-screen --- src/ota.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ota.rs b/src/ota.rs index 09ef371..accc7dc 100644 --- a/src/ota.rs +++ b/src/ota.rs @@ -78,7 +78,11 @@ fn main() -> anyhow::Result<()> { let sysloop = esp_idf_svc::eventloop::EspSystemEventLoop::take()?; let mut bl = esp_idf_svc::hal::gpio::PinDriver::output(peripherals.pins.gpio11)?; - bl.set_low()?; + if cfg!(feature = "new-screen") { + bl.set_high()?; + } else { + bl.set_low()?; + } lcd::init_spi( peripherals.spi3, @@ -280,8 +284,16 @@ mod lcd { }; use u8g2_fonts::U8g2TextStyle; + #[cfg(feature = "new-screen")] + pub const DISPLAY_WIDTH: usize = 320; + #[cfg(feature = "new-screen")] + pub const DISPLAY_HEIGHT: usize = 170; + + #[cfg(not(feature = "new-screen"))] pub const DISPLAY_WIDTH: usize = 284; + #[cfg(not(feature = "new-screen"))] pub const DISPLAY_HEIGHT: usize = 78; + static mut ESP_LCD_PANEL_HANDLE: esp_idf_svc::sys::esp_lcd_panel_handle_t = std::ptr::null_mut(); pub type ColorFormat = Rgb565; @@ -341,11 +353,18 @@ mod lcd { const DISPLAY_MIRROR_X: bool = true; const DISPLAY_MIRROR_Y: bool = false; const DISPLAY_SWAP_XY: bool = true; + #[cfg(feature = "new-screen")] + const DISPLAY_INVERT_COLOR: bool = true; + #[cfg(not(feature = "new-screen"))] const DISPLAY_INVERT_COLOR: bool = false; ::log::info!("Reset LCD panel"); unsafe { - esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; + if cfg!(feature = "new-screen") { + esp!(esp_lcd_panel_set_gap(panel, 0, 34))?; + } else { + esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; + } esp!(esp_lcd_panel_reset(panel))?; esp!(esp_lcd_panel_init(panel))?; esp!(esp_lcd_panel_invert_color(panel, DISPLAY_INVERT_COLOR))?; From d47c9eea315bce87e99d811c2f6ead60c790a954 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Fri, 8 May 2026 16:03:28 +0800 Subject: [PATCH 04/15] fix: lock tokio to 1.48.0 to fix random runtime crash Tokio 1.50.0+ had compatibility issues with ESP-IDF environment, causing intermittent LoadProhibited panics in CurrentThread::new. Co-Authored-By: Claude Opus 4.5 --- Cargo.lock | 639 +---------------------------------------------------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 636 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd704fd..1999fd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,41 +8,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" -[[package]] -name = "aead" -version = "0.6.0-rc.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b657e772794c6b04730ea897b66a058ccd866c16d1967da05eeeecec39043fe" -dependencies = [ - "crypto-common", - "inout", -] - -[[package]] -name = "aes" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8" -dependencies = [ - "cipher", - "cpubits", - "cpufeatures 0.3.0", -] - -[[package]] -name = "aes-gcm" -version = "0.11.0-rc.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22c0c90bbe8d4f77c3ca9ddabe41a1f8382d6fc1f7cea89459d0f320371f972" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - [[package]] name = "aho-corasick" version = "1.1.4" @@ -135,24 +100,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" -[[package]] -name = "base16ct" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" - [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" - [[package]] name = "bindgen" version = "0.71.1" @@ -185,15 +138,6 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" -[[package]] -name = "block-buffer" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" -dependencies = [ - "hybrid-array", -] - [[package]] name = "bstr" version = "1.12.1" @@ -310,29 +254,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" -[[package]] -name = "chacha20" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures 0.3.0", -] - -[[package]] -name = "chacha20poly1305" -version = "0.11.0-rc.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9ed179664f12fd6f155f6dd632edf5f3806d48c228c67ff78366f2a0eb6b5e" -dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", -] - [[package]] name = "chrono" version = "0.4.44" @@ -344,17 +265,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "cipher" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34d8227fe1ba289043aeb13792056ff80fd6de1a9f49137a5f499de8e8c78ea" -dependencies = [ - "block-buffer", - "crypto-common", - "inout", -] - [[package]] name = "clang-sys" version = "1.8.1" @@ -375,24 +285,12 @@ dependencies = [ "cc", ] -[[package]] -name = "cmov" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f88a43d011fc4a6876cb7344703e297c71dda42494fee094d5f7c76bf13f746" - [[package]] name = "color_quant" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" -[[package]] -name = "const-oid" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" - [[package]] name = "const_format" version = "0.2.35" @@ -419,30 +317,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "cpubits" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef0c543070d296ea414df2dd7625d1b24866ce206709d8a4a424f28377f5861" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "cpufeatures" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" -dependencies = [ - "libc", -] - [[package]] name = "crc32fast" version = "1.5.0" @@ -483,89 +357,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "crypto-bigint" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a0d26b245348befa0c121944541476763dcc46ede886c88f9d12e1697d27c3" -dependencies = [ - "cpubits", - "ctutils", - "hybrid-array", - "num-traits", - "rand_core", - "serdect", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710" -dependencies = [ - "hybrid-array", - "rand_core", -] - -[[package]] -name = "crypto-primes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21f41f23de7d24cdbda7f0c4d9c0351f99a4ceb258ef30e5c1927af8987ffe5a" -dependencies = [ - "crypto-bigint", - "libm", - "rand_core", -] - -[[package]] -name = "ctr" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17469f8eb9bdbfad10f71f4cfddfd38b01143520c0e717d8796ccb4d44d44e42" -dependencies = [ - "cipher", -] - -[[package]] -name = "ctutils" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" -dependencies = [ - "cmov", - "subtle", -] - -[[package]] -name = "curve25519-dalek" -version = "5.0.0-pre.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335f1947f241137a14106b6f5acc5918a5ede29c9d71d3f2cb1678d5075d9fc3" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "curve25519-dalek-derive", - "digest", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "cvt" version = "0.1.2" @@ -650,97 +441,12 @@ dependencies = [ "thiserror 2.0.18", ] -[[package]] -name = "der" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fd89660b2dc699704064e59e9dba0147b903e85319429e131620d022be411b" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" -dependencies = [ - "block-buffer", - "const-oid", - "crypto-common", - "ctutils", -] - -[[package]] -name = "ecdsa" -version = "0.17.0-rc.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91bbdd377139884fafcad8dc43a760a3e1e681aa26db910257fa6535b70e1829" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", - "zeroize", -] - -[[package]] -name = "ed25519" -version = "3.0.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e914c7c52decb085cea910552e24c63ac019e3ab8bf001ff736da9a9d9d890" -dependencies = [ - "pkcs8", - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "3.0.0-pre.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053618a4c3d3bc24f188aa660ae75a46eeab74ef07fb415c61431e5e7cd4749b" -dependencies = [ - "curve25519-dalek", - "ed25519", - "serde", - "sha2", - "signature", - "subtle", - "zeroize", -] - [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -[[package]] -name = "elliptic-curve" -version = "0.14.0-rc.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e84043d573efd4ac9d2d125817979a379204bf7e328b25a4a30487e8d100e618" -dependencies = [ - "base16ct", - "crypto-bigint", - "crypto-common", - "digest", - "hkdf", - "hybrid-array", - "pem-rfc7468", - "pkcs8", - "rand_core", - "rustcrypto-ff", - "rustcrypto-group", - "sec1", - "subtle", - "zeroize", -] - [[package]] name = "embassy-futures" version = "0.1.2" @@ -1045,12 +751,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - [[package]] name = "filetime" version = "0.2.27" @@ -1223,20 +923,10 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "rand_core", "wasip2", "wasip3", ] -[[package]] -name = "ghash" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5" -dependencies = [ - "polyval", -] - [[package]] name = "gif" version = "0.14.2" @@ -1345,24 +1035,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hkdf" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" -dependencies = [ - "hmac", -] - -[[package]] -name = "hmac" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" -dependencies = [ - "digest", -] - [[package]] name = "home" version = "0.5.12" @@ -1388,17 +1060,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" -[[package]] -name = "hybrid-array" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3944cf8cf766b40e2a1a333ee5e9b563f854d5fa49d6a8ca2764e97c6eddb214" -dependencies = [ - "subtle", - "typenum", - "zeroize", -] - [[package]] name = "iana-time-zone" version = "0.1.65" @@ -1489,15 +1150,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "inout" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" -dependencies = [ - "hybrid-array", -] - [[package]] name = "itertools" version = "0.13.0" @@ -1545,12 +1197,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "libm" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" - [[package]] name = "libredox" version = "0.1.16" @@ -1729,80 +1375,18 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "p256" -version = "0.14.0-rc.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f0a10fe314869359cb2901342b045f4e5a962ef9febc006f03d2a8c848fe4c" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primefield", - "primeorder", - "sha2", -] - -[[package]] -name = "p384" -version = "0.14.0-rc.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b079e66810c55ab3d6ba424e056dc4aefcdb8046c8c3f3816142edbdd7af7721" -dependencies = [ - "ecdsa", - "elliptic-curve", - "fiat-crypto", - "primefield", - "primeorder", - "sha2", -] - [[package]] name = "parking" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "pem-rfc7468" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" -dependencies = [ - "base64ct", -] - [[package]] name = "pin-project-lite" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" -[[package]] -name = "pkcs1" -version = "0.8.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "pkcs8" -version = "0.11.0-rc.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12922b6296c06eb741b02d7b5161e3aaa22864af38dfa025a1a3ba3f68c84577" -dependencies = [ - "der", - "spki", -] - [[package]] name = "plain" version = "0.2.3" @@ -1822,27 +1406,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "poly1305" -version = "0.9.0-rc.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19feddcbdf17fad33f40041c7f9e768faf19455f32a6d52ba1b8b65ffc7b1cae" -dependencies = [ - "cpufeatures 0.3.0", - "universal-hash", -] - -[[package]] -name = "polyval" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfc63250416fea14f5749b90725916a6c903f599d51cb635aa7a52bfd03eede" -dependencies = [ - "cpubits", - "cpufeatures 0.3.0", - "universal-hash", -] - [[package]] name = "prettyplease" version = "0.2.37" @@ -1853,29 +1416,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "primefield" -version = "0.14.0-rc.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6543f5eec854fbf74ba5ef651fbdc9408919b47c3e1526623687135c16d12e9" -dependencies = [ - "crypto-bigint", - "crypto-common", - "rand_core", - "rustcrypto-ff", - "subtle", - "zeroize", -] - -[[package]] -name = "primeorder" -version = "0.14.0-rc.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "569d9ad6ef822bb0322c7e7d84e5e286244050bd5246cac4c013535ae91c2c90" -dependencies = [ - "elliptic-curve", -] - [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -1943,12 +1483,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rand_core" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" - [[package]] name = "redox_syscall" version = "0.7.4" @@ -2001,16 +1535,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "rfc6979" -version = "0.5.0-rc.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a3127ee32baec36af75b4107082d9bd823501ec14a4e016be4b6b37faa74ae" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "ring" version = "0.17.14" @@ -2044,61 +1568,12 @@ dependencies = [ "serde", ] -[[package]] -name = "rsa" -version = "0.10.0-rc.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ed3e93fc7e473e464b9726f4759659e72bc8665e4b8ea227547024f416d905" -dependencies = [ - "const-oid", - "crypto-bigint", - "crypto-primes", - "digest", - "pkcs1", - "pkcs8", - "rand_core", - "sha2", - "signature", - "spki", - "zeroize", -] - [[package]] name = "rustc-hash" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rustcrypto-ff" -version = "0.14.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2a8adb347447693cd2ba0d218c4b66c62da9b0a5672b17b981e4291ec65ff6" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "rustcrypto-group" -version = "0.14.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "369f9b61aa45933c062c9f6b5c3c50ab710687eca83dd3802653b140b43f85ed" -dependencies = [ - "rand_core", - "rustcrypto-ff", - "subtle", -] - [[package]] name = "rustix" version = "0.38.44" @@ -2147,34 +1622,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-rustcrypto" -version = "0.0.2-alpha" -source = "git+https://github.com/RustCrypto/rustls-rustcrypto?rev=aecee37208823f6a4ffabeb7c0a1227015b131cb#aecee37208823f6a4ffabeb7c0a1227015b131cb" -dependencies = [ - "aead", - "aes-gcm", - "chacha20poly1305", - "crypto-common", - "der", - "digest", - "ecdsa", - "ed25519-dalek", - "getrandom 0.4.2", - "hmac", - "p256", - "p384", - "paste", - "pkcs8", - "rsa", - "rustls", - "rustls-pki-types", - "sec1", - "sha2", - "signature", - "x25519-dalek", -] - [[package]] name = "rustls-webpki" version = "0.103.12" @@ -2201,20 +1648,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "sec1" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d" -dependencies = [ - "base16ct", - "ctutils", - "der", - "hybrid-array", - "subtle", - "zeroize", -] - [[package]] name = "semver" version = "1.0.28" @@ -2268,49 +1701,18 @@ dependencies = [ "zmij", ] -[[package]] -name = "serdect" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9af4a3e75ebd5599b30d4de5768e00b5095d518a79fefc3ecbaf77e665d1ec06" -dependencies = [ - "base16ct", - "serde", -] - [[package]] name = "sha1_smol" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" -[[package]] -name = "sha2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.0", - "digest", -] - [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "signature" -version = "3.0.0-rc.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1880df446116126965eeec169136b2e0251dba37c6223bcc819569550edea3" -dependencies = [ - "digest", - "rand_core", -] - [[package]] name = "simd-adler32" version = "0.3.9" @@ -2339,16 +1741,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "spki" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -2482,9 +1874,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.52.0" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91135f59b1cbf38c91e73cf3386fca9bb77915c45ce2771460c9d92f0f3d776" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ "bytes", "libc", @@ -2497,9 +1889,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.7.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" dependencies = [ "proc-macro2", "quote", @@ -2618,16 +2010,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "universal-hash" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" -dependencies = [ - "crypto-common", - "ctutils", -] - [[package]] name = "untrusted" version = "0.9.0" @@ -2659,7 +2041,6 @@ dependencies = [ "ansi-parser 0.9.1", "anyhow", "bytes", - "elliptic-curve", "embedded-graphics", "embedded-svc", "embedded-text", @@ -2672,7 +2053,6 @@ dependencies = [ "image", "log", "rmp-serde", - "rustls-rustcrypto", "serde", "serde_json", "tokio", @@ -3084,17 +2464,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "x25519-dalek" -version = "3.0.0-pre.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d5d6ff67acd3945b933e592bfa7143db4fcbb2f871754b6b9fbd7847fc5aea" -dependencies = [ - "curve25519-dalek", - "rand_core", - "zeroize", -] - [[package]] name = "zerocopy" version = "0.8.48" diff --git a/Cargo.toml b/Cargo.toml index c2c7150..9b11c24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ image = { version = "0.25.6", default-features = false, features = [ "webp", ] } -tokio = { version = "1.43.0", features = [ +tokio = { version = "=1.48.0", features = [ "net", "rt", "time", From 54c6f13d9014c96eb418e8592280e2d5ef900f36 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 11 May 2026 01:04:46 +0800 Subject: [PATCH 05/15] refactor: rename feature new-screen to max2 Co-Authored-By: Claude Opus 4.5 --- Cargo.toml | 2 +- src/lcd.rs | 18 +++++++++--------- src/main.rs | 2 +- src/ota.rs | 16 ++++++++-------- src/ws.rs | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9b11c24..bc4b97f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ opt-level = "z" [features] default = [] -new-screen = [] +max2 = [] experimental = ["esp-idf-svc/experimental"] diff --git a/src/lcd.rs b/src/lcd.rs index 86bebd3..b4271a4 100644 --- a/src/lcd.rs +++ b/src/lcd.rs @@ -20,14 +20,14 @@ use esp_idf_svc::{ }; use u8g2_fonts::U8g2TextStyle; -#[cfg(feature = "new-screen")] +#[cfg(feature = "max2")] pub const DISPLAY_WIDTH: usize = 320; -#[cfg(feature = "new-screen")] +#[cfg(feature = "max2")] pub const DISPLAY_HEIGHT: usize = 170; -#[cfg(not(feature = "new-screen"))] +#[cfg(not(feature = "max2"))] pub const DISPLAY_WIDTH: usize = 284; -#[cfg(not(feature = "new-screen"))] +#[cfg(not(feature = "max2"))] pub const DISPLAY_HEIGHT: usize = 78; static mut ESP_LCD_PANEL_HANDLE: esp_idf_svc::sys::esp_lcd_panel_handle_t = std::ptr::null_mut(); @@ -84,14 +84,14 @@ pub fn init_lcd(cs: Gpio12, dc: Gpio13, rst: Gpio14) -> Result<(), EspError> { const DISPLAY_MIRROR_X: bool = true; const DISPLAY_MIRROR_Y: bool = false; const DISPLAY_SWAP_XY: bool = true; - #[cfg(feature = "new-screen")] + #[cfg(feature = "max2")] const DISPLAY_INVERT_COLOR: bool = true; - #[cfg(not(feature = "new-screen"))] + #[cfg(not(feature = "max2"))] const DISPLAY_INVERT_COLOR: bool = false; ::log::info!("Reset LCD panel"); unsafe { - if cfg!(feature = "new-screen") { + if cfg!(feature = "max2") { esp!(esp_lcd_panel_set_gap(panel, 0, 36))?; } else { esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; @@ -440,7 +440,7 @@ mod new_jpg { pub fn flush_to_lcd(&self) -> i32 { let ptr = unsafe { std::slice::from_raw_parts(self.ptr.cast_const(), self.size) }; - if cfg!(feature = "new-screen") { + if cfg!(feature = "max2") { super::flush_display(ptr, 0, 0, 320, 168) } else { super::flush_display(ptr, 0, 0, 288, 80) @@ -466,7 +466,7 @@ mod new_jpg { let mut config = jpeg_dec_config_t::default(); config.output_type = jpeg_pixel_format_t_JPEG_PIXEL_FORMAT_RGB565_LE; - if cfg!(feature = "new-screen") { + if cfg!(feature = "max2") { config.clipper.height = 168; config.clipper.width = 320; } else { diff --git a/src/main.rs b/src/main.rs index ca5c85c..9287a16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,7 +88,7 @@ fn main() -> anyhow::Result<()> { let partition = esp_idf_svc::nvs::EspDefaultNvsPartition::take()?; let mut bl = esp_idf_svc::hal::gpio::PinDriver::output(peripherals.pins.gpio11)?; - if cfg!(feature = "new-screen") { + if cfg!(feature = "max2") { bl.set_high()?; } else { bl.set_low()?; diff --git a/src/ota.rs b/src/ota.rs index 8740c1a..9ba8514 100644 --- a/src/ota.rs +++ b/src/ota.rs @@ -78,7 +78,7 @@ fn main() -> anyhow::Result<()> { let sysloop = esp_idf_svc::eventloop::EspSystemEventLoop::take()?; let mut bl = esp_idf_svc::hal::gpio::PinDriver::output(peripherals.pins.gpio11)?; - if cfg!(feature = "new-screen") { + if cfg!(feature = "max2") { bl.set_high()?; } else { bl.set_low()?; @@ -306,14 +306,14 @@ mod lcd { }; use u8g2_fonts::U8g2TextStyle; - #[cfg(feature = "new-screen")] + #[cfg(feature = "max2")] pub const DISPLAY_WIDTH: usize = 320; - #[cfg(feature = "new-screen")] + #[cfg(feature = "max2")] pub const DISPLAY_HEIGHT: usize = 170; - #[cfg(not(feature = "new-screen"))] + #[cfg(not(feature = "max2"))] pub const DISPLAY_WIDTH: usize = 284; - #[cfg(not(feature = "new-screen"))] + #[cfg(not(feature = "max2"))] pub const DISPLAY_HEIGHT: usize = 78; static mut ESP_LCD_PANEL_HANDLE: esp_idf_svc::sys::esp_lcd_panel_handle_t = @@ -375,14 +375,14 @@ mod lcd { const DISPLAY_MIRROR_X: bool = true; const DISPLAY_MIRROR_Y: bool = false; const DISPLAY_SWAP_XY: bool = true; - #[cfg(feature = "new-screen")] + #[cfg(feature = "max2")] const DISPLAY_INVERT_COLOR: bool = true; - #[cfg(not(feature = "new-screen"))] + #[cfg(not(feature = "max2"))] const DISPLAY_INVERT_COLOR: bool = false; ::log::info!("Reset LCD panel"); unsafe { - if cfg!(feature = "new-screen") { + if cfg!(feature = "max2") { esp!(esp_lcd_panel_set_gap(panel, 0, 34))?; } else { esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; diff --git a/src/ws.rs b/src/ws.rs index e3c8777..a22d548 100644 --- a/src/ws.rs +++ b/src/ws.rs @@ -11,7 +11,7 @@ pub struct Server { impl Server { pub async fn new(uri: String) -> anyhow::Result { - let uri = if cfg!(feature = "new-screen") { + let uri = if cfg!(feature = "max2") { format!("{}?pty=false&img=true&width=320&height=168", uri) } else { format!("{}?pty=false&img=true&width=288&height=80", uri) From b9c5d75c2b48668b06293c43339dd4a374f69358 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 11 May 2026 01:06:19 +0800 Subject: [PATCH 06/15] refactor: use hal::reset::restart instead of sys::esp_restart Co-Authored-By: Claude Opus 4.5 --- src/main.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9287a16..43fca35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -386,9 +386,7 @@ fn main() -> anyhow::Result<()> { log::error!("Failed to connect to WiFi: {:?}", r.err()); lcd::display_text(&mut target, " WiFi connection failed\n", 0)?; std::thread::sleep(std::time::Duration::from_secs(60)); - unsafe { - esp_idf_svc::sys::esp_restart(); - } + esp_idf_svc::hal::reset::restart(); } if setting.server_url.starts_with("wss") { @@ -399,9 +397,7 @@ fn main() -> anyhow::Result<()> { log::error!("Failed to sync time: {:?}", r.err()); lcd::display_text(&mut target, " Time sync failed\n", 0)?; std::thread::sleep(std::time::Duration::from_secs(60)); - unsafe { - esp_idf_svc::sys::esp_restart(); - } + esp_idf_svc::hal::reset::restart(); } } @@ -442,9 +438,7 @@ fn main() -> anyhow::Result<()> { log::info!("App exited successfully"); } - unsafe { - esp_idf_svc::sys::esp_restart(); - } + esp_idf_svc::hal::reset::restart(); } pub fn log_heap() { From f64c908d1e0319bdf79d42258737812a4b08ef9c Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 11 May 2026 01:08:05 +0800 Subject: [PATCH 07/15] feat: add runtime error handling and debug logs - Add proper error handling for Tokio runtime creation - Add heap logging at key points for debugging - Comment out BT_NIMBLE_HOST_TASK_STACK_SIZE config Co-Authored-By: Claude Opus 4.5 --- sdkconfig.defaults | 2 +- src/lcd.rs | 2 +- src/main.rs | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sdkconfig.defaults b/sdkconfig.defaults index a54d859..611ed62 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -32,5 +32,5 @@ CONFIG_BT_BLE_ENABLED=y CONFIG_BT_BLUEDROID_ENABLED=n CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_NVS_PERSIST=y -CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=5120 +# CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=5120 diff --git a/src/lcd.rs b/src/lcd.rs index b4271a4..ef668ee 100644 --- a/src/lcd.rs +++ b/src/lcd.rs @@ -44,7 +44,7 @@ pub fn init_spi(_spi: SPI3, mosi: Gpio21, clk: Gpio47) -> Result<(), EspError> { buscfg.sclk_io_num = clk.pin(); buscfg.__bindgen_anon_3.quadwp_io_num = GPIO_NUM_NC; buscfg.__bindgen_anon_4.quadhd_io_num = GPIO_NUM_NC; - buscfg.max_transfer_sz = (DISPLAY_WIDTH * DISPLAY_HEIGHT * std::mem::size_of::()) as i32; + buscfg.max_transfer_sz = 4096; esp!(unsafe { spi_bus_initialize(SPI3::device(), &buscfg, spi_common_dma_t_SPI_DMA_CH_AUTO,) }) } diff --git a/src/main.rs b/src/main.rs index 43fca35..ec0409a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -208,8 +208,20 @@ fn main() -> anyhow::Result<()> { let runtime = tokio::runtime::Builder::new_current_thread() .enable_all() - .build() - .unwrap(); + .build(); + + if let Err(e) = runtime { + log::error!("Failed to create Tokio runtime: {:?}", e); + lcd::display_text( + &mut target, + &format!("Failed to create Tokio runtime:\n{:?}", e), + 0, + )?; + std::thread::sleep(std::time::Duration::from_secs(5)); + esp_idf_svc::hal::reset::restart(); + } + + let runtime = runtime.unwrap(); let mut mode = 3; From 88d5af5a6e282ebf5c77ac2d14b15576e1eeeb24 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 11 May 2026 01:21:25 +0800 Subject: [PATCH 08/15] fix: adjust max2 LCD panel gap from 36 to 34 Co-Authored-By: Claude Opus 4.5 --- src/lcd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lcd.rs b/src/lcd.rs index ef668ee..574c5ff 100644 --- a/src/lcd.rs +++ b/src/lcd.rs @@ -92,7 +92,7 @@ pub fn init_lcd(cs: Gpio12, dc: Gpio13, rst: Gpio14) -> Result<(), EspError> { ::log::info!("Reset LCD panel"); unsafe { if cfg!(feature = "max2") { - esp!(esp_lcd_panel_set_gap(panel, 0, 36))?; + esp!(esp_lcd_panel_set_gap(panel, 0, 34))?; } else { esp!(esp_lcd_panel_set_gap(panel, 18, 82))?; } From 802dc727a94f7c804164704d59c4e40de62ea25e Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 11 May 2026 01:24:09 +0800 Subject: [PATCH 09/15] feat: add max2 build targets and CI support - Add max2, max2_bin, max2_ota_bin build targets in build.sh - Update release workflow to build and upload max2 artifacts - Add max2 feature build check to CI Co-Authored-By: Claude Opus 4.5 --- .github/workflows/release.yml | 8 ++++++++ .github/workflows/rust_ci.yml | 2 ++ build.sh | 23 ++++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5db008..d92152f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,9 +42,15 @@ jobs: - name: Build keys run: ./build.sh keys + - name: Build max2 + run: ./build.sh max2 + - name: Build keys_ota_bin run: ./build.sh keys_ota_bin + - name: Build max2_ota_bin + run: ./build.sh max2_ota_bin + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -52,6 +58,8 @@ jobs: path: | ./vibekeys_ota.bin ./vibekeys.bin + ./vibekeys_max2_ota.bin + ./vibekeys_max2.bin release: needs: build diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml index 0b58fed..d9e3862 100644 --- a/.github/workflows/rust_ci.yml +++ b/.github/workflows/rust_ci.yml @@ -23,6 +23,8 @@ jobs: action: - command: build args: --release + - command: build + args: --release --features max2 - command: fmt args: --all -- --check --color always steps: diff --git a/build.sh b/build.sh index c7754fc..594c75e 100755 --- a/build.sh +++ b/build.sh @@ -16,11 +16,21 @@ case "$MODE" in cargo build --bin vibekeys --release espflash save-image --chip esp32s3 --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_1 target/xtensa-esp32s3-espidf/release/vibekeys ./vibekeys_ota.bin ;; + max2) + echo "Building max2 image..." + cargo build --bin vibekeys --release --features max2 + espflash save-image --chip esp32s3 --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_1 target/xtensa-esp32s3-espidf/release/vibekeys ./vibekeys_max2_ota.bin + ;; keys_bin) echo "Building keys binary image..." cargo build --bin vibekeys --release espflash save-image --chip esp32s3 --merge --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_1 target/xtensa-esp32s3-espidf/release/vibekeys ./vibekeys.bin ;; + max2_bin) + echo "Building max2 binary image..." + cargo build --bin vibekeys --release --features max2 + espflash save-image --chip esp32s3 --merge --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_1 target/xtensa-esp32s3-espidf/release/vibekeys ./vibekeys_max2.bin + ;; keys_ota_bin) echo "Building keys binary image with OTA header..." cargo build --bin vibekeys --release @@ -29,13 +39,24 @@ case "$MODE" in espflash save-image --chip esp32s3 --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_0 target/xtensa-esp32s3-espidf/release/ota ./ota.bin dd if=ota.bin of=vibekeys.bin bs=1 seek=$((0x210000)) conv=notrunc ;; + max2_ota_bin) + echo "Building max2 binary image with OTA header..." + cargo build --bin vibekeys --release --features max2 + cargo build --bin ota --release + espflash save-image --chip esp32s3 --merge --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_1 target/xtensa-esp32s3-espidf/release/vibekeys ./vibekeys_max2.bin + espflash save-image --chip esp32s3 --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_0 target/xtensa-esp32s3-espidf/release/ota ./ota.bin + dd if=ota.bin of=vibekeys_max2.bin bs=1 seek=$((0x210000)) conv=notrunc + ;; *) - echo "Usage: $0 {ota|keys|keys_bin|keys_ota_bin}" + echo "Usage: $0 {ota|keys|max2|keys_bin|max2_bin|keys_ota_bin|max2_ota_bin}" echo "" echo " ota - Build OTA image" echo " keys - Build keys image" + echo " max2 - Build max2 image" echo " keys_bin - Build keys binary image (without OTA header)" + echo " max2_bin - Build max2 binary image (without OTA header)" echo " keys_ota_bin - Build keys binary image with OTA header" + echo " max2_ota_bin - Build max2 binary image with OTA header" exit 1 ;; esac From 1937c2f5a416c6bea5515efca57b6c26c3431ce5 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 11 May 2026 01:26:29 +0800 Subject: [PATCH 10/15] chore: bump version to 0.2.3 Co-Authored-By: Claude Opus 4.5 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1999fd5..1e51372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2036,7 +2036,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vibekeys" -version = "0.2.2" +version = "0.2.3" dependencies = [ "ansi-parser 0.9.1", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index bc4b97f..5d18202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vibekeys" -version = "0.2.2" +version = "0.2.3" authors = ["csh <458761603@qq.com>"] edition = "2021" resolver = "2" From 17010d3c2f44a6987e7ba210c75de4ee0425015c Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Tue, 12 May 2026 18:08:22 +0800 Subject: [PATCH 11/15] fix: adjust max2 DISPLAY_HEIGHT from 170 to 172 Co-Authored-By: Claude Opus 4.5 --- src/lcd.rs | 2 +- src/ota.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lcd.rs b/src/lcd.rs index 574c5ff..c826250 100644 --- a/src/lcd.rs +++ b/src/lcd.rs @@ -23,7 +23,7 @@ use u8g2_fonts::U8g2TextStyle; #[cfg(feature = "max2")] pub const DISPLAY_WIDTH: usize = 320; #[cfg(feature = "max2")] -pub const DISPLAY_HEIGHT: usize = 170; +pub const DISPLAY_HEIGHT: usize = 172; #[cfg(not(feature = "max2"))] pub const DISPLAY_WIDTH: usize = 284; diff --git a/src/ota.rs b/src/ota.rs index 9ba8514..5ddf180 100644 --- a/src/ota.rs +++ b/src/ota.rs @@ -309,7 +309,7 @@ mod lcd { #[cfg(feature = "max2")] pub const DISPLAY_WIDTH: usize = 320; #[cfg(feature = "max2")] - pub const DISPLAY_HEIGHT: usize = 170; + pub const DISPLAY_HEIGHT: usize = 172; #[cfg(not(feature = "max2"))] pub const DISPLAY_WIDTH: usize = 284; From bbc58fa798c036489004d1aa98cc1a79666ec036 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 18 May 2026 22:33:50 +0800 Subject: [PATCH 12/15] fix: remove redundant battery level setting in HID report --- src/bt_keyboard_mode.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bt_keyboard_mode.rs b/src/bt_keyboard_mode.rs index 1c223cc..5e47c43 100644 --- a/src/bt_keyboard_mode.rs +++ b/src/bt_keyboard_mode.rs @@ -662,8 +662,6 @@ impl Keyboard { hid.report_map(HID_KEYBOARD_REPORT_DISCRIPTOR); - hid.set_battery_level(battery_level); - let hid_service_id = hid.hid_service().lock().uuid(); Ok(Self { From 5b3d7ca318580f19939b218c777a6fa68ebe3635 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 18 May 2026 22:54:06 +0800 Subject: [PATCH 13/15] fix: add max2 feature flag to ota binary build Co-Authored-By: Claude Opus 4.7 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 594c75e..04750dd 100755 --- a/build.sh +++ b/build.sh @@ -42,7 +42,7 @@ case "$MODE" in max2_ota_bin) echo "Building max2 binary image with OTA header..." cargo build --bin vibekeys --release --features max2 - cargo build --bin ota --release + cargo build --bin ota --release --features max2 espflash save-image --chip esp32s3 --merge --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_1 target/xtensa-esp32s3-espidf/release/vibekeys ./vibekeys_max2.bin espflash save-image --chip esp32s3 --flash-size 16mb --partition-table partitions.csv --target-app-partition ota_0 target/xtensa-esp32s3-espidf/release/ota ./ota.bin dd if=ota.bin of=vibekeys_max2.bin bs=1 seek=$((0x210000)) conv=notrunc From 0d6ee810f50ebad0ecfbcdaf1e1086dc6a597bf5 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 18 May 2026 23:01:57 +0800 Subject: [PATCH 14/15] fix: log image display error instead of propagating Co-Authored-By: Claude Opus 4.7 --- src/lcd.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lcd.rs b/src/lcd.rs index c826250..0a428f0 100644 --- a/src/lcd.rs +++ b/src/lcd.rs @@ -724,7 +724,9 @@ impl UI { } => { self.image_buffer.extend_from_slice(&data); if is_last { - self.show_self_image_buffer(format)?; + if let Err(e) = self.show_self_image_buffer(format) { + log::error!("Failed to display image: {:?}", e); + } self.image_buffer.clear(); } Ok(()) From 2ac107e99410a0814ea568a2283a6dea97e47830 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 18 May 2026 23:17:58 +0800 Subject: [PATCH 15/15] bump to `0.2.4` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5d18202..86ece1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vibekeys" -version = "0.2.3" +version = "0.2.4" authors = ["csh <458761603@qq.com>"] edition = "2021" resolver = "2"