Add silent mode for sensor detection and moisture measurement

- Introduced the `silent` parameter to prevent UI progress updates during automatic operations.
- Enhanced CAN robustness with improved bus-off management, retransmission settings, and jitter tolerance.
- Added auto-refresh functionality for plant moisture and sensor detection with configurable enablement.
This commit is contained in:
2026-03-29 14:21:12 +02:00
parent 4cf5f6d151
commit 7121dd0fae
4 changed files with 274 additions and 194 deletions

View File

@@ -12,7 +12,9 @@ export class PlantViews {
constructor(syncConfig: Controller) {
this.measure_moisture = document.getElementById("measure_moisture") as HTMLButtonElement
this.measure_moisture.onclick = syncConfig.measure_moisture
this.measure_moisture.onclick = async () => {
return syncConfig.measure_moisture(false)
}
this.plantsDiv = document.getElementById("plants") as HTMLDivElement;
for (let plantId = 0; plantId < PLANT_COUNT; plantId++) {
this.plants[plantId] = new PlantView(plantId, this.plantsDiv, syncConfig);
@@ -48,16 +50,15 @@ export class PlantViews {
plantView.setTestResult(response)
}
applyDetectionResult(json: Detection) {
for (let i = 0; i < PLANT_COUNT; i++) {
var plantResult = json.plant[i];
this.plants[i].setDetectionResult(plantResult);
}
}
applyDetectionResult(json: Detection) {
for (let i = 0; i < PLANT_COUNT; i++) {
var plantResult = json.plant[i];
this.plants[i].setDetectionResult(plantResult);
}
}
}
export class PlantView {
private readonly moistureSensorMinFrequency: HTMLInputElement;
private readonly moistureSensorMaxFrequency: HTMLInputElement;
@@ -240,10 +241,10 @@ export class PlantView {
}
updateVisibility(plantConfig: PlantConfig) {
let sensorOnly = document.getElementsByClassName("plantSensorEnabledOnly_"+ this.plantId)
let pumpOnly = document.getElementsByClassName("plantPumpEnabledOnly_"+ this.plantId)
let targetOnly = document.getElementsByClassName("plantTargetEnabledOnly_"+ this.plantId)
let minOnly = document.getElementsByClassName("plantMinEnabledOnly_"+ this.plantId)
let sensorOnly = document.getElementsByClassName("plantSensorEnabledOnly_" + this.plantId)
let pumpOnly = document.getElementsByClassName("plantPumpEnabledOnly_" + this.plantId)
let targetOnly = document.getElementsByClassName("plantTargetEnabledOnly_" + this.plantId)
let minOnly = document.getElementsByClassName("plantMinEnabledOnly_" + this.plantId)
console.log("updateVisibility plantConfig: " + plantConfig.mode)
let showSensor = plantConfig.sensor_a || plantConfig.sensor_b
@@ -259,7 +260,7 @@ export class PlantView {
// this.plantDiv.style.display = "none";
// }
console.log("updateVisibility showsensor: " + showSensor + " pump " + showPump + " target " +showTarget + " min " + showMin)
console.log("updateVisibility showsensor: " + showSensor + " pump " + showPump + " target " + showTarget + " min " + showMin)
// for (const element of Array.from(sensorOnly)) {
// if (showSensor) {
@@ -336,7 +337,7 @@ export class PlantView {
getConfig(): PlantConfig {
let conv: PlantConfig = {
let conv: PlantConfig = {
mode: this.mode.value,
target_moisture: this.targetMoisture.valueAsNumber,
min_moisture: this.minMoisture.valueAsNumber,
@@ -361,11 +362,11 @@ export class PlantView {
setDetectionResult(plantResult: DetectionPlant) {
console.log("setDetectionResult plantResult: " + plantResult.sensor_a + " " + plantResult.sensor_b)
var changed = false;
if (this.sensorAInstalled.checked != plantResult.sensor_a){
if (this.sensorAInstalled.checked != plantResult.sensor_a) {
changed = true;
this.sensorAInstalled.checked = plantResult.sensor_a;
}
if (this.sensorBInstalled.checked != plantResult.sensor_b){
if (this.sensorBInstalled.checked != plantResult.sensor_b) {
changed = true;
this.sensorBInstalled.checked = plantResult.sensor_b;
}