Skip to content

Commit a7e6a62

Browse files
committed
Light control presets: UI red, green, blue to .editor folder
UI == - MultiInput: Pad: support presets - WIP - Module: updateRecursive: support object (e.g. presets) - wip Server ===== - FileService: move walkThroughFiles and extractPath to utilities - Utilities: create .cpp and add walkThroughFiles and extractPath and copyFile - LightsControl: presets: jsonObject as value. add setPresetsFromFolder and call at boot, when files in preset folder changes and onUpdate preset
1 parent a8f61b9 commit a7e6a62

File tree

14 files changed

+15341
-15287
lines changed

14 files changed

+15341
-15287
lines changed

docs/general/gettingstarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<img width="400" alt="Screenshot 2025-06-07 at 21 01 02" src="https://github.com/user-attachments/assets/5d4d581f-5586-43c0-a5ea-02930effc3d8" />
5252

5353
* **That's it**. You can now change effect nodes, or add nodes. For audio add the AudioSync node. More how to's will be added. At the moment:
54-
* Check the help pages on this documentation site
54+
* Check the help pages on this documentation site, especially the [editor page](https://moonmodules.org/MoonLight/moonbase/module/editor/)
5555
* press the ? in MoonLight to go directly to the relevant page
5656
More how to's will be added. At the moment:
5757
* Live scripts: [how to run a live script](https://github.com/MoonModules/MoonLight/blob/main/docs/moonbase/module/liveScripts.md#how-to-run-a-live-script)

docs/moonbase/module/editor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Typically a node will define a layout (🚥), or an effect (🔥), or a modifier
2525
* MoonLight will use the layout definition to generate a **mapping** of a virtual coordinate space to a physical coordinate space. Most simple example is a panel which has a snake layout. The mapping will create a virtual layer where the snake layout is hidden.
2626

2727
* **Effect** 🔥: An effect runs in a virtual layer (see above about mapping to a physical layer). Historically there are 1D, 2D and 3D effects. A 1D effect only fills leds in x space, leaving y and z blank. 2D also the y space, 3D all spaces. Future goal is that all effects fill all spaces (example is bouncing balls which was a 1D effect but has been made 2D). See also Modifiers which can take a 1D effect and make a 2D or 3D effect out of it: e.g. a 1D effect can be presented as a circle, or sphere.
28-
* An effect has a loop which is ran for each frame produced. In each loop, the pixels in the virtual layer gets it's values using the setLight function. It can take a CRGB value as parameter (default) but can also deal with multichannel lights like Moving Heads.
28+
* An effect has a loop which is ran for each frame produced. In each loop, the lights in the virtual layer gets it's values using the setRGB function. For multichannel lights also functions as setWhite or (for Moving Heads) setPan, setTilt, setZoom etc. Also getRGB etc functions exists.
2929
* Multiple effects can be defined, they all run during one frame. In the future each effect will have a start and end coordinate so they can also be displayed on parts of the fixture.
3030

3131
* **Modifier** 💎: a modifier is an effect on an effect. It can change the size of the virtual layer, it can map the pixels other then 1:1 (e.g. mirror, multiply them or a 1D line can become a 2D circle) and it can change each light set in an effect during a loop (e.g. rotate the effect)

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

Lines changed: 0 additions & 122 deletions
This file was deleted.

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@
6363
}
6464
}
6565
66+
let hoverTimeout: any = null;
67+
let popupCell: number | null = null;
68+
69+
function handleMouseEnter(rowIndex: number, colIndex: number, cell: number) {
70+
hoverTimeout = setTimeout(() => {
71+
popupCell = cell;
72+
}, 1000); // 1 second
73+
}
74+
75+
function handleMouseLeave() {
76+
clearTimeout(hoverTimeout);
77+
popupCell = null;
78+
}
79+
6680
</script>
6781

6882
<label class="label cursor-pointer" for={property.name}>
@@ -191,17 +205,23 @@
191205
<div class="flex flex-row space-x-2">
192206
{#each row as cell, colIndex}
193207
<button
194-
class="btn btn-square btn-primary w-{property.size} h-{property.size} text-xl rounded-lg"
208+
class="btn btn-square w-{property.size} h-{property.size} text-xl rounded-lg {
209+
value.active == cell?`btn-error`:Array.isArray(value.list) && value.list.includes(cell) ? `btn-success` : 'btn-primary'}"
195210
type="button"
196211
draggable="true"
197212
on:dragstart={(event) => handleDragStart(event, rowIndex, colIndex)}
198213
on:dragover|preventDefault
199214
on:drop={(event) => handleDrop(event, rowIndex, colIndex)}
200-
on:click={(event:any) => {console.log(rowIndex, colIndex, cell); value = cell; onChange(event)}}
201-
on:mouseenter={(event:any) => {if (property.hover) {console.log("mousenter", rowIndex, colIndex, cell); value = cell; onChange(event)}}}
202-
on:mouseleave={(event:any) => {if (false) {console.log("mouseleave", rowIndex, colIndex, cell); value = cell; onChange(event)}}}
215+
on:click={(event:any) => {console.log(rowIndex, colIndex, cell); value.list.push(cell); value.active = cell; onChange(event)}}
216+
on:mouseenter={(event:any) => {console.log("mousenter", rowIndex, colIndex, cell); if (property.hover) {value.active = cell; onChange(event)} else handleMouseEnter(rowIndex, colIndex, cell)}}
217+
on:mouseleave={handleMouseLeave}
203218
>
204219
{cell}
220+
{#if popupCell === cell}
221+
<div class="absolute z-50 bg-base-200 p-2 rounded shadow-lg mt-2">
222+
Popup for {cell}
223+
</div>
224+
{/if}
205225
</button>
206226
{/each}
207227
</div>

interface/src/routes/menu.svelte

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,6 @@
176176
page.data.features.download_firmware) &&
177177
(!page.data.features.security || $user.admin)
178178
},
179-
{
180-
title: 'Demo App',
181-
icon: Control,
182-
href: '/demo',
183-
feature: true
184-
},
185179
]
186180
}
187181
] as menuItem[]);

interface/src/routes/moonbase/module/Module.svelte

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@
121121
function updateRecursive(oldData:any, newData: any) {
122122
//loop over properties
123123
for (let key in newData) {
124-
if (typeof newData[key] != 'object') {
125-
if (newData[key] != oldData[key]) {
126-
// console.log("updateRecursive", key, newData[key], oldData[key]);
127-
oldData[key] = newData[key]; //trigger reactiveness
128-
}
129-
} else {
124+
// if (typeof newData[key] != 'object') {
125+
// if (newData[key] != oldData[key]) {
126+
// // console.log("updateRecursive", key, newData[key], oldData[key]);
127+
// oldData[key] = newData[key]; //trigger reactiveness
128+
// }
129+
// } else {
130130
if (Array.isArray(newData[key])) {
131131
//loop over array
132132
if (!oldData[key]) oldData[key] = []; //create an empty array
@@ -141,8 +141,14 @@
141141
} else
142142
updateRecursive(oldData[key][i], newData[key][i]);
143143
}
144+
} else {
145+
if (newData[key] != oldData[key]) {
146+
// console.log("updateRecursive", key, newData[key], oldData[key]);
147+
oldData[key] = newData[key]; //trigger reactiveness
148+
}
149+
144150
}
145-
}
151+
// }
146152
}
147153
}
148154

0 commit comments

Comments
 (0)