mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-30 21:18:25 +00:00
Remove points
This commit is contained in:
1 parent
70d45a19ae
commit
402096798a
5 files changed
+14
-16
No files matched your search
+2
-4
@@ -3255,12 +3255,9 @@ static inline size_t mg_print_field(mg_pfn_t fn, void *arg, va_list *ap) {
|
|||||||
} else if (f->type == MG_VAL_INT) {
|
} else if (f->type == MG_VAL_INT) {
|
||||||
n += mg_xprintf(fn, arg, "%d", *(int *) f->value);
|
n += mg_xprintf(fn, arg, "%d", *(int *) f->value);
|
||||||
} else if (f->type == MG_VAL_DBL) {
|
} else if (f->type == MG_VAL_DBL) {
|
||||||
n += mg_xprintf(fn, arg, "%g", *(double *) f->value);
|
n += mg_xprintf(fn, arg, "%.2f", *(double *) f->value);
|
||||||
} else if (f->type == MG_VAL_STR) {
|
} else if (f->type == MG_VAL_STR) {
|
||||||
// struct mg_str *s = * (struct mg_str *) f->value;
|
|
||||||
n += mg_xprintf(fn, arg, "%m", MG_ESC(f->value));
|
n += mg_xprintf(fn, arg, "%m", MG_ESC(f->value));
|
||||||
// } else if (f->type == MG_VAL_FN) {
|
|
||||||
// n += mg_xprintf(fn, arg, val.fn ? "%M" : "null", val.fn);
|
|
||||||
} else {
|
} else {
|
||||||
n += mg_xprintf(fn, arg, "null");
|
n += mg_xprintf(fn, arg, "null");
|
||||||
}
|
}
|
||||||
@@ -3313,6 +3310,7 @@ static inline void mg_dash_send_change(struct mg_mgr *mgr, struct mg_dash *dash,
|
|||||||
const char *name) {
|
const char *name) {
|
||||||
struct mg_field_set *set = mg_dash_find_field_set(dash, mg_str(name));
|
struct mg_field_set *set = mg_dash_find_field_set(dash, mg_str(name));
|
||||||
if (set != NULL) {
|
if (set != NULL) {
|
||||||
|
if (set->sync) set->sync(false);
|
||||||
mg_dash_broadcast(mgr, "{%m:%m,%m:{%m:%M}}", MG_ESC("method"),
|
mg_dash_broadcast(mgr, "{%m:%m,%m:{%m:%M}}", MG_ESC("method"),
|
||||||
MG_ESC("change"), MG_ESC("params"), MG_ESC(set->name),
|
MG_ESC("change"), MG_ESC("params"), MG_ESC(set->name),
|
||||||
mg_print_field_set, set);
|
mg_print_field_set, set);
|
||||||
|
|||||||
+2
-4
@@ -110,12 +110,9 @@ static inline size_t mg_print_field(mg_pfn_t fn, void *arg, va_list *ap) {
|
|||||||
} else if (f->type == MG_VAL_INT) {
|
} else if (f->type == MG_VAL_INT) {
|
||||||
n += mg_xprintf(fn, arg, "%d", *(int *) f->value);
|
n += mg_xprintf(fn, arg, "%d", *(int *) f->value);
|
||||||
} else if (f->type == MG_VAL_DBL) {
|
} else if (f->type == MG_VAL_DBL) {
|
||||||
n += mg_xprintf(fn, arg, "%g", *(double *) f->value);
|
n += mg_xprintf(fn, arg, "%.2f", *(double *) f->value);
|
||||||
} else if (f->type == MG_VAL_STR) {
|
} else if (f->type == MG_VAL_STR) {
|
||||||
// struct mg_str *s = * (struct mg_str *) f->value;
|
|
||||||
n += mg_xprintf(fn, arg, "%m", MG_ESC(f->value));
|
n += mg_xprintf(fn, arg, "%m", MG_ESC(f->value));
|
||||||
// } else if (f->type == MG_VAL_FN) {
|
|
||||||
// n += mg_xprintf(fn, arg, val.fn ? "%M" : "null", val.fn);
|
|
||||||
} else {
|
} else {
|
||||||
n += mg_xprintf(fn, arg, "null");
|
n += mg_xprintf(fn, arg, "null");
|
||||||
}
|
}
|
||||||
@@ -168,6 +165,7 @@ static inline void mg_dash_send_change(struct mg_mgr *mgr, struct mg_dash *dash,
|
|||||||
const char *name) {
|
const char *name) {
|
||||||
struct mg_field_set *set = mg_dash_find_field_set(dash, mg_str(name));
|
struct mg_field_set *set = mg_dash_find_field_set(dash, mg_str(name));
|
||||||
if (set != NULL) {
|
if (set != NULL) {
|
||||||
|
if (set->sync) set->sync(false);
|
||||||
mg_dash_broadcast(mgr, "{%m:%m,%m:{%m:%M}}", MG_ESC("method"),
|
mg_dash_broadcast(mgr, "{%m:%m,%m:{%m:%M}}", MG_ESC("method"),
|
||||||
MG_ESC("change"), MG_ESC("params"), MG_ESC(set->name),
|
MG_ESC("change"), MG_ESC("params"), MG_ESC(set->name),
|
||||||
mg_print_field_set, set);
|
mg_print_field_set, set);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static void sync_control(bool is_write) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read-only device Metrics
|
// Read-only device Metrics
|
||||||
static int s_ram = 32, s_cpu = 37, s_humidity = 59;
|
static int s_ram = 32, s_cpu = 7, s_humidity = 59;
|
||||||
static double s_temperature = 24.8;
|
static double s_temperature = 24.8;
|
||||||
|
|
||||||
static struct mg_field fields_metrics[] = {
|
static struct mg_field fields_metrics[] = {
|
||||||
@@ -45,8 +45,9 @@ static struct mg_field fields_metrics[] = {
|
|||||||
|
|
||||||
static void sync_metrics(bool is_write) {
|
static void sync_metrics(bool is_write) {
|
||||||
if (is_write) return;
|
if (is_write) return;
|
||||||
// Read values from hardware into the state variables
|
s_ram = 25 + (rand() % 16); // Sumulate metric change
|
||||||
// s_ram = calculate_current_free_ram();
|
s_cpu = 7 + (rand() % 21);
|
||||||
|
s_temperature = 14.8 + ((double)rand() / RAND_MAX) * 20.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read-write device settings
|
// Read-write device settings
|
||||||
@@ -127,8 +128,7 @@ void mongoose_poll(void) {
|
|||||||
{
|
{
|
||||||
// Send metrics change periodically
|
// Send metrics change periodically
|
||||||
static uint64_t timer = 0;
|
static uint64_t timer = 0;
|
||||||
if (mg_timer_expired(&timer, 30000, mg_now())) {
|
if (mg_timer_expired(&timer, 300, mg_now())) {
|
||||||
sync_metrics(false);
|
|
||||||
mg_dash_send_change(&s_mgr, &s_dashboard, "metrics");
|
mg_dash_send_change(&s_mgr, &s_dashboard, "metrics");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
Dashboard.init({
|
Dashboard.init({
|
||||||
debug: true,
|
debug: true,
|
||||||
data: {
|
data: {
|
||||||
points: [],
|
chart1: {data: ''},
|
||||||
controls: {
|
controls: {
|
||||||
fan: true,
|
fan: true,
|
||||||
relay1: false,
|
relay1: false,
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
--spacing-2: 0.5rem;
|
--spacing-2: 0.5rem;
|
||||||
--spacing-3: 0.75rem;
|
--spacing-3: 0.75rem;
|
||||||
--spacing-4: 1rem;
|
--spacing-4: 1rem;
|
||||||
|
--spacing-5: 1.25rem;
|
||||||
|
--spacing-6: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -46,7 +48,7 @@ body {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: var(--spacing-4);
|
gap: var(--spacing-4);
|
||||||
padding: var(--spacing-2) var(--spacing-3);
|
padding: var(--spacing-2) var(--spacing-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-left {
|
.header-left {
|
||||||
@@ -134,7 +136,7 @@ body {
|
|||||||
.tab-stage {
|
.tab-stage {
|
||||||
max-width: var(--max-width);
|
max-width: var(--max-width);
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 5.5rem var(--spacing-3) var(--spacing-3);
|
padding: 5.5rem var(--spacing-4) var(--spacing-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-panel {
|
.tab-panel {
|
||||||
|
|||||||
Reference in new issue
Block a user