From 1fc04a58a002840e961fdfb89a772fc66f0ba9bc Mon Sep 17 00:00:00 2001 From: Empire Date: Fri, 26 Apr 2024 18:52:53 +0200 Subject: [PATCH] stuff --- board/PlantCtrlESP32.kicad_pro | 5 +---- rust/.cargo/config.toml | 2 +- rust/Cargo.toml | 8 +++++++- rust/src/plant_hal.rs | 14 ++++++++++---- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/board/PlantCtrlESP32.kicad_pro b/board/PlantCtrlESP32.kicad_pro index 3b5323d..6197e50 100644 --- a/board/PlantCtrlESP32.kicad_pro +++ b/board/PlantCtrlESP32.kicad_pro @@ -574,10 +574,7 @@ "version": 3 }, "net_colors": null, - "netclass_assignments": { - "Net-(battery1-Pin_1)": "BAT-", - "VBAT": "BAT+" - }, + "netclass_assignments": null, "netclass_patterns": [ { "netclass": "3V", diff --git a/rust/.cargo/config.toml b/rust/.cargo/config.toml index 779b375..c75f782 100644 --- a/rust/.cargo/config.toml +++ b/rust/.cargo/config.toml @@ -27,4 +27,4 @@ MCU="esp32c6" ESP_IDF_VERSION = "v5.2.1" CHRONO_TZ_TIMEZONE_FILTER="UTC|Europe/Berlin" CARGO_WORKSPACE_DIR = { value = "", relative = true } -RUST_BACKTRACE = "full" \ No newline at end of file +RUST_BACKTRACE = "full" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index f999bef..59e55cb 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -47,7 +47,6 @@ embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf- [dependencies] log = { version = "0.4", default-features = false } -esp-idf-svc = { version = "0.48.0", default-features = false } serde = { version = "1.0.192", features = ["derive"] } average = { version = "0.14.1" , features = ["std"] } #esp32 = "0.28.0" @@ -56,6 +55,7 @@ ds18b20 = "0.1.1" embedded-svc = { version = "0.27.0", features = ["experimental"] } esp-idf-hal = "0.43.0" esp-idf-sys = { version = "0.34.0", features = ["binstart", "native"] } +esp-idf-svc = { version = "0.48.0", default-features = false } esp_idf_build = "0.1.3" chrono = { version = "0.4.23", default-features = false , features = ["iana-time-zone" , "alloc"] } chrono-tz = {version="0.8.0", default-features = false , features = [ "filter-by-regex" ]} @@ -70,6 +70,12 @@ once_cell = "1.19.0" measurements = "0.11.0" bq34z100 = "0.2.1" +[patch.crates-io] +esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal.git" } +esp-idf-sys = { git = "https://github.com/empirephoenix/esp-idf-sys.git" } +# esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys.git" } +esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc.git" } + [build-dependencies] embuild = "0.31.3" vergen = { version = "8.2.6", features = ["build", "git", "gitcl"] } diff --git a/rust/src/plant_hal.rs b/rust/src/plant_hal.rs index 7e6374b..a6686f3 100644 --- a/rust/src/plant_hal.rs +++ b/rust/src/plant_hal.rs @@ -676,7 +676,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> { } } } - embedded_svc::mqtt::client::EventPayload::Connected{session_present: _} => { + embedded_svc::mqtt::client::EventPayload::Connected(_) => { mqtt_connected_event_received_copy .store(true, std::sync::atomic::Ordering::Relaxed); mqtt_connected_event_ok_copy @@ -894,6 +894,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> { fn print_battery( battery_driver: &mut Bq34z100g1Driver, ) -> Result<(), Bq34Z100Error> { + println!("Try communicating with battery"); let fwversion = battery_driver.fw_version().unwrap_or_else(|e| { println!("Firmeware {:?}", e); 0 @@ -956,14 +957,19 @@ impl CreatePlantHal<'_> for PlantHal { let config = I2cConfig::new() .scl_enable_pullup(false) .sda_enable_pullup(false) - .baudrate(10_u32.kHz().into()); + .baudrate(10_u32.kHz().into()) + .timeout(Duration::from_millis(10).into); let scl = peripherals.pins.gpio19; let sda = peripherals.pins.gpio20; let driver = I2cDriver::new(i2c, sda, scl, &config).unwrap(); - + let i2c_port = driver.port(); - esp!(unsafe { esp_idf_sys::i2c_set_timeout(i2c_port, 2)}).unwrap(); + let mut timeout:i32 = 0; + esp!(unsafe { esp_idf_sys::i2c_get_timeout(i2c_port, &mut timeout)}).unwrap(); + println!("Default i2c timeout is {}", timeout); + + //esp!(unsafe { esp_idf_sys::i2c_set_timeout(i2c_port, 1)}).unwrap(); let mut battery_driver: Bq34z100g1Driver = Bq34z100g1Driver { i2c: driver,