diff --git a/rust/src/webserver/webserver.rs b/rust/src/webserver/webserver.rs index d307c47..661027f 100644 --- a/rust/src/webserver/webserver.rs +++ b/rust/src/webserver/webserver.rs @@ -1,11 +1,11 @@ //offer ota and config mode use std::{ - io::{BufRead, BufReader, Read, Write}, str::from_utf8, sync::{atomic::AtomicBool, Arc}, }; +use esp_idf_svc::io::BufRead; use crate::{ espota::OtaUpdate, get_version, map_range_moisture, plant_hal::FileInfo, BOARD_ACCESS, }; @@ -242,7 +242,7 @@ fn flash_bq(filename: &str, dryrun: bool) -> anyhow::Result<()> { let file_handle = board.get_file_handle(filename, false)?; - let mut reader = BufReader::with_capacity(512, file_handle).lines(); + let mut reader = std::io::BufRead::lines(std::io::BufReader::with_capacity(512, file_handle)); let mut line = 0; loop { board.general_fault(toggle); @@ -373,7 +373,7 @@ pub fn httpd(_reboot_now: Arc) -> Box> { let mut buffer: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]; let mut total_read: usize = 0; loop { - let read = file_handle.read(&mut buffer)?; + let read = std::io::Read::read(&mut file_handle, &mut buffer)?; total_read += read; println!( "sending {read} bytes of {total_read} for file {}", @@ -416,7 +416,7 @@ pub fn httpd(_reboot_now: Arc) -> Box> { total_read += read; println!("sending {read} bytes of {total_read} for upload {filename}"); let to_write = &buffer[0..read]; - file_handle.write(to_write)?; + std::io::Write::write(&mut file_handle, to_write)?; println!("wrote {read} bytes of {total_read} for upload {filename}"); if read == 0 { break; @@ -508,9 +508,12 @@ pub fn httpd(_reboot_now: Arc) -> Box> { .unwrap(); server .fn_handler("/bootstrap-grid.css", Method::Get, |request| { - request - .into_ok_response()? - .write(include_bytes!("bootstrap-grid.css"))?; + let headers = [ + ("Access-Control-Allow-Origin", "*"), + ("Access-Control-Allow-Headers", "*"), + ("Content-Type", "text/css") + ]; + request.into_response(200, None, &headers)?.write(include_bytes!("bootstrap-grid.css"))?; anyhow::Ok(()) }) .unwrap(); diff --git a/rust/src_webpack/src/batteryview.html b/rust/src_webpack/src/batteryview.html index 4c2bfb9..b75d6c5 100644 --- a/rust/src_webpack/src/batteryview.html +++ b/rust/src_webpack/src/batteryview.html @@ -1,46 +1,42 @@ -
-
-
-
-
- Time: -
-
- ⟳ -
- +
+
+ Battery: +
+
+
-
- V: -
-
-
- mA: -
-
-
- Cycles: -
-
-
- design mA: -
-
-
- remaining mA: -
-
-
- charge %: -
-
-
- health %: -
-
-
- Temp °C: -
-
+ +
+ V: +
+
+
+ mA: +
+
+
+ Cycles: +
+
+
+ design mA: +
+
+
+ remaining mA: +
+
+
+ charge %: +
+
+
+ health %: +
+
+
+ Temp °C: +
+
\ No newline at end of file diff --git a/rust/src_webpack/src/main.html b/rust/src_webpack/src/main.html index a569b7f..74290ef 100644 --- a/rust/src_webpack/src/main.html +++ b/rust/src_webpack/src/main.html @@ -1,113 +1,116 @@ - - + } + -
- - -
- -
- -
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
-
+ + + +

config

+

Plants:

+ +
+ + -
- -

Light:

- Enable Nightlight -
- Start - - Stop - -
-
- - Light only when dark -
-

Plants:

- -
-

diff --git a/rust/src_webpack/src/main.ts b/rust/src_webpack/src/main.ts index aa917d0..7f7043a 100644 --- a/rust/src_webpack/src/main.ts +++ b/rust/src_webpack/src/main.ts @@ -8,7 +8,7 @@ document.body.innerHTML = require('./main.html') as string; import { TimeView } from "./timeview"; import { PlantView, PlantViews } from "./plant"; import { NetworkConfigView } from "./network"; -import { NightLampView } from "./nightmode"; +import { NightLampView } from "./nightlightview"; import { TankConfigView } from "./tankview"; import { SubmitView } from "./submitView"; import { ProgressView } from "./progress"; @@ -256,6 +256,6 @@ const controller = new Controller(); controller.updateRTCData(); controller.updateBatteryData(); controller.downloadConfig(); -n controller.measure_moisture(); +//controller.measure_moisture(); controller.version(); diff --git a/rust/src_webpack/src/nightlightview.html b/rust/src_webpack/src/nightlightview.html new file mode 100644 index 0000000..3168650 --- /dev/null +++ b/rust/src_webpack/src/nightlightview.html @@ -0,0 +1,14 @@ +

Light:

+ Enable Nightlight +
+ Start + + Stop + +
+
+ + Light only when dark +
\ No newline at end of file diff --git a/rust/src_webpack/src/nightmode.ts b/rust/src_webpack/src/nightlightview.ts similarity index 94% rename from rust/src_webpack/src/nightmode.ts rename to rust/src_webpack/src/nightlightview.ts index eb7e9e0..8e1eaad 100644 --- a/rust/src_webpack/src/nightmode.ts +++ b/rust/src_webpack/src/nightlightview.ts @@ -5,6 +5,9 @@ export class NightLampView { private readonly night_lamp_time_start: HTMLSelectElement; private readonly night_lamp_time_end: HTMLSelectElement; constructor(controller:Controller){ + (document.getElementById("lightview") as HTMLElement).innerHTML = require('./nightlightview.html') as string; + + this.night_lamp_only_when_dark = document.getElementById("night_lamp_only_when_dark") as HTMLInputElement; this.night_lamp_only_when_dark.onchange = controller.configChanged this.night_lamp_time_start = document.getElementById("night_lamp_time_start") as HTMLSelectElement; diff --git a/rust/src_webpack/src/ota.html b/rust/src_webpack/src/ota.html index d25fc79..c5a0eff 100644 --- a/rust/src_webpack/src/ota.html +++ b/rust/src_webpack/src/ota.html @@ -1,22 +1,25 @@ -
-
-
- Current Firmware -
+
+
+ Current Firmware
-
-
- Buildtime: - -
-
- Buildhash: - -
+
+
+
+ Buildtime: +
-
-
-
-
+
+
+
+ Buildhash: +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/rust/src_webpack/src/plant.html b/rust/src_webpack/src/plant.html index d1dafbf..f7904fa 100644 --- a/rust/src_webpack/src/plant.html +++ b/rust/src_webpack/src/plant.html @@ -1,31 +1,32 @@ -
-Plant ${plantId} +
+ Plant ${plantId} + +
+
+ +
+
+
+
Live:
+
+
+
Sensor A:
+ loading +
Sensor B:
+ loading +
+
+
+ Mode: +
+ -
-
- -
-
-
-
Live:
-
-
-
Sensor A:
- loading -
Sensor B:
- loading -
-
-
- Mode:
- - -
Target Moisture:
@@ -34,26 +35,27 @@
Pump Time (s):
- +
Pump Cooldown (m):
- +
"Pump Hour Start":
- -
-
-
"Pump Hour End":
- -
-
-
Sensor B installed:
- -
-
-
Max Consecutive Pump Count:
- -
- + +
+
+
"Pump Hour End":
+ +
+
+
Sensor B installed:
+ +
+
+
Max Consecutive Pump Count:
+ +
+
\ No newline at end of file diff --git a/rust/src_webpack/src/plant.ts b/rust/src_webpack/src/plant.ts index a18f49f..bc5a6a3 100644 --- a/rust/src_webpack/src/plant.ts +++ b/rust/src_webpack/src/plant.ts @@ -66,7 +66,10 @@ export class PlantView { const template = require('./plant.html') as string; const plantRaw = template.replaceAll("${plantId}", String(plantId)); this.plantDiv.innerHTML = plantRaw - this.plantDiv.classList.add("col-auto" ) + + this.plantDiv.classList.add("col-12" ) + this.plantDiv.classList.add("col-sm-6" ) + this.plantDiv.classList.add("col-md-auto" ) parent.appendChild(this.plantDiv) this.header = document.getElementById("plant_"+plantId+"_header")! diff --git a/rust/src_webpack/src/tankview.html b/rust/src_webpack/src/tankview.html index a42723d..fa86185 100644 --- a/rust/src_webpack/src/tankview.html +++ b/rust/src_webpack/src/tankview.html @@ -1,27 +1,29 @@ -

Tank:

-
- - Enable Tank Sensor +
+
Tank:
-
- - Allow Pumping if Sensor Error +
+ +
Enable Tank Sensor
+
+
+ +
Ignore Sensor Error
-
- - Tank Size mL +
+ +
Tank Size mL
-
- - Tank Warn Percent (mapped in relation to empty and full) +
+ +
Tank Warn Percent (mapped in relation to empty and full)
-
- - Tank Empty Percent (% max move) +
+ +
Tank Empty Percent (% max move)
-
- - Tank Full Percent (% max move) +
+ +
Tank Full Percent (% max move)
\ No newline at end of file diff --git a/rust/src_webpack/src/timeview.html b/rust/src_webpack/src/timeview.html index 70c506e..518ade6 100644 --- a/rust/src_webpack/src/timeview.html +++ b/rust/src_webpack/src/timeview.html @@ -1,8 +1,5 @@ -
-
-
-
+
Time:
@@ -25,4 +22,3 @@
-
diff --git a/rust/src_webpack/webpack.config.js b/rust/src_webpack/webpack.config.js index 4604ecc..98ba6dc 100644 --- a/rust/src_webpack/webpack.config.js +++ b/rust/src_webpack/webpack.config.js @@ -8,7 +8,7 @@ const isDevServer = process.env.WEBPACK_SERVE; console.log("Dev server is " + isDevServer); var host; if (isDevServer){ - host = 'http://192.168.0.103'; + host = 'http://192.168.0.105'; } else { host = ''; }