+
+ Temperature |
+
+ {{ Math.round(temperature * 100) / 100 }}°C
+ |
+
+
+ Soil Moisture |
+
+ {{ Math.round(soil_moisture * 1000) / 10 }}%
+ |
+
Lights |
-
+
|
Fan |
-
+
|
Pump |
-
-
- {{ water_state ? "Pump active" : "Pump inactive" }}
+
+
+
+
+
+
|
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/html/growpi/src/main.js b/html/growpi/src/main.js
index 5315290..66ddca2 100644
--- a/html/growpi/src/main.js
+++ b/html/growpi/src/main.js
@@ -1,9 +1,10 @@
-import 'primevue/resources/themes/aura-light-green/theme.css'
+import 'primevue/resources/themes/aura-dark-green/theme.css'
import { createApp } from 'vue'
import PrimeVue from 'primevue/config'
import App from './App.vue'
-createApp(App).mount('#app')
-App.use(PrimeVue)
+const app = createApp(App)
+app.use(PrimeVue)
+app.mount('#app')
diff --git a/src/config.rs b/src/config.rs
index ad2a9ea..9cb0ef1 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -44,6 +44,14 @@ pub struct BoardSettings {
pub logic_level: f32,
}
+#[derive(Serialize, Deserialize)]
+pub struct ControllerSettings {
+ pub temperature_set_point_upper: f32,
+ pub temperature_set_point_lower: f32,
+ pub temperature_loop_mins: u64,
+ pub soil_loop_hours: u64,
+}
+
#[derive(Serialize, Deserialize)]
pub struct Configuration {
pub board_settings: BoardSettings,
@@ -51,6 +59,7 @@ pub struct Configuration {
pub soil_moisture_settings: SoilMoistureSettings,
pub thermistor_settings: ThermistorSettings,
pub water_pump_settings: WaterPumpSettings,
+ pub controller_settings: ControllerSettings,
}
impl Configuration {
@@ -93,6 +102,12 @@ impl Default for Configuration {
water_pump_settings: WaterPumpSettings {
grams_per_millisecond: 0.05281,
},
+ controller_settings: ControllerSettings {
+ temperature_set_point_upper: 35.,
+ temperature_set_point_lower: 28.,
+ temperature_loop_mins: 60,
+ soil_loop_hours: 12,
+ },
}
}
}
diff --git a/src/control.rs b/src/control.rs
index 1143936..196dcb8 100644
--- a/src/control.rs
+++ b/src/control.rs
@@ -12,24 +12,41 @@ use crate::{
async fn temperature_control(program_state: ProgramStateShared) -> GenericResult<()> {
let mut program_state = program_state.lock().map_err(lock_err)?;
+ let config = &program_state.config.controller_settings;
+
let current_temperature = sensors::get_temperature(&program_state.config)?;
- if current_temperature > 28. {
+ if current_temperature > config.temperature_set_point_upper {
actuators::switch_fan(crate::io::RelaySwitchState::On, &mut program_state)?;
- } else {
+ } else if current_temperature < config.temperature_set_point_lower {
actuators::switch_fan(crate::io::RelaySwitchState::Off, &mut program_state)?;
}
Ok(())
}
async fn temperature_control_loop(program_state: ProgramStateShared) {
+ let loop_duration = program_state
+ .lock()
+ .map(|program_state| {
+ program_state
+ .config
+ .controller_settings
+ .temperature_loop_mins
+ })
+ .unwrap_or(1);
+
loop {
let _ = temperature_control(program_state.clone()).await;
- tokio::time::sleep(Duration::from_mins(1)).await;
+ tokio::time::sleep(Duration::from_mins(loop_duration)).await;
}
}
async fn soil_moisture_control_loop(program_state: ProgramStateShared) {
+ let loop_duration = program_state
+ .lock()
+ .map(|program_state| program_state.config.controller_settings.soil_loop_hours)
+ .unwrap_or(1);
+
loop {
- tokio::time::sleep(Duration::from_days(1)).await;
+ tokio::time::sleep(Duration::from_hours(loop_duration)).await;
}
}