mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-08 16:11:18 +00:00
Enhance cube package
This commit is contained in:
1 parent
91715b380d
commit
961a6f0a46
16 files changed
+378
-138
No files matched your search
@@ -2,10 +2,10 @@
|
||||
|
||||
PROG ?= example
|
||||
TOP ?= ../../..
|
||||
SOURCES = main.c dashboard.c file_data.c $(TOP)/mongoose.c
|
||||
SOURCES = dashboard.c file_data.c $(TOP)/mongoose.c
|
||||
CFLAGS_EXTRA ?= -DMG_TLS=MG_TLS_BUILTIN
|
||||
CFLAGS ?= -W -Wall -Wextra -Werror -Wundef -Wshadow -O0 $(CFLAGS_EXTRA)
|
||||
PFLAGS = -I$(TOP) -DMG_DATA_SIZE=64 -DMG_ENABLE_LINES=1
|
||||
PFLAGS = -I$(TOP) -DMG_DATA_SIZE=64 -DMG_ENABLE_LINES=1 -DMAIN
|
||||
AFLAGS ?= -fsanitize=signed-integer-overflow,address,undefined,alignment
|
||||
|
||||
all: $(PROG)
|
||||
@@ -17,13 +17,12 @@ $(PROG): $(SOURCES) $(TOP)/mongoose.h
|
||||
|
||||
# Create an embedded filesystem containing compressed dashboard.html
|
||||
file_data.c: dashboard.html
|
||||
node $(TOP)/resources/inline.js dashboard.html -o out.html
|
||||
node $(TOP)/resources/pack.js out.html:dashboard.html:gzip > file_data.c
|
||||
node $(TOP)/resources/html2c.js dashboard.html -o file_data.c
|
||||
@echo "On-flash size: `grep -oE '[0-9]+' file_data.c | wc -l`"
|
||||
|
||||
# For development: rebuild and restart if any of the sources change
|
||||
watch:
|
||||
node $(TOP)/resources/watch.js -w main.c -w dashboard.c -w $(TOP)/mongoose.h -w dashboard.html -- make
|
||||
node $(TOP)/resources/watch.js -w dashboard.c -w $(TOP)/mongoose.h -w dashboard.html -- make
|
||||
|
||||
clean:
|
||||
rm -rf $(PROG) *.exe *.obj *.dSYM mongoose out.* file_data.c
|
||||
rm -rf $(PROG) *.exe *.obj *.dSYM mongoose file_data.c
|
||||
@@ -1,36 +0,0 @@
|
||||
# Device dashboard
|
||||
|
||||
This is the AI specification file for the Web device dashboard.
|
||||
|
||||
## General rules
|
||||
|
||||
Your goal is to produce a dashboard.c and dashboard.html files
|
||||
|
||||
Fetch the initial implementation of these two files from:
|
||||
|
||||
https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/minimal/dashboard.c
|
||||
https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/minimal/dashboard.html
|
||||
|
||||
The C API for dashboard.c is described at https://mongoose.ws/docs/api/dash/
|
||||
|
||||
The C API header file is at https://github.com/cesanta/mongoose/blob/master/src/dash.h
|
||||
|
||||
The minimal reference project is at https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/minimal/
|
||||
|
||||
The full reference project is at https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/full/
|
||||
|
||||
For editing dashboard.html, use only Mongoose `data-bind` and `${...}` template syntax
|
||||
|
||||
No vanilla JS event listeners, no fetch calls, no custom reactive logic.
|
||||
|
||||
## dashboard.html
|
||||
|
||||
On a page, create single control panel titled "LED control"
|
||||
|
||||
On that control, add 3 LED toggles: LED1, LED2, LED3
|
||||
|
||||
Update Dashboard.init call accordingly. Update dashboard.c accordingly - have 3 LEDs in the "leds" data set.
|
||||
|
||||
## dashboard.c
|
||||
|
||||
Don't touch it
|
||||
@@ -45,3 +45,21 @@ void mg_dash_init(struct mg_mgr *mgr) {
|
||||
void mg_dash_poll(struct mg_mgr *mgr) {
|
||||
(void) mgr;
|
||||
}
|
||||
|
||||
// On desktop, build with -DMAIN flag to include main().
|
||||
// On embedded system, run this code in your main() function
|
||||
#ifdef MAIN
|
||||
int main(void) {
|
||||
struct mg_mgr mgr;
|
||||
|
||||
mg_mgr_init(&mgr);
|
||||
mg_dash_init(&mgr);
|
||||
|
||||
for (;;) {
|
||||
mg_mgr_poll(&mgr, 1);
|
||||
mg_dash_poll(&mgr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -54,6 +54,11 @@
|
||||
Open this page in two or more browser windows and see how the dashboards
|
||||
stay synchronised when changes are made in any of them.
|
||||
</div>
|
||||
|
||||
<div style="text-align: left; margin-top: 6px;">
|
||||
To customize this dashboard, follow
|
||||
<a target="_blank" href="https://mongoose.ws/docs/guides/web-dashboard-guide/">https://mongoose.ws/docs/guides/web-dashboard-guide/</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2026 Cesanta Software Limited
|
||||
// SPDX-License-Identifier: GPL-2.0-only or commercial
|
||||
|
||||
#include "mongoose.h"
|
||||
|
||||
int main(void) {
|
||||
struct mg_mgr mgr;
|
||||
|
||||
mg_mgr_init(&mgr);
|
||||
mg_dash_init(&mgr);
|
||||
|
||||
for (;;) {
|
||||
mg_mgr_poll(&mgr, 10);
|
||||
mg_dash_poll(&mgr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user