Skip to content

Commit 2313af2

Browse files
authored
Merge branch 'main' into MyHomeControlDefenitions
2 parents 2a795d2 + 7ac94ce commit 2313af2

File tree

16 files changed

+12972
-12853
lines changed

16 files changed

+12972
-12853
lines changed

firmware/esp32-p4.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ upload_speed = 921600
2626
; framework = arduino
2727
; monitor_speed = 115200
2828
build_flags = ${esp32-p4-base.build_flags}
29-
-Wl,-wrap,esp_dma_capable_malloc ;; makes SDIO for ESP-Hosted use PSRAM if available.
30-
29+
; -Wl,-wrap,esp_dma_capable_malloc ;; makes SDIO for ESP-Hosted use PSRAM if available. (calls to esp_dma_capable_malloc() get redirected to __wrap_esp_dma_capable_malloc())
3130
lib_deps = ${esp32-p4-base.lib_deps}
3231
; RAM: [= ] 11.2% (used 36580 bytes from 327680 bytes)
3332
; Flash: [======== ] 82.3% (used 1726193 bytes from 2097152 bytes)

interface/src/lib/components/moonbase/MultiInput.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
{:else if property.type == 'number'}
185185
<input
186186
type="number"
187-
style="width: {String(property.max || 255).length + 4}ch"
187+
style="width: {String(property.max || 255).length + 5}ch"
188188
min={property.min ? property.min : 0}
189189
max={property.max ? property.max : 255}
190190
class="input invalid:border-error invalid:border-2"

interface/src/routes/moonbase/monitor/Monitor.svelte

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@
5454
let offsetRGB: number;
5555
let offsetWhite: number;
5656
let isPositions: boolean = false;
57+
let lightPreset: number;
58+
let nrOfChannels: number = 0;
5759
// let offsetRed:number;
5860
// let offsetGreen:number;
5961
// let offsetBlue:number;
62+
const lightPreset_RGB2040 = 9;
6063
6164
const handleHeader = (header: Uint8Array) => {
6265
console.log('Monitor.handleHeader', header);
@@ -70,10 +73,12 @@
7073
// offsetBlue = (header[6] >> 6) & 0x3; // bits 6-7
7174
// offsetWhite = header[13];
7275
73-
nrOfLights = view.getUint16(12, true); // header[12] + 256 * header[13];
74-
channelsPerLight = view.getUint8(19); //header[19];
75-
offsetRGB = view.getUint8(20); //header[20];
76-
offsetWhite = view.getUint8(21); //header[21];
76+
nrOfLights = view.getUint16(12, true);
77+
channelsPerLight = view.getUint8(19);
78+
offsetRGB = view.getUint8(20);
79+
offsetWhite = view.getUint8(21);
80+
nrOfChannels = view.getUint16(32, true);
81+
lightPreset = view.getUint8(34);
7782
7883
//rebuild scene
7984
createScene(el);
@@ -95,17 +100,18 @@
95100
depth,
96101
nrOfLights,
97102
channelsPerLight,
98-
offsetRGB
103+
offsetRGB,
104+
nrOfChannels
99105
);
100106
};
101107
102108
const handlePositions = (positions: Uint8Array) => {
103109
console.log('Monitor.handlePositions', positions);
104110
105-
for (let index = 0; index < nrOfLights * 3; index += 3) {
106-
let x = positions[index];
107-
let y = positions[index + 1];
108-
let z = positions[index + 2];
111+
for (let indexP = 0; indexP < nrOfLights; indexP++) {
112+
let x = positions[indexP * 3];
113+
let y = positions[indexP * 3 + 1];
114+
let z = positions[indexP * 3 + 2];
109115
110116
//set to -1,1 coordinate system of webGL
111117
//width -1 etc as 0,0 should be top left, not bottom right
@@ -124,17 +130,20 @@
124130
done = true;
125131
}
126132
clearColors();
133+
const groupSize = 20 * channelsPerLight; // RGB2040 groups: 20 lights per physical group (will be 3 channelsPerLight)
127134
//max size supported is 255x255x255 (index < width * height * depth) ... todo: only any of the component < 255
128-
for (let index = 0; index < nrOfLights * channelsPerLight; index += channelsPerLight) {
129-
// && index < width * height * depth
130-
// colorLed(index/3, data[index]/255, data[index+1]/255, data[index+2]/255);
131-
const r = channels[index + offsetRGB + 0] / 255;
132-
const g = channels[index + offsetRGB + 1] / 255;
133-
const b = channels[index + offsetRGB + 2] / 255;
134-
let w = 0;
135-
if (offsetWhite != 255) w = channels[index + offsetRGB + 3] / 255; //add white channel if present
136-
const a = 1.0; // Full opacity
137-
colors.push(r + w, g + w, b + w, a);
135+
for (let index = 0; index < nrOfChannels; index += channelsPerLight) {
136+
if (lightPreset != lightPreset_RGB2040 || Math.floor(index / groupSize) % 2 == 0) {
137+
// Math.floor: RGB2040 Skip the empty channels
138+
// && index < width * height * depth
139+
const r = channels[index + offsetRGB + 0] / 255;
140+
const g = channels[index + offsetRGB + 1] / 255;
141+
const b = channels[index + offsetRGB + 2] / 255;
142+
let w = 0;
143+
if (offsetWhite != 255) w = channels[index + offsetRGB + 3] / 255; //add white channel if present
144+
const a = 1.0; // Full opacity
145+
colors.push(r + w, g + w, b + w, a);
146+
}
138147
}
139148
140149
updateScene(vertices, colors);

lib/framework/WWWData.h

Lines changed: 12735 additions & 12732 deletions
Large diffs are not rendered by default.

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ build_flags =
5656
-D BUILD_TARGET=\"$PIOENV\"
5757
-D APP_NAME=\"MoonLight\" ; 🌙 Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename
5858
-D APP_VERSION=\"0.6.1\" ; semver compatible version string
59-
-D APP_DATE=\"2025121212\" ; 🌙
59+
-D APP_DATE=\"2025121511\" ; 🌙
6060

6161
-D PLATFORM_VERSION=\"pioarduino-55.03.34\" ; 🌙 make sure it matches with above plaftform
6262

src/MoonBase/Modules/ModuleIO.h

Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "MoonBase/Module.h"
1818

19-
enum IO_PinUsage {
19+
enum IO_PinUsageEnum {
2020
pin_Unused, // 0
2121
pin_LED,
2222
pin_LED_CW,
@@ -65,7 +65,7 @@ enum IO_PinUsage {
6565
pin_count
6666
};
6767

68-
enum IO_Boards {
68+
enum IO_BoardsEnum {
6969
board_none, //
7070
board_QuinLEDDigUnoV3,
7171
board_QuinLEDDigQuadV3,
@@ -112,8 +112,8 @@ class ModuleIO : public Module {
112112
addControlValue(control, "QuinLED Dig Quad v3");
113113
addControlValue(control, "QuinLED Dig Octa v2");
114114
addControlValue(control, "QuinLED Dig 2Go");
115-
addControlValue(control, "Serg Universal Shield v5 🚧");
116-
addControlValue(control, "Serg Mini Shield 🚧");
115+
addControlValue(control, "Serg Universal Shield");
116+
addControlValue(control, "Serg Mini Shield");
117117
addControlValue(control, "Mathieu SE16 v1");
118118
addControlValue(control, "MyHome-Control V43 controller");
119119
addControlValue(control, "MyHome-Control P4 Nano Shield V1.0");
@@ -281,8 +281,8 @@ class ModuleIO : public Module {
281281

282282
if (boardID == board_SE16V1) {
283283
object["maxPower"] = 500;
284-
uint8_t ledPins[16] = {47, 48, 21, 38, 14, 39, 13, 40, 12, 41, 11, 42, 10, 2, 3, 1}; // LED_PINS
285-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
284+
uint8_t ledPins[] = {47, 48, 21, 38, 14, 39, 13, 40, 12, 41, 11, 42, 10, 2, 3, 1}; // LED_PINS
285+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
286286
pinAssigner.assignPin(0, pin_ButtonPush);
287287
pinAssigner.assignPin(45, pin_ButtonPush);
288288
pinAssigner.assignPin(46, pin_Button_LightsOn);
@@ -317,8 +317,8 @@ class ModuleIO : public Module {
317317
// Dig-Quad-V3
318318
// esp32-d0 (4MB)
319319
object["maxPower"] = 150;
320-
uint8_t ledPins[4] = {16, 3, 1, 4}; // LED_PINS
321-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
320+
uint8_t ledPins[] = {16, 3, 1, 4}; // LED_PINS
321+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
322322
pinAssigner.assignPin(0, pin_ButtonPush);
323323

324324
pinAssigner.assignPin(15, pin_Relay);
@@ -330,9 +330,9 @@ class ModuleIO : public Module {
330330
// pinAssigner.assignPin(32, pin_Exposed;
331331
} else if (boardID == board_QuinLEDDigOctaV2) {
332332
// Dig-Octa-32-8L
333-
object["maxPower"] = 400; // 10A Fuse * 8 ... 400 W
334-
uint8_t ledPins[8] = {0, 1, 2, 3, 4, 5, 12, 13}; // LED_PINS
335-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
333+
object["maxPower"] = 400; // 10A Fuse * 8 ... 400 W
334+
uint8_t ledPins[] = {0, 1, 2, 3, 4, 5, 12, 13}; // LED_PINS
335+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
336336
pinAssigner.assignPin(33, pin_Relay);
337337
pinAssigner.assignPin(34, pin_ButtonPush);
338338
} else if (boardID == board_QuinLEDDig2Go) {
@@ -351,8 +351,8 @@ class ModuleIO : public Module {
351351
pinAssigner.assignPin(25, pin_Exposed);
352352
// pinAssigner.assignPin(xx, pin_I2S_MCLK);
353353
// } else if (boardID == board_QuinLEDPenta) {
354-
// uint8_t ledPins[5] = {14, 13, 12, 4, 2}; // LED_PINS
355-
// for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
354+
// uint8_t ledPins[] = {14, 13, 12, 4, 2}; // LED_PINS
355+
// for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
356356
// pinAssigner.assignPin(34, pin_ButtonPush);
357357
// pinAssigner.assignPin(35, pin_ButtonPush);
358358
// pinAssigner.assignPin(39, pin_ButtonPush);
@@ -373,12 +373,31 @@ class ModuleIO : public Module {
373373
// pinAssigner.assignPin(5, pin_LED);
374374
} else if (boardID == board_SergMiniShield) {
375375
object["maxPower"] = 50; // 10A Fuse ...
376-
pinAssigner.assignPin(1, pin_LED);
377-
pinAssigner.assignPin(3, pin_LED);
376+
pinAssigner.assignPin(16, pin_LED);
377+
// pinAssigner.assignPin(17, pin_LED); // e.g. apa102...
378+
379+
// pinAssigner.assignPin(??, pin_Button_LightsOn); // which pin ?
380+
pinAssigner.assignPin(19, pin_Relay_LightsOn); // optional
381+
382+
// e.g. for mic
383+
pinAssigner.assignPin(32, pin_I2S_SD);
384+
pinAssigner.assignPin(15, pin_I2S_WS);
385+
pinAssigner.assignPin(14, pin_I2S_SCK);
386+
// pinAssigner.assignPin(36, nc/ao...);
387+
388+
// e.g. for 4 line display
389+
pinAssigner.assignPin(21, pin_I2C_SDA);
390+
pinAssigner.assignPin(22, pin_I2C_SCL);
378391
} else if (boardID == board_SergUniShieldV5) {
379392
object["maxPower"] = 50; // 10A Fuse ...
380-
pinAssigner.assignPin(1, pin_LED);
381-
pinAssigner.assignPin(3, pin_LED);
393+
394+
pinAssigner.assignPin(16, pin_LED); // first pin
395+
if (_state.data["jumper1"])
396+
pinAssigner.assignPin(1, pin_LED);
397+
else // default
398+
pinAssigner.assignPin(3, pin_LED);
399+
400+
pinAssigner.assignPin(17, pin_Button_LightsOn);
382401
pinAssigner.assignPin(19, pin_Relay_LightsOn);
383402
} else if (boardID == board_MHCV43) { // https://shop.myhome-control.de/ABC-WLED-Controller-Board-5-24V/HW10015
384403
object["maxPower"] = 75; // 15A Fuse @ 5V
@@ -407,6 +426,39 @@ class ModuleIO : public Module {
407426
} else { // off - default
408427
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
409428
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
429+
pinAssigner.assignPin(18, pin_Infrared);
430+
431+
// e.g. for mic
432+
pinAssigner.assignPin(32, pin_I2S_SD);
433+
pinAssigner.assignPin(15, pin_I2S_WS);
434+
pinAssigner.assignPin(14, pin_I2S_SCK);
435+
// pinAssigner.assignPin(36, nc/ao...);
436+
437+
// e.g. for 4 line display
438+
pinAssigner.assignPin(21, pin_I2C_SDA);
439+
pinAssigner.assignPin(22, pin_I2C_SCL);
440+
441+
// pinAssigner.assignPin(?, pin_Temperature); // todo: check temp pin
442+
443+
} else if (boardID == board_MHCD0) {
444+
pinAssigner.assignPin(3, pin_Voltage);
445+
} else if (boardID == board_MHCP4Nano) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027
446+
object["maxPower"] = 100; // Assuming decent LED power!!
447+
if (_state.data["jumper1"]) { // on
448+
uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED_PINS
449+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
450+
// per default used as LED Pins
451+
pinAssigner.assignPin(3, pin_RS485);
452+
pinAssigner.assignPin(4, pin_RS485);
453+
pinAssigner.assignPin(22, pin_RS485);
454+
pinAssigner.assignPin(24, pin_RS485);
455+
pinAssigner.assignPin(2, pin_Exposed);
456+
pinAssigner.assignPin(46, pin_Exposed);
457+
pinAssigner.assignPin(47, pin_Exposed);
458+
pinAssigner.assignPin(48, pin_Exposed);
459+
} else { // off - default
460+
uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27, 3, 22, 24, 4, 46, 47, 2, 48}; // 16 LED_PINS
461+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
410462
}
411463

412464
if (_state.data["switch2"]) {
@@ -426,9 +478,9 @@ class ModuleIO : public Module {
426478
} else if (boardID == board_YvesV48) {
427479
pinAssigner.assignPin(3, pin_LED);
428480
} else if (boardID == board_TroyP4Nano) {
429-
object["maxPower"] = 10; // USB compliant
430-
uint8_t ledPins[16] = {2, 3, 4, 5, 6, 20, 21, 22, 23, 26, 27, 32, 33, 36, 47, 48}; // LED_PINS
431-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
481+
object["maxPower"] = 10; // USB compliant
482+
uint8_t ledPins[] = {2, 3, 4, 5, 6, 20, 21, 22, 23, 26, 27, 32, 33, 36, 47, 48}; // LED_PINS
483+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
432484
pinAssigner.assignPin(7, pin_I2C_SDA);
433485
pinAssigner.assignPin(8, pin_I2C_SCL);
434486
pinAssigner.assignPin(9, pin_Reserved); // I2S Sound Output Pin
@@ -454,16 +506,20 @@ class ModuleIO : public Module {
454506
// 53 is for PA enable but it's exposed on header and works for WLED pin output. Best to not use it but left available.
455507
// 54 is "C4 EN pin" so I guess we shouldn't fuck with that.
456508
} else if (boardID == board_AtomS3) {
457-
uint8_t ledPins[4] = {5, 6, 7, 8}; // LED_PINS
458-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
509+
uint8_t ledPins[] = {5, 6, 7, 8}; // LED_PINS
510+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
459511
} else if (boardID == board_Cube202010) {
460512
object["maxPower"] = 50;
461-
uint8_t ledPins[10] = {22, 21, 14, 18, 5, 4, 2, 15, 13, 12}; // LED_PINS
462-
// char pins[80] = "2,3,4,16,17,18,19,21,22,23,25,26,27,32,33"; //(D0), more pins possible. to do: complete list.
463-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
513+
uint8_t ledPins[] = {22, 21, 14, 18, 5, 4, 2, 15, 13, 12}; // LED_PINS
514+
// char pins[80] = "2,3,4,16,17,18,19,21,22,23,25,26,27,32,33"; //(D0), more pins possible. to do: complete list.
515+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
464516
} else { // default
465517
object["maxPower"] = 10; // USB compliant
518+
#ifdef CONFIG_IDF_TARGET_ESP32P4
519+
pinAssigner.assignPin(37, pin_LED);
520+
#else
466521
pinAssigner.assignPin(16, pin_LED);
522+
#endif
467523

468524
// trying to add more pins, but these pins not liked by esp32-d0-16MB ... 🚧
469525
// pinAssigner.assignPin(4, pin_LED_02;

0 commit comments

Comments
 (0)