Skip to content

Commit d4c4f77

Browse files
authored
Merge pull request #73 from wladwnt/MyHomeControlDefenitions
Update board definitions
2 parents 7ac94ce + 2313af2 commit d4c4f77

File tree

2 files changed

+67
-17
lines changed

2 files changed

+67
-17
lines changed

docs/moonbase/inputoutput.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ For each board the following presets are defined:
1212

1313
* Modded: set when any pin differs from the selected board preset. Press off to return to the preset defaults.
1414
* 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/)
15-
* Jumper1: If the board contains a jumper, it can define pin behaviour. Eg. select between Infrared and Ethernet.
15+
* 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
1616
* Pins: Assign functionality to gpio pins. Other modules and nodes use the pin assignments made here.
1717
* GPIO = gpio_num;
1818
* Usage: See below
@@ -75,7 +75,12 @@ For each board the following presets are defined:
7575
* 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/)
7676
* After install, select the **MHC P4 Nano Shield** board preset to have the pins assigned correctly.
7777
* Assuming 100W LED power; change if needed.
78-
* 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).
78+
* Switch1: (set also the switches on the board)
79+
* off (default): 16 LED pins.
80+
* On: 8 LED pins, 4 RS-485 pins and 4 exposed pins
81+
* Switch2:
82+
* off (default): Pins 10, 11, 12, 13 used for build-in Mic over I2S, pin 7 and 8: I2C SDA and SCL
83+
* On: Pins 33, 25, 32, 36 used for Line in, pin 7 and 8: additional LED pins.
7984
* 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.
8085

8186

@@ -84,4 +89,4 @@ For each board the following presets are defined:
8489
![SE-16p](../firmware/installer/images/esp32-s3-stephanelec-16p.jpg){: style="width:100px"}
8590

8691
* Choose the esp32-s3-devkitc-1-n8r8v board in the [MoonLight Installer](../../gettingstarted/installer/)
87-
* Set jumper1 the same as you set it on the board: on: Infrared, off: Ethernet
92+
* Set Switch1 the same as you set the jumper on the board: off / default: Ethernet. on: Infrared.

src/MoonBase/Modules/ModuleIO.h

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ enum IO_PinUsageEnum {
5858
pin_SPI_MOSI,
5959
pin_PHY_CS,
6060
pin_PHY_IRQ,
61-
pin_RS485,
61+
pin_RS485_TX,
62+
pin_RS485_RX,
63+
pin_Dig_Input, // Digital Input pin type. May contains some protection circuit
6264
pin_Reserved,
6365
pin_count
6466
};
@@ -74,8 +76,8 @@ enum IO_BoardsEnum {
7476
board_SergUniShieldV5,
7577
board_SergMiniShield,
7678
board_SE16V1,
77-
board_MHCD0, // by Wladi
78-
board_MHCP4Nano, // by Wladi
79+
board_MHCV43, // by Wladi
80+
board_MHCP4NanoV1, // by Wladi V1.0
7981
board_YvesV48,
8082
board_TroyP4Nano,
8183
board_AtomS3,
@@ -113,8 +115,8 @@ class ModuleIO : public Module {
113115
addControlValue(control, "Serg Universal Shield");
114116
addControlValue(control, "Serg Mini Shield");
115117
addControlValue(control, "Mathieu SE16 v1");
116-
addControlValue(control, "MHC D0 Shield 🚧");
117-
addControlValue(control, "MHC P4 Nano Shield");
118+
addControlValue(control, "MyHome-Control V43 controller");
119+
addControlValue(control, "MyHome-Control P4 Nano Shield V1.0");
118120
addControlValue(control, "Yves V48 🚧");
119121
addControlValue(control, "Troy P4 Nano 🚧");
120122
addControlValue(control, "Atom S3R");
@@ -127,7 +129,10 @@ class ModuleIO : public Module {
127129
control = addControl(controls, "maxPower", "number", 0, 500, false, "Watt");
128130
control["default"] = 10;
129131

130-
control = addControl(controls, "jumper1", "checkbox");
132+
control = addControl(controls, "switch1", "checkbox");
133+
control["default"] = false;
134+
135+
control = addControl(controls, "switch2", "checkbox");
131136
control["default"] = false;
132137

133138
control = addControl(controls, "pins", "rows");
@@ -181,7 +186,9 @@ class ModuleIO : public Module {
181186
addControlValue(control, "SPI MOSI");
182187
addControlValue(control, "PHY CS");
183188
addControlValue(control, "PHY IRQ");
184-
addControlValue(control, "RS-485");
189+
addControlValue(control, "RS-485 TX");
190+
addControlValue(control, "RS-485 RX");
191+
addControlValue(control, "Digital Input");
185192
addControlValue(control, "Reserved");
186193

187194
control = addControl(rows, "index", "number", 1, 32); // max 32 of one type, e.g 32 led pins
@@ -282,7 +289,7 @@ class ModuleIO : public Module {
282289
pinAssigner.assignPin(8, pin_Voltage);
283290
pinAssigner.assignPin(9, pin_Current);
284291

285-
if (_state.data["jumper1"]) {
292+
if (_state.data["switch1"]) {
286293
pinAssigner.assignPin(5, pin_Infrared);
287294
} else { // default
288295
pinAssigner.assignPin(5, pin_SPI_MISO);
@@ -392,6 +399,33 @@ class ModuleIO : public Module {
392399

393400
pinAssigner.assignPin(17, pin_Button_LightsOn);
394401
pinAssigner.assignPin(19, pin_Relay_LightsOn);
402+
} else if (boardID == board_MHCV43) { // https://shop.myhome-control.de/ABC-WLED-Controller-Board-5-24V/HW10015
403+
object["maxPower"] = 75; // 15A Fuse @ 5V
404+
uint8_t ledPins[] = {12, 13, 16, 18}; // 4 LED_PINS
405+
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
406+
pinAssigner.assignPin(32, pin_I2S_SD);
407+
pinAssigner.assignPin(15, pin_I2S_WS);
408+
pinAssigner.assignPin(14, pin_I2S_SCK);
409+
pinAssigner.assignPin(0, pin_I2S_MCLK);
410+
uint8_t exposedPins[] = {4, 5, 17, 19, 21, 22, 23, 25, 26, 27, 33};
411+
for (int i = 0; i < sizeof(exposedPins); i++) pinAssigner.assignPin(exposedPins[i], pin_Exposed); // Ethernet Pins
412+
} else if (boardID == board_MHCP4NanoV1) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027
413+
object["maxPower"] = 100; // Assuming decent LED power!!
414+
415+
if (_state.data["switch1"]) { // on
416+
uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED pins in this order
417+
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
418+
pinAssigner.assignPin(3, pin_RS485_TX);
419+
pinAssigner.assignPin(4, pin_RS485_TX);
420+
pinAssigner.assignPin(22, pin_RS485_TX);
421+
pinAssigner.assignPin(24, pin_RS485_TX);
422+
pinAssigner.assignPin(2, pin_Dig_Input);
423+
pinAssigner.assignPin(46, pin_Dig_Input);
424+
pinAssigner.assignPin(47, pin_Dig_Input);
425+
pinAssigner.assignPin(48, pin_Dig_Input);
426+
} else { // off - default
427+
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
428+
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
395429
pinAssigner.assignPin(18, pin_Infrared);
396430

397431
// e.g. for mic
@@ -426,10 +460,21 @@ class ModuleIO : public Module {
426460
uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27, 3, 22, 24, 4, 46, 47, 2, 48}; // 16 LED_PINS
427461
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
428462
}
429-
pinAssigner.assignPin(33, pin_I2S_SD);
430-
pinAssigner.assignPin(26, pin_I2S_WS);
431-
pinAssigner.assignPin(32, pin_I2S_SCK);
432-
pinAssigner.assignPin(36, pin_I2S_MCLK);
463+
464+
if (_state.data["switch2"]) {
465+
// pins used for Line-In
466+
pinAssigner.assignPin(33, pin_I2S_SD);
467+
pinAssigner.assignPin(26, pin_I2S_WS);
468+
pinAssigner.assignPin(32, pin_I2S_SCK);
469+
pinAssigner.assignPin(36, pin_I2S_MCLK);
470+
} else { // default
471+
// Pins used for build-in Mic over I2S
472+
pinAssigner.assignPin(10, pin_I2S_WS);
473+
pinAssigner.assignPin(11, pin_I2S_SD);
474+
pinAssigner.assignPin(12, pin_I2S_SCK);
475+
pinAssigner.assignPin(13, pin_I2S_MCLK);
476+
}
477+
433478
} else if (boardID == board_YvesV48) {
434479
pinAssigner.assignPin(3, pin_LED);
435480
} else if (boardID == board_TroyP4Nano) {
@@ -508,8 +553,8 @@ class ModuleIO : public Module {
508553
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<String>().c_str());
509554
newBoardID = _state.data["boardPreset"]; // run in sveltekit task
510555
}
511-
} else if (updatedItem.name == "jumper1" && !_state.updateOriginId.contains("server")) { // not done by this module: done by UI
512-
// rebuild with new jumper setting
556+
} else if ((updatedItem.name == "switch1" || updatedItem.name == "switch2") && !_state.updateOriginId.contains("server")) {
557+
// rebuild with new switch setting
513558
_state.data["modded"] = false;
514559
newBoardID = _state.data["boardPreset"]; // run in sveltekit task
515560
} else if (updatedItem.name == "usage" && !_state.updateOriginId.contains("server")) { // not done by this module: done by UI

0 commit comments

Comments
 (0)