You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Implement function onUpdate to define what happens if data changes
69
+
* Implement function **onUpdate** to define what happens if data changes
70
70
* struct UpdatedItem defines the update (parent property (including index in case of multiple records), name of property and value)
71
71
* This runs in the httpd / webserver task. To run it in the main (application task use runInLoopTask - see [ModuleAnimations](https://github.com/ewowi/MoonBase/blob/main/src/custom/ModuleAnimations.h)) - as httpd stack has been increased runInLoopTask is less needed
72
72
73
73
```cpp
74
-
voidonUpdate(UpdatedItem updatedItem) override
74
+
voidonUpdate(UpdatedItem &updatedItem) override
75
75
{
76
76
if (equal(updatedItem.name, "lightsOn") || equal(updatedItem.name, "brightness")) {
* Add the module in [menu.svelte](https://github.com/ewowi/MoonBase/blob/main/interface/src/routes/menu.svelte) (this will be automated in the future)
@@ -112,9 +140,17 @@ submenu: [
112
140
113
141
* This is all to create a fully functioning new module
114
142
115
-
Moonbase-Modules is implemented in:
143
+
### Readonly data
144
+
145
+
A module can consist of data which is edited by the user (e.g. selecting an animation to run) and data which is send from the server to the UI (e.g. a list of running processes). Currently both type of valuas are stored in state data and definition. Distinguished by property["ro"] = true in setupDefinition. So the client uses state data and definition to build a screen with both types visually mixed together (what is desirable). Currently there are 2 websocket events: one for the entire state (including readonly) and one only for readonly which only contains the changed values. Module.svelte handles readonly differently by the function handleRO which calls updateRecursive which only update the parts of the data which has changed.
146
+
147
+
It might be arguable that readonly variables are not stored in state data.
148
+
149
+
### Server
116
150
117
151
*[Module.h](https://github.com/ewowi/MoonBase/blob/main/src/custom/Module.h) and [Module.cpp](https://github.com/ewowi/MoonBase/blob/main/src/custom/Module.cpp) will generate all the required server code
152
+
153
+
### UI
118
154
*[Module.svelte](https://github.com/ewowi/MoonBase/blob/main/interface/src/routes/custom/module/Module.svelte) will deal with the UI
119
155
*[MultiInput.svelte](https://github.com/ewowi/MoonBase/blob/main/interface/src/lib/components/custom/MultiInput.svelte) is used by Module.svelte to display the right UI widget based on what is defined in the definition json
120
156
* Modifications done in [menu.svelte](https://github.com/ewowi/MoonBase/blob/main/interface/src/routes/menu.svelte) do identify a module by href and not by title alone
0 commit comments