mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Merge pull request #11864 from s-hadinger/berry_cond_compile
Berry conditional compile for modules
This commit is contained in:
commit
c65af4d4d3
@ -7,6 +7,8 @@
|
|||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
#include "be_object.h"
|
#include "be_object.h"
|
||||||
|
|
||||||
|
#ifdef USE_ENERGY_SENSOR
|
||||||
|
|
||||||
extern int b_nrg_read(bvm *vm);
|
extern int b_nrg_read(bvm *vm);
|
||||||
|
|
||||||
// #if !BE_USE_PRECOMPILED_OBJECT
|
// #if !BE_USE_PRECOMPILED_OBJECT
|
||||||
@ -24,3 +26,5 @@ module tasmota (scope: global, depend: 1) {
|
|||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
#include "../generate/be_fixed_tasmota.h"
|
#include "../generate/be_fixed_tasmota.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // USE_ENERGY_SENSOR
|
@ -290,7 +290,7 @@ be_native_module_attr_table(gpio) {
|
|||||||
be_define_native_module(gpio, NULL);
|
be_define_native_module(gpio, NULL);
|
||||||
#else
|
#else
|
||||||
/* @const_object_info_begin
|
/* @const_object_info_begin
|
||||||
module gpio (scope: global, depend: BE_USE_TASMOTA) {
|
module gpio (scope: global) {
|
||||||
LOW, int(0)
|
LOW, int(0)
|
||||||
HIGH, int(1)
|
HIGH, int(1)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "be_string.h"
|
#include "be_string.h"
|
||||||
#include "be_gc.h"
|
#include "be_gc.h"
|
||||||
|
|
||||||
|
#ifdef USE_LIGHT
|
||||||
extern int l_getlight(bvm *vm);
|
extern int l_getlight(bvm *vm);
|
||||||
extern int l_setlight(bvm *vm);
|
extern int l_setlight(bvm *vm);
|
||||||
|
|
||||||
@ -39,3 +39,5 @@ module tasmota (scope: global, depend: 1) {
|
|||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
#include "../generate/be_fixed_tasmota.h"
|
#include "../generate/be_fixed_tasmota.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // USE_LIGHT
|
@ -63,15 +63,19 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
|
|||||||
&be_native_module(solidify),
|
&be_native_module(solidify),
|
||||||
#endif
|
#endif
|
||||||
/* user-defined modules register start */
|
/* user-defined modules register start */
|
||||||
#if BE_USE_TASMOTA
|
|
||||||
&be_native_module(gpio),
|
&be_native_module(gpio),
|
||||||
|
#ifdef USE_LIGHT
|
||||||
&be_native_module(light),
|
&be_native_module(light),
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_LVGL
|
#ifdef USE_LVGL
|
||||||
&be_native_module(lvgl),
|
&be_native_module(lvgl),
|
||||||
#endif // USE_LVGL
|
#endif // USE_LVGL
|
||||||
|
#ifdef USE_ENERGY_SENSOR
|
||||||
&be_native_module(energy),
|
&be_native_module(energy),
|
||||||
#endif
|
#endif // USE_ENERGY_SENSOR
|
||||||
|
|
||||||
|
|
||||||
/* user-defined modules register end */
|
/* user-defined modules register end */
|
||||||
NULL /* do not remove */
|
NULL /* do not remove */
|
||||||
@ -98,7 +102,9 @@ BERRY_API void be_load_custom_libs(bvm *vm)
|
|||||||
/* be_load_xxxlib(vm); */
|
/* be_load_xxxlib(vm); */
|
||||||
#endif
|
#endif
|
||||||
be_load_tasmota_ntvlib(vm);
|
be_load_tasmota_ntvlib(vm);
|
||||||
|
#ifdef USE_I2C
|
||||||
be_load_wirelib(vm);
|
be_load_wirelib(vm);
|
||||||
|
#endif // USE_I2C
|
||||||
be_load_driverlib(vm);
|
be_load_driverlib(vm);
|
||||||
#ifdef USE_LVGL
|
#ifdef USE_LVGL
|
||||||
// LVGL
|
// LVGL
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include "be_string.h"
|
#include "be_string.h"
|
||||||
#include "be_gc.h"
|
#include "be_gc.h"
|
||||||
|
|
||||||
|
#ifdef USE_I2C
|
||||||
|
|
||||||
extern int b_wire_init(bvm *vm);
|
extern int b_wire_init(bvm *vm);
|
||||||
|
|
||||||
extern int b_wire_begintransmission(bvm *vm);
|
extern int b_wire_begintransmission(bvm *vm);
|
||||||
@ -241,3 +243,5 @@ module tasmota (scope: global, depend: 1) {
|
|||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
#include "../generate/be_fixed_tasmota.h"
|
#include "../generate/be_fixed_tasmota.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // USE_I2C
|
@ -158,12 +158,6 @@
|
|||||||
#define BE_USE_GC_MODULE 1
|
#define BE_USE_GC_MODULE 1
|
||||||
#define BE_USE_SOLIDIFY_MODULE 1
|
#define BE_USE_SOLIDIFY_MODULE 1
|
||||||
|
|
||||||
// #ifdef ESP32
|
|
||||||
#define BE_USE_TASMOTA 1
|
|
||||||
// #else
|
|
||||||
// #define BE_USE_TASMOTA 0
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
/* Macro: BE_EXPLICIT_XXX
|
/* Macro: BE_EXPLICIT_XXX
|
||||||
* If these macros are defined, the corresponding function will
|
* If these macros are defined, the corresponding function will
|
||||||
* use the version defined by these macros. These macro definitions
|
* use the version defined by these macros. These macro definitions
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef USE_BERRY
|
#ifdef USE_BERRY
|
||||||
|
|
||||||
|
#ifdef USE_ENERGY_SENSOR
|
||||||
|
|
||||||
#include <berry.h>
|
#include <berry.h>
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +34,6 @@
|
|||||||
*
|
*
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef USE_ENERGY_SENSOR
|
|
||||||
// Berry: `begintransmission(address:int) -> nil`
|
// Berry: `begintransmission(address:int) -> nil`
|
||||||
int32_t b_nrg_read(struct bvm *vm);
|
int32_t b_nrg_read(struct bvm *vm);
|
||||||
int32_t b_nrg_read(struct bvm *vm) {
|
int32_t b_nrg_read(struct bvm *vm) {
|
||||||
@ -53,18 +54,17 @@ extern "C" {
|
|||||||
be_pop(vm, 1);
|
be_pop(vm, 1);
|
||||||
be_return(vm); // Return
|
be_return(vm); // Return
|
||||||
}
|
}
|
||||||
#else // USE_ENERGY_SENSOR
|
}
|
||||||
|
|
||||||
|
#endif // USE_ENERGY_SENSOR
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
//
|
//
|
||||||
int32_t b_wire_energymissing(struct bvm *vm);
|
int32_t b_wire_energymissing(struct bvm *vm);
|
||||||
int32_t b_wire_energymissing(struct bvm *vm) {
|
int32_t b_wire_energymissing(struct bvm *vm) {
|
||||||
be_raise(vm, "feature_error", "Energy sensor is not enabled, use '#define USE_ENERGY_SENSOR'");
|
be_raise(vm, "feature_error", "Energy sensor is not enabled, use '#define USE_ENERGY_SENSOR'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// define weak aliases
|
|
||||||
int32_t b_nrg_read(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_energymissing")));
|
|
||||||
#endif // USE_ENERGY_SENSOR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // USE_BERRY
|
#endif // USE_BERRY
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef USE_BERRY
|
#ifdef USE_BERRY
|
||||||
|
|
||||||
|
#ifdef USE_LIGHT
|
||||||
|
|
||||||
#include <berry.h>
|
#include <berry.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
@ -29,7 +31,6 @@
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#ifdef USE_LIGHT
|
|
||||||
// push the light status object on the vm stack
|
// push the light status object on the vm stack
|
||||||
void push_getlight(bvm *vm, uint32_t light_num) {
|
void push_getlight(bvm *vm, uint32_t light_num) {
|
||||||
bool data_present = false; // do we have relevant data
|
bool data_present = false; // do we have relevant data
|
||||||
@ -295,18 +296,15 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
be_raise(vm, kTypeError, nullptr);
|
be_raise(vm, kTypeError, nullptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else // #ifdef USE_LIGHT
|
#endif // USE_LIGHT
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
int32_t b_light_missing(struct bvm *vm) {
|
int32_t b_light_missing(struct bvm *vm) {
|
||||||
be_raise(vm, "feature_error", "LIGHT is not enabled, use '#define USE_LIGHT'");
|
be_raise(vm, "feature_error", "LIGHT is not enabled, use '#define USE_LIGHT'");
|
||||||
}
|
}
|
||||||
int32_t l_getlight(struct bvm *vm) __attribute__ ((weak, alias ("b_light_missing")));
|
|
||||||
int32_t l_setlight(struct bvm *vm) __attribute__ ((weak, alias ("b_light_missing")));
|
|
||||||
int32_t l_gamma8(struct bvm *vm) __attribute__ ((weak, alias ("b_light_missing")));
|
|
||||||
int32_t l_gamma10(struct bvm *vm) __attribute__ ((weak, alias ("b_light_missing")));
|
|
||||||
int32_t l_rev_gamma10(struct bvm *vm) __attribute__ ((weak, alias ("b_light_missing")));
|
|
||||||
#endif // #ifdef USE_LIGHT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_BERRY
|
#endif // USE_BERRY
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef USE_BERRY
|
#ifdef USE_BERRY
|
||||||
|
|
||||||
|
#ifdef USE_I2C
|
||||||
|
|
||||||
#include <berry.h>
|
#include <berry.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
@ -52,7 +54,6 @@ int32_t getBus(bvm *vm) {
|
|||||||
*
|
*
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef USE_I2C
|
|
||||||
// Berry: `init([bus:int = 0]) -> nil
|
// Berry: `init([bus:int = 0]) -> nil
|
||||||
int32_t b_wire_init(struct bvm *vm);
|
int32_t b_wire_init(struct bvm *vm);
|
||||||
int32_t b_wire_init(struct bvm *vm) {
|
int32_t b_wire_init(struct bvm *vm) {
|
||||||
@ -241,28 +242,16 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
be_raise(vm, kTypeError, nullptr);
|
be_raise(vm, kTypeError, nullptr);
|
||||||
}
|
}
|
||||||
#else // USE_I2C
|
}
|
||||||
//
|
|
||||||
|
#endif // USE_I2C
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
// Handle methods that require I2C to be enabled
|
||||||
int32_t b_wire_i2cmissing(struct bvm *vm);
|
int32_t b_wire_i2cmissing(struct bvm *vm);
|
||||||
int32_t b_wire_i2cmissing(struct bvm *vm) {
|
int32_t b_wire_i2cmissing(struct bvm *vm) {
|
||||||
be_raise(vm, "feature_error", "I2C is not enabled, use '#define USE_I2C'");
|
be_raise(vm, "feature_error", "I2C is not enabled, use '#define USE_I2C'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// define weak aliases
|
|
||||||
int32_t b_wire_init(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_begintransmission(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_endtransmission(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_requestfrom(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_available(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_write(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_read(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_scan(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_validwrite(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_validread(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_readbytes(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_writebytes(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
int32_t b_wire_detect(struct bvm *vm) __attribute__ ((weak, alias ("b_wire_i2cmissing")));
|
|
||||||
#endif // USE_I2C
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_BERRY
|
#endif // USE_BERRY
|
||||||
|
@ -32,7 +32,9 @@ const char berry_prog[] =
|
|||||||
|
|
||||||
// auto-import modules
|
// auto-import modules
|
||||||
// // import alias
|
// // import alias
|
||||||
|
#ifdef USE_ENERGY_SENSOR
|
||||||
"import energy "
|
"import energy "
|
||||||
|
#endif
|
||||||
|
|
||||||
// Phase 1
|
// Phase 1
|
||||||
"class Tasmota: Tasmota_ntv "
|
"class Tasmota: Tasmota_ntv "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user