Skip to content

Commit 7ac94ce

Browse files
authored
Merge pull request #74 from MoonModules/board-presets-p4
Board presets p4
2 parents 7e55d29 + 1e7a578 commit 7ac94ce

File tree

16 files changed

+12961
-12861
lines changed

16 files changed

+12961
-12861
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: 70 additions & 33 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,
@@ -63,7 +63,7 @@ enum IO_PinUsage {
6363
pin_count
6464
};
6565

66-
enum IO_Boards {
66+
enum IO_BoardsEnum {
6767
board_none, //
6868
board_QuinLEDDigUnoV3,
6969
board_QuinLEDDigQuadV3,
@@ -110,8 +110,8 @@ class ModuleIO : public Module {
110110
addControlValue(control, "QuinLED Dig Quad v3");
111111
addControlValue(control, "QuinLED Dig Octa v2");
112112
addControlValue(control, "QuinLED Dig 2Go");
113-
addControlValue(control, "Serg Universal Shield v5 🚧");
114-
addControlValue(control, "Serg Mini Shield 🚧");
113+
addControlValue(control, "Serg Universal Shield");
114+
addControlValue(control, "Serg Mini Shield");
115115
addControlValue(control, "Mathieu SE16 v1");
116116
addControlValue(control, "MHC D0 Shield 🚧");
117117
addControlValue(control, "MHC P4 Nano Shield");
@@ -274,8 +274,8 @@ class ModuleIO : public Module {
274274

275275
if (boardID == board_SE16V1) {
276276
object["maxPower"] = 500;
277-
uint8_t ledPins[16] = {47, 48, 21, 38, 14, 39, 13, 40, 12, 41, 11, 42, 10, 2, 3, 1}; // LED_PINS
278-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
277+
uint8_t ledPins[] = {47, 48, 21, 38, 14, 39, 13, 40, 12, 41, 11, 42, 10, 2, 3, 1}; // LED_PINS
278+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
279279
pinAssigner.assignPin(0, pin_ButtonPush);
280280
pinAssigner.assignPin(45, pin_ButtonPush);
281281
pinAssigner.assignPin(46, pin_Button_LightsOn);
@@ -310,8 +310,8 @@ class ModuleIO : public Module {
310310
// Dig-Quad-V3
311311
// esp32-d0 (4MB)
312312
object["maxPower"] = 150;
313-
uint8_t ledPins[4] = {16, 3, 1, 4}; // LED_PINS
314-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
313+
uint8_t ledPins[] = {16, 3, 1, 4}; // LED_PINS
314+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
315315
pinAssigner.assignPin(0, pin_ButtonPush);
316316

317317
pinAssigner.assignPin(15, pin_Relay);
@@ -323,9 +323,9 @@ class ModuleIO : public Module {
323323
// pinAssigner.assignPin(32, pin_Exposed;
324324
} else if (boardID == board_QuinLEDDigOctaV2) {
325325
// Dig-Octa-32-8L
326-
object["maxPower"] = 400; // 10A Fuse * 8 ... 400 W
327-
uint8_t ledPins[8] = {0, 1, 2, 3, 4, 5, 12, 13}; // LED_PINS
328-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
326+
object["maxPower"] = 400; // 10A Fuse * 8 ... 400 W
327+
uint8_t ledPins[] = {0, 1, 2, 3, 4, 5, 12, 13}; // LED_PINS
328+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
329329
pinAssigner.assignPin(33, pin_Relay);
330330
pinAssigner.assignPin(34, pin_ButtonPush);
331331
} else if (boardID == board_QuinLEDDig2Go) {
@@ -344,8 +344,8 @@ class ModuleIO : public Module {
344344
pinAssigner.assignPin(25, pin_Exposed);
345345
// pinAssigner.assignPin(xx, pin_I2S_MCLK);
346346
// } else if (boardID == board_QuinLEDPenta) {
347-
// uint8_t ledPins[5] = {14, 13, 12, 4, 2}; // LED_PINS
348-
// for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
347+
// uint8_t ledPins[] = {14, 13, 12, 4, 2}; // LED_PINS
348+
// for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
349349
// pinAssigner.assignPin(34, pin_ButtonPush);
350350
// pinAssigner.assignPin(35, pin_ButtonPush);
351351
// pinAssigner.assignPin(39, pin_ButtonPush);
@@ -366,20 +366,53 @@ class ModuleIO : public Module {
366366
// pinAssigner.assignPin(5, pin_LED);
367367
} else if (boardID == board_SergMiniShield) {
368368
object["maxPower"] = 50; // 10A Fuse ...
369-
pinAssigner.assignPin(1, pin_LED);
370-
pinAssigner.assignPin(3, pin_LED);
369+
pinAssigner.assignPin(16, pin_LED);
370+
// pinAssigner.assignPin(17, pin_LED); // e.g. apa102...
371+
372+
// pinAssigner.assignPin(??, pin_Button_LightsOn); // which pin ?
373+
pinAssigner.assignPin(19, pin_Relay_LightsOn); // optional
374+
375+
// e.g. for mic
376+
pinAssigner.assignPin(32, pin_I2S_SD);
377+
pinAssigner.assignPin(15, pin_I2S_WS);
378+
pinAssigner.assignPin(14, pin_I2S_SCK);
379+
// pinAssigner.assignPin(36, nc/ao...);
380+
381+
// e.g. for 4 line display
382+
pinAssigner.assignPin(21, pin_I2C_SDA);
383+
pinAssigner.assignPin(22, pin_I2C_SCL);
371384
} else if (boardID == board_SergUniShieldV5) {
372385
object["maxPower"] = 50; // 10A Fuse ...
373-
pinAssigner.assignPin(1, pin_LED);
374-
pinAssigner.assignPin(3, pin_LED);
386+
387+
pinAssigner.assignPin(16, pin_LED); // first pin
388+
if (_state.data["jumper1"])
389+
pinAssigner.assignPin(1, pin_LED);
390+
else // default
391+
pinAssigner.assignPin(3, pin_LED);
392+
393+
pinAssigner.assignPin(17, pin_Button_LightsOn);
375394
pinAssigner.assignPin(19, pin_Relay_LightsOn);
395+
pinAssigner.assignPin(18, pin_Infrared);
396+
397+
// e.g. for mic
398+
pinAssigner.assignPin(32, pin_I2S_SD);
399+
pinAssigner.assignPin(15, pin_I2S_WS);
400+
pinAssigner.assignPin(14, pin_I2S_SCK);
401+
// pinAssigner.assignPin(36, nc/ao...);
402+
403+
// e.g. for 4 line display
404+
pinAssigner.assignPin(21, pin_I2C_SDA);
405+
pinAssigner.assignPin(22, pin_I2C_SCL);
406+
407+
// pinAssigner.assignPin(?, pin_Temperature); // todo: check temp pin
408+
376409
} else if (boardID == board_MHCD0) {
377410
pinAssigner.assignPin(3, pin_Voltage);
378-
} else if (boardID == board_MHCP4Nano) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027
379-
object["maxPower"] = 100; // Assuming decent LED power!!
380-
if (_state.data["jumper1"]) { // on
381-
uint8_t ledPins[8] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED_PINS
382-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
411+
} else if (boardID == board_MHCP4Nano) { // https://shop.myhome-control.de/ABC-WLED-ESP32-P4-Shield/HW10027
412+
object["maxPower"] = 100; // Assuming decent LED power!!
413+
if (_state.data["jumper1"]) { // on
414+
uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED_PINS
415+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
383416
// per default used as LED Pins
384417
pinAssigner.assignPin(3, pin_RS485);
385418
pinAssigner.assignPin(4, pin_RS485);
@@ -389,9 +422,9 @@ class ModuleIO : public Module {
389422
pinAssigner.assignPin(46, pin_Exposed);
390423
pinAssigner.assignPin(47, pin_Exposed);
391424
pinAssigner.assignPin(48, pin_Exposed);
392-
} else { // off - default
393-
uint8_t ledPins[16] = {21, 20, 25, 5, 7, 23, 8, 27, 3, 22, 24, 4, 46, 47, 2, 48}; // 16 LED_PINS
394-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
425+
} else { // off - default
426+
uint8_t ledPins[] = {21, 20, 25, 5, 7, 23, 8, 27, 3, 22, 24, 4, 46, 47, 2, 48}; // 16 LED_PINS
427+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
395428
}
396429
pinAssigner.assignPin(33, pin_I2S_SD);
397430
pinAssigner.assignPin(26, pin_I2S_WS);
@@ -400,9 +433,9 @@ class ModuleIO : public Module {
400433
} else if (boardID == board_YvesV48) {
401434
pinAssigner.assignPin(3, pin_LED);
402435
} else if (boardID == board_TroyP4Nano) {
403-
object["maxPower"] = 10; // USB compliant
404-
uint8_t ledPins[16] = {2, 3, 4, 5, 6, 20, 21, 22, 23, 26, 27, 32, 33, 36, 47, 48}; // LED_PINS
405-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
436+
object["maxPower"] = 10; // USB compliant
437+
uint8_t ledPins[] = {2, 3, 4, 5, 6, 20, 21, 22, 23, 26, 27, 32, 33, 36, 47, 48}; // LED_PINS
438+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
406439
pinAssigner.assignPin(7, pin_I2C_SDA);
407440
pinAssigner.assignPin(8, pin_I2C_SCL);
408441
pinAssigner.assignPin(9, pin_Reserved); // I2S Sound Output Pin
@@ -428,16 +461,20 @@ class ModuleIO : public Module {
428461
// 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.
429462
// 54 is "C4 EN pin" so I guess we shouldn't fuck with that.
430463
} else if (boardID == board_AtomS3) {
431-
uint8_t ledPins[4] = {5, 6, 7, 8}; // LED_PINS
432-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
464+
uint8_t ledPins[] = {5, 6, 7, 8}; // LED_PINS
465+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
433466
} else if (boardID == board_Cube202010) {
434467
object["maxPower"] = 50;
435-
uint8_t ledPins[10] = {22, 21, 14, 18, 5, 4, 2, 15, 13, 12}; // LED_PINS
436-
// 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.
437-
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
468+
uint8_t ledPins[] = {22, 21, 14, 18, 5, 4, 2, 15, 13, 12}; // LED_PINS
469+
// 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.
470+
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
438471
} else { // default
439472
object["maxPower"] = 10; // USB compliant
473+
#ifdef CONFIG_IDF_TARGET_ESP32P4
474+
pinAssigner.assignPin(37, pin_LED);
475+
#else
440476
pinAssigner.assignPin(16, pin_LED);
477+
#endif
441478

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

0 commit comments

Comments
 (0)