Skip to content

Commit 49287ed

Browse files
committed
Update docs from MoonLight repo
statusbar.svelte: link help to MoonBase repo
1 parent 27b499f commit 49287ed

File tree

12 files changed

+193
-45
lines changed

12 files changed

+193
-45
lines changed

docs/components.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,20 @@ This modal is based on [svelte-modals](https://svelte-modals.mattjennings.io/) w
158158

159159
## MoonBase components
160160

161-
### MultiInput
161+
<img width="30" src="https://github.com/user-attachments/assets/b0e8af99-ed76-422a-8bd1-bfbd9e0f4c44"/>
162162

163-
### File and FileEdit
163+
### MultiInput
164164

165-
#### File
165+
### Array
166166

167-
Input type="file"
167+
* Show an array of objects
168+
* Summary and editor
169+
* Recursive
170+
* An array can have an array e.g. multiple nodes with multiple controls per node
171+
* Uses MultiInput
172+
* Used data and definition rest apis
168173

169-
#### FileEdit
174+
### FileEdit
170175

171176
Arguments
172177

docs/custom/module/animations.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
## Functional
66

7+
* On: lights on or off
8+
* Brightness: brightness of the LEDs when on
9+
* driverOn: sends LED output to ESP32 gpio pins.
10+
* Switch off to see the effect framerate in System Status/Metrics
11+
* Switch on to see the effect framerate throttled by a LED driver in System Status/Metrics (800KHz, 256 leds, 24 bits is 130 fps theoretically - 120 practically)
12+
* Nodes: One or more processes, can be fixture definitions, mappings, effects, projections. Currently all nodes are effects.
13+
* Scrips: Running Live scripts (WIP)
14+
15+
<img width="498" alt="Screenshot 2025-03-29 at 14 12 01" src="https://github.com/user-attachments/assets/3a5a3743-c0a4-4456-96cb-f4abd0d01450" />
16+
17+
718
## Technical
819

920
* See [Modules](https://moonmodules.org/MoonLight/custom/modules/)

docs/custom/modules.md

Lines changed: 91 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,110 @@
11
# Modules
22

3+
<img width="829" alt="image" src="https://github.com/user-attachments/assets/3384f3ba-b5e6-4993-9a8b-80c25878e176" />
4+
35
## Functional
46

5-
With Moonbase Modules it is possible to create a new module entirely from one c++ file
7+
With Moonbase Modules it is possible to create new module entirely from one c++ class by only defining a json document describing the data structure and a function catching all the changes in the data. Http endpont and websockets are created automatically. There is no need to create any UI code, it is entirely driven by the json document.
8+
9+
This is inspired by WLED usermods, further developed in StarBase and now MoonBase (using the ESP32-Sveltekit infrastructure)
610

711
See [Demo](https://moonmodules.org/MoonLight/custom/module/demo/) and [Animations](https://moonmodules.org/MoonLight/custom/module/animations/) as examples
812

913
## Technical
1014

11-
* Create a class which inherits from Module e.g. class ModuleDemo : public Module
15+
* Create a class which inherits from Module
1216
* Call the Module constructor with the name of the module.
13-
* This name will be used to set up http endpoints and webserver sockets
17+
* This name will be used to set up http rest api and webserver sockets
18+
* See [ModuleDemo.h](https://github.com/ewowi/MoonBase/blob/main/src/custom/ModuleDemo.h)
19+
20+
```
21+
class ModuleDemo : public Module
22+
{
23+
public:
24+
25+
ModuleDemo(PsychicHttpServer *server
26+
, ESP32SvelteKit *sveltekit
27+
, FilesService *filesService
28+
) : Module("demo", server, sveltekit, filesService) {
29+
ESP_LOGD("", "ModuleDemo::constructor");
30+
}
31+
}
32+
```
33+
1434
* Implement function setupDefinition to create a json document with the datastructure
15-
* Stored on the file system
16-
* Used to generate the UI
17-
* Used to initialy create the module data
35+
* Store data on the file system
36+
* Generate the UI
37+
* Initialy create the module data
38+
39+
```
40+
void setupDefinition(JsonArray root) override{
41+
JsonObject property;
42+
JsonArray details;
43+
JsonArray values;
44+
45+
property = root.add<JsonObject>(); property["name"] = "hostName"; property["type"] = "text"; property["default"] = "MoonLight";
46+
property = root.add<JsonObject>(); property["name"] = "connectionMode"; property["type"] = "select"; property["default"] = "Signal Strength"; values = property["values"].to<JsonArray>();
47+
values.add("Offline");
48+
values.add("Signal Strength");
49+
values.add("Priority");
50+
51+
property = root.add<JsonObject>(); property["name"] = "savedNetworks"; property["type"] = "array"; details = property["n"].to<JsonArray>();
52+
{
53+
property = details.add<JsonObject>(); property["name"] = "SSID"; property["type"] = "text"; property["default"] = "ewtr"; property["min"] = 3; property["max"] = 32;
54+
property = details.add<JsonObject>(); property["name"] = "Password"; property["type"] = "password"; property["default"] = "";
55+
}
56+
57+
}
58+
59+
```
60+
1861
* Implement function onUpdate to define what happens if data changes
1962
* struct UpdatedItem defines the update (parent property, name of property, value and index (in case of multiple records)
20-
* This is run in the httpd / webserver task. To run it in the main (application task use runInLoopTask - see ModuleAnimations)
21-
* Add the module in main.cpp
22-
* Add the module in menu.svelte (this will be automated in the future)
63+
* This is run 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))
64+
65+
```
66+
void onUpdate(UpdatedItem updatedItem) override
67+
{
68+
if (updatedItem.name == "lightsOn" || updatedItem.name == "brightness") {
69+
ESP_LOGD("", "handle %s.%s[%d] %s", updatedItem.parent.c_str(), updatedItem.name.c_str(), updatedItem.index, updatedItem.value.as<String>());
70+
FastLED.setBrightness(_state.data["lightsOn"]?_state.data["brightness"]:0);
71+
} else if (updatedItem.parent == "nodes" && updatedItem.name == "animation") {
72+
ESP_LOGD("", "handle %s.%s[%d] %s", updatedItem.parent.c_str(), updatedItem.name.c_str(), updatedItem.index, _state.data["nodes"][updatedItem.index]["animation"].as<String>().c_str());
73+
animation = _state.data["nodes"][updatedItem.index]["animation"].as<String>();
74+
compileAndRun(animation);
75+
} else
76+
ESP_LOGD("", "no handle for %s.%s[%d] %s (%d %s)", updatedItem.parent.c_str(), updatedItem.name.c_str(), updatedItem.index, updatedItem.value.as<String>().c_str(), _state.data["driverOn"].as<bool>(), _state.data["nodes"][0]["animation"].as<String>());
77+
}
78+
```
79+
80+
* Add the module in [main.cpp](https://github.com/ewowi/MoonBase/blob/main/src/main.cpp)
2381

24-
<img width="400" alt="image" src="https://github.com/user-attachments/assets/fcec054b-a918-4e31-bca4-71b75aa6673c" />
82+
```
83+
ModuleDemo moduleDemo = ModuleDemo(&server, &esp32sveltekit, &filesService);
84+
...
85+
moduleDemo.begin();
86+
...
87+
moduleDemo.loop();
88+
```
2589

26-
Done by the Modules implementation
27-
* Module.h will generate all the required server code
28-
* Module.svelte will deal with the UI
29-
* MultiInput.svelte is used by Module.svelte to display the right UI widget based on what is defined in the definition json
90+
* 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)
3091

31-
### Server
92+
```
93+
submenu: [
94+
{
95+
title: 'Module Demo',
96+
icon: BulbIcon,
97+
href: '/custom/module?module=demo',
98+
feature: page.data.features.liveanimation,
99+
},
100+
]
101+
```
32102

33-
[Instances.h](https://github.com/MoonModules/MoonLight/blob/main/lib/framework/Instances.h) and [Instances.cpp](https://github.com/MoonModules/MoonLight/blob/main/lib/framework/Instances.cpp)
103+
* This is all to create a fully functioning new module
34104

35-
### UI
105+
Moonbase-Modules is implemented in:
36106

37-
[Instances.svelte](https://github.com/MoonModules/MoonLight/blob/main/interface/src/routes/system/status/Instances.svelte)
107+
* [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
108+
* [Module.svelte](https://github.com/ewowi/MoonBase/blob/main/interface/src/routes/custom/module/Module.svelte) will deal with the UI
109+
* [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
110+
* 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
1.79 MB
Binary file not shown.

docs/general/gettingstarted.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Getting started
22

3-
## Installation
3+
## Installation - Developer
44

55
* Open GitKraken Press + / New tab and select Clone a Repo (Or another git management tool)
66
* Select the folder on your local drive where to copy to (e.g. /github/MoonModules)
7-
* Copy [MoonLight.git](https://github.com/MoonModules/MoonLight.git) (or [MoonBase.git](https://github.com/ewowi/MoonBase.git)) and paste in the URL field of GitKraken
7+
* Copy [MoonBase.git](https://github.com/ewowi/MoonBase.git) or [MoonLight.git](https://github.com/MoonModules/MoonLight.git) and paste in the URL field of GitKraken
88
* Press clone the repo
99
* Open VSCode
1010
* Install the PlatformIO IDE extension
@@ -13,25 +13,39 @@
1313
* On the status bar select the env to flash and the board to flash to
1414
* Select esp32dev for a normal ESP32
1515
* Select esp32-s3-devkitc-1-n16r8v for an ESP32-S2 ([recommended](https://s.click.aliexpress.com/e/_DBAtJ2H) or similar)
16-
* Press PlaformIO:Upload on the statusbar
17-
* The formware is now flashed to your board, after flashing the board will reboot
1816

19-
## Configuration
17+
<img width="617" alt="image" src="https://github.com/user-attachments/assets/349af246-30c7-45dd-92ed-4f2b3900557f" />
2018

19+
* Press PlaformIO:Upload (->) on the statusbar
20+
* The firmware is now flashed to your board, after flashing the board will reboot
2121
* Recommended: Press PlatformIO:Serial Monitor to see the debug information produced
22-
* In case of a newly flashed board, a Wifi access point (AP) will be created. Go to your Wifi settings on your computer and find the new Wifi AP (starts with MoonLight or ESPSvelteKit)
22+
23+
## Installation - End user
24+
25+
[install](https://moonmodules.org/MoonLight/general/index.html)
26+
27+
* release 0.5.4, for latest build follow installation developer
28+
* This is WIP, looks like issue with erasing the board and setting the partitions right ...
29+
* Made using [esp-web-tools](https://esphome.github.io/esp-web-tools/)
30+
31+
## Configuration
32+
33+
* In case of a newly flashed board, a Wifi access point (AP) will be created. Go to your Wifi settings on your computer and find the new Wifi AP (starts with MoonBase, MoonLight or ESPSvelteKit)
34+
* If the board AP is not showing up in your WiFi list it might be helpful to fully erase the board (vscode 👽, Erase flash)
2335
* Connect to the AP (no password needed), a captive portal will show with a welcome screen.
36+
* There seems to be an issue in the captive portal showing Connection to device lost repeatedly. In that case, close the captive portal and open the app in a brower using 192.168.4.1
2437
* Go to the menu and select Wifi / Wifi Station
2538
* Press (+) and enter the SSID and the password of your Wifi Network
2639
* Press Add Network and Apply settings
2740
* The board will reconnect to your Wifi Network
2841
* Go back to your Wifi Network on your computer
2942
* Find out the new IP of the board, or in your Wifi Network settings or by looking at the log in the Serial Monitor (see above)
43+
* (sometimes it takes a while to load pages for the first time, might be related to caching of javascript, on the issuelist)
3044

3145
## Developing
3246

3347
* Read the [ESP32 Sveltekit docs](https://moonmodules.org/MoonLight/eskIndex/) (Latest version (Svelte 5) here [ESP32 Sveltekit docs](https://theelims.github.io/ESP32-sveltekit/))
34-
* Read [Customizing Sveltekit](https://moonmodules.org/MoonLight/general/customizingsveltekit/), this things have normally been done (MoonBase WIP)
48+
* Read [Customizing Sveltekit](https://moonmodules.org/MoonLight/general/customizingsveltekit/)
3549
* UI dev: configure vite.config.ts, go to interface folder, npm install, npm run dev. A local webserver starts on localhost. UI changes will directly be shown via this webserver
3650
* Want to make changes: fork the repo and submit pull requests
3751

@@ -41,12 +55,16 @@
4155
* Search for FastLED.addLeds in the code and update to the pin you use to drive LEDS, reflash the code to the board
4256
* Go to the UI in the browser
4357
* Go to Custom / Files and create or upload Live scripts
44-
* Go to Custom / Live Animation and select the 'hardcoded animations' (Random, Rainbow), you should see it on your panel
58+
* Go to Custom / Module Animations and select the 'hardcoded animations' (Random, Sinelon, Rainbow), you should see it on your panel
4559
* Select any of the Live scripts you uploaded, check the Serial Output for results. (No led output in current version, see below)
4660
* Open the Edit area and change things in the code, see the Serial Output for results
61+
62+
<img width="350" alt="image" src="https://github.com/user-attachments/assets/56bdd019-927b-40cc-9199-9bc6344f8d8b" />
63+
64+
4765
* To do
4866
* Find a way to present feedback to the UI (e.g. error messages as comments in the sc file)
49-
* Extend the code to support led animations ('homework assignment')
67+
* Extend the code in [ModuleAnimations.h](https://github.com/ewowi/MoonBase/blob/main/src/custom/ModuleAnimations.h) to support led animations ('homework assignment')
5068
* see ModuleAnimation.h (Server)
5169

5270
### Current script supported
@@ -77,4 +95,4 @@ void main() {
7795
sync(); //or show??
7896
}
7997
}
80-
```
98+
```

docs/general/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<script
4+
type="module"
5+
src="https://unpkg.com/esp-web-tools@10/dist/web/install-button.js?module"
6+
></script>
7+
</head>
8+
<body>
9+
<p>install esp32-s3-devkitc-1-n16r8v.bin</p>
10+
<esp-web-install-button
11+
manifest="./manifest.json"
12+
></esp-web-install-button>
13+
</body>
14+
</html>

docs/general/manifest.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "MoonLight",
3+
"version": "2025.03.30",
4+
"home_assistant_domain": "esphome",
5+
"funding_url": "https://esphome.io/guides/supporters.html",
6+
"new_install_prompt_erase": true,
7+
"builds": [
8+
{
9+
"chipFamily": "ESP32-S3",
10+
"parts": [
11+
{ "path": "./esp32-s3-devkitc-1-n16r8v.bin", "offset": 0 }
12+
]
13+
}
14+
]
15+
}

docs/index.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ hide:
44
- toc
55
---
66

7-
# MoonBase
7+
# MoonBase / MoonLight
88

9-
<img width="500" alt="MoonBase" src="https://github.com/user-attachments/assets/de0ab735-d547-462e-b7e3-c3f819bf9283" />
9+
<img width="500" alt="MoonLight" src="https://github.com/user-attachments/assets/de0ab735-d547-462e-b7e3-c3f819bf9283" />
1010

11-
* MoonBase is a [MoonModules](https://moonmodules.org) project.
12-
* MoonBase = [ESP32 SvelteKit](https://github.com/theelims/ESP32-sveltekit) + [StarLight as a Service](https://github.com/MoonModules/StarLight/tree/StarAsAService). Check [Discord/MoonLight](https://discord.gg/TC8NSUSCdV) to discuss.
13-
* Work in progress is shown in the [Kanban board](https://github.com/users/ewowi/projects/2). You are more then welcome to add issues, comment on issues or help with issues.
14-
* See also [ESP32-sveltekit POC](https://github.com/theelims/ESP32-sveltekit/issues/68)
15-
* Documentation has been setup (but not customized), see [MoonBaseDocs](https://ewowi.github.io/MoonBase/).
11+
* MoonBase and MoonLight are [MoonModules](https://moonmodules.org) projects.
12+
* MoonBase = [ESP32 SvelteKit](https://github.com/theelims/ESP32-sveltekit) + [ESPLiveScript]([https://github.com/hpwit/StarLight/tree/StarAsAService](https://github.com/hpwit/ESPLiveScript)) + [StarBase](https://github.com/ewowi/StarBase).
13+
* MoonLight = MoonBase + [StarLight as a Service](https://github.com/MoonModules/StarLight/tree/StarAsAService).
14+
* MoonBase is the current work in progress repo, see [Star-Mod-Base-Light-Moon-Svelte-Live](https://moonmodules.org/Star-Mod-Base-Light-Moon-Svelte-Live). MoonLight will be updated later.
15+
* Work in progress is shown in the [Kanban board](https://github.com/users/MoonModules/projects/2). You are more then welcome to add issues, comment on issues or help with issues.
16+
You are more then welcome to add issues, comment on issues or help with issues.
17+
* See also [ESP32-sveltekit - Issue 68 - POC](https://github.com/theelims/ESP32-sveltekit/issues/68)
18+
* Documentation see [MoonLightDocs](https://MoonModules.org/MoonLight/).
19+
* Check [Discord/MoonLight](https://discord.gg/TC8NSUSCdV) to discuss.
1620

1721
[Release 0.5.2](https://github.com/MoonModules/MoonLight/releases/tag/v0.5.2) (Jan 21, 2025):
1822

@@ -21,4 +25,5 @@ hide:
2125
## License
2226

2327
MoonBase, MoonLight: GPL-v3
24-
ESP32 SvelteKit see [ESP32 SvelteKit license](https://github.com/theelims/ESP32-sveltekit?tab=License-1-ov-file#)
28+
29+
ESP32 SvelteKit see [ESP32 SvelteKit license](https://github.com/theelims/ESP32-sveltekit?tab=License-1-ov-file#)

docs/statefulservice.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ esp32sveltekit.getBatteryService()->updateSOC(float stateOfCharge); // update st
550550
esp32sveltekit.getBatteryService()->setCharging(boolean isCharging); // notify the client that the device is charging
551551
```
552552
553-
For devices where battery voltage is exposed on a pin you can measure the voltage and updateSOC by specifying this in platformio.ini:
553+
<img width="30" src="https://github.com/user-attachments/assets/b0e8af99-ed76-422a-8bd1-bfbd9e0f4c44"/> For devices where battery voltage is exposed on a pin you can measure the voltage and updateSOC by specifying this in platformio.ini:
554554
555555
```
556556
-D BATTERY_PIN=35 ; Used if FT_BATTERY=1

docs/system/metrics.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
## Functional
66

7+
Shows system info on a timeline
8+
9+
* <img width="30" src="https://github.com/user-attachments/assets/b0e8af99-ed76-422a-8bd1-bfbd9e0f4c44"/> Performance: show the loops per second of the main application loop. In case of running LEDs this is the Frames Per Second displayed on led fixtures.
10+
* <img width="30" src="https://github.com/user-attachments/assets/b0e8af99-ed76-422a-8bd1-bfbd9e0f4c44"/> PSRAM: Shows the used size of PSRAM, if present
11+
712
## Technical
813

914
### Server

0 commit comments

Comments
 (0)