From ec39c7856b15873226e83d1dcaba76647c3adaab Mon Sep 17 00:00:00 2001 From: wladwnt <34422233+wladwnt@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:48:01 +0100 Subject: [PATCH 1/2] Update board definitions --- src/MoonBase/Modules/ModuleIO.h | 86 +++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 26 deletions(-) diff --git a/src/MoonBase/Modules/ModuleIO.h b/src/MoonBase/Modules/ModuleIO.h index 158b599fb..aec5b01fa 100644 --- a/src/MoonBase/Modules/ModuleIO.h +++ b/src/MoonBase/Modules/ModuleIO.h @@ -58,7 +58,9 @@ enum IO_PinUsage { pin_SPI_MOSI, pin_PHY_CS, pin_PHY_IRQ, - pin_RS485, + pin_RS485_TX, + pin_RS485_RX, + pin_Dig_Input, // Digital Input pin type. May contains some protection circuit pin_Reserved, pin_count }; @@ -74,8 +76,8 @@ enum IO_Boards { board_SergUniShieldV5, board_SergMiniShield, board_SE16V1, - board_MHCD0, // by Wladi - board_MHCP4Nano, // by Wladi + board_MHCV43, // by Wladi + board_MHCP4NanoV1, // by Wladi V1.0 board_YvesV48, board_TroyP4Nano, board_AtomS3, @@ -113,8 +115,8 @@ class ModuleIO : public Module { addControlValue(control, "Serg Universal Shield v5 🚧"); addControlValue(control, "Serg Mini Shield 🚧"); addControlValue(control, "Mathieu SE16 v1"); - addControlValue(control, "MHC D0 Shield 🚧"); - addControlValue(control, "MHC P4 Nano Shield"); + addControlValue(control, "MyHome-Control V43 controller"); + addControlValue(control, "MyHome-Control P4 Nano Shield V1.0"); addControlValue(control, "Yves V48 🚧"); addControlValue(control, "Troy P4 Nano 🚧"); addControlValue(control, "Atom S3R"); @@ -129,6 +131,9 @@ class ModuleIO : public Module { control = addControl(controls, "jumper1", "checkbox"); control["default"] = false; + + control = addControl(controls, "UseLineIn", "checkbox"); + control["default"] = false; control = addControl(controls, "pins", "rows"); control["filter"] = "!Unused"; @@ -181,7 +186,9 @@ class ModuleIO : public Module { addControlValue(control, "SPI MOSI"); addControlValue(control, "PHY CS"); addControlValue(control, "PHY IRQ"); - addControlValue(control, "RS-485"); + addControlValue(control, "RS-485 TX"); + addControlValue(control, "RS-485 RX"); + addControlValue(control, "Digital Input"); addControlValue(control, "Reserved"); control = addControl(rows, "index", "number", 1, 32); // max 32 of one type, e.g 32 led pins @@ -373,30 +380,57 @@ class ModuleIO : public Module { pinAssigner.assignPin(1, pin_LED); pinAssigner.assignPin(3, pin_LED); pinAssigner.assignPin(19, pin_Relay_LightsOn); - } else if (boardID == board_MHCD0) { - pinAssigner.assignPin(3, pin_Voltage); - } else if (boardID == board_MHCP4Nano) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 + } else if (boardID == board_MHCV43) { // https://shop.myhome-control.de/ABC-WLED-Controller-Board-5-24V/HW10015 + object["maxPower"] = 75; // 15A Fuse @ 5V + pinAssigner.assignPin(12, pin_LED); + pinAssigner.assignPin(13, pin_LED); + pinAssigner.assignPin(16, pin_LED); + pinAssigner.assignPin(18, pin_LED); + uint8_t ledPins[4] = {12, 13, 16, 18}; // 4 LED_PINS + for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED); + pinAssigner.assignPin(32, pin_I2S_SD); + pinAssigner.assignPin(15, pin_I2S_WS); + pinAssigner.assignPin(14, pin_I2S_SCK); + pinAssigner.assignPin(0, pin_I2S_MCLK); + uint8_t exposedPins[11] = {4, 5, 17, 19, 21, 22, 23, 25, 26, 27, 33}; + for (int i = 0; i < sizeof(exposedPins); i++) pinAssigner.assignPin(exposedPins[i], pin_Exposed); // Ethernet Pins + + } else if (boardID == board_MHCP4NanoV1) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 object["maxPower"] = 100; // Assuming decent LED power!! - if (_state.data["jumper1"]) { // on - uint8_t ledPins[8] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED_PINS + uint8_t ledPins[6] = {21, 20, 25, 5, 23, 27}; // Always LED Pins independend from switches for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED); + if (_state.data["jumper1"]) {// on // per default used as LED Pins - pinAssigner.assignPin(3, pin_RS485); - pinAssigner.assignPin(4, pin_RS485); - pinAssigner.assignPin(22, pin_RS485); - pinAssigner.assignPin(24, pin_RS485); - pinAssigner.assignPin(2, pin_Exposed); - pinAssigner.assignPin(46, pin_Exposed); - pinAssigner.assignPin(47, pin_Exposed); - pinAssigner.assignPin(48, pin_Exposed); - } else { // off - default - uint8_t ledPins[16] = {21, 20, 25, 5, 7, 23, 8, 27, 3, 22, 24, 4, 46, 47, 2, 48}; // 16 LED_PINS + pinAssigner.assignPin(3, pin_RS485_TX); + pinAssigner.assignPin(4, pin_RS485_TX); + pinAssigner.assignPin(22, pin_RS485_TX); + pinAssigner.assignPin(24, pin_RS485_TX); + pinAssigner.assignPin(2, pin_Dig_Input); + pinAssigner.assignPin(46, pin_Dig_Input); + pinAssigner.assignPin(47, pin_Dig_Input); + pinAssigner.assignPin(48, pin_Dig_Input); + } else { // off - default + uint8_t ledPins[8] = {3, 22, 24, 4, 46, 47, 2, 48}; // 8 LED_PINS for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED); } - pinAssigner.assignPin(33, pin_I2S_SD); - pinAssigner.assignPin(26, pin_I2S_WS); - pinAssigner.assignPin(32, pin_I2S_SCK); - pinAssigner.assignPin(36, pin_I2S_MCLK); + if (_state.data["UseLineIn"]) { + // pins used for Line-In + pinAssigner.assignPin(33, pin_I2S_SD); + pinAssigner.assignPin(26, pin_I2S_WS); + pinAssigner.assignPin(32, pin_I2S_SCK); + pinAssigner.assignPin(36, pin_I2S_MCLK); + pinAssigner.assignPin(7, pin_LED); + pinAssigner.assignPin(8, pin_LED); + } else { + // Pins used for build-in Mic over I2S + pinAssigner.assignPin(10, pin_I2S_WS); + pinAssigner.assignPin(11, pin_I2S_SD); + pinAssigner.assignPin(12, pin_I2S_SCK); + pinAssigner.assignPin(13, pin_I2S_MCLK); + pinAssigner.assignPin(7, pin_I2C_SDA); + pinAssigner.assignPin(8, pin_I2C_SCL); + } + } else if (boardID == board_YvesV48) { pinAssigner.assignPin(3, pin_LED); } else if (boardID == board_TroyP4Nano) { @@ -471,7 +505,7 @@ class ModuleIO : public Module { EXT_LOGD(MB_TAG, "%s[%d]%s[%d].%s = %s -> %s", updatedItem.parent[0].c_str(), updatedItem.index[0], updatedItem.parent[1].c_str(), updatedItem.index[1], updatedItem.name.c_str(), updatedItem.oldValue.c_str(), updatedItem.value.as().c_str()); newBoardID = _state.data["boardPreset"]; // run in sveltekit task } - } else if (updatedItem.name == "jumper1" && !_state.updateOriginId.contains("server")) { // not done by this module: done by UI + } else if ( (updatedItem.name == "jumper1" || updatedItem.name == "UseLineIn") && !_state.updateOriginId.contains("server")) { // not done by this module: done by UI // rebuild with new jumper setting _state.data["modded"] = false; newBoardID = _state.data["boardPreset"]; // run in sveltekit task From 2a795d2530cc72221083390237a0036c07884c46 Mon Sep 17 00:00:00 2001 From: ewowi Date: Sat, 13 Dec 2025 17:27:32 +0100 Subject: [PATCH 2/2] IO Module MHC board changes Docs ==== - Inputoutput: describe switch 1 and 2 - ModuleIO: Format document + jumper/uselinein to switch 1 and 2 (board independent), board_MHCV43: remove double entry, board_MHCV43: order of LED pins --- docs/moonbase/inputoutput.md | 11 ++++-- src/MoonBase/Modules/ModuleIO.h | 70 +++++++++++++++------------------ 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/docs/moonbase/inputoutput.md b/docs/moonbase/inputoutput.md index 3d6ba2bbe..b99f342c6 100644 --- a/docs/moonbase/inputoutput.md +++ b/docs/moonbase/inputoutput.md @@ -12,7 +12,7 @@ For each board the following presets are defined: * Modded: set when any pin differs from the selected board preset. Press off to return to the preset defaults. * Max Power in Watts: adjust the brightness to approach this max power, depending on the number of LEDs used. Default 10: 5V * 2A = 10W (so it runs fine on USB). Used by LED drivers, see [Drivers](../../moonlight/drivers/) -* Jumper1: If the board contains a jumper, it can define pin behaviour. Eg. select between Infrared and Ethernet. +* Switch1 and 2: If the board contains a jumper or pins have different functions, a custom switch can be set. Eg. select between Infrared and Ethernet. See boards below for details * Pins: Assign functionality to gpio pins. Other modules and nodes use the pin assignments made here. * GPIO = gpio_num; * Usage: See below @@ -75,7 +75,12 @@ For each board the following presets are defined: * On new ESP32-P4 Nano boards, the WiFi coprocessor needs to be updated first to a recent version, currently ESP-Hosted v2.0.17, see the link in the [MoonLight Installer](../../gettingstarted/installer/) * After install, select the **MHC P4 Nano Shield** board preset to have the pins assigned correctly. * Assuming 100W LED power; change if needed. - * Jumper1: off (default): 16 LED pins. On: 8 LED pins, 4 RS-485 pins and 4 exposed pins (set also the switches on the board). + * Switch1: (set also the switches on the board) + * off (default): 16 LED pins. + * On: 8 LED pins, 4 RS-485 pins and 4 exposed pins + * Switch2: + * off (default): Pins 10, 11, 12, 13 used for build-in Mic over I2S, pin 7 and 8: I2C SDA and SCL + * On: Pins 33, 25, 32, 36 used for Line in, pin 7 and 8: additional LED pins. * Add the Parallel LED Driver, see [Drivers](../../moonlight/drivers/). It uses [@troyhacks](https://github.com/troyhacks) his parallel IO driver to drive all LED pins configured for the shield. @@ -84,4 +89,4 @@ For each board the following presets are defined: ![SE-16p](../firmware/installer/images/esp32-s3-stephanelec-16p.jpg){: style="width:100px"} * Choose the esp32-s3-devkitc-1-n8r8v board in the [MoonLight Installer](../../gettingstarted/installer/) -* Set jumper1 the same as you set it on the board: on: Infrared, off: Ethernet \ No newline at end of file +* Set Switch1 the same as you set the jumper on the board: off / default: Ethernet. on: Infrared. \ No newline at end of file diff --git a/src/MoonBase/Modules/ModuleIO.h b/src/MoonBase/Modules/ModuleIO.h index aec5b01fa..236ce82b8 100644 --- a/src/MoonBase/Modules/ModuleIO.h +++ b/src/MoonBase/Modules/ModuleIO.h @@ -59,8 +59,8 @@ enum IO_PinUsage { pin_PHY_CS, pin_PHY_IRQ, pin_RS485_TX, - pin_RS485_RX, - pin_Dig_Input, // Digital Input pin type. May contains some protection circuit + pin_RS485_RX, + pin_Dig_Input, // Digital Input pin type. May contains some protection circuit pin_Reserved, pin_count }; @@ -76,7 +76,7 @@ enum IO_Boards { board_SergUniShieldV5, board_SergMiniShield, board_SE16V1, - board_MHCV43, // by Wladi + board_MHCV43, // by Wladi board_MHCP4NanoV1, // by Wladi V1.0 board_YvesV48, board_TroyP4Nano, @@ -129,10 +129,10 @@ class ModuleIO : public Module { control = addControl(controls, "maxPower", "number", 0, 500, false, "Watt"); control["default"] = 10; - control = addControl(controls, "jumper1", "checkbox"); + control = addControl(controls, "switch1", "checkbox"); control["default"] = false; - - control = addControl(controls, "UseLineIn", "checkbox"); + + control = addControl(controls, "switch2", "checkbox"); control["default"] = false; control = addControl(controls, "pins", "rows"); @@ -187,8 +187,8 @@ class ModuleIO : public Module { addControlValue(control, "PHY CS"); addControlValue(control, "PHY IRQ"); addControlValue(control, "RS-485 TX"); - addControlValue(control, "RS-485 RX"); - addControlValue(control, "Digital Input"); + addControlValue(control, "RS-485 RX"); + addControlValue(control, "Digital Input"); addControlValue(control, "Reserved"); control = addControl(rows, "index", "number", 1, 32); // max 32 of one type, e.g 32 led pins @@ -289,7 +289,7 @@ class ModuleIO : public Module { pinAssigner.assignPin(8, pin_Voltage); pinAssigner.assignPin(9, pin_Current); - if (_state.data["jumper1"]) { + if (_state.data["switch1"]) { pinAssigner.assignPin(5, pin_Infrared); } else { // default pinAssigner.assignPin(5, pin_SPI_MISO); @@ -380,27 +380,22 @@ class ModuleIO : public Module { pinAssigner.assignPin(1, pin_LED); pinAssigner.assignPin(3, pin_LED); pinAssigner.assignPin(19, pin_Relay_LightsOn); - } else if (boardID == board_MHCV43) { // https://shop.myhome-control.de/ABC-WLED-Controller-Board-5-24V/HW10015 - object["maxPower"] = 75; // 15A Fuse @ 5V - pinAssigner.assignPin(12, pin_LED); - pinAssigner.assignPin(13, pin_LED); - pinAssigner.assignPin(16, pin_LED); - pinAssigner.assignPin(18, pin_LED); - uint8_t ledPins[4] = {12, 13, 16, 18}; // 4 LED_PINS + } else if (boardID == board_MHCV43) { // https://shop.myhome-control.de/ABC-WLED-Controller-Board-5-24V/HW10015 + object["maxPower"] = 75; // 15A Fuse @ 5V + uint8_t ledPins[] = {12, 13, 16, 18}; // 4 LED_PINS for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED); - pinAssigner.assignPin(32, pin_I2S_SD); + pinAssigner.assignPin(32, pin_I2S_SD); pinAssigner.assignPin(15, pin_I2S_WS); pinAssigner.assignPin(14, pin_I2S_SCK); pinAssigner.assignPin(0, pin_I2S_MCLK); - uint8_t exposedPins[11] = {4, 5, 17, 19, 21, 22, 23, 25, 26, 27, 33}; + uint8_t exposedPins[] = {4, 5, 17, 19, 21, 22, 23, 25, 26, 27, 33}; for (int i = 0; i < sizeof(exposedPins); i++) pinAssigner.assignPin(exposedPins[i], pin_Exposed); // Ethernet Pins - - } else if (boardID == board_MHCP4NanoV1) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 - object["maxPower"] = 100; // Assuming decent LED power!! - uint8_t ledPins[6] = {21, 20, 25, 5, 23, 27}; // Always LED Pins independend from switches + } else if (boardID == board_MHCP4NanoV1) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027 + object["maxPower"] = 100; // Assuming decent LED power!! + + if (_state.data["switch1"]) { // on + uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED pins in this order for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED); - if (_state.data["jumper1"]) {// on - // per default used as LED Pins pinAssigner.assignPin(3, pin_RS485_TX); pinAssigner.assignPin(4, pin_RS485_TX); pinAssigner.assignPin(22, pin_RS485_TX); @@ -409,28 +404,25 @@ 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 - uint8_t ledPins[8] = {3, 22, 24, 4, 46, 47, 2, 48}; // 8 LED_PINS + } else { // off - default + uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27, 3, 22, 24, 4, 46, 47, 2, 48}; // 16 LED_PINS in this order for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED); } - if (_state.data["UseLineIn"]) { - // pins used for Line-In - pinAssigner.assignPin(33, pin_I2S_SD); + + if (_state.data["switch2"]) { + // pins used for Line-In + pinAssigner.assignPin(33, pin_I2S_SD); pinAssigner.assignPin(26, pin_I2S_WS); pinAssigner.assignPin(32, pin_I2S_SCK); pinAssigner.assignPin(36, pin_I2S_MCLK); - pinAssigner.assignPin(7, pin_LED); - pinAssigner.assignPin(8, pin_LED); - } else { - // Pins used for build-in Mic over I2S - pinAssigner.assignPin(10, pin_I2S_WS); + } else { // default + // Pins used for build-in Mic over I2S + pinAssigner.assignPin(10, pin_I2S_WS); pinAssigner.assignPin(11, pin_I2S_SD); pinAssigner.assignPin(12, pin_I2S_SCK); pinAssigner.assignPin(13, pin_I2S_MCLK); - pinAssigner.assignPin(7, pin_I2C_SDA); - pinAssigner.assignPin(8, pin_I2C_SCL); } - + } else if (boardID == board_YvesV48) { pinAssigner.assignPin(3, pin_LED); } else if (boardID == board_TroyP4Nano) { @@ -505,8 +497,8 @@ class ModuleIO : public Module { EXT_LOGD(MB_TAG, "%s[%d]%s[%d].%s = %s -> %s", updatedItem.parent[0].c_str(), updatedItem.index[0], updatedItem.parent[1].c_str(), updatedItem.index[1], updatedItem.name.c_str(), updatedItem.oldValue.c_str(), updatedItem.value.as().c_str()); newBoardID = _state.data["boardPreset"]; // run in sveltekit task } - } else if ( (updatedItem.name == "jumper1" || updatedItem.name == "UseLineIn") && !_state.updateOriginId.contains("server")) { // not done by this module: done by UI - // rebuild with new jumper setting + } else if ((updatedItem.name == "switch1" || updatedItem.name == "switch2") && !_state.updateOriginId.contains("server")) { + // rebuild with new switch setting _state.data["modded"] = false; newBoardID = _state.data["boardPreset"]; // run in sveltekit task } else if (updatedItem.name == "usage" && !_state.updateOriginId.contains("server")) { // not done by this module: done by UI