unify some ticking
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m49s
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m49s
This commit is contained in:
parent
0f6091a615
commit
647583ec5b
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2573,7 +2573,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.20"
|
||||
version = "1.0.21"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.20"
|
||||
version = "1.0.21"
|
||||
edition = "2021"
|
||||
license = "MITNFA"
|
||||
description = "Controls Tesla charge rate based on solar charge data"
|
||||
|
|
|
@ -59,7 +59,6 @@ pub fn write_to_config<'a>() -> ConfigHandle<'a> {
|
|||
#[serde(default)]
|
||||
pub struct Config {
|
||||
pub tesla_update_interval_seconds: u64,
|
||||
pub tesla_update_interval_while_charging_seconds: u64,
|
||||
pub pl_watch_interval_seconds: u64,
|
||||
pub pl_timeout_milliseconds: u64,
|
||||
pub coords: Coords,
|
||||
|
@ -87,7 +86,7 @@ impl Default for PidControls {
|
|||
Self {
|
||||
proportional_gain: 1.,
|
||||
derivative_gain: 1.,
|
||||
loop_time_seconds: 30,
|
||||
loop_time_seconds: 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +110,6 @@ impl Default for Config {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
tesla_update_interval_seconds: 120,
|
||||
tesla_update_interval_while_charging_seconds: 5,
|
||||
pl_watch_interval_seconds: 5,
|
||||
pl_timeout_milliseconds: 400,
|
||||
coords: Coords {
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -171,10 +171,6 @@ async fn main() {
|
|||
tokio::time::interval(std::time::Duration::from_secs(
|
||||
access_config().tesla_update_interval_seconds,
|
||||
));
|
||||
let mut charge_data_update_interval =
|
||||
tokio::time::interval(std::time::Duration::from_secs(
|
||||
access_config().tesla_update_interval_while_charging_seconds,
|
||||
));
|
||||
let mut charge_rate_update_interval =
|
||||
tokio::time::interval(std::time::Duration::from_secs(
|
||||
access_config().pid_controls.loop_time_seconds,
|
||||
|
@ -189,17 +185,13 @@ async fn main() {
|
|||
interface.refresh().await
|
||||
}
|
||||
},
|
||||
_ = charge_data_update_interval.tick() => {
|
||||
if interface.state.read().unwrap().is_charging_at_home() {
|
||||
interface.refresh().await
|
||||
}
|
||||
},
|
||||
_ = charge_rate_update_interval.tick() => {
|
||||
if interface.state.read().unwrap().is_charging_at_home() {
|
||||
was_connected = true;
|
||||
if let Some(request) = tesla_charge_rate_controller.control_charge_rate() {
|
||||
interface.process_request(request).await;
|
||||
}
|
||||
interface.refresh().await
|
||||
} else if was_connected
|
||||
&& interface
|
||||
.state
|
||||
|
|
Loading…
Reference in a new issue