-
-
Notifications
You must be signed in to change notification settings - Fork 12
Sensors #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sensors #128
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,7 @@ esp_err_t SystemStatus::systemStatus(PsychicRequest *request) | |
| root["core_temp"] = temperatureRead(); | ||
| root["cpu_reset_reason"] = verbosePrintResetReason(esp_reset_reason()); | ||
| root["uptime"] = millis() / 1000; | ||
| root["lps"] = 100; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded Every other field in this response is read from hardware or runtime state, but 🤖 Prompt for AI Agents |
||
| #ifdef CONFIG_IDF_TARGET_ESP32P4 | ||
| esp_hosted_coprocessor_fwver_t c6_fw_version; | ||
| esp_hosted_get_coprocessor_fwversion(&c6_fw_version); | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ enum IO_PinUsageEnum { | |
| pin_Dig_Input, // Digital Input pin type. May contains some protection circuit | ||
| pin_Exposed, | ||
| pin_Reserved, | ||
| pin_PIR, // support for PIR (passive infrared) sensor | ||
| pin_count | ||
| }; | ||
|
|
||
|
|
@@ -171,8 +172,8 @@ class ModuleIO : public Module { | |
| addControlValue(control, "I2S WS"); | ||
| addControlValue(control, "I2S SCK"); | ||
| addControlValue(control, "I2S MCLK"); | ||
| addControlValue(control, "I2C SDA"); | ||
| addControlValue(control, "I2C SCL"); | ||
| addControlValue(control, "I2C SDA 🔌"); | ||
| addControlValue(control, "I2C SCL 🔌"); | ||
| addControlValue(control, "Button 🛎️"); | ||
| addControlValue(control, "Button 𓐟"); | ||
| addControlValue(control, "Button LightOn 🛎️"); | ||
|
|
@@ -209,6 +210,7 @@ class ModuleIO : public Module { | |
| addControlValue(control, "Digital Input"); | ||
| addControlValue(control, "Exposed"); | ||
| addControlValue(control, "Reserved"); | ||
| addControlValue(control, "PIR ♨️"); | ||
|
|
||
| control = addControl(rows, "index", "number", 1, 32); // max 32 of one type, e.g 32 led pins | ||
| control["default"] = UINT8_MAX; | ||
|
|
@@ -259,6 +261,7 @@ class ModuleIO : public Module { | |
| JsonDocument doc; | ||
| JsonObject newState = doc.to<JsonObject>(); | ||
| newState["modded"] = false; | ||
| newState["I2CReady"] = false; | ||
|
|
||
| JsonArray pins = newState["pins"].to<JsonArray>(); | ||
|
|
||
|
|
@@ -491,10 +494,10 @@ class ModuleIO : public Module { | |
| pinAssigner.assignPin(0, pin_I2S_MCLK); | ||
| uint8_t exposedPins[] = {4, 5, 17, 19, 21, 22, 23, 25, 26, 27, 33}; | ||
| for (uint8_t gpio : exposedPins) pinAssigner.assignPin(gpio, pin_Exposed); // Ethernet Pins | ||
| } else if (boardID == board_MHCV57PRO) { // https://shop.myhome-control.de/ABC-WLED-Controller-PRO-V57-mit-iMOSFET/HW10030 | ||
| newState["maxPower"] = 75; // 15A Fuse @ 5V | ||
| uint8_t ledPins[] = {12, 13, 18, 32}; // 4 LED_PINS | ||
|
|
||
| } else if (boardID == board_MHCV57PRO) { // https://shop.myhome-control.de/ABC-WLED-Controller-PRO-V57-mit-iMOSFET/HW10030 | ||
| newState["maxPower"] = 75; // 15A Fuse @ 5V | ||
| uint8_t ledPins[] = {12, 13, 18, 32}; // 4 LED_PINS | ||
| for (uint8_t gpio : ledPins) pinAssigner.assignPin(gpio, pin_LED); | ||
| pinAssigner.assignPin(4, pin_Relay_LightsOn); | ||
| pinAssigner.assignPin(35, pin_I2S_SD); | ||
|
|
@@ -504,8 +507,8 @@ class ModuleIO : public Module { | |
| uint8_t exposedPins[] = {4, 5, 17, 19, 21, 22, 23, 25, 26, 27, 33}; | ||
| for (uint8_t gpio : exposedPins) pinAssigner.assignPin(gpio, pin_Exposed); // Ethernet Pins | ||
|
|
||
| } else if (boardID == board_MHCP4NanoV1) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 | ||
| newState["maxPower"] = 100; // Assuming decent LED power!! | ||
| } else if (boardID == board_MHCP4NanoV1) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 | ||
| newState["maxPower"] = 100; // Assuming decent LED power!! | ||
|
|
||
| if (_state.data["switch1"]) { // on: 8 LED Pins + RS485 + Dig Input | ||
| uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED pins in this order | ||
|
|
@@ -536,11 +539,11 @@ class ModuleIO : public Module { | |
| pinAssigner.assignPin(12, pin_I2S_SCK); | ||
| pinAssigner.assignPin(13, pin_I2S_MCLK); | ||
| } | ||
| } else if (boardID == board_MHCP4NanoV2) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 | ||
| newState["maxPower"] = 100; // Assuming decent LED power!! | ||
| pinAssigner.assignPin(7, pin_I2C_SDA); // on V2 these are I2C Pins | ||
| pinAssigner.assignPin(8, pin_I2C_SCL); // on V2 these are I2C Pins | ||
| if (_state.data["switch1"]) { // on: 8 LED Pins + RS485 + Dig Input | ||
| } else if (boardID == board_MHCP4NanoV2) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 | ||
| newState["maxPower"] = 100; // Assuming decent LED power!! | ||
| pinAssigner.assignPin(7, pin_I2C_SDA); // on V2 these are I2C Pins | ||
| pinAssigner.assignPin(8, pin_I2C_SCL); // on V2 these are I2C Pins | ||
| if (_state.data["switch1"]) { // on: 8 LED Pins + RS485 + Dig Input | ||
| uint8_t ledPins[] = {21, 20, 25, 5, 22, 23, 24, 27}; // 8 LED pins in this order | ||
| for (uint8_t gpio : ledPins) pinAssigner.assignPin(gpio, pin_LED); | ||
| pinAssigner.assignPin(3, pin_RS485_TX); | ||
|
|
@@ -551,7 +554,7 @@ class ModuleIO : public Module { | |
| pinAssigner.assignPin(46, pin_Dig_Input); | ||
| pinAssigner.assignPin(47, pin_Dig_Input); | ||
| pinAssigner.assignPin(48, pin_Dig_Input); | ||
| } else { // off / default: 16 LED pins | ||
| } else { // off / default: 16 LED pins | ||
| uint8_t ledPins[] = {21, 20, 25, 5, 22, 23, 24, 27, 3, 6, 53, 4, 46, 47, 2, 48}; // 16 LED_PINS in this order | ||
| for (uint8_t gpio : ledPins) pinAssigner.assignPin(gpio, pin_LED); | ||
| } | ||
|
|
@@ -609,8 +612,9 @@ class ModuleIO : public Module { | |
| for (uint8_t gpio : ledPins) pinAssigner.assignPin(gpio, pin_LED); | ||
| } else if (boardID == board_LuxceoMood1XiaoMod) { | ||
| newState["maxPower"] = 50; | ||
| uint8_t ledPins[] = {1, 2, 3, 4}; | ||
| uint8_t ledPins[] = {1, 2, 3}; | ||
| for (uint8_t gpio : ledPins) pinAssigner.assignPin(gpio, pin_LED); | ||
| pinAssigner.assignPin(4, pin_PIR); | ||
| pinAssigner.assignPin(5, pin_I2C_SDA); | ||
| pinAssigner.assignPin(6, pin_I2C_SCL); | ||
| pinAssigner.assignPin(7, pin_SPI_SCK); | ||
|
|
@@ -713,14 +717,22 @@ class ModuleIO : public Module { | |
| } | ||
| } | ||
|
|
||
| void loop() override { | ||
| bool called = false; | ||
|
|
||
| void loop20ms() override { | ||
| // run in sveltekit task | ||
| Module::loop(); | ||
| Module::loop20ms(); | ||
|
|
||
| if (newBoardID != UINT8_MAX) { | ||
| setBoardPresetDefaults(newBoardID); // run from sveltekit task | ||
| newBoardID = UINT8_MAX; | ||
| } | ||
|
|
||
| // during boot, the IO module is unchanged , not triggering updates, so need to do it manually | ||
| if (!called) { | ||
| callUpdateHandlers(_moduleName); // calls readPins for all subscribed handlers | ||
| called = true; | ||
| } | ||
|
Comment on lines
+720
to
+735
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double handler fan-out on boot when a board preset is active. When Consider either:
Also, Proposed fix- bool called = false;
+ bool _initialPinReadDone = false;
void loop20ms() override {
// run in sveltekit task
Module::loop20ms();
if (newBoardID != UINT8_MAX) {
setBoardPresetDefaults(newBoardID); // run from sveltekit task
newBoardID = UINT8_MAX;
+ _initialPinReadDone = true; // setBoardPresetDefaults→update already notified handlers
}
// during boot, the IO module is unchanged , not triggering updates, so need to do it manually
- if (!called) {
+ if (!_initialPinReadDone) {
callUpdateHandlers(_moduleName); // calls readPins for all subscribed handlers
- called = true;
+ _initialPinReadDone = true;
}
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| void readPins() { | ||
|
|
@@ -938,7 +950,7 @@ class ModuleIO : public Module { | |
| adc_attenuation_t current_readout_current_adc_attenuation = ADC_11db; | ||
| #endif | ||
|
|
||
| void loop1s() { | ||
| void loop1s() override { | ||
| if (_triggerUpdateI2C != UINT8_MAX) { | ||
| _updateI2CDevices(); | ||
| _triggerUpdateI2C = UINT8_MAX; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against releases with no assets.
If a GitHub release has no uploaded assets (e.g., a draft),
release.assetscould beundefinedor an empty array. Accessing.lengthonundefinedwill throw aTypeError. Consider adding an early return.Also,
includes()on Line 66 is a loose substring match — if target names overlap (e.g.,"esp32"matching a binary named"firmware-esp32s3.bin"), the wrong asset could be selected. Consider a more precise match (e.g., exact segment match or a regex with word boundaries).Proposed guard
function confirmGithubUpdate(release: any) { let url = ''; + if (!release.assets || release.assets.length === 0) { + modals.open(InfoDialog as unknown as ModalComponent<any>, { + title: 'No matching firmware found', + message: 'No assets found in release ' + release.name, + dismiss: { label: 'OK', icon: Check }, + onDismiss: () => modals.close() + }); + return; + } for (let i = 0; i < release.assets.length; i++) {🤖 Prompt for AI Agents