Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions firmware/esp32-p4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ upload_speed = 921600
; framework = arduino
; monitor_speed = 115200
build_flags = ${esp32-p4-base.build_flags}
-Wl,-wrap,esp_dma_capable_malloc ;; makes SDIO for ESP-Hosted use PSRAM if available.

; -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())
lib_deps = ${esp32-p4-base.lib_deps}
; RAM: [= ] 11.2% (used 36580 bytes from 327680 bytes)
; Flash: [======== ] 82.3% (used 1726193 bytes from 2097152 bytes)
Expand Down
2 changes: 1 addition & 1 deletion interface/src/lib/components/moonbase/MultiInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
{:else if property.type == 'number'}
<input
type="number"
style="width: {String(property.max || 255).length + 4}ch"
style="width: {String(property.max || 255).length + 5}ch"
min={property.min ? property.min : 0}
max={property.max ? property.max : 255}
class="input invalid:border-error invalid:border-2"
Expand Down
47 changes: 28 additions & 19 deletions interface/src/routes/moonbase/monitor/Monitor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@
let offsetRGB: number;
let offsetWhite: number;
let isPositions: boolean = false;
let lightPreset: number;
let nrOfChannels: number = 0;
// let offsetRed:number;
// let offsetGreen:number;
// let offsetBlue:number;
const lightPreset_RGB2040 = 9;

const handleHeader = (header: Uint8Array) => {
console.log('Monitor.handleHeader', header);
Expand All @@ -70,10 +73,12 @@
// offsetBlue = (header[6] >> 6) & 0x3; // bits 6-7
// offsetWhite = header[13];

nrOfLights = view.getUint16(12, true); // header[12] + 256 * header[13];
channelsPerLight = view.getUint8(19); //header[19];
offsetRGB = view.getUint8(20); //header[20];
offsetWhite = view.getUint8(21); //header[21];
nrOfLights = view.getUint16(12, true);
channelsPerLight = view.getUint8(19);
offsetRGB = view.getUint8(20);
offsetWhite = view.getUint8(21);
nrOfChannels = view.getUint16(32, true);
lightPreset = view.getUint8(34);

//rebuild scene
createScene(el);
Expand All @@ -95,17 +100,18 @@
depth,
nrOfLights,
channelsPerLight,
offsetRGB
offsetRGB,
nrOfChannels
);
};

const handlePositions = (positions: Uint8Array) => {
console.log('Monitor.handlePositions', positions);

for (let index = 0; index < nrOfLights * 3; index += 3) {
let x = positions[index];
let y = positions[index + 1];
let z = positions[index + 2];
for (let indexP = 0; indexP < nrOfLights; indexP++) {
let x = positions[indexP * 3];
let y = positions[indexP * 3 + 1];
let z = positions[indexP * 3 + 2];

//set to -1,1 coordinate system of webGL
//width -1 etc as 0,0 should be top left, not bottom right
Expand All @@ -124,17 +130,20 @@
done = true;
}
clearColors();
const groupSize = 20 * channelsPerLight; // RGB2040 groups: 20 lights per physical group (will be 3 channelsPerLight)
//max size supported is 255x255x255 (index < width * height * depth) ... todo: only any of the component < 255
for (let index = 0; index < nrOfLights * channelsPerLight; index += channelsPerLight) {
// && index < width * height * depth
// colorLed(index/3, data[index]/255, data[index+1]/255, data[index+2]/255);
const r = channels[index + offsetRGB + 0] / 255;
const g = channels[index + offsetRGB + 1] / 255;
const b = channels[index + offsetRGB + 2] / 255;
let w = 0;
if (offsetWhite != 255) w = channels[index + offsetRGB + 3] / 255; //add white channel if present
const a = 1.0; // Full opacity
colors.push(r + w, g + w, b + w, a);
for (let index = 0; index < nrOfChannels; index += channelsPerLight) {
if (lightPreset != lightPreset_RGB2040 || Math.floor(index / groupSize) % 2 == 0) {
// Math.floor: RGB2040 Skip the empty channels
// && index < width * height * depth
const r = channels[index + offsetRGB + 0] / 255;
const g = channels[index + offsetRGB + 1] / 255;
const b = channels[index + offsetRGB + 2] / 255;
let w = 0;
if (offsetWhite != 255) w = channels[index + offsetRGB + 3] / 255; //add white channel if present
const a = 1.0; // Full opacity
colors.push(r + w, g + w, b + w, a);
}
}

updateScene(vertices, colors);
Expand Down
25,467 changes: 12,735 additions & 12,732 deletions lib/framework/WWWData.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ build_flags =
-D BUILD_TARGET=\"$PIOENV\"
-D APP_NAME=\"MoonLight\" ; 🌙 Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename
-D APP_VERSION=\"0.6.1\" ; semver compatible version string
-D APP_DATE=\"2025121212\" ; 🌙
-D APP_DATE=\"2025121511\" ; 🌙

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

Expand Down
103 changes: 70 additions & 33 deletions src/MoonBase/Modules/ModuleIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "MoonBase/Module.h"

enum IO_PinUsage {
enum IO_PinUsageEnum {
pin_Unused, // 0
pin_LED,
pin_LED_CW,
Expand Down Expand Up @@ -63,7 +63,7 @@ enum IO_PinUsage {
pin_count
};

enum IO_Boards {
enum IO_BoardsEnum {
board_none, //
board_QuinLEDDigUnoV3,
board_QuinLEDDigQuadV3,
Expand Down Expand Up @@ -110,8 +110,8 @@ class ModuleIO : public Module {
addControlValue(control, "QuinLED Dig Quad v3");
addControlValue(control, "QuinLED Dig Octa v2");
addControlValue(control, "QuinLED Dig 2Go");
addControlValue(control, "Serg Universal Shield v5 🚧");
addControlValue(control, "Serg Mini Shield 🚧");
addControlValue(control, "Serg Universal Shield");
addControlValue(control, "Serg Mini Shield");
addControlValue(control, "Mathieu SE16 v1");
addControlValue(control, "MHC D0 Shield 🚧");
addControlValue(control, "MHC P4 Nano Shield");
Expand Down Expand Up @@ -274,8 +274,8 @@ class ModuleIO : public Module {

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

pinAssigner.assignPin(15, pin_Relay);
Expand All @@ -323,9 +323,9 @@ class ModuleIO : public Module {
// pinAssigner.assignPin(32, pin_Exposed;
} else if (boardID == board_QuinLEDDigOctaV2) {
// Dig-Octa-32-8L
object["maxPower"] = 400; // 10A Fuse * 8 ... 400 W
uint8_t ledPins[8] = {0, 1, 2, 3, 4, 5, 12, 13}; // LED_PINS
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
object["maxPower"] = 400; // 10A Fuse * 8 ... 400 W
uint8_t ledPins[] = {0, 1, 2, 3, 4, 5, 12, 13}; // LED_PINS
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
pinAssigner.assignPin(33, pin_Relay);
pinAssigner.assignPin(34, pin_ButtonPush);
} else if (boardID == board_QuinLEDDig2Go) {
Expand All @@ -344,8 +344,8 @@ class ModuleIO : public Module {
pinAssigner.assignPin(25, pin_Exposed);
// pinAssigner.assignPin(xx, pin_I2S_MCLK);
// } else if (boardID == board_QuinLEDPenta) {
// uint8_t ledPins[5] = {14, 13, 12, 4, 2}; // LED_PINS
// for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
// uint8_t ledPins[] = {14, 13, 12, 4, 2}; // LED_PINS
// for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
// pinAssigner.assignPin(34, pin_ButtonPush);
// pinAssigner.assignPin(35, pin_ButtonPush);
// pinAssigner.assignPin(39, pin_ButtonPush);
Expand All @@ -366,20 +366,53 @@ class ModuleIO : public Module {
// pinAssigner.assignPin(5, pin_LED);
} else if (boardID == board_SergMiniShield) {
object["maxPower"] = 50; // 10A Fuse ...
pinAssigner.assignPin(1, pin_LED);
pinAssigner.assignPin(3, pin_LED);
pinAssigner.assignPin(16, pin_LED);
// pinAssigner.assignPin(17, pin_LED); // e.g. apa102...

// pinAssigner.assignPin(??, pin_Button_LightsOn); // which pin ?
pinAssigner.assignPin(19, pin_Relay_LightsOn); // optional

// e.g. for mic
pinAssigner.assignPin(32, pin_I2S_SD);
pinAssigner.assignPin(15, pin_I2S_WS);
pinAssigner.assignPin(14, pin_I2S_SCK);
// pinAssigner.assignPin(36, nc/ao...);

// e.g. for 4 line display
pinAssigner.assignPin(21, pin_I2C_SDA);
pinAssigner.assignPin(22, pin_I2C_SCL);
} else if (boardID == board_SergUniShieldV5) {
object["maxPower"] = 50; // 10A Fuse ...
pinAssigner.assignPin(1, pin_LED);
pinAssigner.assignPin(3, pin_LED);

pinAssigner.assignPin(16, pin_LED); // first pin
if (_state.data["jumper1"])
pinAssigner.assignPin(1, pin_LED);
else // default
pinAssigner.assignPin(3, pin_LED);

pinAssigner.assignPin(17, pin_Button_LightsOn);
pinAssigner.assignPin(19, pin_Relay_LightsOn);
pinAssigner.assignPin(18, pin_Infrared);

// e.g. for mic
pinAssigner.assignPin(32, pin_I2S_SD);
pinAssigner.assignPin(15, pin_I2S_WS);
pinAssigner.assignPin(14, pin_I2S_SCK);
// pinAssigner.assignPin(36, nc/ao...);

// e.g. for 4 line display
pinAssigner.assignPin(21, pin_I2C_SDA);
pinAssigner.assignPin(22, pin_I2C_SCL);

// pinAssigner.assignPin(?, pin_Temperature); // todo: check temp pin

} 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
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
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
} else if (boardID == board_MHCP4Nano) { // 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[] = {21, 20, 25, 5, 7, 23, 8, 27}; // 8 LED_PINS
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
// per default used as LED Pins
pinAssigner.assignPin(3, pin_RS485);
pinAssigner.assignPin(4, pin_RS485);
Expand All @@ -389,9 +422,9 @@ class ModuleIO : public Module {
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
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
} 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
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
}
pinAssigner.assignPin(33, pin_I2S_SD);
pinAssigner.assignPin(26, pin_I2S_WS);
Expand All @@ -400,9 +433,9 @@ class ModuleIO : public Module {
} else if (boardID == board_YvesV48) {
pinAssigner.assignPin(3, pin_LED);
} else if (boardID == board_TroyP4Nano) {
object["maxPower"] = 10; // USB compliant
uint8_t ledPins[16] = {2, 3, 4, 5, 6, 20, 21, 22, 23, 26, 27, 32, 33, 36, 47, 48}; // LED_PINS
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
object["maxPower"] = 10; // USB compliant
uint8_t ledPins[] = {2, 3, 4, 5, 6, 20, 21, 22, 23, 26, 27, 32, 33, 36, 47, 48}; // LED_PINS
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
pinAssigner.assignPin(7, pin_I2C_SDA);
pinAssigner.assignPin(8, pin_I2C_SCL);
pinAssigner.assignPin(9, pin_Reserved); // I2S Sound Output Pin
Expand All @@ -428,16 +461,20 @@ class ModuleIO : public Module {
// 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.
// 54 is "C4 EN pin" so I guess we shouldn't fuck with that.
} else if (boardID == board_AtomS3) {
uint8_t ledPins[4] = {5, 6, 7, 8}; // LED_PINS
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
uint8_t ledPins[] = {5, 6, 7, 8}; // LED_PINS
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
} else if (boardID == board_Cube202010) {
object["maxPower"] = 50;
uint8_t ledPins[10] = {22, 21, 14, 18, 5, 4, 2, 15, 13, 12}; // LED_PINS
// 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.
for (int i = 0; i < sizeof(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
uint8_t ledPins[] = {22, 21, 14, 18, 5, 4, 2, 15, 13, 12}; // LED_PINS
// 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.
for (int i = 0; i < std::size(ledPins); i++) pinAssigner.assignPin(ledPins[i], pin_LED);
} else { // default
object["maxPower"] = 10; // USB compliant
#ifdef CONFIG_IDF_TARGET_ESP32P4
pinAssigner.assignPin(37, pin_LED);
#else
pinAssigner.assignPin(16, pin_LED);
#endif

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