mirror of https://github.com/arendst/Tasmota.git
widget support for Berry/MI32 dashboard (#22359)
This commit is contained in:
parent
0f2b3b1898
commit
b5a487a595
|
@ -25,6 +25,9 @@ BE_FUNC_CTYPE_DECLARE(be_MI32_set_hum, "", "ii");
|
|||
extern void be_MI32_set_temp(int slot, int temp_val);
|
||||
BE_FUNC_CTYPE_DECLARE(be_MI32_set_temp, "", "ii");
|
||||
|
||||
extern bbool be_MI32_widget(const char *sbuf, void* function);
|
||||
BE_FUNC_CTYPE_DECLARE(be_MI32_widget, "b", "s[c]");
|
||||
|
||||
#include "be_fixed_MI32.h"
|
||||
|
||||
/* @const_object_info_begin
|
||||
|
@ -35,6 +38,7 @@ module MI32 (scope: global) {
|
|||
set_bat, ctype_func(be_MI32_set_bat)
|
||||
set_hum, ctype_func(be_MI32_set_hum)
|
||||
set_temp, ctype_func(be_MI32_set_temp)
|
||||
widget, ctype_func(be_MI32_widget)
|
||||
}
|
||||
@const_object_info_end */
|
||||
|
||||
|
|
|
@ -44,6 +44,12 @@ extern "C" {
|
|||
extern void MI32setTemperatureForSlot(uint32_t slot, float value);
|
||||
extern uint8_t * MI32getDeviceMAC(uint32_t slot);
|
||||
|
||||
struct {
|
||||
const char * data = nullptr;
|
||||
size_t size = 0;
|
||||
void* callback = nullptr;
|
||||
} be_MI32Widget;
|
||||
|
||||
int be_MI32_devices(void) {
|
||||
return MI32numberOfDevices();
|
||||
}
|
||||
|
@ -73,6 +79,18 @@ extern "C" {
|
|||
MI32setTemperatureForSlot(slot,temp_val);
|
||||
}
|
||||
|
||||
bool be_MI32_widget(const char* sbuf, void* function){
|
||||
if (function){
|
||||
be_MI32Widget.callback = function;
|
||||
}
|
||||
if(be_MI32Widget.size == 0){
|
||||
be_MI32Widget.data = sbuf;
|
||||
be_MI32Widget.size = strlen(sbuf);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** BLE - generic BLE functions
|
||||
|
@ -358,5 +376,6 @@ MI32.get_MAC(slot)
|
|||
MI32.set_bat(slot,int)
|
||||
MI32.set_hum(slot,float)
|
||||
MI32.set_temp(slot,float)
|
||||
MI32.widget(string[,cb])
|
||||
|
||||
*/
|
|
@ -919,6 +919,14 @@ extern "C" {
|
|||
return _name;
|
||||
}
|
||||
|
||||
void MI32sendBerryWidget() {
|
||||
if(be_MI32Widget.size != 0) {
|
||||
WSContentSend(be_MI32Widget.data, be_MI32Widget.size);
|
||||
be_MI32Widget.data = nullptr;
|
||||
be_MI32Widget.size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} //extern "C"
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
@ -2361,6 +2369,9 @@ void CmndMi32Option(void){
|
|||
\*********************************************************************************************/
|
||||
#ifdef USE_MI_EXT_GUI
|
||||
bool MI32HandleWebGUIResponse(void){
|
||||
if(be_MI32Widget.callback != nullptr){
|
||||
((void(*)())be_MI32Widget.callback)();
|
||||
}
|
||||
char tmp[16];
|
||||
WebGetArg(PSTR("wi"), tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
|
@ -2373,6 +2384,8 @@ bool MI32HandleWebGUIResponse(void){
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MI32sendBerryWidget();
|
||||
}
|
||||
WSContentEnd();
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue