From 8155d2c66a709386599d79a9090f78e634a247fa Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 21 Mar 2021 17:12:10 +0100 Subject: [PATCH] Minor fixes --- .../Berry-0.1.10/src/port/berry_conf.h | 10 +++++-- tasmota/xdrv_52_3_berry_tasmota.ino | 2 +- tasmota/xdrv_52_9_berry.ino | 28 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/lib/libesp32/Berry-0.1.10/src/port/berry_conf.h b/lib/libesp32/Berry-0.1.10/src/port/berry_conf.h index 57fbe6208..74fc7f505 100644 --- a/lib/libesp32/Berry-0.1.10/src/port/berry_conf.h +++ b/lib/libesp32/Berry-0.1.10/src/port/berry_conf.h @@ -163,8 +163,14 @@ * The default is to use the functions in the standard library. **/ #ifdef USE_BERRY_PSRAM - extern void *special_malloc(uint32_t size); - extern void *special_realloc(void *ptr, size_t size); +#ifdef __cplusplus +extern "C" { +#endif + extern void *berry_malloc(uint32_t size); + extern void *berry_realloc(void *ptr, size_t size); +#ifdef __cplusplus +} +#endif #define BE_EXPLICIT_MALLOC special_malloc #define BE_EXPLICIT_REALLOC special_realloc #else diff --git a/tasmota/xdrv_52_3_berry_tasmota.ino b/tasmota/xdrv_52_3_berry_tasmota.ino index bd9e1a8cc..e29382d18 100644 --- a/tasmota/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/xdrv_52_3_berry_tasmota.ino @@ -317,7 +317,7 @@ extern "C" { int32_t top = be_top(vm); // Get the number of arguments if (top == 1 || (top == 2 && be_isint(vm, 2))) { int32_t light_num = 0; - if (top > 0) { + if (top > 1) { light_num = be_toint(vm, 2); } push_getlight(vm, light_num); diff --git a/tasmota/xdrv_52_9_berry.ino b/tasmota/xdrv_52_9_berry.ino index dcdeb25b5..df2ba5b6b 100644 --- a/tasmota/xdrv_52_9_berry.ino +++ b/tasmota/xdrv_52_9_berry.ino @@ -47,6 +47,32 @@ void checkBeTop(void) { } } +/*********************************************************************************************\ + * Memory handler + * Use PSRAM if available +\*********************************************************************************************/ +extern "C" { + void *berry_malloc(uint32_t size); + void *berry_realloc(void *ptr, size_t size); +#ifdef USE_BERRY_PSRAM + void *berry_malloc(uint32_t size) { + return special_malloc(size); + } + void *berry_realloc(void *ptr, size_t size) { + return special_realloc(ptr, size); + } +#else + void *berry_malloc(uint32_t size) { + return malloc(size); + } + void *berry_realloc(void *ptr, size_t size) { + return realloc(ptr, size); + } +#endif // USE_BERRY_PSRAM + +} + + /*********************************************************************************************\ * Handlers for Berry calls and async * @@ -564,7 +590,7 @@ void HandleBerryConsoleRefresh(void) if (svalue.length()) { berry.log.reset(); // clear all previous logs berry.repl_active = true; // start recording - AddLog_P(LOG_LEVEL_INFO, PSTR("BRY: received command %s"), svalue.c_str()); + // AddLog_P(LOG_LEVEL_INFO, PSTR("BRY: received command %s"), svalue.c_str()); berry.log.addString(svalue.c_str(), nullptr, BERRY_CONSOLE_CMD_DELIMITER); // Call berry