Merge branch 'arendst:development' into development

This commit is contained in:
logon84 2021-12-06 01:35:12 +01:00 committed by GitHub
commit 56d697f30a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 364 additions and 84 deletions

View File

@ -51,7 +51,7 @@ static void class_init(bvm *vm, bclass *c, const bnfuncinfo *lib)
++slib;
}
}
be_map_release(vm, c->members); /* clear space */
be_map_compact(vm, c->members); /* clear space */
}
}

View File

@ -40,7 +40,7 @@ bclass* be_newclass(bvm *vm, bstring *name, bclass *super)
void be_class_compress(bvm *vm, bclass *c)
{
if (!gc_isconst(c) && c->members) {
be_map_release(vm, c->members); /* clear space */
be_map_compact(vm, c->members); /* clear space */
}
}
@ -220,7 +220,7 @@ static binstance* newobject(bvm *vm, bclass *c)
/* Instanciate new instance from stack with argc parameters */
/* Pushes the constructor on the stack to be executed if a construtor is found */
/* Returns true if a constructor is found */
bbool be_class_newobj(bvm *vm, bclass *c, int32_t pos, int argc, int mode)
bbool be_class_newobj(bvm *vm, bclass *c, int pos, int argc, int mode)
{
bvalue init;
binstance *obj = newobject(vm, c); /* create empty object hierarchy from class hierarchy */

View File

@ -58,7 +58,7 @@ void be_prim_method_bind(bvm *vm, bclass *c, bstring *name, bntvfunc f);
void be_closure_method_bind(bvm *vm, bclass *c, bstring *name, bclosure *cl);
int be_class_closure_count(bclass *c);
void be_class_upvalue_init(bvm *vm, bclass *c);
bbool be_class_newobj(bvm *vm, bclass *c, int32_t pos, int argc, int mode);
bbool be_class_newobj(bvm *vm, bclass *c, int pos, int argc, int mode);
int be_instance_member_simple(bvm *vm, binstance *obj, bstring *name, bvalue *dst);
int be_instance_member(bvm *vm, binstance *obj, bstring *name, bvalue *dst);
int be_class_member(bvm *vm, bclass *obj, bstring *name, bvalue *dst);

View File

@ -54,7 +54,7 @@ static int is_object(bvm *vm, const char *class, int idx)
}
be_remove(vm, -2);
}
const char *name = be_classname(vm, idx);
const char *name = be_classname(vm, -1);
bbool ret = !strcmp(name, class);
be_pop(vm, 1);
return ret;

View File

@ -343,7 +343,7 @@ bmapnode* be_map_val2node(bvalue *value)
return (bmapnode *)((size_t)value - sizeof(bmapkey));
}
void be_map_release(bvm *vm, bmap *map)
void be_map_compact(bvm *vm, bmap *map)
{
(void)vm;
if (!gc_isconst(map)) {

View File

@ -56,6 +56,6 @@ bvalue* be_map_insertstr(bvm *vm, bmap *map, bstring *key, bvalue *value);
void be_map_removestr(bvm *vm, bmap *map, bstring *key);
bmapnode* be_map_next(bmap *map, bmapiter *iter);
bmapnode* be_map_val2node(bvalue *value);
void be_map_release(bvm *vm, bmap *map);
void be_map_compact(bvm *vm, bmap *map);
#endif

View File

@ -99,7 +99,7 @@ static bmodule* new_module(bvm *vm, const bntvmodule *nm)
obj->table = NULL; /* gc protection */
obj->table = be_map_new(vm);
insert_attrs(vm, obj->table, nm);
be_map_release(vm, obj->table); /* clear space */
be_map_compact(vm, obj->table); /* clear space */
be_stackpop(vm, 1);
}
return obj;

View File

@ -42,7 +42,7 @@ static void m_solidify_bvalue(bvm *vm, bvalue * value, const char *classname, co
static void m_solidify_map(bvm *vm, bmap * map, const char *class_name)
{
// compact first
be_map_release(vm, map);
be_map_compact(vm, map);
logfmt(" be_nested_map(%i,\n", map->count);

View File

@ -330,7 +330,6 @@ static bstring* string_range(bvm *vm, bstring *str, binstance *range)
{
bint lower, upper;
bint size = str_len(str); /* size of source string */
// bint size = be_data_size(vm, -1); /* get source list size */
/* get index range */
bvalue temp;
be_instance_member(vm, range, be_newstr(vm, "__lower__"), &temp);

View File

@ -87,7 +87,7 @@ bvalue* be_global_var(bvm *vm, int index)
void be_global_release_space(bvm *vm)
{
be_map_release(vm, global(vm).vtab);
be_map_compact(vm, global(vm).vtab);
be_vector_release(vm, &global(vm).vlist);
}
@ -130,7 +130,7 @@ int be_builtin_new(bvm *vm, bstring *name)
void be_bulitin_release_space(bvm *vm)
{
be_map_release(vm, builtin(vm).vtab);
be_map_compact(vm, builtin(vm).vtab);
be_vector_release(vm, &builtin(vm).vlist);
}
#else

View File

@ -142,7 +142,7 @@
_vm->cf->status = PRIM_FUNC; \
}
static void prep_closure(bvm *vm, int32_t pos, int argc, int mode);
static void prep_closure(bvm *vm, int pos, int argc, int mode);
static void attribute_error(bvm *vm, const char *t, bvalue *b, bvalue *c)
{
@ -1186,7 +1186,7 @@ newframe: /* a new call frame */
}
}
static void prep_closure(bvm *vm, int32_t pos, int argc, int mode)
static void prep_closure(bvm *vm, int pos, int argc, int mode)
{
bvalue *v, *end;
bproto *proto = var2cl(vm->reg + pos)->proto;
@ -1211,7 +1211,7 @@ static void prep_closure(bvm *vm, int32_t pos, int argc, int mode)
}
}
static void do_closure(bvm *vm, int32_t pos, int argc)
static void do_closure(bvm *vm, int pos, int argc)
{
// bvalue *v, *end;
// bproto *proto = var2cl(reg)->proto;
@ -1225,7 +1225,7 @@ static void do_closure(bvm *vm, int32_t pos, int argc)
vm_exec(vm);
}
static void do_ntvclos(bvm *vm, int32_t pos, int argc)
static void do_ntvclos(bvm *vm, int pos, int argc)
{
bntvclos *f = var_toobj(vm->reg + pos);
push_native(vm, vm->reg + pos, argc, 0);
@ -1233,7 +1233,7 @@ static void do_ntvclos(bvm *vm, int32_t pos, int argc)
ret_native(vm);
}
static void do_ntvfunc(bvm *vm, int32_t pos, int argc)
static void do_ntvfunc(bvm *vm, int pos, int argc)
{
bntvfunc f = var_tontvfunc(vm->reg + pos);
push_native(vm, vm->reg + pos, argc, 0);
@ -1241,7 +1241,7 @@ static void do_ntvfunc(bvm *vm, int32_t pos, int argc)
ret_native(vm);
}
static void do_class(bvm *vm, int32_t pos, int argc)
static void do_class(bvm *vm, int pos, int argc)
{
if (be_class_newobj(vm, var_toobj(vm->reg + pos), pos, ++argc, 0)) {
be_incrtop(vm);
@ -1254,7 +1254,7 @@ void be_dofunc(bvm *vm, bvalue *v, int argc)
{
be_assert(vm->reg <= v && v < vm->stacktop);
be_assert(vm->stack <= vm->reg && vm->reg < vm->stacktop);
int32_t pos = v - vm->reg;
int pos = v - vm->reg;
switch (var_type(v)) {
case BE_CLASS: do_class(vm, pos, argc); break;
case BE_CLOSURE: do_closure(vm, pos, argc); break;

View File

@ -716,6 +716,9 @@
#define D_CMND_BR_RUN ""
#define D_BR_NOT_STARTED "Berry not started"
// Commands xdrv_60_shift595.ino - 74x595 family shift register driver
#define D_CMND_SHIFT595_DEVICE_COUNT "Shift595DeviceCount"
// Commands xsns_02_analog.ino
#define D_CMND_ADCPARAM "AdcParam"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Herzschlag"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 - TX"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Battito cardiaco"
#define D_GPIO_SHIFT595_SRCLK "74x595 - SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 - RCLK"
#define D_GPIO_SHIFT595_OE "74x595 - OE"
#define D_GPIO_SHIFT595_SER "74x595 - SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "А"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "А"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "A"

View File

@ -843,6 +843,10 @@
#define D_SENSOR_HRG15_TX "HRG15 Tx"
#define D_SENSOR_VINDRIKTNING_RX "VINDRIKTNING"
#define D_SENSOR_HEARTBEAT "Heartbeat"
#define D_GPIO_SHIFT595_SRCLK "74x595 SRCLK"
#define D_GPIO_SHIFT595_RCLK "74x595 RCLK"
#define D_GPIO_SHIFT595_OE "74x595 OE"
#define D_GPIO_SHIFT595_SER "74x595 SER"
// Units
#define D_UNIT_AMPERE "安培"

View File

@ -893,6 +893,10 @@
// -- Other sensors/drivers -----------------------
//#define USE_SHIFT595 // Add support for 74xx595 8-bit shift registers (+0k7 code)
#define SHIFT595_INVERT_OUTPUTS false // [SetOption133] Don't invert outputs of 74x595 shift register
#define SHIFT595_DEVICE_COUNT 1 // [Shift595DeviceCount] Set the number of connected 74x595 shift registers
//#define USE_TM1638 // Add support for TM1638 switches copying Switch1 .. Switch8 (+1k code)
//#define USE_HX711 // Add support for HX711 load cell (+1k5 code)
// #define USE_HX711_GUI // Add optional web GUI to HX711 as scale (+1k8 code)

View File

@ -161,8 +161,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t energy_phase : 1; // bit 15 (v9.5.0.9) - SetOption129 - (Energy) Show phase information
uint32_t show_heap_with_timestamp : 1; // bit 16 (v9.5.0.9) - SetOption130 - (Debug) Show heap with logging timestamp
uint32_t tuya_allow_dimmer_0 : 1; // bit 17 (v10.0.0.3) - SetOption131 - (Tuya) Allow save dimmer = 0 receved by MCU
uint32_t tls_use_fingerprint : 1; // bit 18 (v10.0.0.4) - SetOption132 - (TLS) use fingerprint validation instead of CA based
uint32_t spare19 : 1; // bit 19
uint32_t tls_use_fingerprint : 1; // bit 18 (v10.0.0.4) - SetOption132 - (TLS) Use fingerprint validation instead of CA based
uint32_t shift595_invert_outputs : 1; // bit 19 (v10.0.0.4) - SetOption133 - (Shift595) Invert outputs of 74x595 shift registers
uint32_t spare20 : 1; // bit 20
uint32_t spare21 : 1; // bit 21
uint32_t spare22 : 1; // bit 22
@ -250,7 +250,7 @@ typedef union {
uint32_t sonoff_l1_music_sync : 1; // bit 5 (v9.5.0.5) - CMND_L1MUSICSYNC - Enable sync to music
uint32_t influxdb_default : 1; // bit 6 (v9.5.0.5) - Set influxdb initial defaults if 0
uint32_t influxdb_state : 1; // bit 7 (v9.5.0.5) - CMND_IFX - Enable influxdb support
uint32_t spare08 : 1; // bit 8
uint32_t sspm_display : 1; // bit 8 (v10.0.0.4) - CMND_SSPMDISPLAY - Enable gui display of powered on relays only
uint32_t spare09 : 1; // bit 9
uint32_t spare10 : 1; // bit 10
uint32_t spare11 : 1; // bit 11
@ -686,8 +686,9 @@ typedef struct {
uint8_t weight_change; // E9F
uint8_t web_color2[2][3]; // EA0 Needs to be on integer / 3 distance from web_color
uint8_t free_ea6[33]; // EA6
uint8_t free_ea6[32]; // EA6
uint8_t shift595_device_count; // EC6
uint8_t sta_config; // EC7
uint8_t sta_active; // EC8
uint8_t rule_stop; // EC9

View File

@ -1196,6 +1196,9 @@ void SettingsDefaultSet2(void) {
flag4.mqtt_tls |= MQTT_TLS_ENABLED;
flag4.mqtt_no_retain |= MQTT_NO_RETAIN;
flag5.shift595_invert_outputs |= SHIFT595_INVERT_OUTPUTS;
Settings->shift595_device_count = SHIFT595_DEVICE_COUNT;
Settings->flag = flag;
Settings->flag2 = flag2;
Settings->flag3 = flag3;

View File

@ -21,10 +21,15 @@ extern "C" {
extern struct rst_info resetInfo;
}
#ifdef USE_KNX
bool knx_started = false;
#endif // USE_KNX
/*********************************************************************************************\
* Watchdog extension (https://github.com/esp8266/Arduino/issues/1532)
\*********************************************************************************************/
#ifdef ESP8266
#include <Ticker.h>
Ticker tickerOSWatch;
@ -38,12 +43,7 @@ uint8_t oswatch_blocked_loop = 0;
//void OsWatchTicker() IRAM_ATTR;
#endif // USE_WS2812_DMA
#ifdef USE_KNX
bool knx_started = false;
#endif // USE_KNX
void OsWatchTicker(void)
{
void OsWatchTicker(void) {
uint32_t t = millis();
uint32_t last_run = t - oswatch_last_loop_time;
@ -66,27 +66,33 @@ void OsWatchTicker(void)
}
}
void OsWatchInit(void)
{
void OsWatchInit(void) {
oswatch_blocked_loop = RtcSettings.oswatch_blocked_loop;
RtcSettings.oswatch_blocked_loop = 0;
oswatch_last_loop_time = millis();
tickerOSWatch.attach_ms(((OSWATCH_RESET_TIME / 3) * 1000), OsWatchTicker);
}
void OsWatchLoop(void)
{
void OsWatchLoop(void) {
oswatch_last_loop_time = millis();
// while(1) delay(1000); // this will trigger the os watch
}
bool OsWatchBlockedLoop(void)
{
bool OsWatchBlockedLoop(void) {
return oswatch_blocked_loop;
}
uint32_t ResetReason(void)
{
#else // Anything except ESP8266
void OsWatchInit(void) {}
void OsWatchLoop(void) {}
bool OsWatchBlockedLoop(void) {
return false;
}
#endif // ESP8266
uint32_t ResetReason(void) {
/*
user_interface.h
REASON_DEFAULT_RST = 0, // "Power on" normal startup by power on
@ -100,9 +106,8 @@ uint32_t ResetReason(void)
return ESP_ResetInfoReason();
}
String GetResetReason(void)
{
if (oswatch_blocked_loop) {
String GetResetReason(void) {
if (OsWatchBlockedLoop()) {
char buff[32];
strncpy_P(buff, PSTR(D_JSON_BLOCKED_LOOP), sizeof(buff));
return String(buff);

View File

@ -784,7 +784,9 @@ void ResponseAppendFeatures(void)
#ifdef USE_SONOFF_SPM
feature8 |= 0x00040000;
#endif
// feature8 |= 0x00080000;
#ifdef USE_SHIFT595
feature8 |= 0x00080000; // xdrv_60_shift595.ino
#endif
// feature8 |= 0x00100000;
// feature8 |= 0x00200000;

View File

@ -1043,7 +1043,7 @@ void Every100mSeconds(void)
if (TasmotaGlobal.pulse_timer[i] != 0L) { // Timer active?
if (TimeReached(TasmotaGlobal.pulse_timer[i])) { // Timer finished?
TasmotaGlobal.pulse_timer[i] = 0L; // Turn off this timer
for (uint32_t j = 0; j < TasmotaGlobal.devices_present; j = j +MAX_PULSETIMERS) {
for (uint32_t j = 0; (i + j) < TasmotaGlobal.devices_present; j = j +MAX_PULSETIMERS) {
ExecuteCommandPower(i + j +1, (POWER_ALL_OFF_PULSETIME_ON == Settings->poweronstate) ? POWER_ON : POWER_OFF, SRC_PULSETIMER);
}
}

View File

@ -176,6 +176,7 @@ enum UserSelectablePins {
GPIO_BL0942_RX, // BL0942 Serial interface
GPIO_HM330X_SET, // HM330X SET pin (sleep when low)
GPIO_HEARTBEAT, GPIO_HEARTBEAT_INV,
GPIO_SHIFT595_SRCLK, GPIO_SHIFT595_RCLK, GPIO_SHIFT595_OE, GPIO_SHIFT595_SER, // 74x595 Shift register
GPIO_SENSOR_END };
enum ProgramSelectablePins {
@ -372,7 +373,9 @@ const char kSensorNames[] PROGMEM =
D_SENSOR_BL0942_RX "|"
D_SENSOR_HM330X_SET "|"
D_SENSOR_HEARTBEAT "|" D_SENSOR_HEARTBEAT "_i|"
;
D_GPIO_SHIFT595_SRCLK "|" D_GPIO_SHIFT595_RCLK "|" D_GPIO_SHIFT595_OE "|" D_GPIO_SHIFT595_SER "|"
;
const char kSensorNamesFixed[] PROGMEM =
D_SENSOR_USER;
@ -930,6 +933,13 @@ const uint16_t kGpioNiceList[] PROGMEM = {
AGPIO(GPIO_ADC_JOY) + MAX_ADCS, // Joystick
AGPIO(GPIO_ADC_PH) + MAX_ADCS, // Analog PH Sensor
#endif // ESP32
#ifdef USE_SHIFT595
AGPIO(GPIO_SHIFT595_SRCLK), // 74x595 shift register
AGPIO(GPIO_SHIFT595_RCLK),
AGPIO(GPIO_SHIFT595_OE),
AGPIO(GPIO_SHIFT595_SER),
#endif
};
/*-------------------------------------------------------------------------------------------*\

View File

@ -0,0 +1,119 @@
/*
xdrv_60_shift595.ino - 74x595 shift register family support for Tasmota
Copyright (C) 2021 Jacek Ziółkowski
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_SHIFT595
#define XDRV_60 60
const char kShift595Commands[] PROGMEM = "|" D_CMND_SHIFT595_DEVICE_COUNT ;
void (* const Shift595Command[])(void) PROGMEM = { &CmndShift595Devices };
struct Shift595 {
uint8_t pinSRCLK;
uint8_t pinRCLK;
uint8_t pinSER;
uint8_t pinOE;
uint8_t outputs;
uint8_t first;
bool connected = false;
} *Shift595 = nullptr;
void Shift595ConfigurePin(uint8_t pin, uint8_t value = 0) {
pinMode(pin, OUTPUT);
digitalWrite(pin, value);
}
void Shift595Init(void) {
if (PinUsed(GPIO_SHIFT595_SRCLK) && PinUsed(GPIO_SHIFT595_RCLK) && PinUsed(GPIO_SHIFT595_SER)) {
Shift595 = (struct Shift595*)calloc(1, sizeof(struct Shift595));
if (Shift595) {
Shift595->pinSRCLK = Pin(GPIO_SHIFT595_SRCLK);
Shift595->pinRCLK = Pin(GPIO_SHIFT595_RCLK);
Shift595->pinSER = Pin(GPIO_SHIFT595_SER);
Shift595ConfigurePin(Shift595->pinSRCLK);
Shift595ConfigurePin(Shift595->pinRCLK);
Shift595ConfigurePin(Shift595->pinSER);
if (PinUsed(GPIO_SHIFT595_OE)) {
Shift595->pinOE = Pin(GPIO_SHIFT595_OE);
Shift595ConfigurePin(Shift595->pinOE, 1);
}
Shift595->first = TasmotaGlobal.devices_present;
Shift595->outputs = Settings->shift595_device_count * 8;
TasmotaGlobal.devices_present += Shift595->outputs;
Shift595->connected = true;
AddLog(LOG_LEVEL_DEBUG, PSTR("595: Controlling relays POWER%d to POWER%d"), Shift595->first + 1, Shift595->first + Shift595->outputs);
}
}
}
void Shift595LatchPin(uint8_t pin) {
digitalWrite(pin, 1);
digitalWrite(pin, 0);
}
void Shift595SwitchRelay(void) {
if (Shift595 && Shift595->connected == true) {
for (uint32_t i = 0; i < Shift595->outputs; i++) {
uint8_t relay_state = bitRead(XdrvMailbox.index, Shift595->first + Shift595->outputs -1 -i);
digitalWrite(Shift595->pinSER, Settings->flag5.shift595_invert_outputs ? !relay_state : relay_state);
Shift595LatchPin(Shift595->pinSRCLK);
}
Shift595LatchPin(Shift595->pinRCLK);
if (PinUsed(GPIO_SHIFT595_OE)) {
digitalWrite(Shift595->pinOE, 0);
}
}
}
void CmndShift595Devices(void) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 3)) {
Settings->shift595_device_count = (1 == XdrvMailbox.payload) ? SHIFT595_DEVICE_COUNT : XdrvMailbox.payload;
TasmotaGlobal.restart_flag = 2;
}
ResponseCmndNumber(Settings->shift595_device_count);
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdrv60(uint8_t function) {
bool result = false;
if (FUNC_PRE_INIT == function) {
Shift595Init();
} else if (Shift595) {
switch (function) {
case FUNC_SET_POWER:
Shift595SwitchRelay();
break;
case FUNC_COMMAND:
result = DecodeCommand(kShift595Commands, Shift595Command);
break;
}
}
return result;
}
#endif // USE_SHIFT595

View File

@ -1082,29 +1082,30 @@ bool SSPMButton(void) {
/*********************************************************************************************/
const uint16_t SSPM_SIZE = 128;
const char kSSPMEnergyPhases[] PROGMEM = "%*_f</td><td>%*_f</td><td>%*_f</td><td>%*_f</td><td style='white-space:nowrap'>|[%*_f,%*_f,%*_f,%*_f]";
char* SSPMEnergyFormat(char* result, float* input, uint32_t resolution, bool json) {
char layout[100];
GetTextIndexed(layout, sizeof(layout), json, kSSPMEnergyPhases);
ext_snprintf_P(result, SSPM_SIZE, layout, resolution, &input[0], resolution, &input[1], resolution, &input[2], resolution, &input[3]);
char* SSPMEnergyFormat(char* result, float* input, uint32_t resolution, uint8_t* indirect, uint8_t offset, uint32_t count) {
result[0] = '\0';
for (uint32_t i = 0; i < count; i++) {
ext_snprintf_P(result, SSPM_SIZE, PSTR("%s<td>%*_f</td>"), result, resolution, &input[indirect[offset +i]]);
}
ext_snprintf_P(result, SSPM_SIZE, PSTR("%s<td style='white-space:nowrap'>"), result);
return result;
}
const char HTTP_SSPM_VOLTAGE[] PROGMEM =
"{s}" D_VOLTAGE "</th><td>%s" D_UNIT_VOLT "{e}"; // {s} = <tr><th>, {m} = </th><td style='width:20px;white-space:nowrap'>, {e} = </td></tr>
"{s}" D_VOLTAGE "</th>%s" D_UNIT_VOLT "{e}"; // {s} = <tr><th>, {m} = </th><td style='width:20px;white-space:nowrap'>, {e} = </td></tr>
const char HTTP_SSPM_CURRENT[] PROGMEM =
"{s}" D_CURRENT "</th><td>%s" D_UNIT_AMPERE "{e}";
"{s}" D_CURRENT "</th>%s" D_UNIT_AMPERE "{e}";
const char HTTP_SSPM_POWER[] PROGMEM =
"{s}" D_POWERUSAGE_ACTIVE "</th><td>%s" D_UNIT_WATT "{e}";
"{s}" D_POWERUSAGE_ACTIVE "</th>%s" D_UNIT_WATT "{e}";
const char HTTP_SSPM_POWER2[] PROGMEM =
"{s}" D_POWERUSAGE_APPARENT "</th><td>%s" D_UNIT_VA "{e}"
"{s}" D_POWERUSAGE_REACTIVE "</th><td>%s" D_UNIT_VAR "{e}"
"{s}" D_POWER_FACTOR "</th><td>%s{e}";
"{s}" D_POWERUSAGE_APPARENT "</th>%s" D_UNIT_VA "{e}"
"{s}" D_POWERUSAGE_REACTIVE "</th>%s" D_UNIT_VAR "{e}"
"{s}" D_POWER_FACTOR "</th>%s{e}";
const char HTTP_SSPM_ENERGY[] PROGMEM =
"{s}" D_ENERGY_TODAY "</th><td>%s" D_UNIT_KILOWATTHOUR "{e}"
"{s}" D_ENERGY_YESTERDAY "</th><td>%s" D_UNIT_KILOWATTHOUR "{e}"
"{s}" D_ENERGY_TOTAL "</th><td>%s" D_UNIT_KILOWATTHOUR "{e}";
"{s}" D_ENERGY_TODAY "</th>%s" D_UNIT_KILOWATTHOUR "{e}"
"{s}" D_ENERGY_YESTERDAY "</th>%s" D_UNIT_KILOWATTHOUR "{e}"
"{s}" D_ENERGY_TOTAL "</th>%s" D_UNIT_KILOWATTHOUR "{e}";
void SSPMEnergyShow(bool json) {
if (!TasmotaGlobal.devices_present) { return; } // Not ready yet
@ -1152,30 +1153,50 @@ void SSPMEnergyShow(bool json) {
}
ResponseAppend_P(PSTR("]}"));
} else {
Sspm->rotate++;
if (Sspm->rotate >= TasmotaGlobal.devices_present) {
Sspm->rotate = 0;
uint8_t relay[SSPM_MAX_MODULES * 4];
uint8_t indirect[SSPM_MAX_MODULES * 4];
uint32_t index = 0;
power_t power = TasmotaGlobal.power;
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) {
if ((0 == Settings->sbflag1.sspm_display) ||
((1 == Settings->sbflag1.sspm_display) && (power >> i) &1)) {
relay[index] = i +1;
indirect[index] = i;
index++;
}
}
uint32_t module = Sspm->rotate >> 2;
uint32_t relay_base = module * 4;
WSContentSend_P(PSTR("</table>{t}{s}")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>)
for (uint32_t i = 1; i < 5; i++) {
WSContentSend_P(PSTR("</th><th style='width:60px;white-space:nowrap'>L%d"), relay_base +i);
if (index) {
uint32_t offset = 0;
if (index > 4) {
Sspm->rotate++;
if (Sspm->rotate >= ((index -1) >> 2) << 3) {
Sspm->rotate = 0;
}
offset = (Sspm->rotate >> 2) * 4;
}
uint32_t count = index - offset;
if (count > 4) { count = 4; }
WSContentSend_P(PSTR("</table>{t}{s}")); // First column is empty ({t} = <table style='width:100%'>, {s} = <tr><th>)
for (uint32_t i = 0; i < count; i++) {
WSContentSend_P(PSTR("</th><th style='width:60px;white-space:nowrap'>L%d"), relay[offset +i]);
}
WSContentSend_P(PSTR("</th><td>{e}")); // Last column is units ({e} = </td></tr>)
char value_chr[SSPM_SIZE];
WSContentSend_PD(HTTP_SSPM_VOLTAGE, SSPMEnergyFormat(value_chr, Sspm->voltage[0], Settings->flag2.voltage_resolution, indirect, offset, count));
WSContentSend_PD(HTTP_SSPM_CURRENT, SSPMEnergyFormat(value_chr, Sspm->current[0], Settings->flag2.current_resolution, indirect, offset, count));
WSContentSend_PD(HTTP_SSPM_POWER, SSPMEnergyFormat(value_chr, Sspm->active_power[0], Settings->flag2.wattage_resolution, indirect, offset, count));
char valu2_chr[SSPM_SIZE];
char valu3_chr[SSPM_SIZE];
WSContentSend_PD(HTTP_SSPM_POWER2, SSPMEnergyFormat(value_chr, Sspm->apparent_power[0], Settings->flag2.wattage_resolution, indirect, offset, count),
SSPMEnergyFormat(valu2_chr, Sspm->reactive_power[0], Settings->flag2.wattage_resolution, indirect, offset, count),
SSPMEnergyFormat(valu3_chr, Sspm->power_factor[0], 2, indirect, offset, count));
WSContentSend_PD(HTTP_SSPM_ENERGY, SSPMEnergyFormat(value_chr, Sspm->energy_today[0], Settings->flag2.energy_resolution, indirect, offset, count),
SSPMEnergyFormat(valu2_chr, Sspm->energy_yesterday[0], Settings->flag2.energy_resolution, indirect, offset, count),
SSPMEnergyFormat(valu3_chr, Sspm->energy_total[0], Settings->flag2.energy_resolution, indirect, offset, count));
WSContentSend_P(PSTR("</table>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
}
WSContentSend_P(PSTR("</th><td>{e}")); // Last column is units ({e} = </td></tr>)
char value_chr[SSPM_SIZE];
WSContentSend_PD(HTTP_SSPM_VOLTAGE, SSPMEnergyFormat(value_chr, Sspm->voltage[module], Settings->flag2.voltage_resolution, json));
WSContentSend_PD(HTTP_SSPM_CURRENT, SSPMEnergyFormat(value_chr, Sspm->current[module], Settings->flag2.current_resolution, json));
WSContentSend_PD(HTTP_SSPM_POWER, SSPMEnergyFormat(value_chr, Sspm->active_power[module], Settings->flag2.wattage_resolution, json));
char valu2_chr[SSPM_SIZE];
char valu3_chr[SSPM_SIZE];
WSContentSend_PD(HTTP_SSPM_POWER2, SSPMEnergyFormat(value_chr, Sspm->apparent_power[module], Settings->flag2.wattage_resolution, json),
SSPMEnergyFormat(valu2_chr, Sspm->reactive_power[module], Settings->flag2.wattage_resolution, json),
SSPMEnergyFormat(valu3_chr, Sspm->power_factor[module], 2, json));
WSContentSend_PD(HTTP_SSPM_ENERGY, SSPMEnergyFormat(value_chr, Sspm->energy_today[module], Settings->flag2.energy_resolution, json),
SSPMEnergyFormat(valu2_chr, Sspm->energy_yesterday[module], Settings->flag2.energy_resolution, json),
SSPMEnergyFormat(valu3_chr, Sspm->energy_total[module], Settings->flag2.energy_resolution, json));
WSContentSend_P(PSTR("</table>{t}")); // {t} = <table style='width:100%'> - Define for next FUNC_WEB_SENSOR
}
}
@ -1184,10 +1205,10 @@ void SSPMEnergyShow(bool json) {
\*********************************************************************************************/
const char kSSPMCommands[] PROGMEM = "SSPM|" // Prefix
"Log|Energy|History|Scan|IamHere" ;
"Log|Energy|History|Scan|IamHere|Display" ;
void (* const SSPMCommand[])(void) PROGMEM = {
&CmndSSPMLog, &CmndSSPMEnergy, &CmndSSPMEnergyHistory, &CmndSSPMScan, &CmndSSPMIamHere };
&CmndSSPMLog, &CmndSSPMEnergy, &CmndSSPMEnergyHistory, &CmndSSPMScan, &CmndSSPMIamHere, &CmndSSPMDisplay };
void CmndSSPMLog(void) {
// Report 29 log entries
@ -1222,6 +1243,14 @@ void CmndSSPMIamHere(void) {
ResponseCmndDone();
}
void CmndSSPMDisplay(void) {
// Select either all relays or only powered on relays
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
Settings->sbflag1.sspm_display = XdrvMailbox.payload;
}
ResponseCmndNumber(Settings->sbflag1.sspm_display);
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/

View File

@ -186,7 +186,8 @@ a_setoption = [[
"(Energy) Show phase information",
"(Debug) Show heap with logging timestamp",
"(Tuya) Allow save dimmer = 0 receved by MCU",
"","",
"(TLS) Use fingerprint validation instead of CA based",
"(Shift595) Invert outputs of 74x595 shift registers",
"","","","",
"","","","",
"","","",""
@ -260,7 +261,7 @@ a_features = [[
"USE_BM8563","USE_ENERGY_DUMMY","USE_AM2320","USE_T67XX",
"USE_MCP2515","USE_TASMESH","USE_WIFI_RANGE_EXTENDER","USE_INFLUXDB",
"USE_HRG15","USE_VINDRIKTNING","USE_SCD40","USE_HM330X",
"USE_HDC2010","USE_LSC_MCSL","USE_SONOFF_SPM","",
"USE_HDC2010","USE_LSC_MCSL","USE_SONOFF_SPM","USE_SHIFT595",
"","","","",
"","","","",
"","","",""
@ -291,7 +292,7 @@ else:
obj = json.load(fp)
def StartDecode():
print ("\n*** decode-status.py v20211201 by Theo Arends and Jacek Ziolkowski ***")
print ("\n*** decode-status.py v20211205 by Theo Arends and Jacek Ziolkowski ***")
# print("Decoding\n{}".format(obj))