let berry drivers provide "after_teleperiod" handlers (#21351)

this is useful if you want to periodically report the state of something
handled separately to the sensors output.
This commit is contained in:
David Gwynne 2024-05-06 03:42:27 +10:00 committed by GitHub
parent c41f18a9b6
commit cced3d1d93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,7 @@ class Driver
var save_before_restart var save_before_restart
var web_sensor var web_sensor
var json_append var json_append
var after_teleperiod
var button_pressed var button_pressed
var display var display

View File

@ -70,7 +70,7 @@ be_local_closure(Driver_add_cmd, /* name */
** Solidified class: Driver ** Solidified class: Driver
********************************************************************/ ********************************************************************/
be_local_class(Driver, be_local_class(Driver,
13, 14,
NULL, NULL,
be_nested_map(14, be_nested_map(14,
( (struct bmapnode*) &(const bmapnode[]) { ( (struct bmapnode*) &(const bmapnode[]) {
@ -87,6 +87,7 @@ be_local_class(Driver,
{ be_const_key(web_add_management_button, 0), be_const_var(5) }, { be_const_key(web_add_management_button, 0), be_const_var(5) },
{ be_const_key(every_100ms, 13), be_const_var(1) }, { be_const_key(every_100ms, 13), be_const_var(1) },
{ be_const_key(json_append, -1), be_const_var(10) }, { be_const_key(json_append, -1), be_const_var(10) },
{ be_const_key(after_teleperiod, -1), be_const_var(13) },
{ be_const_key(web_add_button, -1), be_const_var(3) }, { be_const_key(web_add_button, -1), be_const_var(3) },
})), })),
(bstring*) &be_const_str_Driver (bstring*) &be_const_str_Driver

View File

@ -985,6 +985,9 @@ bool Xdrv52(uint32_t function)
case FUNC_JSON_APPEND: case FUNC_JSON_APPEND:
callBerryEventDispatcher(PSTR("json_append"), nullptr, 0, nullptr); callBerryEventDispatcher(PSTR("json_append"), nullptr, 0, nullptr);
break; break;
case FUNC_AFTER_TELEPERIOD:
callBerryEventDispatcher(PSTR("after_teleperiod"), nullptr, 0, nullptr);
break;
case FUNC_BUTTON_PRESSED: case FUNC_BUTTON_PRESSED:
callBerryEventDispatcher(PSTR("button_pressed"), nullptr, 0, nullptr); callBerryEventDispatcher(PSTR("button_pressed"), nullptr, 0, nullptr);