-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e201e2c
commit a6bd5c8
Showing
6 changed files
with
217 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.embuild | ||
/target | ||
/Cargo.lock | ||
KiCad/*.lck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Algorithm Setup</title> | ||
<style> | ||
body {{ | ||
font-family: 'Arial', sans-serif; | ||
background-color: #f0f4f8; | ||
margin: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
}} | ||
|
||
.container {{ | ||
background-color: white; | ||
box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.1); | ||
padding: 20px; | ||
border-radius: 12px; | ||
width: 90%; | ||
max-width: 400px; | ||
}} | ||
|
||
h1 {{ | ||
text-align: center; | ||
color: #333; | ||
margin-bottom: 20px; | ||
}} | ||
|
||
label {{ | ||
font-weight: bold; | ||
color: #555; | ||
display: block; | ||
margin-bottom: 8px; | ||
}} | ||
|
||
input[type="text"], | ||
input[type="password"] {{ | ||
width: 94%; | ||
padding: 10px; | ||
margin-bottom: 20px; | ||
border: 1px solid #ccc; | ||
border-radius: 6px; | ||
font-size: 1rem; | ||
}} | ||
|
||
.btn {{ | ||
display: inline-block; | ||
background-color: #00796b; | ||
color: white; | ||
padding: 10px 15px; | ||
font-size: 1rem; | ||
border-radius: 8px; | ||
border: none; | ||
width: 100%; | ||
cursor: pointer; | ||
text-align: center; | ||
}} | ||
|
||
.btn:hover {{ | ||
background-color: #004d40; | ||
}} | ||
|
||
.message {{ | ||
text-align: center; | ||
font-size: large; | ||
color: #d32f2f; | ||
margin-top: 10px; | ||
font-size: 0.9rem; | ||
}} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>Algorithm Setup</h1> | ||
<p>The Td value can be adjusted by providing custom values here. The equation is Final_TD = <b>m</b> * Raw_TD + | ||
<b>b</b> By adjusting these values, you can alter your measured Td.</p> | ||
<form method="get"> | ||
<label for="m">m-value (1)</label> | ||
<input type="number" id="m" name="m" placeholder="1" value="{m_val}" required> | ||
|
||
<label for="b">b-value (0)</label> | ||
<input type="number" id="b" name="b" placeholder="0" value="{b_val}" required> | ||
|
||
<button type="submit" class="btn">Save</button> | ||
</form> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use anyhow::bail; | ||
use esp_idf_svc::nvs::{EspNvs, EspNvsPartition, NvsDefault}; | ||
use log::warn; | ||
|
||
pub fn get_saved_algorithm_variables(nvs: EspNvsPartition<NvsDefault>) -> (f32, f32) { | ||
let nvs = match EspNvs::new(nvs, "algo", true) { | ||
Ok(nvs) => nvs, | ||
Err(_) => { | ||
warn!("NVS init failed"); | ||
return (0., 1.); | ||
} | ||
}; | ||
let mut b_val_buffer = vec![0; 256]; | ||
let b_value: f32 = nvs | ||
.get_str("b", &mut b_val_buffer) | ||
.ok() | ||
.flatten() | ||
.and_then(|s| s.parse::<f32>().ok()) | ||
.unwrap_or(0.0); | ||
let mut m_val_buffer = vec![0; 256]; | ||
let m_value = nvs | ||
.get_str("m", &mut m_val_buffer) | ||
.ok() | ||
.flatten() | ||
.and_then(|s| s.parse::<f32>().ok()) | ||
.unwrap_or(1.0); | ||
(b_value, m_value) | ||
} | ||
|
||
pub fn save_algorithm_variables( | ||
b: &str, | ||
m: &str, | ||
nvs: EspNvsPartition<NvsDefault>, | ||
) -> anyhow::Result<()> { | ||
let mut nvs = match EspNvs::new(nvs, "algo", true) { | ||
Ok(nvs) => nvs, | ||
Err(_) => { | ||
bail!("NVS failed"); | ||
} | ||
}; | ||
|
||
nvs.set_str("m", m)?; | ||
nvs.set_str("b", b)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters