update: refactor and enhance CAN sensor initialization, reorganize GPIO assignments, improve error detection and logging, and streamline TWAI handling
This commit is contained in:
@@ -141,6 +141,10 @@ export interface TestPump {
|
||||
pump: number
|
||||
}
|
||||
|
||||
export interface CanPower {
|
||||
state: boolean
|
||||
}
|
||||
|
||||
export interface SetTime {
|
||||
time: string
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
<h3>Plants:</h3>
|
||||
<button id="measure_moisture">Measure Moisture</button>
|
||||
<button id="detect_sensors" style="display:none">Detect/Test Sensors</button>
|
||||
<input id="can_power" type="checkbox">Power CAN</input>
|
||||
<div id="plants" class="plantlist"></div>
|
||||
|
||||
<div class="flexcontainer-rev">
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
SetTime, SSIDList, TankInfo,
|
||||
TestPump,
|
||||
VersionInfo,
|
||||
FileList, SolarState, PumpTestResult, DetectionResult
|
||||
FileList, SolarState, PumpTestResult, DetectionResult, CanPower
|
||||
} from "./api";
|
||||
import {SolarView} from "./solarview";
|
||||
import {toast} from "./toast";
|
||||
@@ -527,6 +527,18 @@ export class Controller {
|
||||
setTimeout(this.waitForReboot, 1000)
|
||||
}
|
||||
|
||||
private setCanPower(checked: boolean) {
|
||||
var body: CanPower = {
|
||||
state : checked
|
||||
}
|
||||
var pretty = JSON.stringify(body, undefined, 1);
|
||||
|
||||
fetch(PUBLIC_URL + "/can_power", {
|
||||
method: "POST",
|
||||
body: pretty
|
||||
})
|
||||
}
|
||||
|
||||
initialConfig: PlantControllerConfig | null = null
|
||||
readonly rebootBtn: HTMLButtonElement
|
||||
readonly exitBtn: HTMLButtonElement
|
||||
@@ -544,6 +556,7 @@ export class Controller {
|
||||
readonly fileview: FileView;
|
||||
readonly logView: LogView
|
||||
readonly detectBtn: HTMLButtonElement
|
||||
readonly can_power: HTMLInputElement;
|
||||
|
||||
constructor() {
|
||||
this.timeView = new TimeView(this)
|
||||
@@ -569,7 +582,13 @@ export class Controller {
|
||||
this.exitBtn.onclick = () => {
|
||||
controller.exit();
|
||||
}
|
||||
this.can_power = document.getElementById("can_power") as HTMLInputElement
|
||||
this.can_power.onchange = () => {
|
||||
controller.setCanPower(this.can_power.checked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const controller = new Controller();
|
||||
|
||||
Reference in New Issue
Block a user