adjustments
This commit is contained in:
parent
4a8fffb3cc
commit
f0f0e9f27e
@ -1,3 +1,5 @@
|
|||||||
|
use std::{fs::File, io::Write};
|
||||||
|
|
||||||
use chrono::{Datelike, Timelike, NaiveDateTime};
|
use chrono::{Datelike, Timelike, NaiveDateTime};
|
||||||
|
|
||||||
use chrono_tz::Europe::Berlin;
|
use chrono_tz::Europe::Berlin;
|
||||||
@ -50,6 +52,9 @@ fn main() -> Result<()>{
|
|||||||
|
|
||||||
println!("cur is {}", cur);
|
println!("cur is {}", cur);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//continous/interrupt?
|
//continous/interrupt?
|
||||||
//check if boot button is pressed, if longer than 5s delete config and reboot into config mode
|
//check if boot button is pressed, if longer than 5s delete config and reboot into config mode
|
||||||
|
|
||||||
@ -59,10 +64,12 @@ fn main() -> Result<()>{
|
|||||||
Ok(conf) => {
|
Ok(conf) => {
|
||||||
|
|
||||||
},
|
},
|
||||||
Err(err) => todo!(),
|
Err(err) => {
|
||||||
|
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
let proceed = config.unwrap();
|
// let proceed = config.unwrap();
|
||||||
|
|
||||||
//check if we have a config file
|
//check if we have a config file
|
||||||
// if not found or parsing error -> error very fast blink general fault
|
// if not found or parsing error -> error very fast blink general fault
|
||||||
@ -72,9 +79,9 @@ fn main() -> Result<()>{
|
|||||||
//blink general fault error_no_config_after_upgrade
|
//blink general fault error_no_config_after_upgrade
|
||||||
//once config is set store it and reboot
|
//once config is set store it and reboot
|
||||||
|
|
||||||
if proceed.tank_sensor_enabled() {
|
//if proceed.tank_sensor_enabled() {
|
||||||
|
|
||||||
}
|
//}
|
||||||
//is tank sensor enabled in config?
|
//is tank sensor enabled in config?
|
||||||
//measure tank level (without wifi due to interference)
|
//measure tank level (without wifi due to interference)
|
||||||
//TODO this should be a result// detect invalid measurement value
|
//TODO this should be a result// detect invalid measurement value
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
mod config;
|
//mod config;
|
||||||
|
|
||||||
use embedded_svc::wifi::{Configuration, ClientConfiguration, AuthMethod};
|
use embedded_svc::wifi::{Configuration, ClientConfiguration, AuthMethod};
|
||||||
use esp_idf_svc::eventloop::EspSystemEventLoop;
|
use esp_idf_svc::eventloop::EspSystemEventLoop;
|
||||||
use esp_idf_svc::nvs::EspDefaultNvsPartition;
|
use esp_idf_svc::nvs::EspDefaultNvsPartition;
|
||||||
use esp_idf_svc::wifi::EspWifi;
|
use esp_idf_svc::wifi::EspWifi;
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Read;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use anyhow::{Context, Result, bail};
|
use anyhow::{Context, Result, bail, Ok};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
|
||||||
use chrono::{Utc, NaiveDateTime, DateTime};
|
use chrono::{Utc, NaiveDateTime, DateTime};
|
||||||
@ -26,6 +28,8 @@ use shift_register_driver::sipo::ShiftRegister40;
|
|||||||
use esp_idf_hal::gpio::{PinDriver, Gpio39, Gpio4, AnyInputPin};
|
use esp_idf_hal::gpio::{PinDriver, Gpio39, Gpio4, AnyInputPin};
|
||||||
use esp_idf_hal::prelude::Peripherals;
|
use esp_idf_hal::prelude::Peripherals;
|
||||||
|
|
||||||
|
use crate::config;
|
||||||
|
|
||||||
pub const PLANT_COUNT:usize = 8;
|
pub const PLANT_COUNT:usize = 8;
|
||||||
const PINS_PER_PLANT:usize = 5;
|
const PINS_PER_PLANT:usize = 5;
|
||||||
const PLANT_PUMP_OFFSET:usize = 0;
|
const PLANT_PUMP_OFFSET:usize = 0;
|
||||||
@ -97,7 +101,7 @@ pub trait PlantCtrlBoardInteraction{
|
|||||||
//keep state during deepsleep
|
//keep state during deepsleep
|
||||||
fn fault(&self,plant:usize, enable:bool);
|
fn fault(&self,plant:usize, enable:bool);
|
||||||
|
|
||||||
fn get_config(&mut self) -> Result<Config>;
|
fn get_config(&mut self) -> Result<config::Config>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait CreatePlantHal<'a> {
|
pub trait CreatePlantHal<'a> {
|
||||||
@ -442,7 +446,10 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_config(&mut self) -> Result<config::Config> {
|
fn get_config(&mut self) -> Result<config::Config> {
|
||||||
todo!()
|
let config_file = File::open("config.cfg")?;
|
||||||
|
//serde_json::from_str(&data);
|
||||||
|
bail!("Not implemented");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user