This commit is contained in:
Empire 2024-03-27 21:10:37 +01:00
parent b4ad668620
commit 1f71b94238
4 changed files with 65820 additions and 24823 deletions

View File

@ -197,6 +197,13 @@
"zones_allow_external_fillets": true,
"zones_use_no_outline": true
},
"ipc2581": {
"dist": "",
"distpn": "",
"internal_id": "",
"mfg": "",
"mpn": ""
},
"layer_presets": [],
"viewports": []
},
@ -1000,14 +1007,75 @@
"gencad": "",
"idf": "",
"netlist": "PlantCtrlESP32.net",
"plot": "",
"pos_files": "",
"specctra_dsn": "",
"step": "",
"svg": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"annotate_start_num": 0,
"bom_fmt_presets": [],
"bom_fmt_settings": {
"field_delimiter": ",",
"keep_line_breaks": false,
"keep_tabs": false,
"name": "CSV",
"ref_delimiter": ",",
"ref_range_delimiter": "",
"string_delimiter": "\""
},
"bom_presets": [],
"bom_settings": {
"exclude_dnp": false,
"fields_ordered": [
{
"group_by": false,
"label": "Reference",
"name": "Reference",
"show": true
},
{
"group_by": true,
"label": "Value",
"name": "Value",
"show": true
},
{
"group_by": false,
"label": "Datasheet",
"name": "Datasheet",
"show": true
},
{
"group_by": false,
"label": "Footprint",
"name": "Footprint",
"show": true
},
{
"group_by": false,
"label": "Qty",
"name": "${QUANTITY}",
"show": true
},
{
"group_by": true,
"label": "DNP",
"name": "${DNP}",
"show": true
}
],
"filter_string": "",
"group_symbols": true,
"name": "Grouped By Value",
"sort_asc": true,
"sort_field": "Reference"
},
"connection_grid_size": 50.0,
"drawing": {
"dashed_lines_dash_length_ratio": 12.0,
"dashed_lines_gap_length_ratio": 3.0,
@ -1021,6 +1089,11 @@
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"label_size_ratio": 0.25,
"operating_point_overlay_i_precision": 3,
"operating_point_overlay_i_range": "~A",
"operating_point_overlay_v_precision": 3,
"operating_point_overlay_v_range": "~V",
"overbar_offset_ratio": 1.23,
"pin_symbol_size": 0.0,
"text_offset_ratio": 0.08
},
@ -1046,6 +1119,7 @@
"spice_external_command": "spice \"%I\"",
"spice_model_current_sheet_as_root": true,
"spice_save_all_currents": false,
"spice_save_all_dissipations": false,
"spice_save_all_voltages": false,
"subpart_first_id": 65,
"subpart_id_separator": 0
@ -1053,7 +1127,7 @@
"sheets": [
[
"c26e8d55-0b6e-4c4e-b7c8-b1fed973201c",
""
"Root"
]
],
"text_variables": {}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
use std::sync::{atomic::AtomicBool, Arc, Mutex};
use chrono::{DateTime, Datelike, Duration, NaiveDateTime, Timelike};
use chrono::{DateTime, Datelike, TimeDelta, Timelike};
use chrono_tz::{Europe::Berlin, Tz};
use esp_idf_hal::delay::Delay;
@ -169,7 +169,7 @@ fn safe_main() -> anyhow::Result<()> {
Ok(cur) => cur,
Err(err) => {
log::error!("time error {}", err);
NaiveDateTime::from_timestamp_millis(0).unwrap().and_utc()
DateTime::from_timestamp_millis(0).unwrap()
}
};
//check if we know the time current > 2020
@ -862,7 +862,7 @@ fn determine_state_target_moisture_for_plant(
state.no_water = true;
}
}
let duration = Duration::minutes((plant_config.pump_cooldown_min).into());
let duration = TimeDelta::try_minutes(plant_config.pump_cooldown_min as i64).unwrap();
let next_pump = board.last_pump_time(plant) + duration;
if next_pump > cur {
let europe_time = next_pump.with_timezone(&Berlin);
@ -913,7 +913,7 @@ fn determine_next_plant(
);
}
config::Mode::TimerOnly => {
let duration = Duration::minutes((plant_config.pump_cooldown_min).into());
let duration = TimeDelta::try_minutes(plant_config.pump_cooldown_min as i64).unwrap();
let next_pump = board.last_pump_time(plant) + duration;
if next_pump > cur {
let europe_time = next_pump.with_timezone(&Berlin);
@ -928,7 +928,7 @@ fn determine_next_plant(
}
}
config::Mode::TimerAndDeadzone => {
let duration = Duration::minutes((60 * plant_config.pump_cooldown_min).into());
let duration = TimeDelta::try_minutes(plant_config.pump_cooldown_min as i64).unwrap();
let next_pump = board.last_pump_time(plant) + duration;
if next_pump > cur {
let europe_time = next_pump.with_timezone(&Berlin);

View File

@ -23,7 +23,7 @@ use std::ffi::CString;
use std::fs::File;
use std::path::Path;
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{DateTime, Utc};
use ds18b20::Ds18b20;
use std::result::Result::Ok as OkStd;
use std::str::FromStr;
@ -277,8 +277,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
fn last_pump_time(&self, plant: usize) -> chrono::DateTime<Utc> {
let ts = unsafe { LAST_WATERING_TIMESTAMP }[plant];
let timestamp = NaiveDateTime::from_timestamp_millis(ts).unwrap();
DateTime::<Utc>::from_naive_utc_and_offset(timestamp, Utc)
return DateTime::from_timestamp_millis(ts).unwrap();
}
fn store_last_pump_time(&mut self, plant: usize, time: chrono::DateTime<Utc>) {
@ -322,9 +321,9 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
fn time(&mut self) -> Result<chrono::DateTime<Utc>> {
let time = EspSystemTime {}.now().as_millis();
let smaller_time = time as i64;
let local_time = NaiveDateTime::from_timestamp_millis(smaller_time)
let local_time = DateTime::from_timestamp_millis(smaller_time)
.ok_or(anyhow!("could not convert timestamp"))?;
Ok(local_time.and_utc())
Ok(local_time)
}
fn sntp(&mut self, max_wait_ms: u32) -> Result<chrono::DateTime<Utc>> {
@ -920,9 +919,8 @@ impl CreatePlantHal<'_> for PlantHal {
);
for i in 0..PLANT_COUNT {
let smaller_time = LAST_WATERING_TIMESTAMP[i];
let local_time = NaiveDateTime::from_timestamp_millis(smaller_time)
let utc_time = DateTime::from_timestamp_millis(smaller_time)
.ok_or(anyhow!("could not convert timestamp"))?;
let utc_time = local_time.and_utc();
let europe_time = utc_time.with_timezone(&Berlin);
println!(