Berry fixes

This commit is contained in:
Stephan Hadinger 2021-03-29 19:44:22 +02:00
parent e4e0eb9467
commit 763ed74c5e
2 changed files with 5 additions and 4 deletions

View File

@ -213,7 +213,7 @@ char * copyStr(const char * str) {
} }
const char ext_invalid_mem[] PROGMEM = "<--INVALID-->"; const char ext_invalid_mem[] PROGMEM = "<--INVALID-->";
const uint32_t min_valid_ptr = 0x3FF00000; // addresses below this line are invalid const uint32_t min_valid_ptr = 0x3F000000; // addresses below this line are invalid
int32_t ext_vsnprintf_P(char * buf, size_t buf_len, const char * fmt_P, va_list va) { int32_t ext_vsnprintf_P(char * buf, size_t buf_len, const char * fmt_P, va_list va) {
va_list va_cpy; va_list va_cpy;

View File

@ -75,6 +75,7 @@ extern "C" {
int32_t top = be_top(vm); // Get the number of arguments int32_t top = be_top(vm); // Get the number of arguments
if (top == 2 && be_isstring(vm, 2)) { // only 1 argument of type string accepted if (top == 2 && be_isstring(vm, 2)) { // only 1 argument of type string accepted
const char * command = be_tostring(vm, 2); const char * command = be_tostring(vm, 2);
be_pop(vm, 2); // clear the stack before calling, because of re-entrant call to Berry in a Rule
ExecuteCommand(command, SRC_BERRY); ExecuteCommand(command, SRC_BERRY);
be_pushstring(vm, TasmotaGlobal.mqtt_data); be_pushstring(vm, TasmotaGlobal.mqtt_data);
be_return(vm); // Return be_return(vm); // Return
@ -294,7 +295,7 @@ extern "C" {
if (data_present) { if (data_present) {
// see ResponseLightState() // see ResponseLightState()
map_insert_bool(vm, "power", bitRead(TasmotaGlobal.power, light_num)); map_insert_bool(vm, "power", bitRead(TasmotaGlobal.power, light_num + Light.device - 1));
map_insert_int(vm, "bri", bri); map_insert_int(vm, "bri", bri);
if (subtype >= LST_RGB) { if (subtype >= LST_RGB) {
@ -364,9 +365,9 @@ extern "C" {
// power // power
if (map_find(vm, "power")) { if (map_find(vm, "power")) {
bool power = be_tobool(vm, -1); bool power = be_tobool(vm, -1);
bool current_power = bitRead(TasmotaGlobal.power, idx); bool current_power = bitRead(TasmotaGlobal.power, idx + Light.device - 1);
if (power != current_power) { // only send command if needed if (power != current_power) { // only send command if needed
ExecuteCommandPower(Light.device + idx, (power) ? POWER_ON : POWER_OFF, SRC_BERRY); ExecuteCommandPower(idx + Light.device, (power) ? POWER_ON : POWER_OFF, SRC_BERRY);
} }
} }
be_pop(vm, 1); be_pop(vm, 1);