probalby found most of the import related stuff, now the real refactor begins
This commit is contained in:
parent
242e748ca0
commit
0d495d0f56
@ -6,7 +6,7 @@ use anyhow::{anyhow, bail, Context};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use alloc::{vec::Vec, string::String};
|
||||
use alloc::{vec::Vec, string::{String, ToString}};
|
||||
|
||||
#[link_section = ".rtc.data"]
|
||||
static mut LAST_WATERING_TIMESTAMP: [i64; PLANT_COUNT] = [0; PLANT_COUNT];
|
||||
|
@ -17,6 +17,7 @@ use crate::{
|
||||
},
|
||||
log::{log, LogMessage},
|
||||
};
|
||||
use alloc::boxed::Box;
|
||||
use anyhow::{Ok, Result};
|
||||
use battery::BQ34Z100G1;
|
||||
use bq34z100::Bq34z100g1Driver;
|
||||
@ -45,18 +46,16 @@ use esp_idf_sys::{
|
||||
};
|
||||
use esp_ota::mark_app_valid;
|
||||
use measurements::{Current, Voltage};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::result::Result::Ok as OkStd;
|
||||
use std::sync::Mutex;
|
||||
use std::time::Duration;
|
||||
use embassy_sync::{Mutex, LazyLock};
|
||||
use esp_idf_hal::can::CAN;
|
||||
use crate::alloc::string::ToString;
|
||||
|
||||
//Only support for 8 right now!
|
||||
pub const PLANT_COUNT: usize = 8;
|
||||
|
||||
const TANK_MULTI_SAMPLE: usize = 11;
|
||||
|
||||
pub static I2C_DRIVER: Lazy<Mutex<I2cDriver<'static>>> = Lazy::new(PlantHal::create_i2c);
|
||||
pub static I2C_DRIVER: LazyLock<Mutex<I2cDriver<'static>>> = LazyLock::new(PlantHal::create_i2c);
|
||||
|
||||
fn deep_sleep(duration_in_ms: u64) -> ! {
|
||||
unsafe {
|
||||
|
@ -10,14 +10,12 @@ use crate::{
|
||||
};
|
||||
use anyhow::{bail, Ok, Result};
|
||||
use embedded_hal::digital::OutputPin;
|
||||
use esp_idf_hal::{
|
||||
gpio::{AnyInputPin, IOPin, InputOutput, PinDriver, Pull},
|
||||
pcnt::{PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex},
|
||||
};
|
||||
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en};
|
||||
use measurements::{Current, Voltage};
|
||||
use plant_ctrl2::sipo::ShiftRegister40;
|
||||
use std::result::Result::Ok as OkStd;
|
||||
use core::result::Result::Ok as OkStd;
|
||||
use alloc::string::ToString;
|
||||
use alloc::boxed::Box;
|
||||
use esp_hall::gpio::Pull;
|
||||
|
||||
const PUMP8_BIT: usize = 0;
|
||||
const PUMP1_BIT: usize = 1;
|
||||
|
@ -12,12 +12,6 @@ use crate::log::{log, LogMessage};
|
||||
use anyhow::bail;
|
||||
use embedded_hal::digital::OutputPin;
|
||||
use embedded_hal_bus::i2c::MutexDevice;
|
||||
use esp_idf_hal::gpio::{AnyInputPin, IOPin, InputOutput, Output, PinDriver, Pull};
|
||||
use esp_idf_hal::i2c::I2cDriver;
|
||||
use esp_idf_hal::pcnt::{
|
||||
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
|
||||
};
|
||||
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en};
|
||||
use ina219::address::{Address, Pin};
|
||||
use ina219::calibration::UnCalibrated;
|
||||
use ina219::configuration::{Configuration, OperatingMode};
|
||||
@ -27,7 +21,9 @@ use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
||||
use std::result::Result::Ok as OkStd;
|
||||
use embedded_can::Frame;
|
||||
use embedded_can::StandardId;
|
||||
use esp_idf_hal::can;
|
||||
use alloc::string::ToString;
|
||||
use alloc::boxed::Box;
|
||||
use esp_hal::gpio::Pull;
|
||||
|
||||
pub enum Charger<'a> {
|
||||
SolarMpptV1 {
|
||||
|
@ -1,3 +1,4 @@
|
||||
use alloc::string::ToString;
|
||||
use embedded_hal_bus::i2c::MutexDevice;
|
||||
use esp_idf_hal::can::CanDriver;
|
||||
use esp_idf_hal::delay::Delay;
|
||||
|
@ -1,4 +1,5 @@
|
||||
use alloc::string::ToString;
|
||||
use alloc::vec::Vec;
|
||||
use serde::Serialize;
|
||||
use std::{collections::HashMap, sync::Mutex};
|
||||
use strum::EnumIter;
|
||||
|
@ -11,7 +11,9 @@ use crate::{
|
||||
hal::{PlantHal, HAL, PLANT_COUNT},
|
||||
//webserver::httpd,
|
||||
};
|
||||
use core::sync::atomic::Ordering;
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::fmt::format;
|
||||
use alloc::string::{String, ToString};
|
||||
use anyhow::{bail, Context};
|
||||
@ -19,10 +21,12 @@ use chrono::{DateTime, Datelike, Timelike, Utc};
|
||||
use chrono_tz::Tz::{self, UTC};
|
||||
use embassy_executor::Spawner;
|
||||
use hal::battery::BatteryState;
|
||||
use esp_hal::{timer::systimer::SystemTimer, clock::CpuClock, delay::Delay};
|
||||
use esp_println::logger;
|
||||
use log::{log, LogMessage};
|
||||
use plant_state::PlantState;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use embassy_sync::{Mutex, LazyLock};
|
||||
use embassy_sync::{Mutex, LazyLock, mutex::MutexGuard};
|
||||
use portable_atomic::AtomicBool;
|
||||
use tank::*;
|
||||
mod config;
|
||||
@ -549,7 +553,7 @@ fn safe_main() -> anyhow::Result<()> {
|
||||
//TODO
|
||||
//mark_app_valid();
|
||||
|
||||
let stay_alive_mqtt = STAY_ALIVE.load(std::sync::atomic::Ordering::Relaxed);
|
||||
let stay_alive_mqtt = STAY_ALIVE.load(Ordering::Relaxed);
|
||||
|
||||
let stay_alive = stay_alive_mqtt;
|
||||
log::info!("Check stay alive, current state is {}", stay_alive);
|
||||
@ -961,11 +965,11 @@ fn wait_infinity(wait_type: WaitType, reboot_now: Arc<AtomicBool>) -> ! {
|
||||
delay_handle.delay_ms(delay);
|
||||
|
||||
if wait_type == WaitType::MqttConfig
|
||||
&& !STAY_ALIVE.load(std::sync::atomic::Ordering::Relaxed)
|
||||
&& !STAY_ALIVE.load(Ordering::Relaxed)
|
||||
{
|
||||
reboot_now.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
reboot_now.store(true, Ordering::Relaxed);
|
||||
}
|
||||
if reboot_now.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
if reboot_now.load(Ordering::Relaxed) {
|
||||
//ensure clean http answer
|
||||
Delay::new_default().delay_ms(500);
|
||||
BOARD_ACCESS.lock().unwrap().board_hal.deep_sleep(1);
|
||||
|
@ -3,6 +3,7 @@ use crate::{
|
||||
hal::{Sensor, HAL},
|
||||
in_time_range,
|
||||
};
|
||||
use alloc::string::String;
|
||||
use chrono::{DateTime, TimeDelta, Utc};
|
||||
use chrono_tz::Tz;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
Loading…
x
Reference in New Issue
Block a user