mirror of https://github.com/arendst/Tasmota.git
Merge pull request #14038 from s-hadinger/berry_lowercase
Rename Berry to berry
This commit is contained in:
commit
48b830c6c4
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018-2020 Guan Wenliang
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,105 @@
|
|||
CFLAGS = -Wall -Wextra -std=c99 -pedantic-errors -O2
|
||||
LIBS = -lm
|
||||
TARGET = berry
|
||||
CC ?= gcc
|
||||
MKDIR = mkdir
|
||||
LFLAGS =
|
||||
|
||||
INCPATH = src default
|
||||
SRCPATH = src default
|
||||
GENERATE = generate
|
||||
CONFIG = default/berry_conf.h
|
||||
COC = tools/coc/coc
|
||||
PY = python3
|
||||
PYCOC = tools/pycoc/main.py
|
||||
CONST_TAB = $(GENERATE)/be_const_strtab.h
|
||||
MAKE_COC = $(MAKE) -C tools/coc
|
||||
|
||||
ifeq ($(OS), Windows_NT) # Windows
|
||||
CFLAGS += -Wno-format # for "%I64d" warning
|
||||
LFLAGS += -Wl,--out-implib,berry.lib # export symbols lib for dll linked
|
||||
TARGET := $(TARGET).exe
|
||||
COC := $(COC).exe
|
||||
PY := $(PY).exe
|
||||
else
|
||||
CFLAGS += -DUSE_READLINE_LIB
|
||||
LIBS += -lreadline -ldl
|
||||
OS := $(shell uname)
|
||||
ifeq ($(OS), Linux)
|
||||
LFLAGS += -Wl,--export-dynamic
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(V), 1)
|
||||
Q=@
|
||||
MSG=@echo
|
||||
MAKE_COC += -s Q=$(Q)
|
||||
else
|
||||
MSG=@true
|
||||
endif
|
||||
|
||||
ifeq ($(TEST), 1)
|
||||
CFLAGS += -fprofile-arcs -ftest-coverage
|
||||
LFLAGS += -fprofile-arcs -ftest-coverage
|
||||
endif
|
||||
|
||||
SRCS = $(foreach dir, $(SRCPATH), $(wildcard $(dir)/*.c))
|
||||
OBJS = $(patsubst %.c, %.o, $(SRCS))
|
||||
DEPS = $(patsubst %.c, %.d, $(SRCS))
|
||||
INCFLAGS = $(foreach dir, $(INCPATH), -I"$(dir)")
|
||||
|
||||
.PHONY : clean
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
debug: CFLAGS += -O0 -g -DBE_DEBUG
|
||||
debug: all
|
||||
|
||||
test: CFLAGS += --coverage
|
||||
test: LFLAGS += --coverage
|
||||
test: all
|
||||
$(MSG) [Run Testcases...]
|
||||
$(Q) ./testall.be
|
||||
$(Q) $(RM) */*.gcno */*.gcda
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(MSG) [Linking...]
|
||||
$(Q) $(CC) $(OBJS) $(LFLAGS) $(LIBS) -o $@
|
||||
$(MSG) done
|
||||
|
||||
$(OBJS): %.o: %.c
|
||||
$(MSG) [Compile] $<
|
||||
$(Q) $(CC) -MM $(CFLAGS) $(INCFLAGS) -MT"$*.d" -MT"$(<:.c=.o)" $< > $*.d
|
||||
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) -c $< -o $@
|
||||
|
||||
sinclude $(DEPS)
|
||||
|
||||
$(OBJS): $(CONST_TAB)
|
||||
|
||||
$(CONST_TAB): $(COC) $(GENERATE) $(SRCS) $(CONFIG)
|
||||
$(MSG) [Prebuild] generate resources
|
||||
$(Q) $(COC) -i $(SRCPATH) -c $(CONFIG) -o $(GENERATE)
|
||||
|
||||
$(GENERATE):
|
||||
$(Q) $(MKDIR) $(GENERATE)
|
||||
|
||||
$(COC):
|
||||
$(MSG) [Make] coc
|
||||
$(Q) $(MAKE_COC)
|
||||
|
||||
install:
|
||||
cp $(TARGET) /usr/local/bin
|
||||
|
||||
uninstall:
|
||||
$(RM) /usr/local/bin/$(TARGET)
|
||||
|
||||
prebuild: $(COC) $(GENERATE)
|
||||
$(MSG) [Prebuild] generate resources
|
||||
$(Q) $(PY) $(PYCOC) -o $(GENERATE) $(SRCPATH) -c $(CONFIG)
|
||||
$(MSG) done
|
||||
|
||||
clean:
|
||||
$(MSG) [Clean...]
|
||||
$(Q) $(RM) $(OBJS) $(DEPS) $(GENERATE)/* berry.lib
|
||||
$(Q) $(MAKE_COC) clean
|
||||
$(MSG) done
|
|
@ -0,0 +1,163 @@
|
|||
<p align="center">
|
||||
<h1 align="center">
|
||||
<img src="https://gitee.com/mirrors/Berry/raw/master/berry-logo.png" alt="Berry" width=272 height=128>
|
||||
</h1>
|
||||
<p align="center">The Berry Script Language.</p>
|
||||
</p>
|
||||
|
||||
## Introduction
|
||||
|
||||
Berry is a ultra-lightweight dynamically typed embedded scripting language. It is designed for lower-performance embedded devices. The Berry interpreter-core's code size is less than 40KiB and can run on less than 4KiB heap (on ARM Cortex M4 CPU, Thumb ISA and ARMCC compiler).
|
||||
|
||||
The interpreter of Berry include a one-pass compiler and register-based VM, all the code is written in ANSI C99. In Berry not every type is a class object. Some simple value types, such as int, real, boolean and string are not class object, but list, map and range are class object. This is a consideration about performance.
|
||||
Register-based VM is the same meaning as above.
|
||||
|
||||
Berry has the following advantages:
|
||||
|
||||
* Lightweight: A well-optimized interpreter with very little resources. Ideal for use in microprocessors.
|
||||
* Fast: optimized one-pass bytecode compiler and register-based virtual machine.
|
||||
* Powerful: supports imperative programming, object-oriented programming, functional programming.
|
||||
* Flexible: Berry is a dynamic type script, and it's intended for embedding in applications. It can provide good dynamic scalability for the host system.
|
||||
* Simple: simple and natural syntax, support garbage collection, and easy to use FFI (foreign function interface).
|
||||
* RAM saving: With compile-time object construction, most of the constant objects are stored in read-only code data segments, so the RAM usage of the interpreter is very low when it starts.
|
||||
|
||||
## Documents
|
||||
|
||||
LaTeX documents repository: [https://github.com/Skiars/berry_doc](https://github.com/Skiars/berry_doc)
|
||||
|
||||
Short Manual: [berry_short_manual.pdf](https://github.com/Skiars/berry_doc/releases/download/latest/berry_short_manual.pdf).
|
||||
|
||||
Reference Manual: [berry_rm_en_us.pdf](https://github.com/Skiars/berry_doc/releases/download/latest/berry_rm_en_us.pdf), [berry_rm_zh_cn.pdf](https://github.com/Skiars/berry_doc/releases/download/latest/berry_rm_zh_cn.pdf).
|
||||
|
||||
Berry's EBNF grammar definition: [tools/grammar/berry.ebnf](./tools/grammar/berry.ebnf)
|
||||
|
||||
## Features
|
||||
|
||||
* Base Type
|
||||
* Nil: `nil`
|
||||
* Boolean: `true` and `false`
|
||||
* Numerical: Integer (`int`) and Real (`real`)
|
||||
* String: Single quotation-mark string and double quotation-mark string
|
||||
* Class: Instance template, read only
|
||||
* Instance: Object constructed by class
|
||||
* Module: Read-write key-value pair table
|
||||
* List: Ordered container, like `[1, 2, 3]`
|
||||
* Map: Hash Map container, like `{ 'a': 1, 2: 3, 'map': {} }`
|
||||
* Range: include a lower and a upper integer value, like `0..5`
|
||||
* Operator and Expression
|
||||
* Assign operator: `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`
|
||||
* Relational operator: `<`, `<=`, `==`, `!=`, `>`, `>=`
|
||||
* Logic operator: `&&`, `||`, `!`
|
||||
* Arithmetic operator: `+`, `-`, `*`, `/`, `%`
|
||||
* Bitwise operator: `&`, `|`, `~`, `^`, `<<`, `>>`
|
||||
* Field operator: `.`
|
||||
* Subscript operator: `[]`
|
||||
* Connect string operator: `+`
|
||||
* Conditional operator: `? :`
|
||||
* Brackets: `()`
|
||||
* Control Structure
|
||||
* Conditional statement: `if-else`
|
||||
* Iteration statement: `while` and `for`
|
||||
* Jump statement: `break` and `continue`
|
||||
* Function
|
||||
* Local variable and block scope
|
||||
* Return statement
|
||||
* Nested functions definition
|
||||
* Closure based on Upvalue
|
||||
* Anonymous function
|
||||
* Lambda expression
|
||||
* Class
|
||||
* Inheritance (only public single inheritance)
|
||||
* Method and Operator Overload
|
||||
* Constructor method
|
||||
* Destructive method
|
||||
* Module Management
|
||||
* Built-in module that takes almost no RAM
|
||||
* Extension module support: script module, bytecode file module and shared library (like *.so, *.dll) module
|
||||
* GC (Garbage collection)
|
||||
* Mark-Sweep GC
|
||||
* Exceptional Handling
|
||||
* Throw any exception value using the `raise` statement
|
||||
* Multiple catch mode
|
||||
* Bytecode file support
|
||||
* Export function to bytecode file
|
||||
* Load the bytecode file and execute
|
||||
|
||||
## Build and Run
|
||||
|
||||
1. Install the readline library (Windows does not need):
|
||||
|
||||
``` bash
|
||||
sudo apt install libreadline-dev # Ubuntu
|
||||
brew install readline # MacOS
|
||||
```
|
||||
|
||||
2. Build (The default compiler is GCC):
|
||||
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
3. Run:
|
||||
|
||||
``` bash
|
||||
./berry # Bash or PowerShell
|
||||
berry # Windows CMD
|
||||
```
|
||||
|
||||
4. Install (Only Unix-like):
|
||||
|
||||
``` bash
|
||||
make install
|
||||
```
|
||||
|
||||
## Editor pulgins
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com/) pulgin are in this directory: [./tools/pulgins/vscode](./tools/pulgins/vscode).
|
||||
|
||||
## Examples
|
||||
|
||||
After compiling successfully, use the `berry` command with no parameters to enter the REPL environment:
|
||||
```
|
||||
Berry 0.0.1 (build in Dec 24 2018, 18:12:49)
|
||||
[GCC 8.2.0] on Linux (default)
|
||||
>
|
||||
```
|
||||
|
||||
Now enter this code:
|
||||
|
||||
``` lua
|
||||
print("Hello world!")
|
||||
```
|
||||
|
||||
You will see this output:
|
||||
|
||||
```
|
||||
Hello world!
|
||||
```
|
||||
|
||||
You can copy this code to the REPL:
|
||||
|
||||
``` ruby
|
||||
def fib(x)
|
||||
if x <= 1
|
||||
return x
|
||||
end
|
||||
return fib(x - 1) + fib(x - 2)
|
||||
end
|
||||
fib(10)
|
||||
```
|
||||
|
||||
This example code will output the result `55` and you can save the above code to a plain text file (eg test.be) and run this command:
|
||||
|
||||
``` bash
|
||||
./berry test.be
|
||||
```
|
||||
|
||||
This will also get the correct output.
|
||||
|
||||
## License
|
||||
|
||||
Berry is free software distributed under the [MIT license](./LICENSE).
|
||||
|
||||
The Berry interpreter partly referred to [Lua](http://www.lua.org/)'s design. View Lua's license here: http://www.lua.org/license.html.
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,712 @@
|
|||
/********************************************************************
|
||||
* Berry module `animate`
|
||||
*
|
||||
* To use: `import animate`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_rotate_init, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
5, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 8]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(closure),
|
||||
/* K2 */ be_nested_str(code),
|
||||
/* K3 */ be_nested_str(push),
|
||||
/* K4 */ be_nested_str(animate),
|
||||
/* K5 */ be_nested_str(ins_ramp),
|
||||
/* K6 */ be_nested_str(ins_goto),
|
||||
/* K7 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[25]) { /* code */
|
||||
0x60140003, // 0000 GETGBL R5 G3
|
||||
0x5C180000, // 0001 MOVE R6 R0
|
||||
0x7C140200, // 0002 CALL R5 1
|
||||
0x8C140B00, // 0003 GETMET R5 R5 K0
|
||||
0x7C140200, // 0004 CALL R5 1
|
||||
0x90020201, // 0005 SETMBR R0 K1 R1
|
||||
0x88140102, // 0006 GETMBR R5 R0 K2
|
||||
0x8C140B03, // 0007 GETMET R5 R5 K3
|
||||
0xB81E0800, // 0008 GETNGBL R7 K4
|
||||
0x8C1C0F05, // 0009 GETMET R7 R7 K5
|
||||
0x5C240400, // 000A MOVE R9 R2
|
||||
0x5C280600, // 000B MOVE R10 R3
|
||||
0x5C2C0800, // 000C MOVE R11 R4
|
||||
0x7C1C0800, // 000D CALL R7 4
|
||||
0x7C140400, // 000E CALL R5 2
|
||||
0x88140102, // 000F GETMBR R5 R0 K2
|
||||
0x8C140B03, // 0010 GETMET R5 R5 K3
|
||||
0xB81E0800, // 0011 GETNGBL R7 K4
|
||||
0x8C1C0F06, // 0012 GETMET R7 R7 K6
|
||||
0x58240007, // 0013 LDCONST R9 K7
|
||||
0x58280007, // 0014 LDCONST R10 K7
|
||||
0x582C0007, // 0015 LDCONST R11 K7
|
||||
0x7C1C0800, // 0016 CALL R7 4
|
||||
0x7C140400, // 0017 CALL R5 2
|
||||
0x80000000, // 0018 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Animate_rotate
|
||||
********************************************************************/
|
||||
extern const bclass be_class_Animate_engine;
|
||||
be_local_class(Animate_rotate,
|
||||
0,
|
||||
&be_class_Animate_engine,
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(Animate_rotate_init_closure) },
|
||||
})),
|
||||
be_str_literal("Animate_rotate")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_from_to_init, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
5, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(closure),
|
||||
/* K2 */ be_nested_str(code),
|
||||
/* K3 */ be_nested_str(push),
|
||||
/* K4 */ be_nested_str(animate),
|
||||
/* K5 */ be_nested_str(ins_ramp),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[16]) { /* code */
|
||||
0x60140003, // 0000 GETGBL R5 G3
|
||||
0x5C180000, // 0001 MOVE R6 R0
|
||||
0x7C140200, // 0002 CALL R5 1
|
||||
0x8C140B00, // 0003 GETMET R5 R5 K0
|
||||
0x7C140200, // 0004 CALL R5 1
|
||||
0x90020201, // 0005 SETMBR R0 K1 R1
|
||||
0x88140102, // 0006 GETMBR R5 R0 K2
|
||||
0x8C140B03, // 0007 GETMET R5 R5 K3
|
||||
0xB81E0800, // 0008 GETNGBL R7 K4
|
||||
0x8C1C0F05, // 0009 GETMET R7 R7 K5
|
||||
0x5C240400, // 000A MOVE R9 R2
|
||||
0x5C280600, // 000B MOVE R10 R3
|
||||
0x5C2C0800, // 000C MOVE R11 R4
|
||||
0x7C1C0800, // 000D CALL R7 4
|
||||
0x7C140400, // 000E CALL R5 2
|
||||
0x80000000, // 000F RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Animate_from_to
|
||||
********************************************************************/
|
||||
extern const bclass be_class_Animate_engine;
|
||||
be_local_class(Animate_from_to,
|
||||
0,
|
||||
&be_class_Animate_engine,
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(Animate_from_to_init_closure) },
|
||||
})),
|
||||
be_str_literal("Animate_from_to")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_back_forth_init, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
5, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 9]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(closure),
|
||||
/* K2 */ be_nested_str(code),
|
||||
/* K3 */ be_nested_str(push),
|
||||
/* K4 */ be_nested_str(animate),
|
||||
/* K5 */ be_nested_str(ins_ramp),
|
||||
/* K6 */ be_const_int(2),
|
||||
/* K7 */ be_nested_str(ins_goto),
|
||||
/* K8 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[34]) { /* code */
|
||||
0x60140003, // 0000 GETGBL R5 G3
|
||||
0x5C180000, // 0001 MOVE R6 R0
|
||||
0x7C140200, // 0002 CALL R5 1
|
||||
0x8C140B00, // 0003 GETMET R5 R5 K0
|
||||
0x7C140200, // 0004 CALL R5 1
|
||||
0x90020201, // 0005 SETMBR R0 K1 R1
|
||||
0x88140102, // 0006 GETMBR R5 R0 K2
|
||||
0x8C140B03, // 0007 GETMET R5 R5 K3
|
||||
0xB81E0800, // 0008 GETNGBL R7 K4
|
||||
0x8C1C0F05, // 0009 GETMET R7 R7 K5
|
||||
0x5C240400, // 000A MOVE R9 R2
|
||||
0x5C280600, // 000B MOVE R10 R3
|
||||
0x0C2C0906, // 000C DIV R11 R4 K6
|
||||
0x7C1C0800, // 000D CALL R7 4
|
||||
0x7C140400, // 000E CALL R5 2
|
||||
0x88140102, // 000F GETMBR R5 R0 K2
|
||||
0x8C140B03, // 0010 GETMET R5 R5 K3
|
||||
0xB81E0800, // 0011 GETNGBL R7 K4
|
||||
0x8C1C0F05, // 0012 GETMET R7 R7 K5
|
||||
0x5C240600, // 0013 MOVE R9 R3
|
||||
0x5C280400, // 0014 MOVE R10 R2
|
||||
0x0C2C0906, // 0015 DIV R11 R4 K6
|
||||
0x7C1C0800, // 0016 CALL R7 4
|
||||
0x7C140400, // 0017 CALL R5 2
|
||||
0x88140102, // 0018 GETMBR R5 R0 K2
|
||||
0x8C140B03, // 0019 GETMET R5 R5 K3
|
||||
0xB81E0800, // 001A GETNGBL R7 K4
|
||||
0x8C1C0F07, // 001B GETMET R7 R7 K7
|
||||
0x58240008, // 001C LDCONST R9 K8
|
||||
0x58280008, // 001D LDCONST R10 K8
|
||||
0x582C0008, // 001E LDCONST R11 K8
|
||||
0x7C1C0800, // 001F CALL R7 4
|
||||
0x7C140400, // 0020 CALL R5 2
|
||||
0x80000000, // 0021 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Animate_back_forth
|
||||
********************************************************************/
|
||||
extern const bclass be_class_Animate_engine;
|
||||
be_local_class(Animate_back_forth,
|
||||
0,
|
||||
&be_class_Animate_engine,
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(Animate_back_forth_init_closure) },
|
||||
})),
|
||||
be_str_literal("Animate_back_forth")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_ins_goto_init, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(pc_rel),
|
||||
/* K1 */ be_nested_str(pc_abs),
|
||||
/* K2 */ be_nested_str(duration),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 4]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x90020202, // 0001 SETMBR R0 K1 R2
|
||||
0x90020403, // 0002 SETMBR R0 K2 R3
|
||||
0x80000000, // 0003 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Animate_ins_goto
|
||||
********************************************************************/
|
||||
be_local_class(Animate_ins_goto,
|
||||
3,
|
||||
NULL,
|
||||
be_nested_map(4,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(pc_rel, -1), be_const_var(0) },
|
||||
{ be_const_key(duration, -1), be_const_var(2) },
|
||||
{ be_const_key(pc_abs, -1), be_const_var(1) },
|
||||
{ be_const_key(init, 2), be_const_closure(Animate_ins_goto_init_closure) },
|
||||
})),
|
||||
be_str_literal("Animate_ins_goto")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_ins_ramp_init, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(a),
|
||||
/* K1 */ be_nested_str(b),
|
||||
/* K2 */ be_nested_str(duration),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 4]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x90020202, // 0001 SETMBR R0 K1 R2
|
||||
0x90020403, // 0002 SETMBR R0 K2 R3
|
||||
0x80000000, // 0003 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Animate_ins_ramp
|
||||
********************************************************************/
|
||||
be_local_class(Animate_ins_ramp,
|
||||
3,
|
||||
NULL,
|
||||
be_nested_map(4,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(a, -1), be_const_var(0) },
|
||||
{ be_const_key(b, 2), be_const_var(1) },
|
||||
{ be_const_key(duration, -1), be_const_var(2) },
|
||||
{ be_const_key(init, -1), be_const_closure(Animate_ins_ramp_init_closure) },
|
||||
})),
|
||||
be_str_literal("Animate_ins_ramp")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: run
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_run, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(millis),
|
||||
/* K2 */ be_nested_str(value),
|
||||
/* K3 */ be_nested_str(ins_time),
|
||||
/* K4 */ be_nested_str(running),
|
||||
/* K5 */ be_nested_str(add_driver),
|
||||
}),
|
||||
&be_const_str_run,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[19]) { /* code */
|
||||
0x4C0C0000, // 0000 LDNIL R3
|
||||
0x1C0C0203, // 0001 EQ R3 R1 R3
|
||||
0x780E0003, // 0002 JMPF R3 #0007
|
||||
0xB80E0000, // 0003 GETNGBL R3 K0
|
||||
0x8C0C0701, // 0004 GETMET R3 R3 K1
|
||||
0x7C0C0200, // 0005 CALL R3 1
|
||||
0x5C040600, // 0006 MOVE R1 R3
|
||||
0x4C0C0000, // 0007 LDNIL R3
|
||||
0x200C0403, // 0008 NE R3 R2 R3
|
||||
0x780E0000, // 0009 JMPF R3 #000B
|
||||
0x90020402, // 000A SETMBR R0 K2 R2
|
||||
0x90020601, // 000B SETMBR R0 K3 R1
|
||||
0x500C0200, // 000C LDBOOL R3 1 0
|
||||
0x90020803, // 000D SETMBR R0 K4 R3
|
||||
0xB80E0000, // 000E GETNGBL R3 K0
|
||||
0x8C0C0705, // 000F GETMET R3 R3 K5
|
||||
0x5C140000, // 0010 MOVE R5 R0
|
||||
0x7C0C0400, // 0011 CALL R3 2
|
||||
0x80000000, // 0012 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_init, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(code),
|
||||
/* K1 */ be_nested_str(pc),
|
||||
/* K2 */ be_const_int(0),
|
||||
/* K3 */ be_nested_str(ins_time),
|
||||
/* K4 */ be_nested_str(running),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 8]) { /* code */
|
||||
0x60040012, // 0000 GETGBL R1 G18
|
||||
0x7C040000, // 0001 CALL R1 0
|
||||
0x90020001, // 0002 SETMBR R0 K0 R1
|
||||
0x90020302, // 0003 SETMBR R0 K1 K2
|
||||
0x90020702, // 0004 SETMBR R0 K3 K2
|
||||
0x50040000, // 0005 LDBOOL R1 0 0
|
||||
0x90020801, // 0006 SETMBR R0 K4 R1
|
||||
0x80000000, // 0007 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: autorun
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_autorun, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(run),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(add_driver),
|
||||
}),
|
||||
&be_const_str_autorun,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 9]) { /* code */
|
||||
0x8C0C0100, // 0000 GETMET R3 R0 K0
|
||||
0x5C140200, // 0001 MOVE R5 R1
|
||||
0x5C180400, // 0002 MOVE R6 R2
|
||||
0x7C0C0600, // 0003 CALL R3 3
|
||||
0xB80E0200, // 0004 GETNGBL R3 K1
|
||||
0x8C0C0702, // 0005 GETMET R3 R3 K2
|
||||
0x5C140000, // 0006 MOVE R5 R0
|
||||
0x7C0C0400, // 0007 CALL R3 2
|
||||
0x80000000, // 0008 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: stop
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_stop, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(running),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(remove_driver),
|
||||
}),
|
||||
&be_const_str_stop,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x50040000, // 0000 LDBOOL R1 0 0
|
||||
0x90020001, // 0001 SETMBR R0 K0 R1
|
||||
0xB8060200, // 0002 GETNGBL R1 K1
|
||||
0x8C040302, // 0003 GETMET R1 R1 K2
|
||||
0x5C0C0000, // 0004 MOVE R3 R0
|
||||
0x7C040400, // 0005 CALL R1 2
|
||||
0x80000000, // 0006 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: is_running
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_is_running, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(running),
|
||||
}),
|
||||
&be_const_str_is_running,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x80040200, // 0001 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: every_50ms
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_every_50ms, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(animate),
|
||||
}),
|
||||
&be_const_str_every_50ms,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 3]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x7C040200, // 0001 CALL R1 1
|
||||
0x80000000, // 0002 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: animate
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_engine_animate, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[22]) { /* constants */
|
||||
/* K0 */ be_nested_str(running),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(millis),
|
||||
/* K3 */ be_nested_str(ins_time),
|
||||
/* K4 */ be_nested_str(pc),
|
||||
/* K5 */ be_nested_str(code),
|
||||
/* K6 */ be_const_int(0),
|
||||
/* K7 */ be_nested_str(internal_error),
|
||||
/* K8 */ be_nested_str(Animate_X20pc_X20is_X20out_X20of_X20range),
|
||||
/* K9 */ be_nested_str(animate),
|
||||
/* K10 */ be_nested_str(ins_ramp),
|
||||
/* K11 */ be_nested_str(closure),
|
||||
/* K12 */ be_nested_str(duration),
|
||||
/* K13 */ be_nested_str(value),
|
||||
/* K14 */ be_nested_str(scale_uint),
|
||||
/* K15 */ be_nested_str(a),
|
||||
/* K16 */ be_nested_str(b),
|
||||
/* K17 */ be_const_int(1),
|
||||
/* K18 */ be_nested_str(ins_goto),
|
||||
/* K19 */ be_nested_str(pc_rel),
|
||||
/* K20 */ be_nested_str(pc_abs),
|
||||
/* K21 */ be_nested_str(unknown_X20instruction),
|
||||
}),
|
||||
&be_const_str_animate,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[99]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x740A0000, // 0001 JMPT R2 #0003
|
||||
0x80000400, // 0002 RET 0
|
||||
0x4C080000, // 0003 LDNIL R2
|
||||
0x1C080202, // 0004 EQ R2 R1 R2
|
||||
0x780A0003, // 0005 JMPF R2 #000A
|
||||
0xB80A0200, // 0006 GETNGBL R2 K1
|
||||
0x8C080502, // 0007 GETMET R2 R2 K2
|
||||
0x7C080200, // 0008 CALL R2 1
|
||||
0x5C040400, // 0009 MOVE R1 R2
|
||||
0x50080200, // 000A LDBOOL R2 1 0
|
||||
0x780A0054, // 000B JMPF R2 #0061
|
||||
0x88080103, // 000C GETMBR R2 R0 K3
|
||||
0x04080202, // 000D SUB R2 R1 R2
|
||||
0x880C0104, // 000E GETMBR R3 R0 K4
|
||||
0x6010000C, // 000F GETGBL R4 G12
|
||||
0x88140105, // 0010 GETMBR R5 R0 K5
|
||||
0x7C100200, // 0011 CALL R4 1
|
||||
0x280C0604, // 0012 GE R3 R3 R4
|
||||
0x780E0002, // 0013 JMPF R3 #0017
|
||||
0x500C0000, // 0014 LDBOOL R3 0 0
|
||||
0x90020003, // 0015 SETMBR R0 K0 R3
|
||||
0x70020049, // 0016 JMP #0061
|
||||
0x880C0104, // 0017 GETMBR R3 R0 K4
|
||||
0x140C0706, // 0018 LT R3 R3 K6
|
||||
0x780E0000, // 0019 JMPF R3 #001B
|
||||
0xB0060F08, // 001A RAISE 1 K7 K8
|
||||
0x880C0104, // 001B GETMBR R3 R0 K4
|
||||
0x88100105, // 001C GETMBR R4 R0 K5
|
||||
0x940C0803, // 001D GETIDX R3 R4 R3
|
||||
0x6014000F, // 001E GETGBL R5 G15
|
||||
0x5C180600, // 001F MOVE R6 R3
|
||||
0xB81E1200, // 0020 GETNGBL R7 K9
|
||||
0x881C0F0A, // 0021 GETMBR R7 R7 K10
|
||||
0x7C140400, // 0022 CALL R5 2
|
||||
0x78160020, // 0023 JMPF R5 #0045
|
||||
0x8810010B, // 0024 GETMBR R4 R0 K11
|
||||
0x8814070C, // 0025 GETMBR R5 R3 K12
|
||||
0x14140405, // 0026 LT R5 R2 R5
|
||||
0x7816000E, // 0027 JMPF R5 #0037
|
||||
0xB8160200, // 0028 GETNGBL R5 K1
|
||||
0x8C140B0E, // 0029 GETMET R5 R5 K14
|
||||
0x5C1C0400, // 002A MOVE R7 R2
|
||||
0x58200006, // 002B LDCONST R8 K6
|
||||
0x8824070C, // 002C GETMBR R9 R3 K12
|
||||
0x8828070F, // 002D GETMBR R10 R3 K15
|
||||
0x882C0710, // 002E GETMBR R11 R3 K16
|
||||
0x7C140C00, // 002F CALL R5 6
|
||||
0x90021A05, // 0030 SETMBR R0 K13 R5
|
||||
0x78120002, // 0031 JMPF R4 #0035
|
||||
0x5C140800, // 0032 MOVE R5 R4
|
||||
0x8818010D, // 0033 GETMBR R6 R0 K13
|
||||
0x7C140200, // 0034 CALL R5 1
|
||||
0x7002002A, // 0035 JMP #0061
|
||||
0x7002000C, // 0036 JMP #0044
|
||||
0x88140710, // 0037 GETMBR R5 R3 K16
|
||||
0x90021A05, // 0038 SETMBR R0 K13 R5
|
||||
0x78120002, // 0039 JMPF R4 #003D
|
||||
0x5C140800, // 003A MOVE R5 R4
|
||||
0x8818010D, // 003B GETMBR R6 R0 K13
|
||||
0x7C140200, // 003C CALL R5 1
|
||||
0x88140104, // 003D GETMBR R5 R0 K4
|
||||
0x00140B11, // 003E ADD R5 R5 K17
|
||||
0x90020805, // 003F SETMBR R0 K4 R5
|
||||
0x8814070C, // 0040 GETMBR R5 R3 K12
|
||||
0x04140405, // 0041 SUB R5 R2 R5
|
||||
0x04140205, // 0042 SUB R5 R1 R5
|
||||
0x90020605, // 0043 SETMBR R0 K3 R5
|
||||
0x7002001A, // 0044 JMP #0060
|
||||
0x6010000F, // 0045 GETGBL R4 G15
|
||||
0x5C140600, // 0046 MOVE R5 R3
|
||||
0xB81A1200, // 0047 GETNGBL R6 K9
|
||||
0x88180D12, // 0048 GETMBR R6 R6 K18
|
||||
0x7C100400, // 0049 CALL R4 2
|
||||
0x78120013, // 004A JMPF R4 #005F
|
||||
0x8810070C, // 004B GETMBR R4 R3 K12
|
||||
0x14100404, // 004C LT R4 R2 R4
|
||||
0x78120001, // 004D JMPF R4 #0050
|
||||
0x70020011, // 004E JMP #0061
|
||||
0x7002000D, // 004F JMP #005E
|
||||
0x88100713, // 0050 GETMBR R4 R3 K19
|
||||
0x20100906, // 0051 NE R4 R4 K6
|
||||
0x78120004, // 0052 JMPF R4 #0058
|
||||
0x88100104, // 0053 GETMBR R4 R0 K4
|
||||
0x88140713, // 0054 GETMBR R5 R3 K19
|
||||
0x00100805, // 0055 ADD R4 R4 R5
|
||||
0x90020804, // 0056 SETMBR R0 K4 R4
|
||||
0x70020001, // 0057 JMP #005A
|
||||
0x88100714, // 0058 GETMBR R4 R3 K20
|
||||
0x90020804, // 0059 SETMBR R0 K4 R4
|
||||
0x8810070C, // 005A GETMBR R4 R3 K12
|
||||
0x04100404, // 005B SUB R4 R2 R4
|
||||
0x04100204, // 005C SUB R4 R1 R4
|
||||
0x90020604, // 005D SETMBR R0 K3 R4
|
||||
0x70020000, // 005E JMP #0060
|
||||
0xB0060F15, // 005F RAISE 1 K7 K21
|
||||
0x7001FFA8, // 0060 JMP #000A
|
||||
0x8808010D, // 0061 GETMBR R2 R0 K13
|
||||
0x80040400, // 0062 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Animate_engine
|
||||
********************************************************************/
|
||||
be_local_class(Animate_engine,
|
||||
6,
|
||||
NULL,
|
||||
be_nested_map(13,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(code, -1), be_const_var(0) },
|
||||
{ be_const_key(run, 4), be_const_closure(Animate_engine_run_closure) },
|
||||
{ be_const_key(running, 8), be_const_var(4) },
|
||||
{ be_const_key(init, -1), be_const_closure(Animate_engine_init_closure) },
|
||||
{ be_const_key(autorun, -1), be_const_closure(Animate_engine_autorun_closure) },
|
||||
{ be_const_key(value, -1), be_const_var(5) },
|
||||
{ be_const_key(stop, 3), be_const_closure(Animate_engine_stop_closure) },
|
||||
{ be_const_key(pc, -1), be_const_var(2) },
|
||||
{ be_const_key(is_running, 11), be_const_closure(Animate_engine_is_running_closure) },
|
||||
{ be_const_key(every_50ms, 10), be_const_closure(Animate_engine_every_50ms_closure) },
|
||||
{ be_const_key(animate, -1), be_const_closure(Animate_engine_animate_closure) },
|
||||
{ be_const_key(closure, -1), be_const_var(1) },
|
||||
{ be_const_key(ins_time, 9), be_const_var(3) },
|
||||
})),
|
||||
be_str_literal("Animate_engine")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: animate
|
||||
********************************************************************/
|
||||
be_local_module(animate,
|
||||
"animate",
|
||||
be_nested_map(6,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(rotate, 2), be_const_class(be_class_Animate_rotate) },
|
||||
{ be_const_key(from_to, 3), be_const_class(be_class_Animate_from_to) },
|
||||
{ be_const_key(back_forth, -1), be_const_class(be_class_Animate_back_forth) },
|
||||
{ be_const_key(ins_goto, -1), be_const_class(be_class_Animate_ins_goto) },
|
||||
{ be_const_key(ins_ramp, -1), be_const_class(be_class_Animate_ins_ramp) },
|
||||
{ be_const_key(engine, -1), be_const_class(be_class_Animate_engine) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(animate);
|
||||
/********************************************************************/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
|||
/********************************************************************
|
||||
* Berry module `webserver`
|
||||
*
|
||||
* To use: `import webserver`
|
||||
*
|
||||
* Allows to respond to HTTP request
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_ALEXA_AVS
|
||||
|
||||
extern int m_aes_gcm_init(bvm *vm);
|
||||
extern int m_aes_gcm_encryt(bvm *vm);
|
||||
extern int m_aes_gcm_decryt(bvm *vm);
|
||||
extern int m_aes_gcm_tag(bvm *vm);
|
||||
|
||||
extern int m_ec_c25519_pubkey(bvm *vm);
|
||||
extern int m_ec_c25519_sharedkey(bvm *vm);
|
||||
|
||||
#include "../generate/be_fixed_be_class_aes_gcm.h"
|
||||
#include "../generate/be_fixed_be_class_ec_c25519.h"
|
||||
|
||||
void be_load_crypto_lib(bvm *vm) {
|
||||
// insert the class GCM in module AES
|
||||
be_newmodule(vm);
|
||||
be_setname(vm, -1, "crypto");
|
||||
be_setglobal(vm, "crypto");
|
||||
|
||||
be_pushntvclass(vm, &be_class_aes_gcm);
|
||||
be_setmember(vm, -2, "AES_GCM");
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_pushntvclass(vm, &be_class_ec_c25519);
|
||||
be_setmember(vm, -2, "EC_C25519");
|
||||
be_pop(vm, 2);
|
||||
}
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_aes_gcm (scope: global, name: AES_GCM) {
|
||||
.p1, var
|
||||
.p2, var
|
||||
|
||||
init, func(m_aes_gcm_init)
|
||||
encrypt, func(m_aes_gcm_encryt)
|
||||
decrypt, func(m_aes_gcm_decryt)
|
||||
tag, func(m_aes_gcm_tag)
|
||||
}
|
||||
|
||||
class be_class_ec_c25519 (scope: global, name: EC_C25519) {
|
||||
public_key, func(m_ec_c25519_pubkey)
|
||||
shared_key, func(m_ec_c25519_sharedkey)
|
||||
}
|
||||
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // USE_ALEXA_AVS
|
|
@ -0,0 +1,494 @@
|
|||
/********************************************************************
|
||||
* Tasmota ctypes mapping
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
#include <string.h>
|
||||
|
||||
extern __attribute__((noreturn)) void be_raisef(bvm *vm, const char *except, const char *msg, ...);
|
||||
|
||||
// binary search within an array of sorted strings
|
||||
// the first 4 bytes are a pointer to a string
|
||||
// returns 0..total_elements-1 or -1 if not found
|
||||
|
||||
int32_t bin_search_ctypes(const char * needle, const void * table, size_t elt_size, size_t total_elements) {
|
||||
int32_t low = 0;
|
||||
int32_t high = total_elements - 1;
|
||||
int32_t mid = (low + high) / 2;
|
||||
// start a dissect
|
||||
while (low <= high) {
|
||||
const char * elt = *(const char **) ( ((uint8_t*)table) + mid * elt_size );
|
||||
int32_t comp = strcmp(needle, elt);
|
||||
if (comp < 0) {
|
||||
high = mid - 1;
|
||||
} else if (comp > 0) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
mid = (low + high) / 2;
|
||||
}
|
||||
if (low <= high) {
|
||||
return mid;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
ctypes_i32 = 14,
|
||||
ctypes_i16 = 12,
|
||||
ctypes_i8 = 11,
|
||||
ctypes_u32 = 4,
|
||||
ctypes_u16 = 2,
|
||||
ctypes_u8 = 1,
|
||||
|
||||
// big endian
|
||||
ctypes_be_i32 = -14,
|
||||
ctypes_be_i16 = -12,
|
||||
ctypes_be_i8 = -11,
|
||||
ctypes_be_u32 = -4,
|
||||
ctypes_be_u16 = -2,
|
||||
ctypes_be_u8 = -1,
|
||||
|
||||
// floating point
|
||||
ctypes_float = 5,
|
||||
ctypes_double = 10,
|
||||
|
||||
// pointer
|
||||
ctypes_ptr32 = 9,
|
||||
ctypes_ptr64 = -9,
|
||||
|
||||
ctypes_bf = 0, //bif-field
|
||||
};
|
||||
|
||||
typedef struct be_ctypes_structure_item_t {
|
||||
const char * name;
|
||||
uint16_t offset_bytes;
|
||||
uint8_t offset_bits : 3;
|
||||
uint8_t len_bits : 5;
|
||||
int8_t type : 5;
|
||||
uint8_t mapping : 3;
|
||||
} be_ctypes_structure_item_t;
|
||||
|
||||
typedef struct be_ctypes_structure_t {
|
||||
uint16_t size_bytes; /* size in bytes */
|
||||
uint16_t size_elt; /* number of elements */
|
||||
const char **instance_mapping; /* array of instance class names for automatic instanciation of class */
|
||||
const be_ctypes_structure_item_t * items;
|
||||
} be_ctypes_structure_t;
|
||||
|
||||
typedef struct be_ctypes_class_t {
|
||||
const char * name;
|
||||
const be_ctypes_structure_t * definitions;
|
||||
} be_ctypes_class_t;
|
||||
|
||||
typedef struct be_ctypes_classes_t {
|
||||
uint16_t size;
|
||||
const char **instance_mapping; /* array of instance class names for automatic instanciation of class */
|
||||
const be_ctypes_class_t * classes;
|
||||
} be_ctypes_classes_t;
|
||||
|
||||
// const be_ctypes_class_t * g_ctypes_classes = NULL;
|
||||
|
||||
//
|
||||
// Constructor for ctypes structure
|
||||
//
|
||||
// If no arg: allocate a bytes() structure of the right size, filled with zeroes
|
||||
// Arg1 is instance self
|
||||
// If arg 2 is int or comptr (and not null): create a mapped bytes buffer to read/write at a specific location (can be copied if need a snapshot)
|
||||
// If arg 2 is a bytes object, consider it's comptr and map the buffer (it's basically casting). WARNING no size check is done so you can easily corrupt memory
|
||||
int be_ctypes_init(bvm *vm) {
|
||||
int argc = be_top(vm);
|
||||
void * src_data = NULL;
|
||||
if (argc > 1 && (be_isint(vm, 2) || be_iscomptr(vm, 2) || be_isbytes(vm, 2))) {
|
||||
if (be_iscomptr(vm, 2)) {
|
||||
src_data = be_tocomptr(vm, 2);
|
||||
} else if (be_isbytes(vm, 2)) {
|
||||
be_getmember(vm, 2, ".p");
|
||||
src_data = be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
} else {
|
||||
src_data = (void*) be_toint(vm, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// look for class definition
|
||||
be_getmember(vm, 1, "_def"); // static class comptr
|
||||
const be_ctypes_structure_t *definitions;
|
||||
definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
|
||||
// call super(self, bytes)
|
||||
be_getglobal(vm, "super"); // push super function
|
||||
be_pushvalue(vm, 1); // push self instance
|
||||
be_getglobal(vm, "bytes"); // push bytes class
|
||||
be_call(vm, 2);
|
||||
be_pop(vm, 2);
|
||||
// berry_log_C("be_ctypes_init> super found %p", be_toint(vm, -1));
|
||||
|
||||
// call bytes.init(self)
|
||||
be_getmember(vm, -1, "init");
|
||||
be_pushvalue(vm, -2);
|
||||
if (src_data) { be_pushcomptr(vm, src_data); } // if mapped, push address
|
||||
be_pushint(vm, definitions ? -definitions->size_bytes : 0); // negative size signals a fixed size
|
||||
be_call(vm, src_data ? 3 : 2); // call with 2 or 3 arguments depending on provided address
|
||||
be_pop(vm, src_data ? 4 : 3);
|
||||
// super(self, bytes) still on top of stack
|
||||
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_return(vm);
|
||||
}
|
||||
|
||||
//
|
||||
// copy ctypes_bytes, with same class and same content
|
||||
//
|
||||
int be_ctypes_copy(bvm *vm) {
|
||||
size_t len;
|
||||
const void * src = be_tobytes(vm, 1, &len);
|
||||
be_classof(vm, 1);
|
||||
// stack: 1/self + class_object
|
||||
be_call(vm, 0); // call empty constructor to build empty resizable copy
|
||||
// stack: 1/ self + new_empty_instance
|
||||
|
||||
// source object (self)
|
||||
be_getmember(vm, 1, ".p");
|
||||
const void* src_buf = be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_getmember(vm, 1, ".len");
|
||||
int32_t src_len = be_toint(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
|
||||
// dest object
|
||||
be_getmember(vm, -1, ".p");
|
||||
const void* dst_buf = be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_getmember(vm, -1, ".len");
|
||||
int32_t dst_len = be_toint(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
|
||||
if (src_len != dst_len) {
|
||||
be_raisef(vm, "internal_error", "new object has wrong size %i (should be %i)", dst_len, src_len);
|
||||
}
|
||||
|
||||
// copy bytes
|
||||
memmove((void*)dst_buf, src_buf, src_len);
|
||||
|
||||
be_return(vm);
|
||||
}
|
||||
|
||||
// get an attribute from a ctypes structure
|
||||
// arg1: ctypes instance
|
||||
// arg2: name of the argument
|
||||
// The class has a `_def` static class attribute with the C low-level mapping definition
|
||||
int be_ctypes_member(bvm *vm) {
|
||||
int argc = be_top(vm);
|
||||
be_getmember(vm, 1, "_def");
|
||||
const be_ctypes_structure_t *definitions;
|
||||
definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
const char *name = be_tostring(vm, 2);
|
||||
|
||||
// look for member
|
||||
int32_t member_idx = bin_search_ctypes(name, &definitions->items[0], sizeof(be_ctypes_structure_item_t), definitions->size_elt);
|
||||
if (member_idx >= 0) {
|
||||
const be_ctypes_structure_item_t *member = &definitions->items[member_idx];
|
||||
// berry_log_C("member found bytes=%i, bits=%i, len_bits=%i, type=%i", member->offset_bytes, member->offset_bits, member->len_bits, member->type);
|
||||
|
||||
// dispatch according to types
|
||||
if (ctypes_bf == member->type) {
|
||||
// bitfield
|
||||
be_getmember(vm, 1, "getbits");
|
||||
be_pushvalue(vm, 1); // self
|
||||
be_pushint(vm, member->offset_bytes * 8 + member->offset_bits);
|
||||
be_pushint(vm, member->len_bits);
|
||||
be_call(vm, 3);
|
||||
be_pop(vm, 3);
|
||||
// int result at top of stack
|
||||
} else if (ctypes_float == member->type) {
|
||||
// Note: double not supported (no need identified)
|
||||
// get raw int32_t
|
||||
be_getmember(vm, 1, "geti"); // self.get or self.geti
|
||||
be_pushvalue(vm, 1); // push self
|
||||
be_pushint(vm, member->offset_bytes);
|
||||
be_pushint(vm, 4); // size is 4 bytes
|
||||
be_call(vm, 3);
|
||||
be_pop(vm, 3);
|
||||
// get int and convert to float
|
||||
int32_t val = be_toint(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
float *fval = (float*) &val; // type wizardry
|
||||
be_pushreal(vm, *fval);
|
||||
} else if (ctypes_ptr32 == member->type) {
|
||||
be_getmember(vm, 1, "geti"); // self.get or self.geti
|
||||
be_pushvalue(vm, 1); // push self
|
||||
be_pushint(vm, member->offset_bytes);
|
||||
be_pushint(vm, 4); // size is 4 bytes TODO 32 bits only supported here
|
||||
be_call(vm, 3);
|
||||
be_pop(vm, 3);
|
||||
// convert to ptr
|
||||
int32_t val = be_toint(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
be_pushcomptr(vm, (void*) val);
|
||||
} else {
|
||||
// general int support
|
||||
int size = member->type; // eventually 1/2/4, positive if little endian, negative if big endian
|
||||
int sign = bfalse; // signed int
|
||||
if (size >= ctypes_i8) {
|
||||
size -= ctypes_i8 - 1;
|
||||
sign = btrue;
|
||||
}
|
||||
if (size <= ctypes_be_i8) {
|
||||
size += ctypes_be_i8 - 1;
|
||||
sign = btrue;
|
||||
}
|
||||
// get
|
||||
be_getmember(vm, 1, sign ? "geti" : "get"); // self.get or self.geti
|
||||
be_pushvalue(vm, 1); // push self
|
||||
be_pushint(vm, member->offset_bytes);
|
||||
be_pushint(vm, size);
|
||||
be_call(vm, 3);
|
||||
be_pop(vm, 3);
|
||||
// int result at top of stack
|
||||
}
|
||||
// the int result is at top of the stack
|
||||
// check if we need an instance mapping
|
||||
if (member->mapping > 0 && definitions->instance_mapping) {
|
||||
const char * mapping_name = definitions->instance_mapping[member->mapping - 1];
|
||||
if (mapping_name) {
|
||||
be_getglobal(vm, mapping_name); // stack: class
|
||||
be_pushvalue(vm, -2); // stack: class, value
|
||||
be_pushint(vm, -1); // stack; class, value, -1
|
||||
be_call(vm, 2); // call constructor with 2 parameters
|
||||
be_pop(vm, 2); // leave new instance on top of stack
|
||||
}
|
||||
}
|
||||
be_return(vm);
|
||||
}
|
||||
|
||||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
// setmember takes 3 arguments:
|
||||
// 1: self (subclass of bytes())
|
||||
// 2: name of member
|
||||
// 3: value
|
||||
int be_ctypes_setmember(bvm *vm) {
|
||||
int argc = be_top(vm);
|
||||
|
||||
// If the value is an instance, we call 'toint()' and replace the value
|
||||
if (be_isinstance(vm, 3)) {
|
||||
|
||||
be_getmember(vm, 3, "toint");
|
||||
if (!be_isnil(vm, -1)) {
|
||||
be_pushvalue(vm, 3);
|
||||
be_call(vm, 1);
|
||||
be_pop(vm, 1);
|
||||
be_moveto(vm, -1, 3);
|
||||
} else {
|
||||
be_raise(vm, "value_error", "Value is an instance without 'toint()' method");
|
||||
}
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
// If the value is a pointer, replace with an int of same value (works only on 32 bits CPU)
|
||||
if (be_iscomptr(vm, 3)) {
|
||||
void * v = be_tocomptr(vm, 3);
|
||||
be_pushint(vm, (int32_t) v);
|
||||
be_moveto(vm, -1, 3);
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
be_getmember(vm, 1, "_def");
|
||||
const be_ctypes_structure_t *definitions;
|
||||
definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
const char *name = be_tostring(vm, 2);
|
||||
|
||||
// look for member
|
||||
int32_t member_idx = bin_search_ctypes(name, &definitions->items[0], sizeof(be_ctypes_structure_item_t), definitions->size_elt);
|
||||
if (member_idx >= 0) {
|
||||
const be_ctypes_structure_item_t *member = &definitions->items[member_idx];
|
||||
// berry_log_C("member found bytes=%i, bits=%i, len_bits=%i, type=%i", member->offset_bytes, member->offset_bits, member->len_bits, member->type);
|
||||
|
||||
// dispatch according to types
|
||||
if (ctypes_bf == member->type) {
|
||||
// bitfield
|
||||
be_getmember(vm, 1, "setbits");
|
||||
be_pushvalue(vm, 1); // self
|
||||
be_pushint(vm, member->offset_bytes * 8 + member->offset_bits);
|
||||
be_pushint(vm, member->len_bits);
|
||||
be_pushvalue(vm, 3); // val
|
||||
be_call(vm, 4);
|
||||
be_pop(vm, 5);
|
||||
be_return_nil(vm);
|
||||
} else if (ctypes_float == member->type) {
|
||||
// Note: double not supported (no need identified)
|
||||
float val = be_toreal(vm, 3);
|
||||
int32_t *ival = (int32_t*) &val;
|
||||
// set
|
||||
be_getmember(vm, 1, "seti");
|
||||
be_pushvalue(vm, 1); // push self
|
||||
be_pushint(vm, member->offset_bytes);
|
||||
be_pushint(vm, *ival);
|
||||
be_pushint(vm, 4); // size is 4 bytes
|
||||
be_call(vm, 4);
|
||||
be_pop(vm, 5);
|
||||
be_return_nil(vm);
|
||||
} else if (ctypes_ptr32 == member->type) {
|
||||
// Note: 64 bits pointer not supported
|
||||
int32_t ptr;
|
||||
if (be_iscomptr(vm, 3)) {
|
||||
ptr = (int32_t) be_tocomptr(vm, 3);
|
||||
} else {
|
||||
ptr = be_toint(vm, 3);
|
||||
}
|
||||
// set
|
||||
be_getmember(vm, 1, "seti");
|
||||
be_pushvalue(vm, 1); // push self
|
||||
be_pushint(vm, member->offset_bytes);
|
||||
be_pushint(vm, ptr);
|
||||
be_pushint(vm, 4); // size is 4 bytes - 64 bits not suppported
|
||||
be_call(vm, 4);
|
||||
be_pop(vm, 5);
|
||||
be_return_nil(vm);
|
||||
} else {
|
||||
// general int support
|
||||
int size = member->type; // eventually 1/2/4, positive if little endian, negative if big endian
|
||||
int sign = bfalse; // signed int
|
||||
if (size >= ctypes_i8) {
|
||||
size -= ctypes_i8 - 1;
|
||||
sign = btrue;
|
||||
}
|
||||
if (size <= ctypes_be_i8) {
|
||||
size += ctypes_be_i8 - 1;
|
||||
sign = btrue;
|
||||
}
|
||||
// set
|
||||
be_getmember(vm, 1, sign ? "seti" : "set"); // self.get or self.geti
|
||||
be_pushvalue(vm, 1); // push self
|
||||
be_pushint(vm, member->offset_bytes);
|
||||
be_pushvalue(vm, 3); // val
|
||||
be_pushint(vm, size);
|
||||
be_call(vm, 4);
|
||||
be_pop(vm, 5);
|
||||
be_return_nil(vm);
|
||||
}
|
||||
} else {
|
||||
be_raisef(vm, "attribute_error", "class '%s' cannot assign to attribute '%s'",
|
||||
be_classname(vm, 1), be_tostring(vm, 2));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// tomap, create a map instance containing all values decoded
|
||||
//
|
||||
int be_ctypes_tomap(bvm *vm) {
|
||||
// don't need argc
|
||||
be_getmember(vm, 1, "_def");
|
||||
const be_ctypes_structure_t *definitions;
|
||||
definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1);
|
||||
be_pop(vm, 1);
|
||||
|
||||
// create empty map
|
||||
be_newobject(vm, "map");
|
||||
|
||||
for (uint32_t i = 0; i < definitions->size_elt; i++) {
|
||||
const be_ctypes_structure_item_t * item = &definitions->items[i];
|
||||
|
||||
be_pushstring(vm, item->name); // stack: map - key
|
||||
|
||||
be_getmember(vm, 1, "member");
|
||||
be_pushvalue(vm, 1);
|
||||
be_pushstring(vm, item->name);
|
||||
be_call(vm, 2);
|
||||
be_pop(vm, 2); // stack: map - key - value
|
||||
|
||||
be_data_insert(vm, -3);
|
||||
be_pop(vm, 2); // stack: map
|
||||
}
|
||||
|
||||
be_pop(vm, 1); // remove map struct, to leave map instance
|
||||
be_return(vm);
|
||||
}
|
||||
|
||||
//
|
||||
// Constructor for ctypes_dyn structure
|
||||
//
|
||||
// Arg1 is instance self
|
||||
// Arg2 is int or comptr (and not null): create a mapped bytes buffer to read/write at a specific location
|
||||
// Arg3 is int or comptr (and not null): the binary definition of the struct (dynamic and not fixed as static member)
|
||||
int be_ctypes_dyn_init(bvm *vm) {
|
||||
int argc = be_top(vm);
|
||||
void * src_data = NULL;
|
||||
const be_ctypes_structure_t * definitions = NULL;
|
||||
if (argc > 2 && (be_isint(vm, 2) || be_iscomptr(vm, 2)) && (be_isint(vm, 3) || be_iscomptr(vm, 3))) {
|
||||
if (be_iscomptr(vm, 2)) {
|
||||
src_data = be_tocomptr(vm, 2);
|
||||
} else {
|
||||
src_data = (void*) be_toint(vm, 2);
|
||||
}
|
||||
if (be_iscomptr(vm, 3)) {
|
||||
definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, 3);
|
||||
} else {
|
||||
definitions = (const be_ctypes_structure_t *) be_toint(vm, 3);
|
||||
}
|
||||
}
|
||||
if (!src_data || !definitions) {
|
||||
be_raise(vm, "value_error", "'address' and 'definition' cannot be null");
|
||||
}
|
||||
|
||||
// store definition in member variable
|
||||
be_pushcomptr(vm, (void*) definitions);
|
||||
be_setmember(vm, 1, "_def"); // static class comptr
|
||||
be_pop(vm, 1);
|
||||
|
||||
// call bytes.init(self)
|
||||
be_getbuiltin(vm, "bytes"); // shortcut `ctypes` init and call directly bytes.init()
|
||||
be_getmember(vm, -1, "init");
|
||||
be_pushvalue(vm, 1);
|
||||
be_pushcomptr(vm, src_data);
|
||||
be_pushint(vm, -definitions->size_bytes); // negative size signals a fixed size
|
||||
be_call(vm, 3); // call with 2 or 3 arguments depending on provided address
|
||||
be_pop(vm, 4);
|
||||
// super(self, bytes) still on top of stack
|
||||
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_return(vm);
|
||||
}
|
||||
|
||||
BE_EXPORT_VARIABLE extern const bclass be_class_bytes;
|
||||
|
||||
#include "../generate/be_fixed_be_class_ctypes.h"
|
||||
#include "../generate/be_fixed_be_class_ctypes_dyn.h"
|
||||
|
||||
void be_load_ctypes_lib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_ctypes);
|
||||
be_setglobal(vm, "ctypes_bytes");
|
||||
be_pop(vm, 1);
|
||||
be_pushntvclass(vm, &be_class_ctypes_dyn);
|
||||
be_setglobal(vm, "ctypes_bytes_dyn");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
/* @const_object_info_begin
|
||||
class be_class_ctypes (scope: global, name: ctypes_bytes, super: be_class_bytes) {
|
||||
_def, nil()
|
||||
copy, func(be_ctypes_copy)
|
||||
init, func(be_ctypes_init)
|
||||
member, func(be_ctypes_member)
|
||||
setmember, func(be_ctypes_setmember)
|
||||
|
||||
tomap, func(be_ctypes_tomap)
|
||||
}
|
||||
@const_object_info_end */
|
||||
|
||||
/* @const_object_info_begin
|
||||
class be_class_ctypes_dyn (scope: global, name: ctypes_bytes_dyn, super: be_class_ctypes) {
|
||||
_def, var
|
||||
init, func(be_ctypes_dyn_init)
|
||||
}
|
||||
@const_object_info_end */
|
|
@ -0,0 +1,29 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import display`
|
||||
*
|
||||
* Initialize Universal Display driver
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_DISPLAY
|
||||
|
||||
// Tasmota specific
|
||||
|
||||
extern int be_ntv_display_start(bvm *vm);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: display
|
||||
********************************************************************/
|
||||
be_local_module(display,
|
||||
"display",
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(start, -1), be_const_func(be_ntv_display_start) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(display);
|
||||
/********************************************************************/
|
||||
|
||||
#endif // USE_DISPLAY
|
|
@ -0,0 +1,153 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `d = Driver()`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Driver_init, /* name */
|
||||
be_nested_proto(
|
||||
1, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
0, /* has constants */
|
||||
NULL, /* no const */
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 1]) { /* code */
|
||||
0x80000000, // 0000 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_tasmota
|
||||
********************************************************************/
|
||||
be_local_closure(Driver_get_tasmota, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
}),
|
||||
&be_const_str_get_tasmota,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x80040200, // 0001 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: add_cmd
|
||||
********************************************************************/
|
||||
be_local_closure(Driver_add_cmd, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
1, /* has sup protos */
|
||||
( &(const struct bproto*[ 1]) {
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
1, /* has upvals */
|
||||
( &(const bupvaldesc[ 2]) { /* upvals */
|
||||
be_local_const_upval(1, 2),
|
||||
be_local_const_upval(1, 0),
|
||||
}),
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
0, /* has constants */
|
||||
NULL, /* no const */
|
||||
&be_const_str__X3Clambda_X3E,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 8]) { /* code */
|
||||
0x68100000, // 0000 GETUPV R4 U0
|
||||
0x68140001, // 0001 GETUPV R5 U1
|
||||
0x5C180000, // 0002 MOVE R6 R0
|
||||
0x5C1C0200, // 0003 MOVE R7 R1
|
||||
0x5C200400, // 0004 MOVE R8 R2
|
||||
0x5C240600, // 0005 MOVE R9 R3
|
||||
0x7C100A00, // 0006 CALL R4 5
|
||||
0x80040800, // 0007 RET 1 R4
|
||||
})
|
||||
),
|
||||
}),
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(add_cmd),
|
||||
}),
|
||||
&be_const_str_add_cmd,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0xB80E0000, // 0000 GETNGBL R3 K0
|
||||
0x8C0C0701, // 0001 GETMET R3 R3 K1
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0x84180000, // 0003 CLOSURE R6 P0
|
||||
0x7C0C0600, // 0004 CALL R3 3
|
||||
0xA0000000, // 0005 CLOSE R0
|
||||
0x80000000, // 0006 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Driver
|
||||
********************************************************************/
|
||||
be_local_class(Driver,
|
||||
13,
|
||||
NULL,
|
||||
be_nested_map(16,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(web_add_main_button, 14), be_const_var(4) },
|
||||
{ be_const_key(web_add_console_button, -1), be_const_var(7) },
|
||||
{ be_const_key(web_add_management_button, 8), be_const_var(5) },
|
||||
{ be_const_key(init, -1), be_const_closure(Driver_init_closure) },
|
||||
{ be_const_key(json_append, -1), be_const_var(10) },
|
||||
{ be_const_key(web_add_config_button, 7), be_const_var(6) },
|
||||
{ be_const_key(every_100ms, -1), be_const_var(1) },
|
||||
{ be_const_key(display, -1), be_const_var(12) },
|
||||
{ be_const_key(web_add_button, 13), be_const_var(3) },
|
||||
{ be_const_key(every_second, -1), be_const_var(0) },
|
||||
{ be_const_key(save_before_restart, -1), be_const_var(8) },
|
||||
{ be_const_key(get_tasmota, -1), be_const_closure(Driver_get_tasmota_closure) },
|
||||
{ be_const_key(web_sensor, 6), be_const_var(9) },
|
||||
{ be_const_key(web_add_handler, -1), be_const_var(2) },
|
||||
{ be_const_key(button_pressed, 1), be_const_var(11) },
|
||||
{ be_const_key(add_cmd, -1), be_const_closure(Driver_add_cmd_closure) },
|
||||
})),
|
||||
be_str_literal("Driver")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_Driver_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_Driver);
|
||||
be_setglobal(vm, "Driver");
|
||||
be_pop(vm, 1);
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL ctypes mapping
|
||||
*******************************************************************/
|
||||
#include "be_ctypes.h"
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
|
||||
/********************************************************************
|
||||
* Generated code, don't edit
|
||||
*******************************************************************/
|
||||
|
||||
static const char * be_ctypes_instance_mappings[]; /* forward definition */
|
||||
|
||||
const be_ctypes_structure_t be_energy_struct = {
|
||||
250, /* size in bytes */
|
||||
85, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[85]) {
|
||||
{ "active_power", 24, 0, 0, ctypes_float, 0 },
|
||||
{ "active_power_2", 28, 0, 0, ctypes_float, 0 },
|
||||
{ "active_power_3", 32, 0, 0, ctypes_float, 0 },
|
||||
{ "apparent_power", 36, 0, 0, ctypes_float, 0 },
|
||||
{ "apparent_power_2", 40, 0, 0, ctypes_float, 0 },
|
||||
{ "apparent_power_3", 44, 0, 0, ctypes_float, 0 },
|
||||
{ "command_code", 205, 0, 0, ctypes_u8, 0 },
|
||||
{ "current", 12, 0, 0, ctypes_float, 0 },
|
||||
{ "current_2", 16, 0, 0, ctypes_float, 0 },
|
||||
{ "current_3", 20, 0, 0, ctypes_float, 0 },
|
||||
{ "current_available", 215, 0, 0, ctypes_u8, 0 },
|
||||
{ "daily", 120, 0, 0, ctypes_float, 0 },
|
||||
{ "daily_2", 124, 0, 0, ctypes_float, 0 },
|
||||
{ "daily_3", 128, 0, 0, ctypes_float, 0 },
|
||||
{ "daily_sum", 144, 0, 0, ctypes_float, 0 },
|
||||
{ "data_valid", 206, 0, 0, ctypes_u8, 0 },
|
||||
{ "data_valid_2", 207, 0, 0, ctypes_u8, 0 },
|
||||
{ "data_valid_3", 208, 0, 0, ctypes_u8, 0 },
|
||||
{ "export_active", 96, 0, 0, ctypes_float, 0 },
|
||||
{ "export_active_2", 100, 0, 0, ctypes_float, 0 },
|
||||
{ "export_active_3", 104, 0, 0, ctypes_float, 0 },
|
||||
{ "fifth_second", 204, 0, 0, ctypes_u8, 0 },
|
||||
{ "frequency", 72, 0, 0, ctypes_float, 0 },
|
||||
{ "frequency_2", 76, 0, 0, ctypes_float, 0 },
|
||||
{ "frequency_3", 80, 0, 0, ctypes_float, 0 },
|
||||
{ "frequency_common", 211, 0, 0, ctypes_u8, 0 },
|
||||
{ "import_active", 84, 0, 0, ctypes_float, 0 },
|
||||
{ "import_active_2", 88, 0, 0, ctypes_float, 0 },
|
||||
{ "import_active_3", 92, 0, 0, ctypes_float, 0 },
|
||||
{ "max_current_flag", 242, 0, 0, ctypes_u8, 0 },
|
||||
{ "max_energy_state", 249, 0, 0, ctypes_u8, 0 },
|
||||
{ "max_power_flag", 238, 0, 0, ctypes_u8, 0 },
|
||||
{ "max_voltage_flag", 240, 0, 0, ctypes_u8, 0 },
|
||||
{ "min_current_flag", 241, 0, 0, ctypes_u8, 0 },
|
||||
{ "min_power_flag", 237, 0, 0, ctypes_u8, 0 },
|
||||
{ "min_voltage_flag", 239, 0, 0, ctypes_u8, 0 },
|
||||
{ "mplh_counter", 244, 0, 0, ctypes_u16, 0 },
|
||||
{ "mplr_counter", 248, 0, 0, ctypes_u8, 0 },
|
||||
{ "mplw_counter", 246, 0, 0, ctypes_u16, 0 },
|
||||
{ "period", 192, 0, 0, ctypes_u32, 0 },
|
||||
{ "period_2", 196, 0, 0, ctypes_u32, 0 },
|
||||
{ "period_3", 200, 0, 0, ctypes_u32, 0 },
|
||||
{ "phase_count", 209, 0, 0, ctypes_u8, 0 },
|
||||
{ "power_factor", 60, 0, 0, ctypes_float, 0 },
|
||||
{ "power_factor_2", 64, 0, 0, ctypes_float, 0 },
|
||||
{ "power_factor_3", 68, 0, 0, ctypes_float, 0 },
|
||||
{ "power_history_0", 218, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_0_2", 220, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_0_3", 222, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_1", 224, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_1_2", 226, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_1_3", 228, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_2", 230, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_2_2", 232, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_history_2_3", 234, 0, 0, ctypes_u16, 0 },
|
||||
{ "power_on", 217, 0, 0, ctypes_u8, 0 },
|
||||
{ "power_steady_counter", 236, 0, 0, ctypes_u8, 0 },
|
||||
{ "reactive_power", 48, 0, 0, ctypes_float, 0 },
|
||||
{ "reactive_power_2", 52, 0, 0, ctypes_float, 0 },
|
||||
{ "reactive_power_3", 56, 0, 0, ctypes_float, 0 },
|
||||
{ "start_energy", 108, 0, 0, ctypes_float, 0 },
|
||||
{ "start_energy_2", 112, 0, 0, ctypes_float, 0 },
|
||||
{ "start_energy_3", 116, 0, 0, ctypes_float, 0 },
|
||||
{ "today_delta_kwh", 156, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_delta_kwh_2", 160, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_delta_kwh_3", 164, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_kwh", 180, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_kwh_2", 184, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_kwh_3", 188, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_offset_init_kwh", 213, 0, 0, ctypes_u8, 0 },
|
||||
{ "today_offset_kwh", 168, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_offset_kwh_2", 172, 0, 0, ctypes_u32, 0 },
|
||||
{ "today_offset_kwh_3", 176, 0, 0, ctypes_u32, 0 },
|
||||
{ "total", 132, 0, 0, ctypes_float, 0 },
|
||||
{ "total_2", 136, 0, 0, ctypes_float, 0 },
|
||||
{ "total_3", 140, 0, 0, ctypes_float, 0 },
|
||||
{ "total_sum", 148, 0, 0, ctypes_float, 0 },
|
||||
{ "type_dc", 216, 0, 0, ctypes_u8, 0 },
|
||||
{ "use_overtemp", 212, 0, 0, ctypes_u8, 0 },
|
||||
{ "voltage", 0, 0, 0, ctypes_float, 0 },
|
||||
{ "voltage_2", 4, 0, 0, ctypes_float, 0 },
|
||||
{ "voltage_3", 8, 0, 0, ctypes_float, 0 },
|
||||
{ "voltage_available", 214, 0, 0, ctypes_u8, 0 },
|
||||
{ "voltage_common", 210, 0, 0, ctypes_u8, 0 },
|
||||
{ "yesterday_sum", 152, 0, 0, ctypes_float, 0 },
|
||||
}};
|
||||
|
||||
static const char * be_ctypes_instance_mappings[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static be_define_ctypes_class(energy_struct, &be_energy_struct, &be_class_ctypes, "energy_struct");
|
||||
|
||||
void be_load_ctypes_energy_definitions_lib(bvm *vm) {
|
||||
ctypes_register_class(vm, &be_class_energy_struct, &be_energy_struct);
|
||||
}
|
||||
/********************************************************************/
|
||||
|
||||
#endif // USE_ENERGY_SENSOR
|
|
@ -0,0 +1,186 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import power`
|
||||
*
|
||||
* read power values
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
|
||||
extern struct ENERGY Energy;
|
||||
/*
|
||||
|
||||
_energy = nil # avoid compilation error
|
||||
energy = module("energy")
|
||||
energy._ptr = nil
|
||||
|
||||
def init(m)
|
||||
import global
|
||||
global._energy = energy_struct(m._ptr)
|
||||
return m
|
||||
end
|
||||
energy.init = init
|
||||
|
||||
def read()
|
||||
return _energy.tomap()
|
||||
end
|
||||
energy.read = read
|
||||
|
||||
def member(k)
|
||||
return _energy.(k)
|
||||
end
|
||||
energy.member = member
|
||||
|
||||
def setmember(k, v)
|
||||
_energy.(k) = v
|
||||
end
|
||||
energy.setmember = setmember
|
||||
|
||||
import solidify
|
||||
solidify.dump(energy)
|
||||
*/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: member
|
||||
********************************************************************/
|
||||
be_local_closure(energy_member, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(_energy),
|
||||
}),
|
||||
&be_const_str_member,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 3]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x88040200, // 0001 GETMBR R1 R1 R0
|
||||
0x80040200, // 0002 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: setmember
|
||||
********************************************************************/
|
||||
be_local_closure(energy_setmember, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(_energy),
|
||||
}),
|
||||
&be_const_str_setmember,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 3]) { /* code */
|
||||
0xB80A0000, // 0000 GETNGBL R2 K0
|
||||
0x90080001, // 0001 SETMBR R2 R0 R1
|
||||
0x80000000, // 0002 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read
|
||||
********************************************************************/
|
||||
be_local_closure(energy_read, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
0, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(_energy),
|
||||
/* K1 */ be_nested_str(tomap),
|
||||
}),
|
||||
&be_const_str_read,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 4]) { /* code */
|
||||
0xB8020000, // 0000 GETNGBL R0 K0
|
||||
0x8C000101, // 0001 GETMET R0 R0 K1
|
||||
0x7C000200, // 0002 CALL R0 1
|
||||
0x80040000, // 0003 RET 1 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(energy_init, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_nested_str(global),
|
||||
/* K1 */ be_nested_str(_energy),
|
||||
/* K2 */ be_nested_str(energy_struct),
|
||||
/* K3 */ be_nested_str(_ptr),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0xA4060000, // 0000 IMPORT R1 K0
|
||||
0xB80A0400, // 0001 GETNGBL R2 K2
|
||||
0x880C0103, // 0002 GETMBR R3 R0 K3
|
||||
0x7C080200, // 0003 CALL R2 1
|
||||
0x90060202, // 0004 SETMBR R1 K1 R2
|
||||
0x80040000, // 0005 RET 1 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: energy
|
||||
********************************************************************/
|
||||
be_local_module(energy,
|
||||
"energy",
|
||||
be_nested_map(5,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(energy_init_closure) },
|
||||
{ be_const_key(member, 2), be_const_closure(energy_member_closure) },
|
||||
{ be_const_key(_ptr, 3), be_const_comptr(&Energy) },
|
||||
{ be_const_key(setmember, -1), be_const_closure(energy_setmember_closure) },
|
||||
{ be_const_key(read, -1), be_const_closure(energy_read_closure) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(energy);
|
||||
/********************************************************************/
|
||||
|
||||
|
||||
// { be_const_key(_ptr, 3), be_const_comptr(&Energy) }, /* patch */
|
||||
|
||||
#endif // USE_ENERGY_SENSOR
|
|
@ -0,0 +1,21 @@
|
|||
/********************************************************************
|
||||
* Berry module `webserver`
|
||||
*
|
||||
* To use: `import webserver`
|
||||
*
|
||||
* Allows to respond to HTTP request
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
extern int p_flash_read(bvm *vm);
|
||||
extern int p_flash_write(bvm *vm);
|
||||
extern int p_flash_erase(bvm *vm);
|
||||
|
||||
/* @const_object_info_begin
|
||||
module flash (scope: global) {
|
||||
read, func(p_flash_read)
|
||||
write, func(p_flash_write)
|
||||
erase, func(p_flash_erase)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "../generate/be_fixed_flash.h"
|
|
@ -0,0 +1,34 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import power`
|
||||
*
|
||||
* read power values
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
// Tasmota specific
|
||||
|
||||
extern int gp_member(bvm *vm);
|
||||
extern int gp_pin_mode(bvm *vm);
|
||||
extern int gp_digital_write(bvm *vm);
|
||||
extern int gp_digital_read(bvm *vm);
|
||||
extern int gp_dac_voltage(bvm *vm);
|
||||
|
||||
extern int gp_pin_used(bvm *vm);
|
||||
extern int gp_pin(bvm *vm);
|
||||
|
||||
/* @const_object_info_begin
|
||||
module gpio (scope: global) {
|
||||
member, func(gp_member)
|
||||
|
||||
pin_mode, func(gp_pin_mode)
|
||||
digital_write, func(gp_digital_write)
|
||||
digital_read, func(gp_digital_read)
|
||||
dac_voltage, func(gp_dac_voltage)
|
||||
|
||||
pin_used, func(gp_pin_used)
|
||||
pin, func(gp_pin)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "../generate/be_fixed_gpio.h"
|
|
@ -0,0 +1,899 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_warning_level
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_warning_level, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read12),
|
||||
/* K1 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_get_warning_level,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E0046, // 0001 LDINT R3 71
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x2C040301, // 0003 AND R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_vbus_current
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_vbus_current, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read12),
|
||||
/* K1 */ be_const_real_hex(0x3EC00000),
|
||||
}),
|
||||
&be_const_str_get_vbus_current,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E005B, // 0001 LDINT R3 92
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_chg_current
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_set_chg_current, /* name */
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(write8),
|
||||
/* K1 */ be_nested_str(read8),
|
||||
}),
|
||||
&be_const_str_set_chg_current,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[12]) { /* code */
|
||||
0x8C080100, // 0000 GETMET R2 R0 K0
|
||||
0x54120032, // 0001 LDINT R4 51
|
||||
0x8C140101, // 0002 GETMET R5 R0 K1
|
||||
0x541E0032, // 0003 LDINT R7 51
|
||||
0x7C140400, // 0004 CALL R5 2
|
||||
0x541A00EF, // 0005 LDINT R6 240
|
||||
0x2C140A06, // 0006 AND R5 R5 R6
|
||||
0x541A000E, // 0007 LDINT R6 15
|
||||
0x2C180206, // 0008 AND R6 R1 R6
|
||||
0x30140A06, // 0009 OR R5 R5 R6
|
||||
0x7C080600, // 000A CALL R2 3
|
||||
0x80000000, // 000B RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bat_current
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_bat_current, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read13),
|
||||
/* K1 */ be_const_real_hex(0x3F000000),
|
||||
}),
|
||||
&be_const_str_get_bat_current,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 9]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E0079, // 0001 LDINT R3 122
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x8C080100, // 0003 GETMET R2 R0 K0
|
||||
0x5412007B, // 0004 LDINT R4 124
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x04040202, // 0006 SUB R1 R1 R2
|
||||
0x08040301, // 0007 MUL R1 R1 K1
|
||||
0x80040200, // 0008 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bat_power
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_bat_power, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read24),
|
||||
/* K1 */ be_const_real_hex(0x3A102DE1),
|
||||
}),
|
||||
&be_const_str_get_bat_power,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E006F, // 0001 LDINT R3 112
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: json_append
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_json_append, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
}),
|
||||
&be_const_str_json_append,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x74060001, // 0001 JMPT R1 #0004
|
||||
0x4C040000, // 0002 LDNIL R1
|
||||
0x80040200, // 0003 RET 1 R1
|
||||
0x80000000, // 0004 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_vbus_voltage
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_vbus_voltage, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read12),
|
||||
/* K1 */ be_const_real_hex(0x3ADED28A),
|
||||
}),
|
||||
&be_const_str_get_vbus_voltage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E0059, // 0001 LDINT R3 90
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_temp
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_temp, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(read12),
|
||||
/* K1 */ be_const_real_hex(0x3DCCCCCD),
|
||||
/* K2 */ be_const_real_hex(0x4310B333),
|
||||
}),
|
||||
&be_const_str_get_temp,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E005D, // 0001 LDINT R3 94
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x04040302, // 0004 SUB R1 R1 K2
|
||||
0x80040200, // 0005 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: battery_present
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_battery_present, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_battery_present,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[15]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x880C0102, // 0002 GETMBR R3 R0 K2
|
||||
0x58100003, // 0003 LDCONST R4 K3
|
||||
0x58140003, // 0004 LDCONST R5 K3
|
||||
0x7C040800, // 0005 CALL R1 4
|
||||
0x540A001F, // 0006 LDINT R2 32
|
||||
0x2C040202, // 0007 AND R1 R1 R2
|
||||
0x78060002, // 0008 JMPF R1 #000C
|
||||
0x50040200, // 0009 LDBOOL R1 1 0
|
||||
0x80040200, // 000A RET 1 R1
|
||||
0x70020001, // 000B JMP #000E
|
||||
0x50040000, // 000C LDBOOL R1 0 0
|
||||
0x80040200, // 000D RET 1 R1
|
||||
0x80000000, // 000E RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_aps_voltage
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_aps_voltage, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read12),
|
||||
/* K1 */ be_const_real_hex(0x3AB78035),
|
||||
}),
|
||||
&be_const_str_get_aps_voltage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E007D, // 0001 LDINT R3 126
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_dcdc_enable
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_set_dcdc_enable, /* name */
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_const_int(1),
|
||||
/* K1 */ be_nested_str(write_bit),
|
||||
/* K2 */ be_const_int(0),
|
||||
/* K3 */ be_const_int(2),
|
||||
/* K4 */ be_const_int(3),
|
||||
}),
|
||||
&be_const_str_set_dcdc_enable,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[22]) { /* code */
|
||||
0x1C0C0300, // 0000 EQ R3 R1 K0
|
||||
0x780E0004, // 0001 JMPF R3 #0007
|
||||
0x8C0C0101, // 0002 GETMET R3 R0 K1
|
||||
0x54160011, // 0003 LDINT R5 18
|
||||
0x58180002, // 0004 LDCONST R6 K2
|
||||
0x5C1C0400, // 0005 MOVE R7 R2
|
||||
0x7C0C0800, // 0006 CALL R3 4
|
||||
0x1C0C0303, // 0007 EQ R3 R1 K3
|
||||
0x780E0004, // 0008 JMPF R3 #000E
|
||||
0x8C0C0101, // 0009 GETMET R3 R0 K1
|
||||
0x54160011, // 000A LDINT R5 18
|
||||
0x541A0003, // 000B LDINT R6 4
|
||||
0x5C1C0400, // 000C MOVE R7 R2
|
||||
0x7C0C0800, // 000D CALL R3 4
|
||||
0x1C0C0304, // 000E EQ R3 R1 K4
|
||||
0x780E0004, // 000F JMPF R3 #0015
|
||||
0x8C0C0101, // 0010 GETMET R3 R0 K1
|
||||
0x54160011, // 0011 LDINT R5 18
|
||||
0x58180000, // 0012 LDCONST R6 K0
|
||||
0x5C1C0400, // 0013 MOVE R7 R2
|
||||
0x7C0C0800, // 0014 CALL R3 4
|
||||
0x80000000, // 0015 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_ldo_voltage
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_set_ldo_voltage, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_const_int(2),
|
||||
/* K1 */ be_nested_str(write8),
|
||||
/* K2 */ be_nested_str(read8),
|
||||
/* K3 */ be_const_int(3),
|
||||
}),
|
||||
&be_const_str_set_ldo_voltage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[39]) { /* code */
|
||||
0x540E0CE3, // 0000 LDINT R3 3300
|
||||
0x240C0403, // 0001 GT R3 R2 R3
|
||||
0x780E0001, // 0002 JMPF R3 #0005
|
||||
0x540A000E, // 0003 LDINT R2 15
|
||||
0x70020004, // 0004 JMP #000A
|
||||
0x540E0063, // 0005 LDINT R3 100
|
||||
0x0C0C0403, // 0006 DIV R3 R2 R3
|
||||
0x54120011, // 0007 LDINT R4 18
|
||||
0x040C0604, // 0008 SUB R3 R3 R4
|
||||
0x5C080600, // 0009 MOVE R2 R3
|
||||
0x1C0C0300, // 000A EQ R3 R1 K0
|
||||
0x780E000C, // 000B JMPF R3 #0019
|
||||
0x8C0C0101, // 000C GETMET R3 R0 K1
|
||||
0x54160027, // 000D LDINT R5 40
|
||||
0x8C180102, // 000E GETMET R6 R0 K2
|
||||
0x54220027, // 000F LDINT R8 40
|
||||
0x7C180400, // 0010 CALL R6 2
|
||||
0x541E000E, // 0011 LDINT R7 15
|
||||
0x2C180C07, // 0012 AND R6 R6 R7
|
||||
0x541E000E, // 0013 LDINT R7 15
|
||||
0x2C1C0407, // 0014 AND R7 R2 R7
|
||||
0x54220003, // 0015 LDINT R8 4
|
||||
0x381C0E08, // 0016 SHL R7 R7 R8
|
||||
0x30180C07, // 0017 OR R6 R6 R7
|
||||
0x7C0C0600, // 0018 CALL R3 3
|
||||
0x1C0C0303, // 0019 EQ R3 R1 K3
|
||||
0x780E000A, // 001A JMPF R3 #0026
|
||||
0x8C0C0101, // 001B GETMET R3 R0 K1
|
||||
0x54160027, // 001C LDINT R5 40
|
||||
0x8C180102, // 001D GETMET R6 R0 K2
|
||||
0x54220027, // 001E LDINT R8 40
|
||||
0x7C180400, // 001F CALL R6 2
|
||||
0x541E00EF, // 0020 LDINT R7 240
|
||||
0x2C180C07, // 0021 AND R6 R6 R7
|
||||
0x541E000E, // 0022 LDINT R7 15
|
||||
0x2C1C0407, // 0023 AND R7 R2 R7
|
||||
0x30180C07, // 0024 OR R6 R6 R7
|
||||
0x7C0C0600, // 0025 CALL R3 3
|
||||
0x80000000, // 0026 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_init, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(I2C_Driver),
|
||||
/* K1 */ be_nested_str(init),
|
||||
/* K2 */ be_nested_str(AXP192),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 9]) { /* code */
|
||||
0x60040003, // 0000 GETGBL R1 G3
|
||||
0x5C080000, // 0001 MOVE R2 R0
|
||||
0xB80E0000, // 0002 GETNGBL R3 K0
|
||||
0x7C040400, // 0003 CALL R1 2
|
||||
0x8C040301, // 0004 GETMET R1 R1 K1
|
||||
0x580C0002, // 0005 LDCONST R3 K2
|
||||
0x54120033, // 0006 LDINT R4 52
|
||||
0x7C040600, // 0007 CALL R1 3
|
||||
0x80000000, // 0008 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bat_voltage
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_bat_voltage, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read12),
|
||||
/* K1 */ be_const_real_hex(0x3A902DE0),
|
||||
}),
|
||||
&be_const_str_get_bat_voltage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E0077, // 0001 LDINT R3 120
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_ldo_enable
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_set_ldo_enable, /* name */
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_const_int(2),
|
||||
/* K1 */ be_nested_str(write_bit),
|
||||
/* K2 */ be_const_int(3),
|
||||
}),
|
||||
&be_const_str_set_ldo_enable,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[15]) { /* code */
|
||||
0x1C0C0300, // 0000 EQ R3 R1 K0
|
||||
0x780E0004, // 0001 JMPF R3 #0007
|
||||
0x8C0C0101, // 0002 GETMET R3 R0 K1
|
||||
0x54160011, // 0003 LDINT R5 18
|
||||
0x58180000, // 0004 LDCONST R6 K0
|
||||
0x5C1C0400, // 0005 MOVE R7 R2
|
||||
0x7C0C0800, // 0006 CALL R3 4
|
||||
0x1C0C0302, // 0007 EQ R3 R1 K2
|
||||
0x780E0004, // 0008 JMPF R3 #000E
|
||||
0x8C0C0101, // 0009 GETMET R3 R0 K1
|
||||
0x54160011, // 000A LDINT R5 18
|
||||
0x58180002, // 000B LDCONST R6 K2
|
||||
0x5C1C0400, // 000C MOVE R7 R2
|
||||
0x7C0C0800, // 000D CALL R3 4
|
||||
0x80000000, // 000E RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_dc_voltage
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_set_dc_voltage, /* name */
|
||||
be_nested_proto(
|
||||
11, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_const_int(1),
|
||||
/* K1 */ be_const_int(3),
|
||||
/* K2 */ be_const_int(0),
|
||||
/* K3 */ be_const_int(2),
|
||||
/* K4 */ be_nested_str(write8),
|
||||
/* K5 */ be_nested_str(read8),
|
||||
}),
|
||||
&be_const_str_set_dc_voltage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[48]) { /* code */
|
||||
0x140C0300, // 0000 LT R3 R1 K0
|
||||
0x740E0001, // 0001 JMPT R3 #0004
|
||||
0x240C0301, // 0002 GT R3 R1 K1
|
||||
0x780E0000, // 0003 JMPF R3 #0005
|
||||
0x80000600, // 0004 RET 0
|
||||
0x4C0C0000, // 0005 LDNIL R3
|
||||
0x541202BB, // 0006 LDINT R4 700
|
||||
0x14100404, // 0007 LT R4 R2 R4
|
||||
0x78120001, // 0008 JMPF R4 #000B
|
||||
0x580C0002, // 0009 LDCONST R3 K2
|
||||
0x70020010, // 000A JMP #001C
|
||||
0x54120DAB, // 000B LDINT R4 3500
|
||||
0x24100404, // 000C GT R4 R2 R4
|
||||
0x78120001, // 000D JMPF R4 #0010
|
||||
0x540E006F, // 000E LDINT R3 112
|
||||
0x7002000B, // 000F JMP #001C
|
||||
0x1C100303, // 0010 EQ R4 R1 K3
|
||||
0x78120004, // 0011 JMPF R4 #0017
|
||||
0x541208E2, // 0012 LDINT R4 2275
|
||||
0x24100404, // 0013 GT R4 R2 R4
|
||||
0x78120001, // 0014 JMPF R4 #0017
|
||||
0x540E003E, // 0015 LDINT R3 63
|
||||
0x70020004, // 0016 JMP #001C
|
||||
0x541202BB, // 0017 LDINT R4 700
|
||||
0x04100404, // 0018 SUB R4 R2 R4
|
||||
0x54160018, // 0019 LDINT R5 25
|
||||
0x0C100805, // 001A DIV R4 R4 R5
|
||||
0x5C0C0800, // 001B MOVE R3 R4
|
||||
0x54120025, // 001C LDINT R4 38
|
||||
0x1C140301, // 001D EQ R5 R1 K1
|
||||
0x78160001, // 001E JMPF R5 #0021
|
||||
0x54120026, // 001F LDINT R4 39
|
||||
0x70020002, // 0020 JMP #0024
|
||||
0x1C140303, // 0021 EQ R5 R1 K3
|
||||
0x78160000, // 0022 JMPF R5 #0024
|
||||
0x54120022, // 0023 LDINT R4 35
|
||||
0x8C140104, // 0024 GETMET R5 R0 K4
|
||||
0x5C1C0800, // 0025 MOVE R7 R4
|
||||
0x8C200105, // 0026 GETMET R8 R0 K5
|
||||
0x5C280800, // 0027 MOVE R10 R4
|
||||
0x7C200400, // 0028 CALL R8 2
|
||||
0x5426007F, // 0029 LDINT R9 128
|
||||
0x2C201009, // 002A AND R8 R8 R9
|
||||
0x5426007E, // 002B LDINT R9 127
|
||||
0x2C240609, // 002C AND R9 R3 R9
|
||||
0x30201009, // 002D OR R8 R8 R9
|
||||
0x7C140600, // 002E CALL R5 3
|
||||
0x80000000, // 002F RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: write_gpio
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_write_gpio, /* name */
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_const_int(0),
|
||||
/* K1 */ be_const_int(2),
|
||||
/* K2 */ be_nested_str(write_bit),
|
||||
/* K3 */ be_const_int(3),
|
||||
}),
|
||||
&be_const_str_write_gpio,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[21]) { /* code */
|
||||
0x280C0300, // 0000 GE R3 R1 K0
|
||||
0x780E0007, // 0001 JMPF R3 #000A
|
||||
0x180C0301, // 0002 LE R3 R1 K1
|
||||
0x780E0005, // 0003 JMPF R3 #000A
|
||||
0x8C0C0102, // 0004 GETMET R3 R0 K2
|
||||
0x54160093, // 0005 LDINT R5 148
|
||||
0x5C180200, // 0006 MOVE R6 R1
|
||||
0x5C1C0400, // 0007 MOVE R7 R2
|
||||
0x7C0C0800, // 0008 CALL R3 4
|
||||
0x70020009, // 0009 JMP #0014
|
||||
0x280C0303, // 000A GE R3 R1 K3
|
||||
0x780E0007, // 000B JMPF R3 #0014
|
||||
0x540E0003, // 000C LDINT R3 4
|
||||
0x180C0203, // 000D LE R3 R1 R3
|
||||
0x780E0004, // 000E JMPF R3 #0014
|
||||
0x8C0C0102, // 000F GETMET R3 R0 K2
|
||||
0x54160095, // 0010 LDINT R5 150
|
||||
0x04180303, // 0011 SUB R6 R1 K3
|
||||
0x5C1C0400, // 0012 MOVE R7 R2
|
||||
0x7C0C0800, // 0013 CALL R3 4
|
||||
0x80000000, // 0014 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: web_sensor
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_web_sensor, /* name */
|
||||
be_nested_proto(
|
||||
11, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[14]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(string),
|
||||
/* K2 */ be_nested_str(format),
|
||||
/* K3 */ be_nested_str(_X7Bs_X7DVBus_X20Voltage_X7Bm_X7D_X25_X2E3f_X20V_X7Be_X7D),
|
||||
/* K4 */ be_nested_str(_X7Bs_X7DVBus_X20Current_X7Bm_X7D_X25_X2E1f_X20mA_X7Be_X7D),
|
||||
/* K5 */ be_nested_str(_X7Bs_X7DBatt_X20Voltage_X7Bm_X7D_X25_X2E3f_X20V_X7Be_X7D),
|
||||
/* K6 */ be_nested_str(_X7Bs_X7DBatt_X20Current_X7Bm_X7D_X25_X2E1f_X20mA_X7Be_X7D),
|
||||
/* K7 */ be_nested_str(_X7Bs_X7DTemp_X20AXP_X7Bm_X7D_X25_X2E1f_X20_XB0C_X7Be_X7D),
|
||||
/* K8 */ be_nested_str(get_vbus_voltage),
|
||||
/* K9 */ be_nested_str(get_bat_voltage),
|
||||
/* K10 */ be_nested_str(get_bat_current),
|
||||
/* K11 */ be_nested_str(get_temp),
|
||||
/* K12 */ be_nested_str(tasmota),
|
||||
/* K13 */ be_nested_str(web_send_decimal),
|
||||
}),
|
||||
&be_const_str_web_sensor,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[26]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x74060001, // 0001 JMPT R1 #0004
|
||||
0x4C040000, // 0002 LDNIL R1
|
||||
0x80040200, // 0003 RET 1 R1
|
||||
0xA4060200, // 0004 IMPORT R1 K1
|
||||
0x8C080302, // 0005 GETMET R2 R1 K2
|
||||
0x40120704, // 0006 CONNECT R4 K3 K4
|
||||
0x40100905, // 0007 CONNECT R4 R4 K5
|
||||
0x40100906, // 0008 CONNECT R4 R4 K6
|
||||
0x40100907, // 0009 CONNECT R4 R4 K7
|
||||
0x8C140108, // 000A GETMET R5 R0 K8
|
||||
0x7C140200, // 000B CALL R5 1
|
||||
0x8C180108, // 000C GETMET R6 R0 K8
|
||||
0x7C180200, // 000D CALL R6 1
|
||||
0x8C1C0109, // 000E GETMET R7 R0 K9
|
||||
0x7C1C0200, // 000F CALL R7 1
|
||||
0x8C20010A, // 0010 GETMET R8 R0 K10
|
||||
0x7C200200, // 0011 CALL R8 1
|
||||
0x8C24010B, // 0012 GETMET R9 R0 K11
|
||||
0x7C240200, // 0013 CALL R9 1
|
||||
0x7C080E00, // 0014 CALL R2 7
|
||||
0xB80E1800, // 0015 GETNGBL R3 K12
|
||||
0x8C0C070D, // 0016 GETMET R3 R3 K13
|
||||
0x5C140400, // 0017 MOVE R5 R2
|
||||
0x7C0C0400, // 0018 CALL R3 2
|
||||
0x80000000, // 0019 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bat_charge_current
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_bat_charge_current, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(read13),
|
||||
/* K1 */ be_const_real_hex(0x3F000000),
|
||||
}),
|
||||
&be_const_str_get_bat_charge_current,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x540E0079, // 0001 LDINT R3 122
|
||||
0x7C040400, // 0002 CALL R1 2
|
||||
0x08040301, // 0003 MUL R1 R1 K1
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_battery_chargin_status
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_battery_chargin_status, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_get_battery_chargin_status,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x880C0102, // 0002 GETMBR R3 R0 K2
|
||||
0x58100003, // 0003 LDCONST R4 K3
|
||||
0x58140003, // 0004 LDCONST R5 K3
|
||||
0x7C040800, // 0005 CALL R1 4
|
||||
0x80040200, // 0006 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_input_power_status
|
||||
********************************************************************/
|
||||
be_local_closure(AXP192_get_input_power_status, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(0),
|
||||
/* K4 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_get_input_power_status,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x880C0102, // 0002 GETMBR R3 R0 K2
|
||||
0x58100003, // 0003 LDCONST R4 K3
|
||||
0x58140004, // 0004 LDCONST R5 K4
|
||||
0x7C040800, // 0005 CALL R1 4
|
||||
0x80040200, // 0006 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: AXP192
|
||||
********************************************************************/
|
||||
extern const bclass be_class_I2C_Driver;
|
||||
be_local_class(AXP192,
|
||||
0,
|
||||
&be_class_I2C_Driver,
|
||||
be_nested_map(21,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(get_warning_level, -1), be_const_closure(AXP192_get_warning_level_closure) },
|
||||
{ be_const_key(get_vbus_current, -1), be_const_closure(AXP192_get_vbus_current_closure) },
|
||||
{ be_const_key(get_aps_voltage, -1), be_const_closure(AXP192_get_aps_voltage_closure) },
|
||||
{ be_const_key(get_bat_current, -1), be_const_closure(AXP192_get_bat_current_closure) },
|
||||
{ be_const_key(get_bat_power, 2), be_const_closure(AXP192_get_bat_power_closure) },
|
||||
{ be_const_key(json_append, -1), be_const_closure(AXP192_json_append_closure) },
|
||||
{ be_const_key(get_vbus_voltage, -1), be_const_closure(AXP192_get_vbus_voltage_closure) },
|
||||
{ be_const_key(get_battery_chargin_status, 9), be_const_closure(AXP192_get_battery_chargin_status_closure) },
|
||||
{ be_const_key(battery_present, -1), be_const_closure(AXP192_battery_present_closure) },
|
||||
{ be_const_key(get_bat_charge_current, 14), be_const_closure(AXP192_get_bat_charge_current_closure) },
|
||||
{ be_const_key(set_dcdc_enable, -1), be_const_closure(AXP192_set_dcdc_enable_closure) },
|
||||
{ be_const_key(get_temp, 19), be_const_closure(AXP192_get_temp_closure) },
|
||||
{ be_const_key(set_chg_current, 13), be_const_closure(AXP192_set_chg_current_closure) },
|
||||
{ be_const_key(set_ldo_enable, 18), be_const_closure(AXP192_set_ldo_enable_closure) },
|
||||
{ be_const_key(set_dc_voltage, -1), be_const_closure(AXP192_set_dc_voltage_closure) },
|
||||
{ be_const_key(get_bat_voltage, 7), be_const_closure(AXP192_get_bat_voltage_closure) },
|
||||
{ be_const_key(write_gpio, -1), be_const_closure(AXP192_write_gpio_closure) },
|
||||
{ be_const_key(web_sensor, -1), be_const_closure(AXP192_web_sensor_closure) },
|
||||
{ be_const_key(init, -1), be_const_closure(AXP192_init_closure) },
|
||||
{ be_const_key(set_ldo_voltage, -1), be_const_closure(AXP192_set_ldo_voltage_closure) },
|
||||
{ be_const_key(get_input_power_status, -1), be_const_closure(AXP192_get_input_power_status_closure) },
|
||||
})),
|
||||
be_str_literal("AXP192")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_AXP192_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_AXP192);
|
||||
be_setglobal(vm, "AXP192");
|
||||
be_pop(vm, 1);
|
||||
}
|
|
@ -0,0 +1,425 @@
|
|||
/********************************************************************
|
||||
* Tasmota I2C_Driver class
|
||||
*
|
||||
* To use: `d = I2C_Driver(addr, name)`
|
||||
* where:
|
||||
* addr: I2C address of the device
|
||||
* name: name of the I2C chip for logging
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read32
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_read32, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read_bytes),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(0),
|
||||
/* K4 */ be_const_int(1),
|
||||
/* K5 */ be_const_int(2),
|
||||
/* K6 */ be_const_int(3),
|
||||
}),
|
||||
&be_const_str_read32,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[20]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x88100102, // 0002 GETMBR R4 R0 K2
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x541A0003, // 0004 LDINT R6 4
|
||||
0x7C080800, // 0005 CALL R2 4
|
||||
0x940C0503, // 0006 GETIDX R3 R2 K3
|
||||
0x54120017, // 0007 LDINT R4 24
|
||||
0x380C0604, // 0008 SHL R3 R3 R4
|
||||
0x94100504, // 0009 GETIDX R4 R2 K4
|
||||
0x5416000F, // 000A LDINT R5 16
|
||||
0x38100805, // 000B SHL R4 R4 R5
|
||||
0x000C0604, // 000C ADD R3 R3 R4
|
||||
0x94100505, // 000D GETIDX R4 R2 K5
|
||||
0x54160007, // 000E LDINT R5 8
|
||||
0x38100805, // 000F SHL R4 R4 R5
|
||||
0x000C0604, // 0010 ADD R3 R3 R4
|
||||
0x94100506, // 0011 GETIDX R4 R2 K6
|
||||
0x000C0604, // 0012 ADD R3 R3 R4
|
||||
0x80040600, // 0013 RET 1 R3
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: write8
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_write8, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(write),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_write8,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 8]) { /* code */
|
||||
0x880C0100, // 0000 GETMBR R3 R0 K0
|
||||
0x8C0C0701, // 0001 GETMET R3 R3 K1
|
||||
0x88140102, // 0002 GETMBR R5 R0 K2
|
||||
0x5C180200, // 0003 MOVE R6 R1
|
||||
0x5C1C0400, // 0004 MOVE R7 R2
|
||||
0x58200003, // 0005 LDCONST R8 K3
|
||||
0x7C0C0A00, // 0006 CALL R3 5
|
||||
0x80040600, // 0007 RET 1 R3
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read12
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_read12, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read_bytes),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(2),
|
||||
/* K4 */ be_const_int(0),
|
||||
/* K5 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_read12,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[12]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x88100102, // 0002 GETMBR R4 R0 K2
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x58180003, // 0004 LDCONST R6 K3
|
||||
0x7C080800, // 0005 CALL R2 4
|
||||
0x940C0504, // 0006 GETIDX R3 R2 K4
|
||||
0x54120003, // 0007 LDINT R4 4
|
||||
0x380C0604, // 0008 SHL R3 R3 R4
|
||||
0x94100505, // 0009 GETIDX R4 R2 K5
|
||||
0x000C0604, // 000A ADD R3 R3 R4
|
||||
0x80040600, // 000B RET 1 R3
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: write_bit
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_write_bit, /* name */
|
||||
be_nested_proto(
|
||||
11, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_const_int(0),
|
||||
/* K1 */ be_const_int(1),
|
||||
/* K2 */ be_nested_str(write8),
|
||||
/* K3 */ be_nested_str(read8),
|
||||
}),
|
||||
&be_const_str_write_bit,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[26]) { /* code */
|
||||
0x14100500, // 0000 LT R4 R2 K0
|
||||
0x74120002, // 0001 JMPT R4 #0005
|
||||
0x54120006, // 0002 LDINT R4 7
|
||||
0x24100404, // 0003 GT R4 R2 R4
|
||||
0x78120000, // 0004 JMPF R4 #0006
|
||||
0x80000800, // 0005 RET 0
|
||||
0x38120202, // 0006 SHL R4 K1 R2
|
||||
0x780E0007, // 0007 JMPF R3 #0010
|
||||
0x8C140102, // 0008 GETMET R5 R0 K2
|
||||
0x5C1C0200, // 0009 MOVE R7 R1
|
||||
0x8C200103, // 000A GETMET R8 R0 K3
|
||||
0x5C280200, // 000B MOVE R10 R1
|
||||
0x7C200400, // 000C CALL R8 2
|
||||
0x30201004, // 000D OR R8 R8 R4
|
||||
0x7C140600, // 000E CALL R5 3
|
||||
0x70020008, // 000F JMP #0019
|
||||
0x8C140102, // 0010 GETMET R5 R0 K2
|
||||
0x5C1C0200, // 0011 MOVE R7 R1
|
||||
0x8C200103, // 0012 GETMET R8 R0 K3
|
||||
0x5C280200, // 0013 MOVE R10 R1
|
||||
0x7C200400, // 0014 CALL R8 2
|
||||
0x542600FE, // 0015 LDINT R9 255
|
||||
0x04241204, // 0016 SUB R9 R9 R4
|
||||
0x2C201009, // 0017 AND R8 R8 R9
|
||||
0x7C140600, // 0018 CALL R5 3
|
||||
0x80000000, // 0019 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read24
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_read24, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read_bytes),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(3),
|
||||
/* K4 */ be_const_int(0),
|
||||
/* K5 */ be_const_int(1),
|
||||
/* K6 */ be_const_int(2),
|
||||
}),
|
||||
&be_const_str_read24,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[16]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x88100102, // 0002 GETMBR R4 R0 K2
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x58180003, // 0004 LDCONST R6 K3
|
||||
0x7C080800, // 0005 CALL R2 4
|
||||
0x940C0504, // 0006 GETIDX R3 R2 K4
|
||||
0x5412000F, // 0007 LDINT R4 16
|
||||
0x380C0604, // 0008 SHL R3 R3 R4
|
||||
0x94100505, // 0009 GETIDX R4 R2 K5
|
||||
0x54160007, // 000A LDINT R5 8
|
||||
0x38100805, // 000B SHL R4 R4 R5
|
||||
0x000C0604, // 000C ADD R3 R3 R4
|
||||
0x94100506, // 000D GETIDX R4 R2 K6
|
||||
0x000C0604, // 000E ADD R3 R3 R4
|
||||
0x80040600, // 000F RET 1 R3
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read8
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_read8, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 4]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_read8,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x88100102, // 0002 GETMBR R4 R0 K2
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x58180003, // 0004 LDCONST R6 K3
|
||||
0x7C080800, // 0005 CALL R2 4
|
||||
0x80040400, // 0006 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_init, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[10]) { /* constants */
|
||||
/* K0 */ be_nested_str(get_tasmota),
|
||||
/* K1 */ be_nested_str(i2c_enabled),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_nested_str(wire),
|
||||
/* K4 */ be_nested_str(wire_scan),
|
||||
/* K5 */ be_nested_str(function),
|
||||
/* K6 */ be_nested_str(name),
|
||||
/* K7 */ be_nested_str(I2C_X3A),
|
||||
/* K8 */ be_nested_str(detected_X20on_X20bus),
|
||||
/* K9 */ be_nested_str(bus),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[44]) { /* code */
|
||||
0x8C100100, // 0000 GETMET R4 R0 K0
|
||||
0x7C100200, // 0001 CALL R4 1
|
||||
0x4C140000, // 0002 LDNIL R5
|
||||
0x20140605, // 0003 NE R5 R3 R5
|
||||
0x78160004, // 0004 JMPF R5 #000A
|
||||
0x8C140901, // 0005 GETMET R5 R4 K1
|
||||
0x5C1C0600, // 0006 MOVE R7 R3
|
||||
0x7C140400, // 0007 CALL R5 2
|
||||
0x74160000, // 0008 JMPT R5 #000A
|
||||
0x80000A00, // 0009 RET 0
|
||||
0x90020402, // 000A SETMBR R0 K2 R2
|
||||
0x8C140904, // 000B GETMET R5 R4 K4
|
||||
0x881C0102, // 000C GETMBR R7 R0 K2
|
||||
0x7C140400, // 000D CALL R5 2
|
||||
0x90020605, // 000E SETMBR R0 K3 R5
|
||||
0x88140103, // 000F GETMBR R5 R0 K3
|
||||
0x78160019, // 0010 JMPF R5 #002B
|
||||
0x60140004, // 0011 GETGBL R5 G4
|
||||
0x5C180200, // 0012 MOVE R6 R1
|
||||
0x7C140200, // 0013 CALL R5 1
|
||||
0x1C140B05, // 0014 EQ R5 R5 K5
|
||||
0x78160004, // 0015 JMPF R5 #001B
|
||||
0x5C140200, // 0016 MOVE R5 R1
|
||||
0x5C180000, // 0017 MOVE R6 R0
|
||||
0x7C140200, // 0018 CALL R5 1
|
||||
0x90020C05, // 0019 SETMBR R0 K6 R5
|
||||
0x70020000, // 001A JMP #001C
|
||||
0x90020C01, // 001B SETMBR R0 K6 R1
|
||||
0x88140106, // 001C GETMBR R5 R0 K6
|
||||
0x4C180000, // 001D LDNIL R6
|
||||
0x1C140A06, // 001E EQ R5 R5 R6
|
||||
0x78160001, // 001F JMPF R5 #0022
|
||||
0x4C140000, // 0020 LDNIL R5
|
||||
0x90020605, // 0021 SETMBR R0 K3 R5
|
||||
0x88140103, // 0022 GETMBR R5 R0 K3
|
||||
0x78160006, // 0023 JMPF R5 #002B
|
||||
0x60140001, // 0024 GETGBL R5 G1
|
||||
0x58180007, // 0025 LDCONST R6 K7
|
||||
0x881C0106, // 0026 GETMBR R7 R0 K6
|
||||
0x58200008, // 0027 LDCONST R8 K8
|
||||
0x88240103, // 0028 GETMBR R9 R0 K3
|
||||
0x88241309, // 0029 GETMBR R9 R9 K9
|
||||
0x7C140800, // 002A CALL R5 4
|
||||
0x80000000, // 002B RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read13
|
||||
********************************************************************/
|
||||
be_local_closure(I2C_Driver_read13, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(wire),
|
||||
/* K1 */ be_nested_str(read_bytes),
|
||||
/* K2 */ be_nested_str(addr),
|
||||
/* K3 */ be_const_int(2),
|
||||
/* K4 */ be_const_int(0),
|
||||
/* K5 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_read13,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[12]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x88100102, // 0002 GETMBR R4 R0 K2
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x58180003, // 0004 LDCONST R6 K3
|
||||
0x7C080800, // 0005 CALL R2 4
|
||||
0x940C0504, // 0006 GETIDX R3 R2 K4
|
||||
0x54120004, // 0007 LDINT R4 5
|
||||
0x380C0604, // 0008 SHL R3 R3 R4
|
||||
0x94100505, // 0009 GETIDX R4 R2 K5
|
||||
0x000C0604, // 000A ADD R3 R3 R4
|
||||
0x80040600, // 000B RET 1 R3
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: I2C_Driver
|
||||
********************************************************************/
|
||||
be_local_class(I2C_Driver,
|
||||
3,
|
||||
NULL,
|
||||
be_nested_map(11,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(read32, -1), be_const_closure(I2C_Driver_read32_closure) },
|
||||
{ be_const_key(write8, 6), be_const_closure(I2C_Driver_write8_closure) },
|
||||
{ be_const_key(name, -1), be_const_var(2) },
|
||||
{ be_const_key(addr, 8), be_const_var(1) },
|
||||
{ be_const_key(read12, -1), be_const_closure(I2C_Driver_read12_closure) },
|
||||
{ be_const_key(wire, 10), be_const_var(0) },
|
||||
{ be_const_key(read13, -1), be_const_closure(I2C_Driver_read13_closure) },
|
||||
{ be_const_key(read24, -1), be_const_closure(I2C_Driver_read24_closure) },
|
||||
{ be_const_key(read8, -1), be_const_closure(I2C_Driver_read8_closure) },
|
||||
{ be_const_key(init, -1), be_const_closure(I2C_Driver_init_closure) },
|
||||
{ be_const_key(write_bit, -1), be_const_closure(I2C_Driver_write_bit_closure) },
|
||||
})),
|
||||
be_str_literal("I2C_Driver")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_I2C_Driver_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_I2C_Driver);
|
||||
be_setglobal(vm, "I2C_Driver");
|
||||
be_pop(vm, 1);
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/********************************************************************
|
||||
* Tasmota I2S audio classes
|
||||
*
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_I2S
|
||||
#ifdef USE_I2S_AUDIO_BERRY
|
||||
|
||||
extern int i2s_output_i2s_init(bvm *vm);
|
||||
extern int i2s_output_i2s_deinit(bvm *vm);
|
||||
extern int i2s_output_i2s_stop(bvm *vm);
|
||||
|
||||
extern int i2s_generator_wav_init(bvm *vm);
|
||||
extern int i2s_generator_wav_deinit(bvm *vm);
|
||||
extern int i2s_generator_wav_begin(bvm *vm);
|
||||
extern int i2s_generator_wav_loop(bvm *vm);
|
||||
extern int i2s_generator_wav_stop(bvm *vm);
|
||||
extern int i2s_generator_wav_isrunning(bvm *vm);
|
||||
|
||||
extern int i2s_generator_mp3_init(bvm *vm);
|
||||
extern int i2s_generator_mp3_deinit(bvm *vm);
|
||||
extern int i2s_generator_mp3_begin(bvm *vm);
|
||||
extern int i2s_generator_mp3_loop(bvm *vm);
|
||||
extern int i2s_generator_mp3_stop(bvm *vm);
|
||||
extern int i2s_generator_mp3_isrunning(bvm *vm);
|
||||
|
||||
#ifdef USE_UFILESYS
|
||||
extern int i2s_file_source_fs_init(bvm *vm);
|
||||
extern int i2s_file_source_fs_deinit(bvm *vm);
|
||||
#endif // USE_UFILESYS
|
||||
|
||||
|
||||
#include "../generate/be_fixed_be_class_audio_output.h"
|
||||
#include "../generate/be_fixed_be_class_audio_output_i2s.h"
|
||||
#include "../generate/be_fixed_be_class_audio_generator.h"
|
||||
#include "../generate/be_fixed_be_class_audio_generator_wav.h"
|
||||
#include "../generate/be_fixed_be_class_audio_generator_mp3.h"
|
||||
#include "../generate/be_fixed_be_class_audio_file_source.h"
|
||||
#include "../generate/be_fixed_be_class_audio_file_source_fs.h"
|
||||
|
||||
void be_load_driver_audio_lib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_audio_output);
|
||||
be_setglobal(vm, "AudioOutput");
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_pushntvclass(vm, &be_class_audio_output_i2s);
|
||||
be_setglobal(vm, "AudioOutputI2S");
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_pushntvclass(vm, &be_class_audio_generator_wav);
|
||||
be_setglobal(vm, "AudioGeneratorWAV");
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_pushntvclass(vm, &be_class_audio_generator_mp3);
|
||||
be_setglobal(vm, "AudioGeneratorMP3");
|
||||
be_pop(vm, 1);
|
||||
|
||||
#ifdef USE_UFILESYS
|
||||
be_pushntvclass(vm, &be_class_audio_file_source_fs);
|
||||
be_setglobal(vm, "AudioFileSourceFS");
|
||||
be_pop(vm, 1);
|
||||
#endif // USE_UFILESYS
|
||||
}
|
||||
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_audio_output (scope: global, name: AudioOutput) {
|
||||
.p, var
|
||||
}
|
||||
|
||||
class be_class_audio_generator (scope: global, name: AudioGenerator) {
|
||||
.p, var
|
||||
}
|
||||
|
||||
class be_class_audio_file_source (scope: global, name: AudioFileSource) {
|
||||
.p, var
|
||||
}
|
||||
|
||||
class be_class_audio_output_i2s (scope: global, name: AudioOutputI2S, super: be_class_audio_output) {
|
||||
init, func(i2s_output_i2s_init)
|
||||
deinit, func(i2s_output_i2s_deinit)
|
||||
stop, func(i2s_output_i2s_stop)
|
||||
}
|
||||
|
||||
class be_class_audio_generator_wav (scope: global, name: AudioGeneratorWAV, super: be_class_audio_generator) {
|
||||
init, func(i2s_generator_wav_init)
|
||||
deinit, func(i2s_generator_wav_deinit)
|
||||
begin, func(i2s_generator_wav_begin)
|
||||
loop, func(i2s_generator_wav_loop)
|
||||
stop, func(i2s_generator_wav_stop)
|
||||
isrunning, func(i2s_generator_wav_isrunning)
|
||||
}
|
||||
|
||||
class be_class_audio_generator_mp3 (scope: global, name: AudioGeneratorMP3, super: be_class_audio_generator) {
|
||||
init, func(i2s_generator_mp3_init)
|
||||
deinit, func(i2s_generator_mp3_deinit)
|
||||
begin, func(i2s_generator_mp3_begin)
|
||||
loop, func(i2s_generator_mp3_loop)
|
||||
stop, func(i2s_generator_mp3_stop)
|
||||
isrunning, func(i2s_generator_mp3_isrunning)
|
||||
}
|
||||
|
||||
class be_class_audio_file_source_fs (scope: global, name: AudioFileSourceFS, super: be_class_audio_file_source) {
|
||||
init, func(i2s_file_source_fs_init)
|
||||
deinit, func(i2s_file_source_fs_deinit)
|
||||
}
|
||||
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // USE_I2S_AUDIO_BERRY
|
||||
#endif // USE_I2S
|
|
@ -0,0 +1,381 @@
|
|||
/********************************************************************
|
||||
* Berry class `Leds_animator`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_WS2812
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_init, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 8]) { /* constants */
|
||||
/* K0 */ be_nested_str(strip),
|
||||
/* K1 */ be_nested_str(bri),
|
||||
/* K2 */ be_nested_str(running),
|
||||
/* K3 */ be_nested_str(pixel_count),
|
||||
/* K4 */ be_nested_str(animators),
|
||||
/* K5 */ be_nested_str(clear),
|
||||
/* K6 */ be_nested_str(tasmota),
|
||||
/* K7 */ be_nested_str(add_driver),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[18]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x540A0031, // 0001 LDINT R2 50
|
||||
0x90020202, // 0002 SETMBR R0 K1 R2
|
||||
0x50080000, // 0003 LDBOOL R2 0 0
|
||||
0x90020402, // 0004 SETMBR R0 K2 R2
|
||||
0x8C080303, // 0005 GETMET R2 R1 K3
|
||||
0x7C080200, // 0006 CALL R2 1
|
||||
0x90020602, // 0007 SETMBR R0 K3 R2
|
||||
0x60080012, // 0008 GETGBL R2 G18
|
||||
0x7C080000, // 0009 CALL R2 0
|
||||
0x90020802, // 000A SETMBR R0 K4 R2
|
||||
0x8C080105, // 000B GETMET R2 R0 K5
|
||||
0x7C080200, // 000C CALL R2 1
|
||||
0xB80A0C00, // 000D GETNGBL R2 K6
|
||||
0x8C080507, // 000E GETMET R2 R2 K7
|
||||
0x5C100000, // 000F MOVE R4 R0
|
||||
0x7C080400, // 0010 CALL R2 2
|
||||
0x80000000, // 0011 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_bri
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_set_bri, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(bri),
|
||||
}),
|
||||
&be_const_str_set_bri,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x80000000, // 0001 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: stop
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_stop, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(running),
|
||||
}),
|
||||
&be_const_str_stop,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 3]) { /* code */
|
||||
0x50040000, // 0000 LDBOOL R1 0 0
|
||||
0x90020001, // 0001 SETMBR R0 K0 R1
|
||||
0x80000000, // 0002 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: animate
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_animate, /* name */
|
||||
be_nested_proto(
|
||||
1, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
0, /* has constants */
|
||||
NULL, /* no const */
|
||||
&be_const_str_animate,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 1]) { /* code */
|
||||
0x80000000, // 0000 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: remove
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_remove, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(remove_driver),
|
||||
}),
|
||||
&be_const_str_remove,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x5C0C0000, // 0002 MOVE R3 R0
|
||||
0x7C040400, // 0003 CALL R1 2
|
||||
0x80000000, // 0004 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: every_50ms
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_every_50ms, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(running),
|
||||
/* K1 */ be_const_int(0),
|
||||
/* K2 */ be_nested_str(animators),
|
||||
/* K3 */ be_nested_str(is_running),
|
||||
/* K4 */ be_nested_str(animate),
|
||||
/* K5 */ be_const_int(1),
|
||||
/* K6 */ be_nested_str(remove),
|
||||
}),
|
||||
&be_const_str_every_50ms,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[25]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x78060015, // 0001 JMPF R1 #0018
|
||||
0x58040001, // 0002 LDCONST R1 K1
|
||||
0x6008000C, // 0003 GETGBL R2 G12
|
||||
0x880C0102, // 0004 GETMBR R3 R0 K2
|
||||
0x7C080200, // 0005 CALL R2 1
|
||||
0x14080202, // 0006 LT R2 R1 R2
|
||||
0x780A000D, // 0007 JMPF R2 #0016
|
||||
0x88080102, // 0008 GETMBR R2 R0 K2
|
||||
0x94080401, // 0009 GETIDX R2 R2 R1
|
||||
0x8C0C0503, // 000A GETMET R3 R2 K3
|
||||
0x7C0C0200, // 000B CALL R3 1
|
||||
0x780E0003, // 000C JMPF R3 #0011
|
||||
0x8C0C0504, // 000D GETMET R3 R2 K4
|
||||
0x7C0C0200, // 000E CALL R3 1
|
||||
0x00040305, // 000F ADD R1 R1 K5
|
||||
0x70020003, // 0010 JMP #0015
|
||||
0x880C0102, // 0011 GETMBR R3 R0 K2
|
||||
0x8C0C0706, // 0012 GETMET R3 R3 K6
|
||||
0x5C140200, // 0013 MOVE R5 R1
|
||||
0x7C0C0400, // 0014 CALL R3 2
|
||||
0x7001FFEC, // 0015 JMP #0003
|
||||
0x8C080104, // 0016 GETMET R2 R0 K4
|
||||
0x7C080200, // 0017 CALL R2 1
|
||||
0x80000000, // 0018 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bri
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_get_bri, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(bri),
|
||||
}),
|
||||
&be_const_str_get_bri,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x80040400, // 0001 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: start
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_start, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(running),
|
||||
}),
|
||||
&be_const_str_start,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 3]) { /* code */
|
||||
0x50040200, // 0000 LDBOOL R1 1 0
|
||||
0x90020001, // 0001 SETMBR R0 K0 R1
|
||||
0x80000000, // 0002 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: add_anim
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_add_anim, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(animators),
|
||||
/* K1 */ be_nested_str(push),
|
||||
/* K2 */ be_nested_str(run),
|
||||
}),
|
||||
&be_const_str_add_anim,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x5C100200, // 0002 MOVE R4 R1
|
||||
0x7C080400, // 0003 CALL R2 2
|
||||
0x8C080302, // 0004 GETMET R2 R1 K2
|
||||
0x7C080200, // 0005 CALL R2 1
|
||||
0x80000000, // 0006 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: clear
|
||||
********************************************************************/
|
||||
be_local_closure(Leds_animator_clear, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(stop),
|
||||
/* K1 */ be_nested_str(strip),
|
||||
/* K2 */ be_nested_str(clear),
|
||||
}),
|
||||
&be_const_str_clear,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x8C040100, // 0000 GETMET R1 R0 K0
|
||||
0x7C040200, // 0001 CALL R1 1
|
||||
0x88040101, // 0002 GETMBR R1 R0 K1
|
||||
0x8C040302, // 0003 GETMET R1 R1 K2
|
||||
0x7C040200, // 0004 CALL R1 1
|
||||
0x80000000, // 0005 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Leds_animator
|
||||
********************************************************************/
|
||||
be_local_class(Leds_animator,
|
||||
5,
|
||||
NULL,
|
||||
be_nested_map(15,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, 12), be_const_closure(Leds_animator_init_closure) },
|
||||
{ be_const_key(clear, -1), be_const_closure(Leds_animator_clear_closure) },
|
||||
{ be_const_key(stop, -1), be_const_closure(Leds_animator_stop_closure) },
|
||||
{ be_const_key(strip, 4), be_const_var(0) },
|
||||
{ be_const_key(pixel_count, 6), be_const_var(1) },
|
||||
{ be_const_key(animate, -1), be_const_closure(Leds_animator_animate_closure) },
|
||||
{ be_const_key(add_anim, 13), be_const_closure(Leds_animator_add_anim_closure) },
|
||||
{ be_const_key(bri, -1), be_const_var(2) },
|
||||
{ be_const_key(every_50ms, -1), be_const_closure(Leds_animator_every_50ms_closure) },
|
||||
{ be_const_key(remove, 7), be_const_closure(Leds_animator_remove_closure) },
|
||||
{ be_const_key(get_bri, -1), be_const_closure(Leds_animator_get_bri_closure) },
|
||||
{ be_const_key(start, -1), be_const_closure(Leds_animator_start_closure) },
|
||||
{ be_const_key(running, -1), be_const_var(3) },
|
||||
{ be_const_key(animators, -1), be_const_var(4) },
|
||||
{ be_const_key(set_bri, 1), be_const_closure(Leds_animator_set_bri_closure) },
|
||||
})),
|
||||
be_str_literal("Leds_animator")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_Leds_animator_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_Leds_animator);
|
||||
be_setglobal(vm, "Leds_animator");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_WS2812
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,50 @@
|
|||
/********************************************************************
|
||||
* Berry class `neopixelbus_ntv`
|
||||
*
|
||||
*******************************************************************/
|
||||
/*
|
||||
|
||||
class Leds_ntv
|
||||
var _p # pointer to internal object of type `NeoPixelBus<FEATURE, METHOD>(uint16_t countPixels, uint8_t pin)`
|
||||
var _t # type of led strip
|
||||
static WS2812_GRB = 1
|
||||
static SK6812_GRBW = 2
|
||||
|
||||
# skeleton for native call
|
||||
def call_native() end
|
||||
end
|
||||
|
||||
*/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_WS2812
|
||||
|
||||
extern int be_neopixelbus_call_native(bvm *vm);
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Leds_ntv
|
||||
********************************************************************/
|
||||
be_local_class(Leds_ntv,
|
||||
2,
|
||||
NULL,
|
||||
be_nested_map(5,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(call_native, -1), be_const_func(be_neopixelbus_call_native) },
|
||||
{ be_const_key(_t, -1), be_const_var(1) },
|
||||
{ be_const_key(_p, 3), be_const_var(0) },
|
||||
{ be_const_key(SK6812_GRBW, 4), be_const_int(2) },
|
||||
{ be_const_key(WS2812_GRB, -1), be_const_int(1) },
|
||||
})),
|
||||
be_str_literal("Leds_ntv")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_Leds_ntv_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_Leds_ntv);
|
||||
be_setglobal(vm, "Leds_ntv");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
// be_const_func(be_neopixelbus_call_native)
|
||||
#endif // USE_WS2812
|
|
@ -0,0 +1,28 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import tasmota`
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LIGHT
|
||||
extern int l_getlight(bvm *vm);
|
||||
extern int l_setlight(bvm *vm);
|
||||
|
||||
extern int l_gamma8(bvm *vm);
|
||||
extern int l_gamma10(bvm *vm);
|
||||
extern int l_rev_gamma10(bvm *vm);
|
||||
|
||||
/* @const_object_info_begin
|
||||
module light (scope: global) {
|
||||
get, func(l_getlight)
|
||||
set, func(l_setlight)
|
||||
|
||||
gamma8, func(l_gamma8)
|
||||
gamma10, func(l_gamma10)
|
||||
reverse_gamma10, func(l_rev_gamma10)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "../generate/be_fixed_light.h"
|
||||
|
||||
#endif // USE_LIGHT
|
|
@ -0,0 +1,313 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_time
|
||||
********************************************************************/
|
||||
be_local_closure(lv_clock_icon_set_time, /* name */
|
||||
be_nested_proto(
|
||||
11, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[10]) { /* constants */
|
||||
/* K0 */ be_nested_str(string),
|
||||
/* K1 */ be_nested_str(hour),
|
||||
/* K2 */ be_nested_str(minute),
|
||||
/* K3 */ be_nested_str(sec),
|
||||
/* K4 */ be_nested_str(format),
|
||||
/* K5 */ be_nested_str(_X2502d_X25s_X2502d),
|
||||
/* K6 */ be_const_int(2),
|
||||
/* K7 */ be_nested_str(_X3A),
|
||||
/* K8 */ be_nested_str(_X20),
|
||||
/* K9 */ be_nested_str(set_text),
|
||||
}),
|
||||
&be_const_str_set_time,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[27]) { /* code */
|
||||
0xA4120000, // 0000 IMPORT R4 K0
|
||||
0x88140101, // 0001 GETMBR R5 R0 K1
|
||||
0x20140205, // 0002 NE R5 R1 R5
|
||||
0x74160005, // 0003 JMPT R5 #000A
|
||||
0x88140102, // 0004 GETMBR R5 R0 K2
|
||||
0x20140405, // 0005 NE R5 R2 R5
|
||||
0x74160002, // 0006 JMPT R5 #000A
|
||||
0x88140103, // 0007 GETMBR R5 R0 K3
|
||||
0x20140605, // 0008 NE R5 R3 R5
|
||||
0x7816000F, // 0009 JMPF R5 #001A
|
||||
0x8C140904, // 000A GETMET R5 R4 K4
|
||||
0x581C0005, // 000B LDCONST R7 K5
|
||||
0x5C200200, // 000C MOVE R8 R1
|
||||
0x10240706, // 000D MOD R9 R3 K6
|
||||
0x78260001, // 000E JMPF R9 #0011
|
||||
0x58240007, // 000F LDCONST R9 K7
|
||||
0x70020000, // 0010 JMP #0012
|
||||
0x58240008, // 0011 LDCONST R9 K8
|
||||
0x5C280400, // 0012 MOVE R10 R2
|
||||
0x7C140A00, // 0013 CALL R5 5
|
||||
0x90020201, // 0014 SETMBR R0 K1 R1
|
||||
0x90020402, // 0015 SETMBR R0 K2 R2
|
||||
0x90020603, // 0016 SETMBR R0 K3 R3
|
||||
0x8C180109, // 0017 GETMET R6 R0 K9
|
||||
0x5C200A00, // 0018 MOVE R8 R5
|
||||
0x7C180400, // 0019 CALL R6 2
|
||||
0x80000000, // 001A RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: every_second
|
||||
********************************************************************/
|
||||
be_local_closure(lv_clock_icon_every_second, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 9]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(time_dump),
|
||||
/* K2 */ be_nested_str(rtc),
|
||||
/* K3 */ be_nested_str(local),
|
||||
/* K4 */ be_nested_str(year),
|
||||
/* K5 */ be_nested_str(set_time),
|
||||
/* K6 */ be_nested_str(hour),
|
||||
/* K7 */ be_nested_str(min),
|
||||
/* K8 */ be_nested_str(sec),
|
||||
}),
|
||||
&be_const_str_every_second,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[17]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0xB80E0000, // 0002 GETNGBL R3 K0
|
||||
0x8C0C0702, // 0003 GETMET R3 R3 K2
|
||||
0x7C0C0200, // 0004 CALL R3 1
|
||||
0x940C0703, // 0005 GETIDX R3 R3 K3
|
||||
0x7C040400, // 0006 CALL R1 2
|
||||
0x94080304, // 0007 GETIDX R2 R1 K4
|
||||
0x540E07B1, // 0008 LDINT R3 1970
|
||||
0x20080403, // 0009 NE R2 R2 R3
|
||||
0x780A0004, // 000A JMPF R2 #0010
|
||||
0x8C080105, // 000B GETMET R2 R0 K5
|
||||
0x94100306, // 000C GETIDX R4 R1 K6
|
||||
0x94140307, // 000D GETIDX R5 R1 K7
|
||||
0x94180308, // 000E GETIDX R6 R1 K8
|
||||
0x7C080800, // 000F CALL R2 4
|
||||
0x80000000, // 0010 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_clock_icon_init, /* name */
|
||||
be_nested_proto(
|
||||
11, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[22]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(lv),
|
||||
/* K2 */ be_nested_str(seg7_font),
|
||||
/* K3 */ be_nested_str(set_style_text_font),
|
||||
/* K4 */ be_nested_str(PART_MAIN),
|
||||
/* K5 */ be_nested_str(STATE_DEFAULT),
|
||||
/* K6 */ be_nested_str(get_height),
|
||||
/* K7 */ be_nested_str(set_text),
|
||||
/* K8 */ be_nested_str(_X2D_X2D_X3A_X2D_X2D),
|
||||
/* K9 */ be_nested_str(refr_size),
|
||||
/* K10 */ be_nested_str(get_width),
|
||||
/* K11 */ be_nested_str(set_y),
|
||||
/* K12 */ be_const_int(2),
|
||||
/* K13 */ be_nested_str(get_style_pad_right),
|
||||
/* K14 */ be_nested_str(set_x),
|
||||
/* K15 */ be_const_int(3),
|
||||
/* K16 */ be_nested_str(set_style_pad_right),
|
||||
/* K17 */ be_nested_str(set_style_bg_color),
|
||||
/* K18 */ be_nested_str(color),
|
||||
/* K19 */ be_nested_str(COLOR_BLACK),
|
||||
/* K20 */ be_nested_str(tasmota),
|
||||
/* K21 */ be_nested_str(add_driver),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[82]) { /* code */
|
||||
0x60080003, // 0000 GETGBL R2 G3
|
||||
0x5C0C0000, // 0001 MOVE R3 R0
|
||||
0x7C080200, // 0002 CALL R2 1
|
||||
0x8C080500, // 0003 GETMET R2 R2 K0
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0xB80A0200, // 0006 GETNGBL R2 K1
|
||||
0x8C080502, // 0007 GETMET R2 R2 K2
|
||||
0x5412000F, // 0008 LDINT R4 16
|
||||
0x7C080400, // 0009 CALL R2 2
|
||||
0x4C0C0000, // 000A LDNIL R3
|
||||
0x200C0403, // 000B NE R3 R2 R3
|
||||
0x780E0007, // 000C JMPF R3 #0015
|
||||
0x8C0C0103, // 000D GETMET R3 R0 K3
|
||||
0x5C140400, // 000E MOVE R5 R2
|
||||
0xB81A0200, // 000F GETNGBL R6 K1
|
||||
0x88180D04, // 0010 GETMBR R6 R6 K4
|
||||
0xB81E0200, // 0011 GETNGBL R7 K1
|
||||
0x881C0F05, // 0012 GETMBR R7 R7 K5
|
||||
0x30180C07, // 0013 OR R6 R6 R7
|
||||
0x7C0C0600, // 0014 CALL R3 3
|
||||
0x4C0C0000, // 0015 LDNIL R3
|
||||
0x200C0203, // 0016 NE R3 R1 R3
|
||||
0x780E0034, // 0017 JMPF R3 #004D
|
||||
0x8C0C0306, // 0018 GETMET R3 R1 K6
|
||||
0x7C0C0200, // 0019 CALL R3 1
|
||||
0x8C100107, // 001A GETMET R4 R0 K7
|
||||
0x58180008, // 001B LDCONST R6 K8
|
||||
0x7C100400, // 001C CALL R4 2
|
||||
0x8C100109, // 001D GETMET R4 R0 K9
|
||||
0x7C100200, // 001E CALL R4 1
|
||||
0x8C10010A, // 001F GETMET R4 R0 K10
|
||||
0x7C100200, // 0020 CALL R4 1
|
||||
0x8C14010B, // 0021 GETMET R5 R0 K11
|
||||
0x8C1C0306, // 0022 GETMET R7 R1 K6
|
||||
0x7C1C0200, // 0023 CALL R7 1
|
||||
0x8C200106, // 0024 GETMET R8 R0 K6
|
||||
0x7C200200, // 0025 CALL R8 1
|
||||
0x041C0E08, // 0026 SUB R7 R7 R8
|
||||
0x0C1C0F0C, // 0027 DIV R7 R7 K12
|
||||
0x7C140400, // 0028 CALL R5 2
|
||||
0x8C14030D, // 0029 GETMET R5 R1 K13
|
||||
0xB81E0200, // 002A GETNGBL R7 K1
|
||||
0x881C0F04, // 002B GETMBR R7 R7 K4
|
||||
0xB8220200, // 002C GETNGBL R8 K1
|
||||
0x88201105, // 002D GETMBR R8 R8 K5
|
||||
0x301C0E08, // 002E OR R7 R7 R8
|
||||
0x7C140400, // 002F CALL R5 2
|
||||
0x8C18010E, // 0030 GETMET R6 R0 K14
|
||||
0x8C20030A, // 0031 GETMET R8 R1 K10
|
||||
0x7C200200, // 0032 CALL R8 1
|
||||
0x04201004, // 0033 SUB R8 R8 R4
|
||||
0x04201005, // 0034 SUB R8 R8 R5
|
||||
0x0420110F, // 0035 SUB R8 R8 K15
|
||||
0x7C180400, // 0036 CALL R6 2
|
||||
0x8C180310, // 0037 GETMET R6 R1 K16
|
||||
0x00200A04, // 0038 ADD R8 R5 R4
|
||||
0x54260005, // 0039 LDINT R9 6
|
||||
0x00201009, // 003A ADD R8 R8 R9
|
||||
0xB8260200, // 003B GETNGBL R9 K1
|
||||
0x88241304, // 003C GETMBR R9 R9 K4
|
||||
0xB82A0200, // 003D GETNGBL R10 K1
|
||||
0x88281505, // 003E GETMBR R10 R10 K5
|
||||
0x3024120A, // 003F OR R9 R9 R10
|
||||
0x7C180600, // 0040 CALL R6 3
|
||||
0x8C180111, // 0041 GETMET R6 R0 K17
|
||||
0xB8220200, // 0042 GETNGBL R8 K1
|
||||
0x8C201112, // 0043 GETMET R8 R8 K18
|
||||
0xB82A0200, // 0044 GETNGBL R10 K1
|
||||
0x88281513, // 0045 GETMBR R10 R10 K19
|
||||
0x7C200400, // 0046 CALL R8 2
|
||||
0xB8260200, // 0047 GETNGBL R9 K1
|
||||
0x88241304, // 0048 GETMBR R9 R9 K4
|
||||
0xB82A0200, // 0049 GETNGBL R10 K1
|
||||
0x88281505, // 004A GETMBR R10 R10 K5
|
||||
0x3024120A, // 004B OR R9 R9 R10
|
||||
0x7C180600, // 004C CALL R6 3
|
||||
0xB80E2800, // 004D GETNGBL R3 K20
|
||||
0x8C0C0715, // 004E GETMET R3 R3 K21
|
||||
0x5C140000, // 004F MOVE R5 R0
|
||||
0x7C0C0400, // 0050 CALL R3 2
|
||||
0x80000000, // 0051 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: del
|
||||
********************************************************************/
|
||||
be_local_closure(lv_clock_icon_del, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(del),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(remove_driver),
|
||||
}),
|
||||
&be_const_str_del,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[10]) { /* code */
|
||||
0x60040003, // 0000 GETGBL R1 G3
|
||||
0x5C080000, // 0001 MOVE R2 R0
|
||||
0x7C040200, // 0002 CALL R1 1
|
||||
0x8C040300, // 0003 GETMET R1 R1 K0
|
||||
0x7C040200, // 0004 CALL R1 1
|
||||
0xB8060200, // 0005 GETNGBL R1 K1
|
||||
0x8C040302, // 0006 GETMET R1 R1 K2
|
||||
0x5C0C0000, // 0007 MOVE R3 R0
|
||||
0x7C040400, // 0008 CALL R1 2
|
||||
0x80000000, // 0009 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_clock_icon
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_label;
|
||||
be_local_class(lv_clock_icon,
|
||||
3,
|
||||
&be_class_lv_label,
|
||||
be_nested_map(7,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(sec, -1), be_const_var(2) },
|
||||
{ be_const_key(hour, -1), be_const_var(0) },
|
||||
{ be_const_key(set_time, 6), be_const_closure(lv_clock_icon_set_time_closure) },
|
||||
{ be_const_key(every_second, -1), be_const_closure(lv_clock_icon_every_second_closure) },
|
||||
{ be_const_key(minute, -1), be_const_var(1) },
|
||||
{ be_const_key(init, 2), be_const_closure(lv_clock_icon_init_closure) },
|
||||
{ be_const_key(del, -1), be_const_closure(lv_clock_icon_del_closure) },
|
||||
})),
|
||||
be_str_literal("lv_clock_icon")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_clock_icon_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_clock_icon);
|
||||
be_setglobal(vm, "lv_clock_icon");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,531 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL ctypes mapping
|
||||
*******************************************************************/
|
||||
#include "be_ctypes.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "be_lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
* Generated code, don't edit
|
||||
*******************************************************************/
|
||||
|
||||
static const char * be_ctypes_instance_mappings[]; /* forward definition */
|
||||
|
||||
const be_ctypes_structure_t be_lv_point = {
|
||||
4, /* size in bytes */
|
||||
2, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[2]) {
|
||||
{ "x", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "y", 2, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_area = {
|
||||
8, /* size in bytes */
|
||||
4, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[4]) {
|
||||
{ "x1", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "x2", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "y1", 2, 0, 0, ctypes_i16, 0 },
|
||||
{ "y2", 6, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_rect_dsc = {
|
||||
51, /* size in bytes */
|
||||
29, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[29]) {
|
||||
{ "bg_color", 4, 0, 0, ctypes_u16, 1 },
|
||||
{ "bg_grad_color", 6, 0, 0, ctypes_u16, 1 },
|
||||
{ "bg_grad_color_stop", 9, 0, 0, ctypes_u8, 0 },
|
||||
{ "bg_grad_dir", 11, 0, 3, ctypes_bf, 0 },
|
||||
{ "bg_img_opa", 22, 0, 0, ctypes_u8, 0 },
|
||||
{ "bg_img_recolor", 20, 0, 0, ctypes_u16, 1 },
|
||||
{ "bg_img_recolor_opa", 23, 0, 0, ctypes_u8, 0 },
|
||||
{ "bg_img_src", 12, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "bg_img_symbol_font", 16, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "bg_img_tiled", 24, 0, 0, ctypes_u8, 0 },
|
||||
{ "bg_main_color_stop", 8, 0, 0, ctypes_u8, 0 },
|
||||
{ "bg_opa", 10, 0, 0, ctypes_u8, 0 },
|
||||
{ "blend_mode", 2, 0, 0, ctypes_u8, 0 },
|
||||
{ "border_color", 26, 0, 0, ctypes_u16, 1 },
|
||||
{ "border_opa", 30, 0, 0, ctypes_u8, 0 },
|
||||
{ "border_post", 31, 0, 1, ctypes_bf, 0 },
|
||||
{ "border_side", 31, 1, 5, ctypes_bf, 0 },
|
||||
{ "border_width", 28, 0, 0, ctypes_i16, 0 },
|
||||
{ "outline_color", 32, 0, 0, ctypes_u16, 1 },
|
||||
{ "outline_opa", 38, 0, 0, ctypes_u8, 0 },
|
||||
{ "outline_pad", 36, 0, 0, ctypes_i16, 0 },
|
||||
{ "outline_width", 34, 0, 0, ctypes_i16, 0 },
|
||||
{ "radius", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "shadow_color", 40, 0, 0, ctypes_u16, 1 },
|
||||
{ "shadow_ofs_x", 44, 0, 0, ctypes_i16, 0 },
|
||||
{ "shadow_ofs_y", 46, 0, 0, ctypes_i16, 0 },
|
||||
{ "shadow_opa", 50, 0, 0, ctypes_u8, 0 },
|
||||
{ "shadow_spread", 48, 0, 0, ctypes_i16, 0 },
|
||||
{ "shadow_width", 42, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_line_dsc = {
|
||||
10, /* size in bytes */
|
||||
9, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[9]) {
|
||||
{ "blend_mode", 9, 0, 2, ctypes_bf, 0 },
|
||||
{ "color", 0, 0, 0, ctypes_u16, 1 },
|
||||
{ "dash_gap", 6, 0, 0, ctypes_i16, 0 },
|
||||
{ "dash_width", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "opa", 8, 0, 0, ctypes_u8, 0 },
|
||||
{ "raw_end", 9, 4, 1, ctypes_bf, 0 },
|
||||
{ "round_end", 9, 3, 1, ctypes_bf, 0 },
|
||||
{ "round_start", 9, 2, 1, ctypes_bf, 0 },
|
||||
{ "width", 2, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_img_dsc = {
|
||||
21, /* size in bytes */
|
||||
10, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[10]) {
|
||||
{ "angle", 0, 0, 0, ctypes_u16, 0 },
|
||||
{ "antialias", 20, 0, 1, ctypes_bf, 0 },
|
||||
{ "blend_mode", 12, 0, 4, ctypes_bf, 0 },
|
||||
{ "frame_id", 16, 0, 0, ctypes_i32, 0 },
|
||||
{ "opa", 11, 0, 0, ctypes_u8, 0 },
|
||||
{ "pivot_x", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "pivot_y", 6, 0, 0, ctypes_i16, 0 },
|
||||
{ "recolor", 8, 0, 0, ctypes_u16, 1 },
|
||||
{ "recolor_opa", 10, 0, 0, ctypes_u8, 0 },
|
||||
{ "zoom", 2, 0, 0, ctypes_u16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_common_dsc = {
|
||||
5, /* size in bytes */
|
||||
2, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[2]) {
|
||||
{ "cb", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "type", 4, 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_line_param_cfg = {
|
||||
9, /* size in bytes */
|
||||
5, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[5]) {
|
||||
{ "p1_x", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "p1_y", 2, 0, 0, ctypes_i16, 0 },
|
||||
{ "p2_x", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "p2_y", 6, 0, 0, ctypes_i16, 0 },
|
||||
{ "side", 8, 0, 2, ctypes_bf, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_line_param = {
|
||||
41, /* size in bytes */
|
||||
15, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[15]) {
|
||||
{ "cfg_p1_x", 8, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_p1_y", 10, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_p2_x", 12, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_p2_y", 14, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_side", 16, 0, 2, ctypes_bf, 0 },
|
||||
{ "dsc_cb", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "dsc_type", 4, 0, 0, ctypes_u8, 0 },
|
||||
{ "flat", 40, 0, 1, ctypes_bf, 0 },
|
||||
{ "inv", 40, 1, 1, ctypes_bf, 0 },
|
||||
{ "origo_x", 20, 0, 0, ctypes_i16, 0 },
|
||||
{ "origo_y", 22, 0, 0, ctypes_i16, 0 },
|
||||
{ "spx", 36, 0, 0, ctypes_i32, 0 },
|
||||
{ "steep", 32, 0, 0, ctypes_i32, 0 },
|
||||
{ "xy_steep", 24, 0, 0, ctypes_i32, 0 },
|
||||
{ "yx_steep", 28, 0, 0, ctypes_i32, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_angle_param_cfg = {
|
||||
8, /* size in bytes */
|
||||
4, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[4]) {
|
||||
{ "end_angle", 6, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_angle", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "vertex_p_x", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "vertex_p_y", 2, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_angle_param = {
|
||||
104, /* size in bytes */
|
||||
37, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[37]) {
|
||||
{ "cfg_end_angle", 14, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_start_angle", 12, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_vertex_p_x", 8, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_vertex_p_y", 10, 0, 0, ctypes_i16, 0 },
|
||||
{ "delta_deg", 102, 0, 0, ctypes_u16, 0 },
|
||||
{ "dsc_cb", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "dsc_type", 4, 0, 0, ctypes_u8, 0 },
|
||||
{ "end_line_cfg_p1_x", 68, 0, 0, ctypes_i16, 0 },
|
||||
{ "end_line_cfg_p1_y", 70, 0, 0, ctypes_i16, 0 },
|
||||
{ "end_line_cfg_p2_x", 72, 0, 0, ctypes_i16, 0 },
|
||||
{ "end_line_cfg_p2_y", 74, 0, 0, ctypes_i16, 0 },
|
||||
{ "end_line_cfg_side", 76, 0, 2, ctypes_bf, 0 },
|
||||
{ "end_line_dsc_cb", 60, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "end_line_dsc_type", 64, 0, 0, ctypes_u8, 0 },
|
||||
{ "end_line_flat", 100, 0, 1, ctypes_bf, 0 },
|
||||
{ "end_line_inv", 100, 1, 1, ctypes_bf, 0 },
|
||||
{ "end_line_origo_x", 80, 0, 0, ctypes_i16, 0 },
|
||||
{ "end_line_origo_y", 82, 0, 0, ctypes_i16, 0 },
|
||||
{ "end_line_spx", 96, 0, 0, ctypes_i32, 0 },
|
||||
{ "end_line_steep", 92, 0, 0, ctypes_i32, 0 },
|
||||
{ "end_line_xy_steep", 84, 0, 0, ctypes_i32, 0 },
|
||||
{ "end_line_yx_steep", 88, 0, 0, ctypes_i32, 0 },
|
||||
{ "start_line_cfg_p1_x", 24, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_line_cfg_p1_y", 26, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_line_cfg_p2_x", 28, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_line_cfg_p2_y", 30, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_line_cfg_side", 32, 0, 2, ctypes_bf, 0 },
|
||||
{ "start_line_dsc_cb", 16, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "start_line_dsc_type", 20, 0, 0, ctypes_u8, 0 },
|
||||
{ "start_line_flat", 56, 0, 1, ctypes_bf, 0 },
|
||||
{ "start_line_inv", 56, 1, 1, ctypes_bf, 0 },
|
||||
{ "start_line_origo_x", 36, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_line_origo_y", 38, 0, 0, ctypes_i16, 0 },
|
||||
{ "start_line_spx", 52, 0, 0, ctypes_i32, 0 },
|
||||
{ "start_line_steep", 48, 0, 0, ctypes_i32, 0 },
|
||||
{ "start_line_xy_steep", 40, 0, 0, ctypes_i32, 0 },
|
||||
{ "start_line_yx_steep", 44, 0, 0, ctypes_i32, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_radius_param_cfg = {
|
||||
11, /* size in bytes */
|
||||
6, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[6]) {
|
||||
{ "outer", 10, 0, 1, ctypes_bf, 0 },
|
||||
{ "radius", 8, 0, 0, ctypes_i16, 0 },
|
||||
{ "rect_x1", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "rect_x2", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "rect_y1", 2, 0, 0, ctypes_i16, 0 },
|
||||
{ "rect_y2", 6, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_sqrt_res = {
|
||||
4, /* size in bytes */
|
||||
2, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[2]) {
|
||||
{ "f", 2, 0, 0, ctypes_u16, 0 },
|
||||
{ "i", 0, 0, 0, ctypes_u16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_radius_param = {
|
||||
28, /* size in bytes */
|
||||
11, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[11]) {
|
||||
{ "cfg_outer", 18, 0, 1, ctypes_bf, 0 },
|
||||
{ "cfg_radius", 16, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_rect_x1", 8, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_rect_x2", 12, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_rect_y1", 10, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_rect_y2", 14, 0, 0, ctypes_i16, 0 },
|
||||
{ "dsc_cb", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "dsc_type", 4, 0, 0, ctypes_u8, 0 },
|
||||
{ "y_prev", 20, 0, 0, ctypes_i32, 0 },
|
||||
{ "y_prev_x_f", 26, 0, 0, ctypes_u16, 0 },
|
||||
{ "y_prev_x_i", 24, 0, 0, ctypes_u16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_fade_param_cfg = {
|
||||
14, /* size in bytes */
|
||||
8, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[8]) {
|
||||
{ "coords_x1", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "coords_x2", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "coords_y1", 2, 0, 0, ctypes_i16, 0 },
|
||||
{ "coords_y2", 6, 0, 0, ctypes_i16, 0 },
|
||||
{ "opa_bottom", 13, 0, 0, ctypes_u8, 0 },
|
||||
{ "opa_top", 12, 0, 0, ctypes_u8, 0 },
|
||||
{ "y_bottom", 10, 0, 0, ctypes_i16, 0 },
|
||||
{ "y_top", 8, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_fade_param = {
|
||||
22, /* size in bytes */
|
||||
10, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[10]) {
|
||||
{ "cfg_coords_x1", 8, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_coords_x2", 12, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_coords_y1", 10, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_coords_y2", 14, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_opa_bottom", 21, 0, 0, ctypes_u8, 0 },
|
||||
{ "cfg_opa_top", 20, 0, 0, ctypes_u8, 0 },
|
||||
{ "cfg_y_bottom", 18, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_y_top", 16, 0, 0, ctypes_i16, 0 },
|
||||
{ "dsc_cb", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "dsc_type", 4, 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_map_param_cfg = {
|
||||
12, /* size in bytes */
|
||||
5, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[5]) {
|
||||
{ "coords_x1", 0, 0, 0, ctypes_i16, 0 },
|
||||
{ "coords_x2", 4, 0, 0, ctypes_i16, 0 },
|
||||
{ "coords_y1", 2, 0, 0, ctypes_i16, 0 },
|
||||
{ "coords_y2", 6, 0, 0, ctypes_i16, 0 },
|
||||
{ "map", 8, 0, 0, ctypes_ptr32, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_map_param = {
|
||||
20, /* size in bytes */
|
||||
7, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[7]) {
|
||||
{ "cfg_coords_x1", 8, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_coords_x2", 12, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_coords_y1", 10, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_coords_y2", 14, 0, 0, ctypes_i16, 0 },
|
||||
{ "cfg_map", 16, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "dsc_cb", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "dsc_type", 4, 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_draw_mask_saved = {
|
||||
8, /* size in bytes */
|
||||
2, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[2]) {
|
||||
{ "custom_id", 4, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "param", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_meter_scale = {
|
||||
34, /* size in bytes */
|
||||
15, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[15]) {
|
||||
{ "angle_range", 30, 0, 0, ctypes_u16, 0 },
|
||||
{ "label_color", 18, 0, 0, ctypes_i16, 0 },
|
||||
{ "label_gap", 16, 0, 0, ctypes_i16, 0 },
|
||||
{ "max", 24, 0, 0, ctypes_i32, 0 },
|
||||
{ "min", 20, 0, 0, ctypes_i32, 0 },
|
||||
{ "r_mod", 28, 0, 0, ctypes_i16, 0 },
|
||||
{ "rotation", 32, 0, 0, ctypes_i16, 0 },
|
||||
{ "tick_cnt", 2, 0, 0, ctypes_u16, 0 },
|
||||
{ "tick_color", 0, 0, 0, ctypes_u16, 1 },
|
||||
{ "tick_length", 4, 0, 0, ctypes_u16, 0 },
|
||||
{ "tick_major_color", 8, 0, 0, ctypes_u16, 1 },
|
||||
{ "tick_major_length", 12, 0, 0, ctypes_u16, 0 },
|
||||
{ "tick_major_nth", 10, 0, 0, ctypes_u16, 0 },
|
||||
{ "tick_major_width", 14, 0, 0, ctypes_u16, 0 },
|
||||
{ "tick_width", 6, 0, 0, ctypes_u16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_meter_indicator = {
|
||||
16, /* size in bytes */
|
||||
5, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[5]) {
|
||||
{ "end_value", 12, 0, 0, ctypes_i32, 0 },
|
||||
{ "opa", 5, 0, 0, ctypes_u8, 0 },
|
||||
{ "scale", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "start_value", 8, 0, 0, ctypes_i32, 0 },
|
||||
{ "type", 4, 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_meter_indicator_needle_img = {
|
||||
24, /* size in bytes */
|
||||
8, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[8]) {
|
||||
{ "end_value", 12, 0, 0, ctypes_i32, 0 },
|
||||
{ "opa", 5, 0, 0, ctypes_u8, 0 },
|
||||
{ "pivot_x", 20, 0, 0, ctypes_i16, 0 },
|
||||
{ "pivot_y", 22, 0, 0, ctypes_i16, 0 },
|
||||
{ "scale", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "src", 16, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "start_value", 8, 0, 0, ctypes_i32, 0 },
|
||||
{ "type", 4, 0, 0, ctypes_u8, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_meter_indicator_needle_line = {
|
||||
22, /* size in bytes */
|
||||
8, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[8]) {
|
||||
{ "color", 20, 0, 0, ctypes_u16, 1 },
|
||||
{ "end_value", 12, 0, 0, ctypes_i32, 0 },
|
||||
{ "opa", 5, 0, 0, ctypes_u8, 0 },
|
||||
{ "r_mod", 18, 0, 0, ctypes_i16, 0 },
|
||||
{ "scale", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "start_value", 8, 0, 0, ctypes_i32, 0 },
|
||||
{ "type", 4, 0, 0, ctypes_u8, 0 },
|
||||
{ "width", 16, 0, 0, ctypes_u16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_meter_indicator_arc = {
|
||||
28, /* size in bytes */
|
||||
9, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[9]) {
|
||||
{ "color", 24, 0, 0, ctypes_u16, 1 },
|
||||
{ "end_value", 12, 0, 0, ctypes_i32, 0 },
|
||||
{ "opa", 5, 0, 0, ctypes_u8, 0 },
|
||||
{ "r_mod", 26, 0, 0, ctypes_i16, 0 },
|
||||
{ "scale", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "src", 20, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "start_value", 8, 0, 0, ctypes_i32, 0 },
|
||||
{ "type", 4, 0, 0, ctypes_u8, 0 },
|
||||
{ "width", 16, 0, 0, ctypes_u16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_meter_indicator_scale_lines = {
|
||||
23, /* size in bytes */
|
||||
9, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[9]) {
|
||||
{ "color_end", 20, 0, 0, ctypes_u16, 1 },
|
||||
{ "color_start", 18, 0, 0, ctypes_u16, 1 },
|
||||
{ "end_value", 12, 0, 0, ctypes_i32, 0 },
|
||||
{ "local_grad", 22, 0, 1, ctypes_bf, 0 },
|
||||
{ "opa", 5, 0, 0, ctypes_u8, 0 },
|
||||
{ "scale", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "start_value", 8, 0, 0, ctypes_i32, 0 },
|
||||
{ "type", 4, 0, 0, ctypes_u8, 0 },
|
||||
{ "width_mod", 16, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_obj_class = {
|
||||
27, /* size in bytes */
|
||||
10, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[10]) {
|
||||
{ "base_class", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "constructor_cb", 4, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "destructor_cb", 8, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "editable", 24, 0, 2, ctypes_bf, 0 },
|
||||
{ "event_cb", 16, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "group_def", 24, 2, 2, ctypes_bf, 0 },
|
||||
{ "height_def", 22, 0, 0, ctypes_i16, 0 },
|
||||
{ "instance_size", 24, 4, 16, ctypes_bf, 0 },
|
||||
{ "user_data", 12, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "width_def", 20, 0, 0, ctypes_i16, 0 },
|
||||
}};
|
||||
|
||||
const be_ctypes_structure_t be_lv_event = {
|
||||
25, /* size in bytes */
|
||||
7, /* number of elements */
|
||||
be_ctypes_instance_mappings,
|
||||
(const be_ctypes_structure_item_t[7]) {
|
||||
{ "code", 8, 0, 0, ctypes_i32, 0 },
|
||||
{ "current_target", 4, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "deleted", 24, 0, 1, ctypes_bf, 0 },
|
||||
{ "param", 16, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "prev", 20, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "target", 0, 0, 0, ctypes_ptr32, 0 },
|
||||
{ "user_data", 12, 0, 0, ctypes_ptr32, 0 },
|
||||
}};
|
||||
|
||||
static const char * be_ctypes_instance_mappings[] = {
|
||||
"lv_color",
|
||||
NULL
|
||||
};
|
||||
|
||||
static be_define_ctypes_class(lv_area, &be_lv_area, &be_class_ctypes, "lv_area");
|
||||
static be_define_ctypes_class(lv_draw_img_dsc, &be_lv_draw_img_dsc, &be_class_ctypes, "lv_draw_img_dsc");
|
||||
static be_define_ctypes_class(lv_draw_line_dsc, &be_lv_draw_line_dsc, &be_class_ctypes, "lv_draw_line_dsc");
|
||||
static be_define_ctypes_class(lv_draw_mask_angle_param, &be_lv_draw_mask_angle_param, &be_class_ctypes, "lv_draw_mask_angle_param");
|
||||
static be_define_ctypes_class(lv_draw_mask_angle_param_cfg, &be_lv_draw_mask_angle_param_cfg, &be_class_ctypes, "lv_draw_mask_angle_param_cfg");
|
||||
static be_define_ctypes_class(lv_draw_mask_common_dsc, &be_lv_draw_mask_common_dsc, &be_class_ctypes, "lv_draw_mask_common_dsc");
|
||||
static be_define_ctypes_class(lv_draw_mask_fade_param, &be_lv_draw_mask_fade_param, &be_class_ctypes, "lv_draw_mask_fade_param");
|
||||
static be_define_ctypes_class(lv_draw_mask_fade_param_cfg, &be_lv_draw_mask_fade_param_cfg, &be_class_ctypes, "lv_draw_mask_fade_param_cfg");
|
||||
static be_define_ctypes_class(lv_draw_mask_line_param, &be_lv_draw_mask_line_param, &be_class_ctypes, "lv_draw_mask_line_param");
|
||||
static be_define_ctypes_class(lv_draw_mask_line_param_cfg, &be_lv_draw_mask_line_param_cfg, &be_class_ctypes, "lv_draw_mask_line_param_cfg");
|
||||
static be_define_ctypes_class(lv_draw_mask_map_param, &be_lv_draw_mask_map_param, &be_class_ctypes, "lv_draw_mask_map_param");
|
||||
static be_define_ctypes_class(lv_draw_mask_map_param_cfg, &be_lv_draw_mask_map_param_cfg, &be_class_ctypes, "lv_draw_mask_map_param_cfg");
|
||||
static be_define_ctypes_class(lv_draw_mask_radius_param, &be_lv_draw_mask_radius_param, &be_class_ctypes, "lv_draw_mask_radius_param");
|
||||
static be_define_ctypes_class(lv_draw_mask_radius_param_cfg, &be_lv_draw_mask_radius_param_cfg, &be_class_ctypes, "lv_draw_mask_radius_param_cfg");
|
||||
static be_define_ctypes_class(lv_draw_mask_saved, &be_lv_draw_mask_saved, &be_class_ctypes, "lv_draw_mask_saved");
|
||||
static be_define_ctypes_class(lv_draw_rect_dsc, &be_lv_draw_rect_dsc, &be_class_ctypes, "lv_draw_rect_dsc");
|
||||
static be_define_ctypes_class(lv_event, &be_lv_event, &be_class_ctypes, "lv_event");
|
||||
static be_define_ctypes_class(lv_meter_indicator, &be_lv_meter_indicator, &be_class_ctypes, "lv_meter_indicator");
|
||||
static be_define_ctypes_class(lv_meter_indicator_arc, &be_lv_meter_indicator_arc, &be_class_ctypes, "lv_meter_indicator_arc");
|
||||
static be_define_ctypes_class(lv_meter_indicator_needle_img, &be_lv_meter_indicator_needle_img, &be_class_ctypes, "lv_meter_indicator_needle_img");
|
||||
static be_define_ctypes_class(lv_meter_indicator_needle_line, &be_lv_meter_indicator_needle_line, &be_class_ctypes, "lv_meter_indicator_needle_line");
|
||||
static be_define_ctypes_class(lv_meter_indicator_scale_lines, &be_lv_meter_indicator_scale_lines, &be_class_ctypes, "lv_meter_indicator_scale_lines");
|
||||
static be_define_ctypes_class(lv_meter_scale, &be_lv_meter_scale, &be_class_ctypes, "lv_meter_scale");
|
||||
static be_define_ctypes_class(lv_obj_class, &be_lv_obj_class, &be_class_ctypes, "lv_obj_class");
|
||||
static be_define_ctypes_class(lv_point, &be_lv_point, &be_class_ctypes, "lv_point");
|
||||
static be_define_ctypes_class(lv_sqrt_res, &be_lv_sqrt_res, &be_class_ctypes, "lv_sqrt_res");
|
||||
|
||||
void be_load_ctypes_lvgl_definitions_lib(bvm *vm) {
|
||||
ctypes_register_class(vm, &be_class_lv_area, &be_lv_area);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_img_dsc, &be_lv_draw_img_dsc);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_line_dsc, &be_lv_draw_line_dsc);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_angle_param, &be_lv_draw_mask_angle_param);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_angle_param_cfg, &be_lv_draw_mask_angle_param_cfg);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_common_dsc, &be_lv_draw_mask_common_dsc);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_fade_param, &be_lv_draw_mask_fade_param);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_fade_param_cfg, &be_lv_draw_mask_fade_param_cfg);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_line_param, &be_lv_draw_mask_line_param);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_line_param_cfg, &be_lv_draw_mask_line_param_cfg);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_map_param, &be_lv_draw_mask_map_param);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_map_param_cfg, &be_lv_draw_mask_map_param_cfg);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_radius_param, &be_lv_draw_mask_radius_param);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_radius_param_cfg, &be_lv_draw_mask_radius_param_cfg);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_mask_saved, &be_lv_draw_mask_saved);
|
||||
ctypes_register_class(vm, &be_class_lv_draw_rect_dsc, &be_lv_draw_rect_dsc);
|
||||
ctypes_register_class(vm, &be_class_lv_event, &be_lv_event);
|
||||
ctypes_register_class(vm, &be_class_lv_meter_indicator, &be_lv_meter_indicator);
|
||||
ctypes_register_class(vm, &be_class_lv_meter_indicator_arc, &be_lv_meter_indicator_arc);
|
||||
ctypes_register_class(vm, &be_class_lv_meter_indicator_needle_img, &be_lv_meter_indicator_needle_img);
|
||||
ctypes_register_class(vm, &be_class_lv_meter_indicator_needle_line, &be_lv_meter_indicator_needle_line);
|
||||
ctypes_register_class(vm, &be_class_lv_meter_indicator_scale_lines, &be_lv_meter_indicator_scale_lines);
|
||||
ctypes_register_class(vm, &be_class_lv_meter_scale, &be_lv_meter_scale);
|
||||
ctypes_register_class(vm, &be_class_lv_obj_class, &be_lv_obj_class);
|
||||
ctypes_register_class(vm, &be_class_lv_point, &be_lv_point);
|
||||
ctypes_register_class(vm, &be_class_lv_sqrt_res, &be_lv_sqrt_res);
|
||||
}
|
||||
|
||||
be_ctypes_class_by_name_t be_ctypes_lvgl_classes[] = {
|
||||
{ "lv_area", &be_class_lv_area },
|
||||
{ "lv_draw_img_dsc", &be_class_lv_draw_img_dsc },
|
||||
{ "lv_draw_line_dsc", &be_class_lv_draw_line_dsc },
|
||||
{ "lv_draw_mask_angle_param", &be_class_lv_draw_mask_angle_param },
|
||||
{ "lv_draw_mask_angle_param_cfg", &be_class_lv_draw_mask_angle_param_cfg },
|
||||
{ "lv_draw_mask_common_dsc", &be_class_lv_draw_mask_common_dsc },
|
||||
{ "lv_draw_mask_fade_param", &be_class_lv_draw_mask_fade_param },
|
||||
{ "lv_draw_mask_fade_param_cfg", &be_class_lv_draw_mask_fade_param_cfg },
|
||||
{ "lv_draw_mask_line_param", &be_class_lv_draw_mask_line_param },
|
||||
{ "lv_draw_mask_line_param_cfg", &be_class_lv_draw_mask_line_param_cfg },
|
||||
{ "lv_draw_mask_map_param", &be_class_lv_draw_mask_map_param },
|
||||
{ "lv_draw_mask_map_param_cfg", &be_class_lv_draw_mask_map_param_cfg },
|
||||
{ "lv_draw_mask_radius_param", &be_class_lv_draw_mask_radius_param },
|
||||
{ "lv_draw_mask_radius_param_cfg", &be_class_lv_draw_mask_radius_param_cfg },
|
||||
{ "lv_draw_mask_saved", &be_class_lv_draw_mask_saved },
|
||||
{ "lv_draw_rect_dsc", &be_class_lv_draw_rect_dsc },
|
||||
{ "lv_event", &be_class_lv_event },
|
||||
{ "lv_meter_indicator", &be_class_lv_meter_indicator },
|
||||
{ "lv_meter_indicator_arc", &be_class_lv_meter_indicator_arc },
|
||||
{ "lv_meter_indicator_needle_img", &be_class_lv_meter_indicator_needle_img },
|
||||
{ "lv_meter_indicator_needle_line", &be_class_lv_meter_indicator_needle_line },
|
||||
{ "lv_meter_indicator_scale_lines", &be_class_lv_meter_indicator_scale_lines },
|
||||
{ "lv_meter_scale", &be_class_lv_meter_scale },
|
||||
{ "lv_obj_class", &be_class_lv_obj_class },
|
||||
{ "lv_point", &be_class_lv_point },
|
||||
{ "lv_sqrt_res", &be_class_lv_sqrt_res },
|
||||
};
|
||||
const size_t be_ctypes_lvgl_classes_size = sizeof(be_ctypes_lvgl_classes)/sizeof(be_ctypes_lvgl_classes[0]);
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,826 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_object_from_ptr
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_get_object_from_ptr, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(cb_obj),
|
||||
/* K1 */ be_nested_str(find),
|
||||
}),
|
||||
&be_const_str_get_object_from_ptr,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[10]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x4C0C0000, // 0001 LDNIL R3
|
||||
0x20080403, // 0002 NE R2 R2 R3
|
||||
0x780A0004, // 0003 JMPF R2 #0009
|
||||
0x88080100, // 0004 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0005 GETMET R2 R2 K1
|
||||
0x5C100200, // 0006 MOVE R4 R1
|
||||
0x7C080400, // 0007 CALL R2 2
|
||||
0x80040400, // 0008 RET 1 R2
|
||||
0x80000000, // 0009 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: widget_event_impl
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_widget_event_impl, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 9]) { /* constants */
|
||||
/* K0 */ be_nested_str(introspect),
|
||||
/* K1 */ be_nested_str(lv),
|
||||
/* K2 */ be_nested_str(lv_obj_class),
|
||||
/* K3 */ be_nested_str(lv_event),
|
||||
/* K4 */ be_nested_str(target),
|
||||
/* K5 */ be_nested_str(get_object_from_ptr),
|
||||
/* K6 */ be_nested_str(instance),
|
||||
/* K7 */ be_nested_str(get),
|
||||
/* K8 */ be_nested_str(widget_event),
|
||||
}),
|
||||
&be_const_str_widget_event_impl,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[28]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0xB8120200, // 0001 GETNGBL R4 K1
|
||||
0x8C100902, // 0002 GETMET R4 R4 K2
|
||||
0x5C180200, // 0003 MOVE R6 R1
|
||||
0x7C100400, // 0004 CALL R4 2
|
||||
0xB8160200, // 0005 GETNGBL R5 K1
|
||||
0x8C140B03, // 0006 GETMET R5 R5 K3
|
||||
0x5C1C0400, // 0007 MOVE R7 R2
|
||||
0x7C140400, // 0008 CALL R5 2
|
||||
0x88180B04, // 0009 GETMBR R6 R5 K4
|
||||
0x8C1C0105, // 000A GETMET R7 R0 K5
|
||||
0x5C240C00, // 000B MOVE R9 R6
|
||||
0x7C1C0400, // 000C CALL R7 2
|
||||
0x60200004, // 000D GETGBL R8 G4
|
||||
0x5C240E00, // 000E MOVE R9 R7
|
||||
0x7C200200, // 000F CALL R8 1
|
||||
0x1C201106, // 0010 EQ R8 R8 K6
|
||||
0x78220008, // 0011 JMPF R8 #001B
|
||||
0x8C200707, // 0012 GETMET R8 R3 K7
|
||||
0x5C280E00, // 0013 MOVE R10 R7
|
||||
0x582C0008, // 0014 LDCONST R11 K8
|
||||
0x7C200600, // 0015 CALL R8 3
|
||||
0x78220003, // 0016 JMPF R8 #001B
|
||||
0x8C200F08, // 0017 GETMET R8 R7 K8
|
||||
0x5C280800, // 0018 MOVE R10 R4
|
||||
0x5C2C0A00, // 0019 MOVE R11 R5
|
||||
0x7C200600, // 001A CALL R8 3
|
||||
0x80000000, // 001B RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: lvgl_event_dispatch
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_lvgl_event_dispatch, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(introspect),
|
||||
/* K1 */ be_nested_str(lv),
|
||||
/* K2 */ be_nested_str(lv_event),
|
||||
/* K3 */ be_nested_str(toptr),
|
||||
/* K4 */ be_nested_str(target),
|
||||
/* K5 */ be_nested_str(cb_event_closure),
|
||||
/* K6 */ be_nested_str(get_object_from_ptr),
|
||||
}),
|
||||
&be_const_str_lvgl_event_dispatch,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[18]) { /* code */
|
||||
0xA40A0000, // 0000 IMPORT R2 K0
|
||||
0xB80E0200, // 0001 GETNGBL R3 K1
|
||||
0x8C0C0702, // 0002 GETMET R3 R3 K2
|
||||
0x8C140503, // 0003 GETMET R5 R2 K3
|
||||
0x5C1C0200, // 0004 MOVE R7 R1
|
||||
0x7C140400, // 0005 CALL R5 2
|
||||
0x7C0C0400, // 0006 CALL R3 2
|
||||
0x88100704, // 0007 GETMBR R4 R3 K4
|
||||
0x88140105, // 0008 GETMBR R5 R0 K5
|
||||
0x94140A04, // 0009 GETIDX R5 R5 R4
|
||||
0x8C180106, // 000A GETMET R6 R0 K6
|
||||
0x5C200800, // 000B MOVE R8 R4
|
||||
0x7C180400, // 000C CALL R6 2
|
||||
0x5C1C0A00, // 000D MOVE R7 R5
|
||||
0x5C200C00, // 000E MOVE R8 R6
|
||||
0x5C240600, // 000F MOVE R9 R3
|
||||
0x7C1C0400, // 0010 CALL R7 2
|
||||
0x80000000, // 0011 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: widget_dtor_impl
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_widget_dtor_impl, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(introspect),
|
||||
/* K1 */ be_nested_str(lv),
|
||||
/* K2 */ be_nested_str(lv_obj_class),
|
||||
/* K3 */ be_nested_str(get_object_from_ptr),
|
||||
/* K4 */ be_nested_str(instance),
|
||||
/* K5 */ be_nested_str(get),
|
||||
/* K6 */ be_nested_str(widget_destructor),
|
||||
}),
|
||||
&be_const_str_widget_dtor_impl,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[22]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0xB8120200, // 0001 GETNGBL R4 K1
|
||||
0x8C100902, // 0002 GETMET R4 R4 K2
|
||||
0x5C180200, // 0003 MOVE R6 R1
|
||||
0x7C100400, // 0004 CALL R4 2
|
||||
0x8C140103, // 0005 GETMET R5 R0 K3
|
||||
0x5C1C0400, // 0006 MOVE R7 R2
|
||||
0x7C140400, // 0007 CALL R5 2
|
||||
0x60180004, // 0008 GETGBL R6 G4
|
||||
0x5C1C0A00, // 0009 MOVE R7 R5
|
||||
0x7C180200, // 000A CALL R6 1
|
||||
0x1C180D04, // 000B EQ R6 R6 K4
|
||||
0x781A0007, // 000C JMPF R6 #0015
|
||||
0x8C180705, // 000D GETMET R6 R3 K5
|
||||
0x5C200A00, // 000E MOVE R8 R5
|
||||
0x58240006, // 000F LDCONST R9 K6
|
||||
0x7C180600, // 0010 CALL R6 3
|
||||
0x781A0002, // 0011 JMPF R6 #0015
|
||||
0x8C180B06, // 0012 GETMET R6 R5 K6
|
||||
0x5C200800, // 0013 MOVE R8 R4
|
||||
0x7C180400, // 0014 CALL R6 2
|
||||
0x80000000, // 0015 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: register_obj
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_register_obj, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(cb_obj),
|
||||
/* K1 */ be_nested_str(_p),
|
||||
}),
|
||||
&be_const_str_register_obj,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[11]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x4C0C0000, // 0001 LDNIL R3
|
||||
0x1C080403, // 0002 EQ R2 R2 R3
|
||||
0x780A0002, // 0003 JMPF R2 #0007
|
||||
0x60080013, // 0004 GETGBL R2 G19
|
||||
0x7C080000, // 0005 CALL R2 0
|
||||
0x90020002, // 0006 SETMBR R0 K0 R2
|
||||
0x88080301, // 0007 GETMBR R2 R1 K1
|
||||
0x880C0100, // 0008 GETMBR R3 R0 K0
|
||||
0x980C0401, // 0009 SETIDX R3 R2 R1
|
||||
0x80000000, // 000A RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: gen_cb
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_gen_cb, /* name */
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
5, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
1, /* has sup protos */
|
||||
( &(const struct bproto*[ 1]) {
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
1, /* has upvals */
|
||||
( &(const bupvaldesc[ 1]) { /* upvals */
|
||||
be_local_const_upval(1, 0),
|
||||
}),
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(lvgl_event_dispatch),
|
||||
}),
|
||||
&be_const_str__X3Clambda_X3E,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x68040000, // 0000 GETUPV R1 U0
|
||||
0x8C040300, // 0001 GETMET R1 R1 K0
|
||||
0x5C0C0000, // 0002 MOVE R3 R0
|
||||
0x7C040400, // 0003 CALL R1 2
|
||||
0x80040200, // 0004 RET 1 R1
|
||||
})
|
||||
),
|
||||
}),
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 8]) { /* constants */
|
||||
/* K0 */ be_nested_str(lv_event_cb),
|
||||
/* K1 */ be_nested_str(cb_event_closure),
|
||||
/* K2 */ be_nested_str(event_cb),
|
||||
/* K3 */ be_nested_str(tasmota),
|
||||
/* K4 */ be_nested_str(gen_cb),
|
||||
/* K5 */ be_nested_str(register_obj),
|
||||
/* K6 */ be_nested_str(null_cb),
|
||||
/* K7 */ be_nested_str(cb_do_nothing),
|
||||
}),
|
||||
&be_const_str_gen_cb,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[41]) { /* code */
|
||||
0x1C140300, // 0000 EQ R5 R1 K0
|
||||
0x78160018, // 0001 JMPF R5 #001B
|
||||
0x88140101, // 0002 GETMBR R5 R0 K1
|
||||
0x4C180000, // 0003 LDNIL R6
|
||||
0x1C140A06, // 0004 EQ R5 R5 R6
|
||||
0x78160002, // 0005 JMPF R5 #0009
|
||||
0x60140013, // 0006 GETGBL R5 G19
|
||||
0x7C140000, // 0007 CALL R5 0
|
||||
0x90020205, // 0008 SETMBR R0 K1 R5
|
||||
0x88140102, // 0009 GETMBR R5 R0 K2
|
||||
0x4C180000, // 000A LDNIL R6
|
||||
0x1C140A06, // 000B EQ R5 R5 R6
|
||||
0x78160004, // 000C JMPF R5 #0012
|
||||
0xB8160600, // 000D GETNGBL R5 K3
|
||||
0x8C140B04, // 000E GETMET R5 R5 K4
|
||||
0x841C0000, // 000F CLOSURE R7 P0
|
||||
0x7C140400, // 0010 CALL R5 2
|
||||
0x90020405, // 0011 SETMBR R0 K2 R5
|
||||
0x8C140105, // 0012 GETMET R5 R0 K5
|
||||
0x5C1C0600, // 0013 MOVE R7 R3
|
||||
0x7C140400, // 0014 CALL R5 2
|
||||
0x88140101, // 0015 GETMBR R5 R0 K1
|
||||
0x98140802, // 0016 SETIDX R5 R4 R2
|
||||
0x88140102, // 0017 GETMBR R5 R0 K2
|
||||
0xA0000000, // 0018 CLOSE R0
|
||||
0x80040A00, // 0019 RET 1 R5
|
||||
0x7002000B, // 001A JMP #0027
|
||||
0x88140106, // 001B GETMBR R5 R0 K6
|
||||
0x4C180000, // 001C LDNIL R6
|
||||
0x1C140A06, // 001D EQ R5 R5 R6
|
||||
0x78160004, // 001E JMPF R5 #0024
|
||||
0xB8160600, // 001F GETNGBL R5 K3
|
||||
0x8C140B04, // 0020 GETMET R5 R5 K4
|
||||
0x881C0107, // 0021 GETMBR R7 R0 K7
|
||||
0x7C140400, // 0022 CALL R5 2
|
||||
0x90020C05, // 0023 SETMBR R0 K6 R5
|
||||
0x88140106, // 0024 GETMBR R5 R0 K6
|
||||
0xA0000000, // 0025 CLOSE R0
|
||||
0x80040A00, // 0026 RET 1 R5
|
||||
0xA0000000, // 0027 CLOSE R0
|
||||
0x80000000, // 0028 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: deregister_obj
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_deregister_obj, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(cb_obj),
|
||||
/* K1 */ be_nested_str(remove),
|
||||
/* K2 */ be_nested_str(cb_event_closure),
|
||||
}),
|
||||
&be_const_str_deregister_obj,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[17]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x4C0C0000, // 0001 LDNIL R3
|
||||
0x20080403, // 0002 NE R2 R2 R3
|
||||
0x780A0003, // 0003 JMPF R2 #0008
|
||||
0x88080100, // 0004 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0005 GETMET R2 R2 K1
|
||||
0x5C100200, // 0006 MOVE R4 R1
|
||||
0x7C080400, // 0007 CALL R2 2
|
||||
0x88080102, // 0008 GETMBR R2 R0 K2
|
||||
0x4C0C0000, // 0009 LDNIL R3
|
||||
0x20080403, // 000A NE R2 R2 R3
|
||||
0x780A0003, // 000B JMPF R2 #0010
|
||||
0x88080102, // 000C GETMBR R2 R0 K2
|
||||
0x8C080501, // 000D GETMET R2 R2 K1
|
||||
0x5C100200, // 000E MOVE R4 R1
|
||||
0x7C080400, // 000F CALL R2 2
|
||||
0x80000000, // 0010 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: widget_cb
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_widget_cb, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
1, /* has sup protos */
|
||||
( &(const struct bproto*[ 3]) {
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
1, /* has upvals */
|
||||
( &(const bupvaldesc[ 1]) { /* upvals */
|
||||
be_local_const_upval(1, 0),
|
||||
}),
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(widget_ctor_impl),
|
||||
}),
|
||||
&be_const_str__X3Clambda_X3E,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x68080000, // 0000 GETUPV R2 U0
|
||||
0x8C080500, // 0001 GETMET R2 R2 K0
|
||||
0x5C100000, // 0002 MOVE R4 R0
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x7C080600, // 0004 CALL R2 3
|
||||
0x80040400, // 0005 RET 1 R2
|
||||
})
|
||||
),
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
1, /* has upvals */
|
||||
( &(const bupvaldesc[ 1]) { /* upvals */
|
||||
be_local_const_upval(1, 0),
|
||||
}),
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(widget_dtor_impl),
|
||||
}),
|
||||
&be_const_str__X3Clambda_X3E,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x68080000, // 0000 GETUPV R2 U0
|
||||
0x8C080500, // 0001 GETMET R2 R2 K0
|
||||
0x5C100000, // 0002 MOVE R4 R0
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x7C080600, // 0004 CALL R2 3
|
||||
0x80040400, // 0005 RET 1 R2
|
||||
})
|
||||
),
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
1, /* has upvals */
|
||||
( &(const bupvaldesc[ 1]) { /* upvals */
|
||||
be_local_const_upval(1, 0),
|
||||
}),
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(widget_event_impl),
|
||||
}),
|
||||
&be_const_str__X3Clambda_X3E,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x68080000, // 0000 GETUPV R2 U0
|
||||
0x8C080500, // 0001 GETMET R2 R2 K0
|
||||
0x5C100000, // 0002 MOVE R4 R0
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x7C080600, // 0004 CALL R2 3
|
||||
0x80040400, // 0005 RET 1 R2
|
||||
})
|
||||
),
|
||||
}),
|
||||
1, /* has constants */
|
||||
( &(const bvalue[15]) { /* constants */
|
||||
/* K0 */ be_nested_str(widget_ctor_cb),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(gen_cb),
|
||||
/* K3 */ be_nested_str(widget_dtor_cb),
|
||||
/* K4 */ be_nested_str(widget_event_cb),
|
||||
/* K5 */ be_nested_str(widget_struct_default),
|
||||
/* K6 */ be_nested_str(lv),
|
||||
/* K7 */ be_nested_str(lv_obj_class),
|
||||
/* K8 */ be_nested_str(lv_obj),
|
||||
/* K9 */ be_nested_str(_class),
|
||||
/* K10 */ be_nested_str(copy),
|
||||
/* K11 */ be_nested_str(base_class),
|
||||
/* K12 */ be_nested_str(constructor_cb),
|
||||
/* K13 */ be_nested_str(destructor_cb),
|
||||
/* K14 */ be_nested_str(event_cb),
|
||||
}),
|
||||
&be_const_str_widget_cb,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[56]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x4C080000, // 0001 LDNIL R2
|
||||
0x1C040202, // 0002 EQ R1 R1 R2
|
||||
0x78060004, // 0003 JMPF R1 #0009
|
||||
0xB8060200, // 0004 GETNGBL R1 K1
|
||||
0x8C040302, // 0005 GETMET R1 R1 K2
|
||||
0x840C0000, // 0006 CLOSURE R3 P0
|
||||
0x7C040400, // 0007 CALL R1 2
|
||||
0x90020001, // 0008 SETMBR R0 K0 R1
|
||||
0x88040103, // 0009 GETMBR R1 R0 K3
|
||||
0x4C080000, // 000A LDNIL R2
|
||||
0x1C040202, // 000B EQ R1 R1 R2
|
||||
0x78060004, // 000C JMPF R1 #0012
|
||||
0xB8060200, // 000D GETNGBL R1 K1
|
||||
0x8C040302, // 000E GETMET R1 R1 K2
|
||||
0x840C0001, // 000F CLOSURE R3 P1
|
||||
0x7C040400, // 0010 CALL R1 2
|
||||
0x90020601, // 0011 SETMBR R0 K3 R1
|
||||
0x88040104, // 0012 GETMBR R1 R0 K4
|
||||
0x4C080000, // 0013 LDNIL R2
|
||||
0x1C040202, // 0014 EQ R1 R1 R2
|
||||
0x78060004, // 0015 JMPF R1 #001B
|
||||
0xB8060200, // 0016 GETNGBL R1 K1
|
||||
0x8C040302, // 0017 GETMET R1 R1 K2
|
||||
0x840C0002, // 0018 CLOSURE R3 P2
|
||||
0x7C040400, // 0019 CALL R1 2
|
||||
0x90020801, // 001A SETMBR R0 K4 R1
|
||||
0x88040105, // 001B GETMBR R1 R0 K5
|
||||
0x4C080000, // 001C LDNIL R2
|
||||
0x1C040202, // 001D EQ R1 R1 R2
|
||||
0x78060016, // 001E JMPF R1 #0036
|
||||
0xB8060C00, // 001F GETNGBL R1 K6
|
||||
0x8C040307, // 0020 GETMET R1 R1 K7
|
||||
0xB80E0C00, // 0021 GETNGBL R3 K6
|
||||
0x880C0708, // 0022 GETMBR R3 R3 K8
|
||||
0x880C0709, // 0023 GETMBR R3 R3 K9
|
||||
0x7C040400, // 0024 CALL R1 2
|
||||
0x8C04030A, // 0025 GETMET R1 R1 K10
|
||||
0x7C040200, // 0026 CALL R1 1
|
||||
0x90020A01, // 0027 SETMBR R0 K5 R1
|
||||
0x88040105, // 0028 GETMBR R1 R0 K5
|
||||
0xB80A0C00, // 0029 GETNGBL R2 K6
|
||||
0x88080508, // 002A GETMBR R2 R2 K8
|
||||
0x88080509, // 002B GETMBR R2 R2 K9
|
||||
0x90061602, // 002C SETMBR R1 K11 R2
|
||||
0x88040105, // 002D GETMBR R1 R0 K5
|
||||
0x88080100, // 002E GETMBR R2 R0 K0
|
||||
0x90061802, // 002F SETMBR R1 K12 R2
|
||||
0x88040105, // 0030 GETMBR R1 R0 K5
|
||||
0x88080103, // 0031 GETMBR R2 R0 K3
|
||||
0x90061A02, // 0032 SETMBR R1 K13 R2
|
||||
0x88040105, // 0033 GETMBR R1 R0 K5
|
||||
0x88080104, // 0034 GETMBR R2 R0 K4
|
||||
0x90061C02, // 0035 SETMBR R1 K14 R2
|
||||
0xA0000000, // 0036 CLOSE R0
|
||||
0x80000000, // 0037 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: _anonymous_
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob__anonymous_, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
0, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(LVG_X3A_X20call_X20to_X20unsupported_X20callback),
|
||||
}),
|
||||
&be_const_str__anonymous_,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 4]) { /* code */
|
||||
0x60000001, // 0000 GETGBL R0 G1
|
||||
0x58040000, // 0001 LDCONST R1 K0
|
||||
0x7C000200, // 0002 CALL R0 1
|
||||
0x80000000, // 0003 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: create_custom_widget
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_create_custom_widget, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[27]) { /* constants */
|
||||
/* K0 */ be_nested_str(introspect),
|
||||
/* K1 */ be_nested_str(lv),
|
||||
/* K2 */ be_nested_str(lv_obj),
|
||||
/* K3 */ be_nested_str(value_error),
|
||||
/* K4 */ be_nested_str(arg_X20must_X20be_X20a_X20subclass_X20of_X20lv_obj),
|
||||
/* K5 */ be_nested_str(widget_struct_by_class),
|
||||
/* K6 */ be_nested_str(find),
|
||||
/* K7 */ be_nested_str(widget_cb),
|
||||
/* K8 */ be_nested_str(widget_struct_default),
|
||||
/* K9 */ be_nested_str(copy),
|
||||
/* K10 */ be_nested_str(base_class),
|
||||
/* K11 */ be_nested_str(_class),
|
||||
/* K12 */ be_nested_str(get),
|
||||
/* K13 */ be_nested_str(widget_width_def),
|
||||
/* K14 */ be_nested_str(width_def),
|
||||
/* K15 */ be_nested_str(widget_height_def),
|
||||
/* K16 */ be_nested_str(height_def),
|
||||
/* K17 */ be_nested_str(widget_editable),
|
||||
/* K18 */ be_nested_str(editable),
|
||||
/* K19 */ be_nested_str(widget_group_def),
|
||||
/* K20 */ be_nested_str(group_def),
|
||||
/* K21 */ be_nested_str(widget_instance_size),
|
||||
/* K22 */ be_nested_str(instance_size),
|
||||
/* K23 */ be_nested_str(obj_class_create_obj),
|
||||
/* K24 */ be_nested_str(_p),
|
||||
/* K25 */ be_nested_str(register_obj),
|
||||
/* K26 */ be_nested_str(class_init_obj),
|
||||
}),
|
||||
&be_const_str_create_custom_widget,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[86]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0x6010000F, // 0001 GETGBL R4 G15
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0xB81A0200, // 0003 GETNGBL R6 K1
|
||||
0x88180D02, // 0004 GETMBR R6 R6 K2
|
||||
0x7C100400, // 0005 CALL R4 2
|
||||
0x74120000, // 0006 JMPT R4 #0008
|
||||
0xB0060704, // 0007 RAISE 1 K3 K4
|
||||
0x88100105, // 0008 GETMBR R4 R0 K5
|
||||
0x4C140000, // 0009 LDNIL R5
|
||||
0x1C100805, // 000A EQ R4 R4 R5
|
||||
0x78120002, // 000B JMPF R4 #000F
|
||||
0x60100013, // 000C GETGBL R4 G19
|
||||
0x7C100000, // 000D CALL R4 0
|
||||
0x90020A04, // 000E SETMBR R0 K5 R4
|
||||
0x60100005, // 000F GETGBL R4 G5
|
||||
0x5C140200, // 0010 MOVE R5 R1
|
||||
0x7C100200, // 0011 CALL R4 1
|
||||
0x88140105, // 0012 GETMBR R5 R0 K5
|
||||
0x8C140B06, // 0013 GETMET R5 R5 K6
|
||||
0x5C1C0800, // 0014 MOVE R7 R4
|
||||
0x7C140400, // 0015 CALL R5 2
|
||||
0x4C180000, // 0016 LDNIL R6
|
||||
0x1C180A06, // 0017 EQ R6 R5 R6
|
||||
0x781A002F, // 0018 JMPF R6 #0049
|
||||
0x8C180107, // 0019 GETMET R6 R0 K7
|
||||
0x7C180200, // 001A CALL R6 1
|
||||
0x88180108, // 001B GETMBR R6 R0 K8
|
||||
0x8C180D09, // 001C GETMET R6 R6 K9
|
||||
0x7C180200, // 001D CALL R6 1
|
||||
0x5C140C00, // 001E MOVE R5 R6
|
||||
0x60180003, // 001F GETGBL R6 G3
|
||||
0x5C1C0200, // 0020 MOVE R7 R1
|
||||
0x7C180200, // 0021 CALL R6 1
|
||||
0x88180D0B, // 0022 GETMBR R6 R6 K11
|
||||
0x90161406, // 0023 SETMBR R5 K10 R6
|
||||
0x8C18070C, // 0024 GETMET R6 R3 K12
|
||||
0x5C200200, // 0025 MOVE R8 R1
|
||||
0x5824000D, // 0026 LDCONST R9 K13
|
||||
0x7C180600, // 0027 CALL R6 3
|
||||
0x781A0001, // 0028 JMPF R6 #002B
|
||||
0x8818030D, // 0029 GETMBR R6 R1 K13
|
||||
0x90161C06, // 002A SETMBR R5 K14 R6
|
||||
0x8C18070C, // 002B GETMET R6 R3 K12
|
||||
0x5C200200, // 002C MOVE R8 R1
|
||||
0x5824000F, // 002D LDCONST R9 K15
|
||||
0x7C180600, // 002E CALL R6 3
|
||||
0x781A0001, // 002F JMPF R6 #0032
|
||||
0x8818030F, // 0030 GETMBR R6 R1 K15
|
||||
0x90162006, // 0031 SETMBR R5 K16 R6
|
||||
0x8C18070C, // 0032 GETMET R6 R3 K12
|
||||
0x5C200200, // 0033 MOVE R8 R1
|
||||
0x58240011, // 0034 LDCONST R9 K17
|
||||
0x7C180600, // 0035 CALL R6 3
|
||||
0x781A0001, // 0036 JMPF R6 #0039
|
||||
0x88180311, // 0037 GETMBR R6 R1 K17
|
||||
0x90162406, // 0038 SETMBR R5 K18 R6
|
||||
0x8C18070C, // 0039 GETMET R6 R3 K12
|
||||
0x5C200200, // 003A MOVE R8 R1
|
||||
0x58240013, // 003B LDCONST R9 K19
|
||||
0x7C180600, // 003C CALL R6 3
|
||||
0x781A0001, // 003D JMPF R6 #0040
|
||||
0x88180313, // 003E GETMBR R6 R1 K19
|
||||
0x90162806, // 003F SETMBR R5 K20 R6
|
||||
0x8C18070C, // 0040 GETMET R6 R3 K12
|
||||
0x5C200200, // 0041 MOVE R8 R1
|
||||
0x58240015, // 0042 LDCONST R9 K21
|
||||
0x7C180600, // 0043 CALL R6 3
|
||||
0x781A0001, // 0044 JMPF R6 #0047
|
||||
0x88180315, // 0045 GETMBR R6 R1 K21
|
||||
0x90162C06, // 0046 SETMBR R5 K22 R6
|
||||
0x88180105, // 0047 GETMBR R6 R0 K5
|
||||
0x98180805, // 0048 SETIDX R6 R4 R5
|
||||
0xB81A0200, // 0049 GETNGBL R6 K1
|
||||
0x8C180D17, // 004A GETMET R6 R6 K23
|
||||
0x5C200A00, // 004B MOVE R8 R5
|
||||
0x5C240400, // 004C MOVE R9 R2
|
||||
0x7C180600, // 004D CALL R6 3
|
||||
0x881C0D18, // 004E GETMBR R7 R6 K24
|
||||
0x90063007, // 004F SETMBR R1 K24 R7
|
||||
0x8C1C0119, // 0050 GETMET R7 R0 K25
|
||||
0x5C240200, // 0051 MOVE R9 R1
|
||||
0x7C1C0400, // 0052 CALL R7 2
|
||||
0x8C1C031A, // 0053 GETMET R7 R1 K26
|
||||
0x7C1C0200, // 0054 CALL R7 1
|
||||
0x80000000, // 0055 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: widget_ctor_impl
|
||||
********************************************************************/
|
||||
be_local_closure(LVGL_glob_widget_ctor_impl, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 9]) { /* constants */
|
||||
/* K0 */ be_nested_str(introspect),
|
||||
/* K1 */ be_nested_str(lv),
|
||||
/* K2 */ be_nested_str(lv_obj_class),
|
||||
/* K3 */ be_nested_str(get_object_from_ptr),
|
||||
/* K4 */ be_nested_str(cb_obj),
|
||||
/* K5 */ be_nested_str(find),
|
||||
/* K6 */ be_nested_str(instance),
|
||||
/* K7 */ be_nested_str(get),
|
||||
/* K8 */ be_nested_str(widget_constructor),
|
||||
}),
|
||||
&be_const_str_widget_ctor_impl,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[29]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0xB8120200, // 0001 GETNGBL R4 K1
|
||||
0x8C100902, // 0002 GETMET R4 R4 K2
|
||||
0x5C180200, // 0003 MOVE R6 R1
|
||||
0x7C100400, // 0004 CALL R4 2
|
||||
0x8C140103, // 0005 GETMET R5 R0 K3
|
||||
0x5C1C0400, // 0006 MOVE R7 R2
|
||||
0x7C140400, // 0007 CALL R5 2
|
||||
0x88180104, // 0008 GETMBR R6 R0 K4
|
||||
0x8C180D05, // 0009 GETMET R6 R6 K5
|
||||
0x5C200A00, // 000A MOVE R8 R5
|
||||
0x7C180400, // 000B CALL R6 2
|
||||
0x781A0001, // 000C JMPF R6 #000F
|
||||
0x88180104, // 000D GETMBR R6 R0 K4
|
||||
0x94140C05, // 000E GETIDX R5 R6 R5
|
||||
0x60180004, // 000F GETGBL R6 G4
|
||||
0x5C1C0A00, // 0010 MOVE R7 R5
|
||||
0x7C180200, // 0011 CALL R6 1
|
||||
0x1C180D06, // 0012 EQ R6 R6 K6
|
||||
0x781A0007, // 0013 JMPF R6 #001C
|
||||
0x8C180707, // 0014 GETMET R6 R3 K7
|
||||
0x5C200A00, // 0015 MOVE R8 R5
|
||||
0x58240008, // 0016 LDCONST R9 K8
|
||||
0x7C180600, // 0017 CALL R6 3
|
||||
0x781A0002, // 0018 JMPF R6 #001C
|
||||
0x8C180B08, // 0019 GETMET R6 R5 K8
|
||||
0x5C200800, // 001A MOVE R8 R4
|
||||
0x7C180400, // 001B CALL R6 2
|
||||
0x80000000, // 001C RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: LVGL_glob
|
||||
********************************************************************/
|
||||
be_local_class(LVGL_glob,
|
||||
9,
|
||||
NULL,
|
||||
be_nested_map(20,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(widget_ctor_cb, 8), be_const_var(4) },
|
||||
{ be_const_key(get_object_from_ptr, 4), be_const_closure(LVGL_glob_get_object_from_ptr_closure) },
|
||||
{ be_const_key(cb_obj, 7), be_const_var(0) },
|
||||
{ be_const_key(widget_struct_by_class, -1), be_const_var(8) },
|
||||
{ be_const_key(widget_event_impl, -1), be_const_closure(LVGL_glob_widget_event_impl_closure) },
|
||||
{ be_const_key(widget_dtor_cb, 6), be_const_var(5) },
|
||||
{ be_const_key(cb_event_closure, -1), be_const_var(1) },
|
||||
{ be_const_key(cb_do_nothing, 16), be_const_static_closure(LVGL_glob__anonymous__closure) },
|
||||
{ be_const_key(null_cb, -1), be_const_var(3) },
|
||||
{ be_const_key(register_obj, -1), be_const_closure(LVGL_glob_register_obj_closure) },
|
||||
{ be_const_key(widget_dtor_impl, 9), be_const_closure(LVGL_glob_widget_dtor_impl_closure) },
|
||||
{ be_const_key(gen_cb, -1), be_const_closure(LVGL_glob_gen_cb_closure) },
|
||||
{ be_const_key(deregister_obj, -1), be_const_closure(LVGL_glob_deregister_obj_closure) },
|
||||
{ be_const_key(widget_struct_default, 12), be_const_var(7) },
|
||||
{ be_const_key(widget_event_cb, -1), be_const_var(6) },
|
||||
{ be_const_key(widget_cb, -1), be_const_closure(LVGL_glob_widget_cb_closure) },
|
||||
{ be_const_key(lvgl_event_dispatch, 3), be_const_closure(LVGL_glob_lvgl_event_dispatch_closure) },
|
||||
{ be_const_key(event_cb, -1), be_const_var(2) },
|
||||
{ be_const_key(create_custom_widget, -1), be_const_closure(LVGL_glob_create_custom_widget_closure) },
|
||||
{ be_const_key(widget_ctor_impl, -1), be_const_closure(LVGL_glob_widget_ctor_impl_closure) },
|
||||
})),
|
||||
be_str_literal("LVGL_glob")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_LVGL_glob_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_LVGL_glob);
|
||||
be_setglobal(vm, "LVGL_glob");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,692 @@
|
|||
/********************************************************************
|
||||
* Generated code, don't edit
|
||||
*******************************************************************/
|
||||
/********************************************************************
|
||||
* LVGL Module
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "be_lvgl.h"
|
||||
#include "lv_theme_openhasp.h"
|
||||
|
||||
extern int lv0_member(bvm *vm); // resolve virtual members
|
||||
|
||||
extern int lv0_start(bvm *vm);
|
||||
|
||||
extern int lv0_register_button_encoder(bvm *vm); // add buttons with encoder logic
|
||||
|
||||
extern int lv0_load_montserrat_font(bvm *vm);
|
||||
extern int lv0_load_seg7_font(bvm *vm);
|
||||
extern int lv0_load_robotocondensed_latin1_font(bvm *vm);
|
||||
extern int lv0_load_font(bvm *vm);
|
||||
extern int lv0_load_freetype_font(bvm *vm);
|
||||
|
||||
extern int lv0_screenshot(bvm *vm);
|
||||
|
||||
static int lv_get_hor_res(void) {
|
||||
return lv_disp_get_hor_res(lv_disp_get_default());
|
||||
}
|
||||
static int lv_get_ver_res(void) {
|
||||
return lv_disp_get_ver_res(lv_disp_get_default());
|
||||
}
|
||||
|
||||
/* `lv` methods */
|
||||
const lvbe_call_c_t lv_func[] = {
|
||||
|
||||
{ "clamp_height", (void*) &lv_clamp_height, "i", "iiii" },
|
||||
{ "clamp_width", (void*) &lv_clamp_width, "i", "iiii" },
|
||||
{ "color_mix", (void*) &lv_color_mix, "lv.lv_color", "(lv.lv_color)(lv.lv_color)i" },
|
||||
{ "dpx", (void*) &lv_dpx, "i", "i" },
|
||||
{ "draw_arc", (void*) &lv_draw_arc, "", "iiiii(lv.lv_area)(lv.lv_draw_arc_dsc)" },
|
||||
{ "draw_arc_dsc_init", (void*) &lv_draw_arc_dsc_init, "", "(lv.lv_draw_arc_dsc)" },
|
||||
{ "draw_arc_get_area", (void*) &lv_draw_arc_get_area, "", "iiiiiib(lv.lv_area)" },
|
||||
{ "draw_img", (void*) &lv_draw_img, "", "(lv.lv_area)(lv.lv_area).(lv.lv_draw_img_dsc)" },
|
||||
{ "draw_img_dsc_init", (void*) &lv_draw_img_dsc_init, "", "(lv.lv_draw_img_dsc)" },
|
||||
{ "draw_label", (void*) &lv_draw_label, "", "(lv.lv_area)(lv.lv_area)(lv.lv_draw_label_dsc)s(lv.lv_draw_label_hint)" },
|
||||
{ "draw_label_dsc_init", (void*) &lv_draw_label_dsc_init, "", "(lv.lv_draw_label_dsc)" },
|
||||
{ "draw_letter", (void*) &lv_draw_letter, "", "(lv.lv_point)(lv.lv_area)(lv.lv_font)i(lv.lv_color)ii" },
|
||||
{ "draw_line", (void*) &lv_draw_line, "", "(lv.lv_point)(lv.lv_point)(lv.lv_area)(lv.lv_draw_line_dsc)" },
|
||||
{ "draw_line_dsc_init", (void*) &lv_draw_line_dsc_init, "", "(lv.lv_draw_line_dsc)" },
|
||||
{ "draw_mask_add", (void*) &lv_draw_mask_add, "i", ".." },
|
||||
{ "draw_mask_angle_init", (void*) &lv_draw_mask_angle_init, "", "(lv.lv_draw_mask_angle_param)iiii" },
|
||||
{ "draw_mask_fade_init", (void*) &lv_draw_mask_fade_init, "", "(lv.lv_draw_mask_fade_param)(lv.lv_area)iiii" },
|
||||
{ "draw_mask_get_cnt", (void*) &lv_draw_mask_get_cnt, "i", "" },
|
||||
{ "draw_mask_line_angle_init", (void*) &lv_draw_mask_line_angle_init, "", "(lv.lv_draw_mask_line_param)iiii" },
|
||||
{ "draw_mask_line_points_init", (void*) &lv_draw_mask_line_points_init, "", "(lv.lv_draw_mask_line_param)iiiii" },
|
||||
{ "draw_mask_map_init", (void*) &lv_draw_mask_map_init, "", "(lv.lv_draw_mask_map_param)(lv.lv_area)(lv.lv_opa)" },
|
||||
{ "draw_mask_radius_init", (void*) &lv_draw_mask_radius_init, "", "(lv.lv_draw_mask_radius_param)(lv.lv_area)ib" },
|
||||
{ "draw_mask_remove_custom", (void*) &lv_draw_mask_remove_custom, ".", "." },
|
||||
{ "draw_mask_remove_id", (void*) &lv_draw_mask_remove_id, ".", "i" },
|
||||
{ "draw_polygon", (void*) &lv_draw_polygon, "", "ii(lv.lv_area)(lv.lv_draw_rect_dsc)" },
|
||||
{ "draw_rect", (void*) &lv_draw_rect, "", "(lv.lv_area)(lv.lv_area)(lv.lv_draw_rect_dsc)" },
|
||||
{ "draw_rect_dsc_init", (void*) &lv_draw_rect_dsc_init, "", "(lv.lv_draw_rect_dsc)" },
|
||||
{ "draw_triangle", (void*) &lv_draw_triangle, "", "i(lv.lv_area)(lv.lv_draw_rect_dsc)" },
|
||||
{ "event_register_id", (void*) &lv_event_register_id, "i", "" },
|
||||
{ "event_send", (void*) &lv_event_send, "i", "(lv.lv_obj)i." },
|
||||
{ "event_set_cover_res", (void*) &lv_event_set_cover_res, "", "(lv.lv_event)(lv.lv_cover_res)" },
|
||||
{ "event_set_ext_draw_size", (void*) &lv_event_set_ext_draw_size, "", "(lv.lv_event)i" },
|
||||
{ "get_hor_res", (void*) &lv_get_hor_res, "i", "" },
|
||||
{ "get_ver_res", (void*) &lv_get_ver_res, "i", "" },
|
||||
{ "group_get_default", (void*) &lv_group_get_default, "lv.lv_group", "" },
|
||||
{ "img_src_get_type", (void*) &lv_img_src_get_type, "i", "." },
|
||||
{ "indev_get_act", (void*) &lv_indev_get_act, "lv.lv_indev", "" },
|
||||
{ "indev_get_obj_act", (void*) &lv_indev_get_obj_act, "lv.lv_obj", "" },
|
||||
{ "indev_read_timer_cb", (void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" },
|
||||
{ "layer_sys", (void*) &lv_layer_sys, "lv.lv_obj", "" },
|
||||
{ "layer_top", (void*) &lv_layer_top, "lv.lv_obj", "" },
|
||||
{ "layout_register", (void*) &lv_layout_register, "i", "^lv_layout_update_cb^." },
|
||||
{ "obj_class_create_obj", (void*) &lv_obj_class_create_obj, "lv.lv_obj", "(lv._lv_obj_class)(lv.lv_obj)" },
|
||||
{ "obj_del_anim_ready_cb", (void*) &lv_obj_del_anim_ready_cb, "", "(lv.lv_anim)" },
|
||||
{ "obj_draw_dsc_init", (void*) &lv_obj_draw_dsc_init, "", "(lv.lv_obj_draw_part_dsc)(lv.lv_area)" },
|
||||
{ "obj_enable_style_refresh", (void*) &lv_obj_enable_style_refresh, "", "b" },
|
||||
{ "obj_event_base", (void*) &lv_obj_event_base, "i", "(lv.lv_obj_class)(lv.lv_event)" },
|
||||
{ "obj_report_style_change", (void*) &lv_obj_report_style_change, "", "(lv.lv_style)" },
|
||||
{ "obj_style_get_selector_part", (void*) &lv_obj_style_get_selector_part, "i", "i" },
|
||||
{ "obj_style_get_selector_state", (void*) &lv_obj_style_get_selector_state, "i", "i" },
|
||||
{ "refr_now", (void*) &lv_refr_now, "", "(lv.lv_disp)" },
|
||||
{ "scr_act", (void*) &lv_scr_act, "lv.lv_obj", "" },
|
||||
{ "scr_load", (void*) &lv_scr_load, "", "(lv.lv_obj)" },
|
||||
{ "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" },
|
||||
{ "theme_apply", (void*) &lv_theme_apply, "", "(lv.lv_obj)" },
|
||||
{ "theme_default_init", (void*) &lv_theme_default_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" },
|
||||
{ "theme_default_is_inited", (void*) &lv_theme_default_is_inited, "b", "" },
|
||||
{ "theme_get_color_primary", (void*) &lv_theme_get_color_primary, "lv.lv_color", "(lv.lv_obj)" },
|
||||
{ "theme_get_color_secondary", (void*) &lv_theme_get_color_secondary, "lv.lv_color", "(lv.lv_obj)" },
|
||||
{ "theme_get_font_large", (void*) &lv_theme_get_font_large, "lv.lv_font", "(lv.lv_obj)" },
|
||||
{ "theme_get_font_normal", (void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" },
|
||||
{ "theme_get_font_small", (void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" },
|
||||
{ "theme_get_from_obj", (void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" },
|
||||
{ "theme_mono_init", (void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" },
|
||||
{ "theme_openhasp_init", (void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" },
|
||||
{ "theme_openhasp_is_inited", (void*) &lv_theme_openhasp_is_inited, "b", "" },
|
||||
{ "theme_set_apply_cb", (void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" },
|
||||
{ "theme_set_parent", (void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" },
|
||||
|
||||
};
|
||||
const size_t lv_func_size = sizeof(lv_func) / sizeof(lv_func[0]);
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct be_constint_t {
|
||||
const char * name;
|
||||
int32_t value;
|
||||
} be_constint_t;
|
||||
|
||||
const be_constint_t lv0_constants[] = {
|
||||
|
||||
{ "ALIGN_BOTTOM_LEFT", LV_ALIGN_BOTTOM_LEFT },
|
||||
{ "ALIGN_BOTTOM_MID", LV_ALIGN_BOTTOM_MID },
|
||||
{ "ALIGN_BOTTOM_RIGHT", LV_ALIGN_BOTTOM_RIGHT },
|
||||
{ "ALIGN_CENTER", LV_ALIGN_CENTER },
|
||||
{ "ALIGN_DEFAULT", LV_ALIGN_DEFAULT },
|
||||
{ "ALIGN_LEFT_MID", LV_ALIGN_LEFT_MID },
|
||||
{ "ALIGN_OUT_BOTTOM_LEFT", LV_ALIGN_OUT_BOTTOM_LEFT },
|
||||
{ "ALIGN_OUT_BOTTOM_MID", LV_ALIGN_OUT_BOTTOM_MID },
|
||||
{ "ALIGN_OUT_BOTTOM_RIGHT", LV_ALIGN_OUT_BOTTOM_RIGHT },
|
||||
{ "ALIGN_OUT_LEFT_BOTTOM", LV_ALIGN_OUT_LEFT_BOTTOM },
|
||||
{ "ALIGN_OUT_LEFT_MID", LV_ALIGN_OUT_LEFT_MID },
|
||||
{ "ALIGN_OUT_LEFT_TOP", LV_ALIGN_OUT_LEFT_TOP },
|
||||
{ "ALIGN_OUT_RIGHT_BOTTOM", LV_ALIGN_OUT_RIGHT_BOTTOM },
|
||||
{ "ALIGN_OUT_RIGHT_MID", LV_ALIGN_OUT_RIGHT_MID },
|
||||
{ "ALIGN_OUT_RIGHT_TOP", LV_ALIGN_OUT_RIGHT_TOP },
|
||||
{ "ALIGN_OUT_TOP_LEFT", LV_ALIGN_OUT_TOP_LEFT },
|
||||
{ "ALIGN_OUT_TOP_MID", LV_ALIGN_OUT_TOP_MID },
|
||||
{ "ALIGN_OUT_TOP_RIGHT", LV_ALIGN_OUT_TOP_RIGHT },
|
||||
{ "ALIGN_RIGHT_MID", LV_ALIGN_RIGHT_MID },
|
||||
{ "ALIGN_TOP_LEFT", LV_ALIGN_TOP_LEFT },
|
||||
{ "ALIGN_TOP_MID", LV_ALIGN_TOP_MID },
|
||||
{ "ALIGN_TOP_RIGHT", LV_ALIGN_TOP_RIGHT },
|
||||
{ "ANIM_IMG_PART_MAIN", LV_ANIM_IMG_PART_MAIN },
|
||||
{ "ANIM_OFF", LV_ANIM_OFF },
|
||||
{ "ANIM_ON", LV_ANIM_ON },
|
||||
{ "ARC_MODE_NORMAL", LV_ARC_MODE_NORMAL },
|
||||
{ "ARC_MODE_REVERSE", LV_ARC_MODE_REVERSE },
|
||||
{ "ARC_MODE_SYMMETRICAL", LV_ARC_MODE_SYMMETRICAL },
|
||||
{ "BAR_MODE_NORMAL", LV_BAR_MODE_NORMAL },
|
||||
{ "BAR_MODE_RANGE", LV_BAR_MODE_RANGE },
|
||||
{ "BAR_MODE_SYMMETRICAL", LV_BAR_MODE_SYMMETRICAL },
|
||||
{ "BASE_DIR_AUTO", LV_BASE_DIR_AUTO },
|
||||
{ "BASE_DIR_LTR", LV_BASE_DIR_LTR },
|
||||
{ "BASE_DIR_NEUTRAL", LV_BASE_DIR_NEUTRAL },
|
||||
{ "BASE_DIR_RTL", LV_BASE_DIR_RTL },
|
||||
{ "BASE_DIR_WEAK", LV_BASE_DIR_WEAK },
|
||||
{ "BLEND_MODE_ADDITIVE", LV_BLEND_MODE_ADDITIVE },
|
||||
{ "BLEND_MODE_NORMAL", LV_BLEND_MODE_NORMAL },
|
||||
{ "BLEND_MODE_SUBTRACTIVE", LV_BLEND_MODE_SUBTRACTIVE },
|
||||
{ "BORDER_SIDE_BOTTOM", LV_BORDER_SIDE_BOTTOM },
|
||||
{ "BORDER_SIDE_FULL", LV_BORDER_SIDE_FULL },
|
||||
{ "BORDER_SIDE_INTERNAL", LV_BORDER_SIDE_INTERNAL },
|
||||
{ "BORDER_SIDE_LEFT", LV_BORDER_SIDE_LEFT },
|
||||
{ "BORDER_SIDE_NONE", LV_BORDER_SIDE_NONE },
|
||||
{ "BORDER_SIDE_RIGHT", LV_BORDER_SIDE_RIGHT },
|
||||
{ "BORDER_SIDE_TOP", LV_BORDER_SIDE_TOP },
|
||||
{ "BTNMATRIX_CTRL_CHECKABLE", LV_BTNMATRIX_CTRL_CHECKABLE },
|
||||
{ "BTNMATRIX_CTRL_CHECKED", LV_BTNMATRIX_CTRL_CHECKED },
|
||||
{ "BTNMATRIX_CTRL_CLICK_TRIG", LV_BTNMATRIX_CTRL_CLICK_TRIG },
|
||||
{ "BTNMATRIX_CTRL_CUSTOM_1", LV_BTNMATRIX_CTRL_CUSTOM_1 },
|
||||
{ "BTNMATRIX_CTRL_CUSTOM_2", LV_BTNMATRIX_CTRL_CUSTOM_2 },
|
||||
{ "BTNMATRIX_CTRL_DISABLED", LV_BTNMATRIX_CTRL_DISABLED },
|
||||
{ "BTNMATRIX_CTRL_HIDDEN", LV_BTNMATRIX_CTRL_HIDDEN },
|
||||
{ "BTNMATRIX_CTRL_NO_REPEAT", LV_BTNMATRIX_CTRL_NO_REPEAT },
|
||||
{ "BTNMATRIX_CTRL_RECOLOR", LV_BTNMATRIX_CTRL_RECOLOR },
|
||||
{ "CHART_AXIS_PRIMARY_X", LV_CHART_AXIS_PRIMARY_X },
|
||||
{ "CHART_AXIS_PRIMARY_Y", LV_CHART_AXIS_PRIMARY_Y },
|
||||
{ "CHART_AXIS_SECONDARY_X", LV_CHART_AXIS_SECONDARY_X },
|
||||
{ "CHART_AXIS_SECONDARY_Y", LV_CHART_AXIS_SECONDARY_Y },
|
||||
{ "CHART_TYPE_BAR", LV_CHART_TYPE_BAR },
|
||||
{ "CHART_TYPE_LINE", LV_CHART_TYPE_LINE },
|
||||
{ "CHART_TYPE_NONE", LV_CHART_TYPE_NONE },
|
||||
{ "CHART_TYPE_SCATTER", LV_CHART_TYPE_SCATTER },
|
||||
{ "CHART_UPDATE_MODE_CIRCULAR", LV_CHART_UPDATE_MODE_CIRCULAR },
|
||||
{ "CHART_UPDATE_MODE_SHIFT", LV_CHART_UPDATE_MODE_SHIFT },
|
||||
{ "COLORWHEEL_MODE_HUE", LV_COLORWHEEL_MODE_HUE },
|
||||
{ "COLORWHEEL_MODE_SATURATION", LV_COLORWHEEL_MODE_SATURATION },
|
||||
{ "COLORWHEEL_MODE_VALUE", LV_COLORWHEEL_MODE_VALUE },
|
||||
{ "COLOR_AQUA", (int32_t) 0x00FFFF },
|
||||
{ "COLOR_BLACK", (int32_t) 0x000000 },
|
||||
{ "COLOR_BLUE", (int32_t) 0x0000FF },
|
||||
{ "COLOR_CYAN", (int32_t) 0x00FFFF },
|
||||
{ "COLOR_GRAY", (int32_t) 0x808080 },
|
||||
{ "COLOR_GREEN", (int32_t) 0x008000 },
|
||||
{ "COLOR_LIME", (int32_t) 0x00FF00 },
|
||||
{ "COLOR_MAGENTA", (int32_t) 0xFF00FF },
|
||||
{ "COLOR_MAROON", (int32_t) 0x800000 },
|
||||
{ "COLOR_NAVY", (int32_t) 0x000080 },
|
||||
{ "COLOR_OLIVE", (int32_t) 0x808000 },
|
||||
{ "COLOR_PURPLE", (int32_t) 0x800080 },
|
||||
{ "COLOR_RED", (int32_t) 0xFF0000 },
|
||||
{ "COLOR_SILVER", (int32_t) 0xC0C0C0 },
|
||||
{ "COLOR_TEAL", (int32_t) 0x008080 },
|
||||
{ "COLOR_WHITE", (int32_t) 0xFFFFFF },
|
||||
{ "COLOR_YELLOW", (int32_t) 0xFFFF00 },
|
||||
{ "COVER_RES_COVER", LV_COVER_RES_COVER },
|
||||
{ "COVER_RES_MASKED", LV_COVER_RES_MASKED },
|
||||
{ "COVER_RES_NOT_COVER", LV_COVER_RES_NOT_COVER },
|
||||
{ "DIR_ALL", LV_DIR_ALL },
|
||||
{ "DIR_BOTTOM", LV_DIR_BOTTOM },
|
||||
{ "DIR_HOR", LV_DIR_HOR },
|
||||
{ "DIR_LEFT", LV_DIR_LEFT },
|
||||
{ "DIR_NONE", LV_DIR_NONE },
|
||||
{ "DIR_RIGHT", LV_DIR_RIGHT },
|
||||
{ "DIR_TOP", LV_DIR_TOP },
|
||||
{ "DIR_VER", LV_DIR_VER },
|
||||
{ "DISP_ROT_180", LV_DISP_ROT_180 },
|
||||
{ "DISP_ROT_270", LV_DISP_ROT_270 },
|
||||
{ "DISP_ROT_90", LV_DISP_ROT_90 },
|
||||
{ "DISP_ROT_NONE", LV_DISP_ROT_NONE },
|
||||
{ "DRAW_MASK_LINE_SIDE_BOTTOM", LV_DRAW_MASK_LINE_SIDE_BOTTOM },
|
||||
{ "DRAW_MASK_LINE_SIDE_LEFT", LV_DRAW_MASK_LINE_SIDE_LEFT },
|
||||
{ "DRAW_MASK_LINE_SIDE_RIGHT", LV_DRAW_MASK_LINE_SIDE_RIGHT },
|
||||
{ "DRAW_MASK_LINE_SIDE_TOP", LV_DRAW_MASK_LINE_SIDE_TOP },
|
||||
{ "DRAW_MASK_RES_CHANGED", LV_DRAW_MASK_RES_CHANGED },
|
||||
{ "DRAW_MASK_RES_FULL_COVER", LV_DRAW_MASK_RES_FULL_COVER },
|
||||
{ "DRAW_MASK_RES_TRANSP", LV_DRAW_MASK_RES_TRANSP },
|
||||
{ "DRAW_MASK_RES_UNKNOWN", LV_DRAW_MASK_RES_UNKNOWN },
|
||||
{ "DRAW_MASK_TYPE_ANGLE", LV_DRAW_MASK_TYPE_ANGLE },
|
||||
{ "DRAW_MASK_TYPE_FADE", LV_DRAW_MASK_TYPE_FADE },
|
||||
{ "DRAW_MASK_TYPE_LINE", LV_DRAW_MASK_TYPE_LINE },
|
||||
{ "DRAW_MASK_TYPE_MAP", LV_DRAW_MASK_TYPE_MAP },
|
||||
{ "DRAW_MASK_TYPE_RADIUS", LV_DRAW_MASK_TYPE_RADIUS },
|
||||
{ "EVENT_ALL", LV_EVENT_ALL },
|
||||
{ "EVENT_CANCEL", LV_EVENT_CANCEL },
|
||||
{ "EVENT_CHILD_CHANGED", LV_EVENT_CHILD_CHANGED },
|
||||
{ "EVENT_CLICKED", LV_EVENT_CLICKED },
|
||||
{ "EVENT_COVER_CHECK", LV_EVENT_COVER_CHECK },
|
||||
{ "EVENT_DEFOCUSED", LV_EVENT_DEFOCUSED },
|
||||
{ "EVENT_DELETE", LV_EVENT_DELETE },
|
||||
{ "EVENT_DRAW_MAIN", LV_EVENT_DRAW_MAIN },
|
||||
{ "EVENT_DRAW_MAIN_BEGIN", LV_EVENT_DRAW_MAIN_BEGIN },
|
||||
{ "EVENT_DRAW_MAIN_END", LV_EVENT_DRAW_MAIN_END },
|
||||
{ "EVENT_DRAW_PART_BEGIN", LV_EVENT_DRAW_PART_BEGIN },
|
||||
{ "EVENT_DRAW_PART_END", LV_EVENT_DRAW_PART_END },
|
||||
{ "EVENT_DRAW_POST", LV_EVENT_DRAW_POST },
|
||||
{ "EVENT_DRAW_POST_BEGIN", LV_EVENT_DRAW_POST_BEGIN },
|
||||
{ "EVENT_DRAW_POST_END", LV_EVENT_DRAW_POST_END },
|
||||
{ "EVENT_FOCUSED", LV_EVENT_FOCUSED },
|
||||
{ "EVENT_GESTURE", LV_EVENT_GESTURE },
|
||||
{ "EVENT_GET_SELF_SIZE", LV_EVENT_GET_SELF_SIZE },
|
||||
{ "EVENT_HIT_TEST", LV_EVENT_HIT_TEST },
|
||||
{ "EVENT_INSERT", LV_EVENT_INSERT },
|
||||
{ "EVENT_KEY", LV_EVENT_KEY },
|
||||
{ "EVENT_LAYOUT_CHANGED", LV_EVENT_LAYOUT_CHANGED },
|
||||
{ "EVENT_LEAVE", LV_EVENT_LEAVE },
|
||||
{ "EVENT_LONG_PRESSED", LV_EVENT_LONG_PRESSED },
|
||||
{ "EVENT_LONG_PRESSED_REPEAT", LV_EVENT_LONG_PRESSED_REPEAT },
|
||||
{ "EVENT_PRESSED", LV_EVENT_PRESSED },
|
||||
{ "EVENT_PRESSING", LV_EVENT_PRESSING },
|
||||
{ "EVENT_PRESS_LOST", LV_EVENT_PRESS_LOST },
|
||||
{ "EVENT_READY", LV_EVENT_READY },
|
||||
{ "EVENT_REFRESH", LV_EVENT_REFRESH },
|
||||
{ "EVENT_REFR_EXT_DRAW_SIZE", LV_EVENT_REFR_EXT_DRAW_SIZE },
|
||||
{ "EVENT_RELEASED", LV_EVENT_RELEASED },
|
||||
{ "EVENT_SCROLL", LV_EVENT_SCROLL },
|
||||
{ "EVENT_SCROLL_BEGIN", LV_EVENT_SCROLL_BEGIN },
|
||||
{ "EVENT_SCROLL_END", LV_EVENT_SCROLL_END },
|
||||
{ "EVENT_SHORT_CLICKED", LV_EVENT_SHORT_CLICKED },
|
||||
{ "EVENT_SIZE_CHANGED", LV_EVENT_SIZE_CHANGED },
|
||||
{ "EVENT_STYLE_CHANGED", LV_EVENT_STYLE_CHANGED },
|
||||
{ "EVENT_VALUE_CHANGED", LV_EVENT_VALUE_CHANGED },
|
||||
{ "FLEX_ALIGN_CENTER", LV_FLEX_ALIGN_CENTER },
|
||||
{ "FLEX_ALIGN_END", LV_FLEX_ALIGN_END },
|
||||
{ "FLEX_ALIGN_SPACE_AROUND", LV_FLEX_ALIGN_SPACE_AROUND },
|
||||
{ "FLEX_ALIGN_SPACE_BETWEEN", LV_FLEX_ALIGN_SPACE_BETWEEN },
|
||||
{ "FLEX_ALIGN_SPACE_EVENLY", LV_FLEX_ALIGN_SPACE_EVENLY },
|
||||
{ "FLEX_ALIGN_START", LV_FLEX_ALIGN_START },
|
||||
{ "FLEX_FLOW_COLUMN", LV_FLEX_FLOW_COLUMN },
|
||||
{ "FLEX_FLOW_COLUMN_REVERSE", LV_FLEX_FLOW_COLUMN_REVERSE },
|
||||
{ "FLEX_FLOW_COLUMN_WRAP", LV_FLEX_FLOW_COLUMN_WRAP },
|
||||
{ "FLEX_FLOW_COLUMN_WRAP_REVERSE", LV_FLEX_FLOW_COLUMN_WRAP_REVERSE },
|
||||
{ "FLEX_FLOW_ROW", LV_FLEX_FLOW_ROW },
|
||||
{ "FLEX_FLOW_ROW_REVERSE", LV_FLEX_FLOW_ROW_REVERSE },
|
||||
{ "FLEX_FLOW_ROW_WRAP", LV_FLEX_FLOW_ROW_WRAP },
|
||||
{ "FLEX_FLOW_ROW_WRAP_REVERSE", LV_FLEX_FLOW_ROW_WRAP_REVERSE },
|
||||
{ "FS_MODE_RD", LV_FS_MODE_RD },
|
||||
{ "FS_MODE_WR", LV_FS_MODE_WR },
|
||||
{ "FS_RES_BUSY", LV_FS_RES_BUSY },
|
||||
{ "FS_RES_DENIED", LV_FS_RES_DENIED },
|
||||
{ "FS_RES_FS_ERR", LV_FS_RES_FS_ERR },
|
||||
{ "FS_RES_FULL", LV_FS_RES_FULL },
|
||||
{ "FS_RES_HW_ERR", LV_FS_RES_HW_ERR },
|
||||
{ "FS_RES_INV_PARAM", LV_FS_RES_INV_PARAM },
|
||||
{ "FS_RES_LOCKED", LV_FS_RES_LOCKED },
|
||||
{ "FS_RES_NOT_EX", LV_FS_RES_NOT_EX },
|
||||
{ "FS_RES_NOT_IMP", LV_FS_RES_NOT_IMP },
|
||||
{ "FS_RES_OK", LV_FS_RES_OK },
|
||||
{ "FS_RES_OUT_OF_MEM", LV_FS_RES_OUT_OF_MEM },
|
||||
{ "FS_RES_TOUT", LV_FS_RES_TOUT },
|
||||
{ "FS_RES_UNKNOWN", LV_FS_RES_UNKNOWN },
|
||||
{ "FS_SEEK_CUR", LV_FS_SEEK_CUR },
|
||||
{ "FS_SEEK_END", LV_FS_SEEK_END },
|
||||
{ "FS_SEEK_SET", LV_FS_SEEK_SET },
|
||||
{ "GRAD_DIR_HOR", LV_GRAD_DIR_HOR },
|
||||
{ "GRAD_DIR_NONE", LV_GRAD_DIR_NONE },
|
||||
{ "GRAD_DIR_VER", LV_GRAD_DIR_VER },
|
||||
{ "GRID_ALIGN_CENTER", LV_GRID_ALIGN_CENTER },
|
||||
{ "GRID_ALIGN_END", LV_GRID_ALIGN_END },
|
||||
{ "GRID_ALIGN_SPACE_AROUND", LV_GRID_ALIGN_SPACE_AROUND },
|
||||
{ "GRID_ALIGN_SPACE_BETWEEN", LV_GRID_ALIGN_SPACE_BETWEEN },
|
||||
{ "GRID_ALIGN_SPACE_EVENLY", LV_GRID_ALIGN_SPACE_EVENLY },
|
||||
{ "GRID_ALIGN_START", LV_GRID_ALIGN_START },
|
||||
{ "GRID_ALIGN_STRETCH", LV_GRID_ALIGN_STRETCH },
|
||||
{ "GROUP_REFOCUS_POLICY_NEXT", LV_GROUP_REFOCUS_POLICY_NEXT },
|
||||
{ "GROUP_REFOCUS_POLICY_PREV", LV_GROUP_REFOCUS_POLICY_PREV },
|
||||
{ "IMGBTN_STATE_CHECKED_DISABLED", LV_IMGBTN_STATE_CHECKED_DISABLED },
|
||||
{ "IMGBTN_STATE_CHECKED_PRESSED", LV_IMGBTN_STATE_CHECKED_PRESSED },
|
||||
{ "IMGBTN_STATE_CHECKED_RELEASED", LV_IMGBTN_STATE_CHECKED_RELEASED },
|
||||
{ "IMGBTN_STATE_DISABLED", LV_IMGBTN_STATE_DISABLED },
|
||||
{ "IMGBTN_STATE_PRESSED", LV_IMGBTN_STATE_PRESSED },
|
||||
{ "IMGBTN_STATE_RELEASED", LV_IMGBTN_STATE_RELEASED },
|
||||
{ "IMG_CF_ALPHA_1BIT", LV_IMG_CF_ALPHA_1BIT },
|
||||
{ "IMG_CF_ALPHA_2BIT", LV_IMG_CF_ALPHA_2BIT },
|
||||
{ "IMG_CF_ALPHA_4BIT", LV_IMG_CF_ALPHA_4BIT },
|
||||
{ "IMG_CF_ALPHA_8BIT", LV_IMG_CF_ALPHA_8BIT },
|
||||
{ "IMG_CF_INDEXED_1BIT", LV_IMG_CF_INDEXED_1BIT },
|
||||
{ "IMG_CF_INDEXED_2BIT", LV_IMG_CF_INDEXED_2BIT },
|
||||
{ "IMG_CF_INDEXED_4BIT", LV_IMG_CF_INDEXED_4BIT },
|
||||
{ "IMG_CF_INDEXED_8BIT", LV_IMG_CF_INDEXED_8BIT },
|
||||
{ "IMG_CF_RAW", LV_IMG_CF_RAW },
|
||||
{ "IMG_CF_RAW_ALPHA", LV_IMG_CF_RAW_ALPHA },
|
||||
{ "IMG_CF_RAW_CHROMA_KEYED", LV_IMG_CF_RAW_CHROMA_KEYED },
|
||||
{ "IMG_CF_TRUE_COLOR", LV_IMG_CF_TRUE_COLOR },
|
||||
{ "IMG_CF_TRUE_COLOR_ALPHA", LV_IMG_CF_TRUE_COLOR_ALPHA },
|
||||
{ "IMG_CF_TRUE_COLOR_CHROMA_KEYED", LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED },
|
||||
{ "IMG_CF_UNKNOWN", LV_IMG_CF_UNKNOWN },
|
||||
{ "IMG_SRC_FILE", LV_IMG_SRC_FILE },
|
||||
{ "IMG_SRC_SYMBOL", LV_IMG_SRC_SYMBOL },
|
||||
{ "IMG_SRC_UNKNOWN", LV_IMG_SRC_UNKNOWN },
|
||||
{ "IMG_SRC_VARIABLE", LV_IMG_SRC_VARIABLE },
|
||||
{ "INDEV_STATE_PRESSED", LV_INDEV_STATE_PRESSED },
|
||||
{ "INDEV_STATE_RELEASED", LV_INDEV_STATE_RELEASED },
|
||||
{ "INDEV_TYPE_BUTTON", LV_INDEV_TYPE_BUTTON },
|
||||
{ "INDEV_TYPE_ENCODER", LV_INDEV_TYPE_ENCODER },
|
||||
{ "INDEV_TYPE_KEYPAD", LV_INDEV_TYPE_KEYPAD },
|
||||
{ "INDEV_TYPE_NONE", LV_INDEV_TYPE_NONE },
|
||||
{ "INDEV_TYPE_POINTER", LV_INDEV_TYPE_POINTER },
|
||||
{ "KEY_BACKSPACE", LV_KEY_BACKSPACE },
|
||||
{ "KEY_DEL", LV_KEY_DEL },
|
||||
{ "KEY_DOWN", LV_KEY_DOWN },
|
||||
{ "KEY_END", LV_KEY_END },
|
||||
{ "KEY_ENTER", LV_KEY_ENTER },
|
||||
{ "KEY_ESC", LV_KEY_ESC },
|
||||
{ "KEY_HOME", LV_KEY_HOME },
|
||||
{ "KEY_LEFT", LV_KEY_LEFT },
|
||||
{ "KEY_NEXT", LV_KEY_NEXT },
|
||||
{ "KEY_PREV", LV_KEY_PREV },
|
||||
{ "KEY_RIGHT", LV_KEY_RIGHT },
|
||||
{ "KEY_UP", LV_KEY_UP },
|
||||
{ "LABEL_LONG_CLIP", LV_LABEL_LONG_CLIP },
|
||||
{ "LABEL_LONG_DOT", LV_LABEL_LONG_DOT },
|
||||
{ "LABEL_LONG_SCROLL", LV_LABEL_LONG_SCROLL },
|
||||
{ "LABEL_LONG_SCROLL_CIRCULAR", LV_LABEL_LONG_SCROLL_CIRCULAR },
|
||||
{ "LABEL_LONG_WRAP", LV_LABEL_LONG_WRAP },
|
||||
{ "METER_INDICATOR_TYPE_ARC", LV_METER_INDICATOR_TYPE_ARC },
|
||||
{ "METER_INDICATOR_TYPE_NEEDLE_IMG", LV_METER_INDICATOR_TYPE_NEEDLE_IMG },
|
||||
{ "METER_INDICATOR_TYPE_NEEDLE_LINE", LV_METER_INDICATOR_TYPE_NEEDLE_LINE },
|
||||
{ "METER_INDICATOR_TYPE_SCALE_LINES", LV_METER_INDICATOR_TYPE_SCALE_LINES },
|
||||
{ "OBJ_CLASS_EDITABLE_FALSE", LV_OBJ_CLASS_EDITABLE_FALSE },
|
||||
{ "OBJ_CLASS_EDITABLE_INHERIT", LV_OBJ_CLASS_EDITABLE_INHERIT },
|
||||
{ "OBJ_CLASS_EDITABLE_TRUE", LV_OBJ_CLASS_EDITABLE_TRUE },
|
||||
{ "OBJ_CLASS_GROUP_DEF_FALSE", LV_OBJ_CLASS_GROUP_DEF_FALSE },
|
||||
{ "OBJ_CLASS_GROUP_DEF_INHERIT", LV_OBJ_CLASS_GROUP_DEF_INHERIT },
|
||||
{ "OBJ_CLASS_GROUP_DEF_TRUE", LV_OBJ_CLASS_GROUP_DEF_TRUE },
|
||||
{ "OBJ_FLAG_ADV_HITTEST", LV_OBJ_FLAG_ADV_HITTEST },
|
||||
{ "OBJ_FLAG_CHECKABLE", LV_OBJ_FLAG_CHECKABLE },
|
||||
{ "OBJ_FLAG_CLICKABLE", LV_OBJ_FLAG_CLICKABLE },
|
||||
{ "OBJ_FLAG_CLICK_FOCUSABLE", LV_OBJ_FLAG_CLICK_FOCUSABLE },
|
||||
{ "OBJ_FLAG_EVENT_BUBBLE", LV_OBJ_FLAG_EVENT_BUBBLE },
|
||||
{ "OBJ_FLAG_FLOATING", LV_OBJ_FLAG_FLOATING },
|
||||
{ "OBJ_FLAG_GESTURE_BUBBLE", LV_OBJ_FLAG_GESTURE_BUBBLE },
|
||||
{ "OBJ_FLAG_HIDDEN", LV_OBJ_FLAG_HIDDEN },
|
||||
{ "OBJ_FLAG_IGNORE_LAYOUT", LV_OBJ_FLAG_IGNORE_LAYOUT },
|
||||
{ "OBJ_FLAG_LAYOUT_1", LV_OBJ_FLAG_LAYOUT_1 },
|
||||
{ "OBJ_FLAG_LAYOUT_2", LV_OBJ_FLAG_LAYOUT_2 },
|
||||
{ "OBJ_FLAG_PRESS_LOCK", LV_OBJ_FLAG_PRESS_LOCK },
|
||||
{ "OBJ_FLAG_SCROLLABLE", LV_OBJ_FLAG_SCROLLABLE },
|
||||
{ "OBJ_FLAG_SCROLL_CHAIN", LV_OBJ_FLAG_SCROLL_CHAIN },
|
||||
{ "OBJ_FLAG_SCROLL_ELASTIC", LV_OBJ_FLAG_SCROLL_ELASTIC },
|
||||
{ "OBJ_FLAG_SCROLL_MOMENTUM", LV_OBJ_FLAG_SCROLL_MOMENTUM },
|
||||
{ "OBJ_FLAG_SCROLL_ONE", LV_OBJ_FLAG_SCROLL_ONE },
|
||||
{ "OBJ_FLAG_SCROLL_ON_FOCUS", LV_OBJ_FLAG_SCROLL_ON_FOCUS },
|
||||
{ "OBJ_FLAG_SNAPABLE", LV_OBJ_FLAG_SNAPABLE },
|
||||
{ "OBJ_FLAG_USER_1", LV_OBJ_FLAG_USER_1 },
|
||||
{ "OBJ_FLAG_USER_2", LV_OBJ_FLAG_USER_2 },
|
||||
{ "OBJ_FLAG_USER_3", LV_OBJ_FLAG_USER_3 },
|
||||
{ "OBJ_FLAG_USER_4", LV_OBJ_FLAG_USER_4 },
|
||||
{ "OBJ_FLAG_WIDGET_1", LV_OBJ_FLAG_WIDGET_1 },
|
||||
{ "OBJ_FLAG_WIDGET_2", LV_OBJ_FLAG_WIDGET_2 },
|
||||
{ "OBJ_TREE_WALK_END", LV_OBJ_TREE_WALK_END },
|
||||
{ "OBJ_TREE_WALK_NEXT", LV_OBJ_TREE_WALK_NEXT },
|
||||
{ "OBJ_TREE_WALK_SKIP_CHILDREN", LV_OBJ_TREE_WALK_SKIP_CHILDREN },
|
||||
{ "OPA_0", LV_OPA_0 },
|
||||
{ "OPA_10", LV_OPA_10 },
|
||||
{ "OPA_100", LV_OPA_100 },
|
||||
{ "OPA_20", LV_OPA_20 },
|
||||
{ "OPA_30", LV_OPA_30 },
|
||||
{ "OPA_40", LV_OPA_40 },
|
||||
{ "OPA_50", LV_OPA_50 },
|
||||
{ "OPA_60", LV_OPA_60 },
|
||||
{ "OPA_70", LV_OPA_70 },
|
||||
{ "OPA_80", LV_OPA_80 },
|
||||
{ "OPA_90", LV_OPA_90 },
|
||||
{ "OPA_COVER", LV_OPA_COVER },
|
||||
{ "OPA_TRANSP", LV_OPA_TRANSP },
|
||||
{ "PALETTE_AMBER", LV_PALETTE_AMBER },
|
||||
{ "PALETTE_BLUE", LV_PALETTE_BLUE },
|
||||
{ "PALETTE_BLUE_GREY", LV_PALETTE_BLUE_GREY },
|
||||
{ "PALETTE_BROWN", LV_PALETTE_BROWN },
|
||||
{ "PALETTE_CYAN", LV_PALETTE_CYAN },
|
||||
{ "PALETTE_DEEP_ORANGE", LV_PALETTE_DEEP_ORANGE },
|
||||
{ "PALETTE_DEEP_PURPLE", LV_PALETTE_DEEP_PURPLE },
|
||||
{ "PALETTE_GREEN", LV_PALETTE_GREEN },
|
||||
{ "PALETTE_GREY", LV_PALETTE_GREY },
|
||||
{ "PALETTE_INDIGO", LV_PALETTE_INDIGO },
|
||||
{ "PALETTE_LIGHT_BLUE", LV_PALETTE_LIGHT_BLUE },
|
||||
{ "PALETTE_LIGHT_GREEN", LV_PALETTE_LIGHT_GREEN },
|
||||
{ "PALETTE_LIME", LV_PALETTE_LIME },
|
||||
{ "PALETTE_NONE", LV_PALETTE_NONE },
|
||||
{ "PALETTE_ORANGE", LV_PALETTE_ORANGE },
|
||||
{ "PALETTE_PINK", LV_PALETTE_PINK },
|
||||
{ "PALETTE_PURPLE", LV_PALETTE_PURPLE },
|
||||
{ "PALETTE_RED", LV_PALETTE_RED },
|
||||
{ "PALETTE_TEAL", LV_PALETTE_TEAL },
|
||||
{ "PALETTE_YELLOW", LV_PALETTE_YELLOW },
|
||||
{ "PART_ANY", LV_PART_ANY },
|
||||
{ "PART_CURSOR", LV_PART_CURSOR },
|
||||
{ "PART_CUSTOM_FIRST", LV_PART_CUSTOM_FIRST },
|
||||
{ "PART_INDICATOR", LV_PART_INDICATOR },
|
||||
{ "PART_ITEMS", LV_PART_ITEMS },
|
||||
{ "PART_KNOB", LV_PART_KNOB },
|
||||
{ "PART_MAIN", LV_PART_MAIN },
|
||||
{ "PART_SCROLLBAR", LV_PART_SCROLLBAR },
|
||||
{ "PART_SELECTED", LV_PART_SELECTED },
|
||||
{ "PART_TEXTAREA_PLACEHOLDER", LV_PART_TEXTAREA_PLACEHOLDER },
|
||||
{ "PART_TICKS", LV_PART_TICKS },
|
||||
{ "RADIUS_CIRCLE", LV_RADIUS_CIRCLE },
|
||||
{ "RES_INV", LV_RES_INV },
|
||||
{ "RES_OK", LV_RES_OK },
|
||||
{ "ROLLER_MODE_INFINITE", LV_ROLLER_MODE_INFINITE },
|
||||
{ "ROLLER_MODE_NORMAL", LV_ROLLER_MODE_NORMAL },
|
||||
{ "SCROLLBAR_MODE_ACTIVE", LV_SCROLLBAR_MODE_ACTIVE },
|
||||
{ "SCROLLBAR_MODE_AUTO", LV_SCROLLBAR_MODE_AUTO },
|
||||
{ "SCROLLBAR_MODE_OFF", LV_SCROLLBAR_MODE_OFF },
|
||||
{ "SCROLLBAR_MODE_ON", LV_SCROLLBAR_MODE_ON },
|
||||
{ "SCROLL_SNAP_CENTER", LV_SCROLL_SNAP_CENTER },
|
||||
{ "SCROLL_SNAP_END", LV_SCROLL_SNAP_END },
|
||||
{ "SCROLL_SNAP_NONE", LV_SCROLL_SNAP_NONE },
|
||||
{ "SCROLL_SNAP_START", LV_SCROLL_SNAP_START },
|
||||
{ "SCR_LOAD_ANIM_FADE_ON", LV_SCR_LOAD_ANIM_FADE_ON },
|
||||
{ "SCR_LOAD_ANIM_MOVE_BOTTOM", LV_SCR_LOAD_ANIM_MOVE_BOTTOM },
|
||||
{ "SCR_LOAD_ANIM_MOVE_LEFT", LV_SCR_LOAD_ANIM_MOVE_LEFT },
|
||||
{ "SCR_LOAD_ANIM_MOVE_RIGHT", LV_SCR_LOAD_ANIM_MOVE_RIGHT },
|
||||
{ "SCR_LOAD_ANIM_MOVE_TOP", LV_SCR_LOAD_ANIM_MOVE_TOP },
|
||||
{ "SCR_LOAD_ANIM_NONE", LV_SCR_LOAD_ANIM_NONE },
|
||||
{ "SCR_LOAD_ANIM_OVER_BOTTOM", LV_SCR_LOAD_ANIM_OVER_BOTTOM },
|
||||
{ "SCR_LOAD_ANIM_OVER_LEFT", LV_SCR_LOAD_ANIM_OVER_LEFT },
|
||||
{ "SCR_LOAD_ANIM_OVER_RIGHT", LV_SCR_LOAD_ANIM_OVER_RIGHT },
|
||||
{ "SCR_LOAD_ANIM_OVER_TOP", LV_SCR_LOAD_ANIM_OVER_TOP },
|
||||
{ "SIZE_CONTENT", LV_SIZE_CONTENT },
|
||||
{ "SLIDER_MODE_NORMAL", LV_SLIDER_MODE_NORMAL },
|
||||
{ "SLIDER_MODE_RANGE", LV_SLIDER_MODE_RANGE },
|
||||
{ "SLIDER_MODE_SYMMETRICAL", LV_SLIDER_MODE_SYMMETRICAL },
|
||||
{ "SPAN_MODE_BREAK", LV_SPAN_MODE_BREAK },
|
||||
{ "SPAN_MODE_EXPAND", LV_SPAN_MODE_EXPAND },
|
||||
{ "SPAN_MODE_FIXED", LV_SPAN_MODE_FIXED },
|
||||
{ "SPAN_OVERFLOW_CLIP", LV_SPAN_OVERFLOW_CLIP },
|
||||
{ "SPAN_OVERFLOW_ELLIPSIS", LV_SPAN_OVERFLOW_ELLIPSIS },
|
||||
{ "STATE_ANY", LV_STATE_ANY },
|
||||
{ "STATE_CHECKED", LV_STATE_CHECKED },
|
||||
{ "STATE_DEFAULT", LV_STATE_DEFAULT },
|
||||
{ "STATE_DISABLED", LV_STATE_DISABLED },
|
||||
{ "STATE_EDITED", LV_STATE_EDITED },
|
||||
{ "STATE_FOCUSED", LV_STATE_FOCUSED },
|
||||
{ "STATE_FOCUS_KEY", LV_STATE_FOCUS_KEY },
|
||||
{ "STATE_HOVERED", LV_STATE_HOVERED },
|
||||
{ "STATE_PRESSED", LV_STATE_PRESSED },
|
||||
{ "STATE_SCROLLED", LV_STATE_SCROLLED },
|
||||
{ "STATE_USER_1", LV_STATE_USER_1 },
|
||||
{ "STATE_USER_2", LV_STATE_USER_2 },
|
||||
{ "STATE_USER_3", LV_STATE_USER_3 },
|
||||
{ "STATE_USER_4", LV_STATE_USER_4 },
|
||||
{ "STYLE_ALIGN", LV_STYLE_ALIGN },
|
||||
{ "STYLE_ANIM_SPEED", LV_STYLE_ANIM_SPEED },
|
||||
{ "STYLE_ANIM_TIME", LV_STYLE_ANIM_TIME },
|
||||
{ "STYLE_ARC_COLOR", LV_STYLE_ARC_COLOR },
|
||||
{ "STYLE_ARC_COLOR_FILTERED", LV_STYLE_ARC_COLOR_FILTERED },
|
||||
{ "STYLE_ARC_IMG_SRC", LV_STYLE_ARC_IMG_SRC },
|
||||
{ "STYLE_ARC_OPA", LV_STYLE_ARC_OPA },
|
||||
{ "STYLE_ARC_ROUNDED", LV_STYLE_ARC_ROUNDED },
|
||||
{ "STYLE_ARC_WIDTH", LV_STYLE_ARC_WIDTH },
|
||||
{ "STYLE_BASE_DIR", LV_STYLE_BASE_DIR },
|
||||
{ "STYLE_BG_COLOR", LV_STYLE_BG_COLOR },
|
||||
{ "STYLE_BG_COLOR_FILTERED", LV_STYLE_BG_COLOR_FILTERED },
|
||||
{ "STYLE_BG_GRAD_COLOR", LV_STYLE_BG_GRAD_COLOR },
|
||||
{ "STYLE_BG_GRAD_COLOR_FILTERED", LV_STYLE_BG_GRAD_COLOR_FILTERED },
|
||||
{ "STYLE_BG_GRAD_DIR", LV_STYLE_BG_GRAD_DIR },
|
||||
{ "STYLE_BG_GRAD_STOP", LV_STYLE_BG_GRAD_STOP },
|
||||
{ "STYLE_BG_IMG_OPA", LV_STYLE_BG_IMG_OPA },
|
||||
{ "STYLE_BG_IMG_RECOLOR", LV_STYLE_BG_IMG_RECOLOR },
|
||||
{ "STYLE_BG_IMG_RECOLOR_FILTERED", LV_STYLE_BG_IMG_RECOLOR_FILTERED },
|
||||
{ "STYLE_BG_IMG_RECOLOR_OPA", LV_STYLE_BG_IMG_RECOLOR_OPA },
|
||||
{ "STYLE_BG_IMG_SRC", LV_STYLE_BG_IMG_SRC },
|
||||
{ "STYLE_BG_IMG_TILED", LV_STYLE_BG_IMG_TILED },
|
||||
{ "STYLE_BG_MAIN_STOP", LV_STYLE_BG_MAIN_STOP },
|
||||
{ "STYLE_BG_OPA", LV_STYLE_BG_OPA },
|
||||
{ "STYLE_BLEND_MODE", LV_STYLE_BLEND_MODE },
|
||||
{ "STYLE_BORDER_COLOR", LV_STYLE_BORDER_COLOR },
|
||||
{ "STYLE_BORDER_COLOR_FILTERED", LV_STYLE_BORDER_COLOR_FILTERED },
|
||||
{ "STYLE_BORDER_OPA", LV_STYLE_BORDER_OPA },
|
||||
{ "STYLE_BORDER_POST", LV_STYLE_BORDER_POST },
|
||||
{ "STYLE_BORDER_SIDE", LV_STYLE_BORDER_SIDE },
|
||||
{ "STYLE_BORDER_WIDTH", LV_STYLE_BORDER_WIDTH },
|
||||
{ "STYLE_CLIP_CORNER", LV_STYLE_CLIP_CORNER },
|
||||
{ "STYLE_COLOR_FILTER_DSC", LV_STYLE_COLOR_FILTER_DSC },
|
||||
{ "STYLE_COLOR_FILTER_OPA", LV_STYLE_COLOR_FILTER_OPA },
|
||||
{ "STYLE_HEIGHT", LV_STYLE_HEIGHT },
|
||||
{ "STYLE_IMG_OPA", LV_STYLE_IMG_OPA },
|
||||
{ "STYLE_IMG_RECOLOR", LV_STYLE_IMG_RECOLOR },
|
||||
{ "STYLE_IMG_RECOLOR_FILTERED", LV_STYLE_IMG_RECOLOR_FILTERED },
|
||||
{ "STYLE_IMG_RECOLOR_OPA", LV_STYLE_IMG_RECOLOR_OPA },
|
||||
{ "STYLE_LAYOUT", LV_STYLE_LAYOUT },
|
||||
{ "STYLE_LINE_COLOR", LV_STYLE_LINE_COLOR },
|
||||
{ "STYLE_LINE_COLOR_FILTERED", LV_STYLE_LINE_COLOR_FILTERED },
|
||||
{ "STYLE_LINE_DASH_GAP", LV_STYLE_LINE_DASH_GAP },
|
||||
{ "STYLE_LINE_DASH_WIDTH", LV_STYLE_LINE_DASH_WIDTH },
|
||||
{ "STYLE_LINE_OPA", LV_STYLE_LINE_OPA },
|
||||
{ "STYLE_LINE_ROUNDED", LV_STYLE_LINE_ROUNDED },
|
||||
{ "STYLE_LINE_WIDTH", LV_STYLE_LINE_WIDTH },
|
||||
{ "STYLE_MAX_HEIGHT", LV_STYLE_MAX_HEIGHT },
|
||||
{ "STYLE_MAX_WIDTH", LV_STYLE_MAX_WIDTH },
|
||||
{ "STYLE_MIN_HEIGHT", LV_STYLE_MIN_HEIGHT },
|
||||
{ "STYLE_MIN_WIDTH", LV_STYLE_MIN_WIDTH },
|
||||
{ "STYLE_OPA", LV_STYLE_OPA },
|
||||
{ "STYLE_OUTLINE_COLOR", LV_STYLE_OUTLINE_COLOR },
|
||||
{ "STYLE_OUTLINE_COLOR_FILTERED", LV_STYLE_OUTLINE_COLOR_FILTERED },
|
||||
{ "STYLE_OUTLINE_OPA", LV_STYLE_OUTLINE_OPA },
|
||||
{ "STYLE_OUTLINE_PAD", LV_STYLE_OUTLINE_PAD },
|
||||
{ "STYLE_OUTLINE_WIDTH", LV_STYLE_OUTLINE_WIDTH },
|
||||
{ "STYLE_PAD_BOTTOM", LV_STYLE_PAD_BOTTOM },
|
||||
{ "STYLE_PAD_COLUMN", LV_STYLE_PAD_COLUMN },
|
||||
{ "STYLE_PAD_LEFT", LV_STYLE_PAD_LEFT },
|
||||
{ "STYLE_PAD_RIGHT", LV_STYLE_PAD_RIGHT },
|
||||
{ "STYLE_PAD_ROW", LV_STYLE_PAD_ROW },
|
||||
{ "STYLE_PAD_TOP", LV_STYLE_PAD_TOP },
|
||||
{ "STYLE_PROP_ANY", LV_STYLE_PROP_ANY },
|
||||
{ "STYLE_PROP_INV", LV_STYLE_PROP_INV },
|
||||
{ "STYLE_RADIUS", LV_STYLE_RADIUS },
|
||||
{ "STYLE_SHADOW_COLOR", LV_STYLE_SHADOW_COLOR },
|
||||
{ "STYLE_SHADOW_COLOR_FILTERED", LV_STYLE_SHADOW_COLOR_FILTERED },
|
||||
{ "STYLE_SHADOW_OFS_X", LV_STYLE_SHADOW_OFS_X },
|
||||
{ "STYLE_SHADOW_OFS_Y", LV_STYLE_SHADOW_OFS_Y },
|
||||
{ "STYLE_SHADOW_OPA", LV_STYLE_SHADOW_OPA },
|
||||
{ "STYLE_SHADOW_SPREAD", LV_STYLE_SHADOW_SPREAD },
|
||||
{ "STYLE_SHADOW_WIDTH", LV_STYLE_SHADOW_WIDTH },
|
||||
{ "STYLE_TEXT_ALIGN", LV_STYLE_TEXT_ALIGN },
|
||||
{ "STYLE_TEXT_COLOR", LV_STYLE_TEXT_COLOR },
|
||||
{ "STYLE_TEXT_COLOR_FILTERED", LV_STYLE_TEXT_COLOR_FILTERED },
|
||||
{ "STYLE_TEXT_DECOR", LV_STYLE_TEXT_DECOR },
|
||||
{ "STYLE_TEXT_FONT", LV_STYLE_TEXT_FONT },
|
||||
{ "STYLE_TEXT_LETTER_SPACE", LV_STYLE_TEXT_LETTER_SPACE },
|
||||
{ "STYLE_TEXT_LINE_SPACE", LV_STYLE_TEXT_LINE_SPACE },
|
||||
{ "STYLE_TEXT_OPA", LV_STYLE_TEXT_OPA },
|
||||
{ "STYLE_TRANSFORM_ANGLE", LV_STYLE_TRANSFORM_ANGLE },
|
||||
{ "STYLE_TRANSFORM_HEIGHT", LV_STYLE_TRANSFORM_HEIGHT },
|
||||
{ "STYLE_TRANSFORM_WIDTH", LV_STYLE_TRANSFORM_WIDTH },
|
||||
{ "STYLE_TRANSFORM_ZOOM", LV_STYLE_TRANSFORM_ZOOM },
|
||||
{ "STYLE_TRANSITION", LV_STYLE_TRANSITION },
|
||||
{ "STYLE_TRANSLATE_X", LV_STYLE_TRANSLATE_X },
|
||||
{ "STYLE_TRANSLATE_Y", LV_STYLE_TRANSLATE_Y },
|
||||
{ "STYLE_WIDTH", LV_STYLE_WIDTH },
|
||||
{ "STYLE_X", LV_STYLE_X },
|
||||
{ "STYLE_Y", LV_STYLE_Y },
|
||||
{ "$SYMBOL_AUDIO", (int32_t) "\xef\x80\x81" },
|
||||
{ "$SYMBOL_BACKSPACE", (int32_t) "\xef\x95\x9A" },
|
||||
{ "$SYMBOL_BATTERY_1", (int32_t) "\xef\x89\x83" },
|
||||
{ "$SYMBOL_BATTERY_2", (int32_t) "\xef\x89\x82" },
|
||||
{ "$SYMBOL_BATTERY_3", (int32_t) "\xef\x89\x81" },
|
||||
{ "$SYMBOL_BATTERY_EMPTY", (int32_t) "\xef\x89\x84" },
|
||||
{ "$SYMBOL_BATTERY_FULL", (int32_t) "\xef\x89\x80" },
|
||||
{ "$SYMBOL_BELL", (int32_t) "\xef\x83\xb3" },
|
||||
{ "$SYMBOL_BLUETOOTH", (int32_t) "\xef\x8a\x93" },
|
||||
{ "$SYMBOL_BULLET", (int32_t) "\xE2\x80\xA2" },
|
||||
{ "$SYMBOL_CALL", (int32_t) "\xef\x82\x95" },
|
||||
{ "$SYMBOL_CHARGE", (int32_t) "\xef\x83\xa7" },
|
||||
{ "$SYMBOL_CLOSE", (int32_t) "\xef\x80\x8d" },
|
||||
{ "$SYMBOL_COPY", (int32_t) "\xef\x83\x85" },
|
||||
{ "$SYMBOL_CUT", (int32_t) "\xef\x83\x84" },
|
||||
{ "$SYMBOL_DIRECTORY", (int32_t) "\xef\x81\xbb" },
|
||||
{ "$SYMBOL_DOWN", (int32_t) "\xef\x81\xb8" },
|
||||
{ "$SYMBOL_DOWNLOAD", (int32_t) "\xef\x80\x99" },
|
||||
{ "$SYMBOL_DRIVE", (int32_t) "\xef\x80\x9c" },
|
||||
{ "$SYMBOL_DUMMY", (int32_t) "\xEF\xA3\xBF" },
|
||||
{ "$SYMBOL_EDIT", (int32_t) "\xef\x8C\x84" },
|
||||
{ "$SYMBOL_EJECT", (int32_t) "\xef\x81\x92" },
|
||||
{ "$SYMBOL_EYE_CLOSE", (int32_t) "\xef\x81\xb0" },
|
||||
{ "$SYMBOL_EYE_OPEN", (int32_t) "\xef\x81\xae" },
|
||||
{ "$SYMBOL_FILE", (int32_t) "\xef\x85\x9b" },
|
||||
{ "$SYMBOL_GPS", (int32_t) "\xef\x84\xa4" },
|
||||
{ "$SYMBOL_HOME", (int32_t) "\xef\x80\x95" },
|
||||
{ "$SYMBOL_IMAGE", (int32_t) "\xef\x80\xbe" },
|
||||
{ "$SYMBOL_KEYBOARD", (int32_t) "\xef\x84\x9c" },
|
||||
{ "$SYMBOL_LEFT", (int32_t) "\xef\x81\x93" },
|
||||
{ "$SYMBOL_LIST", (int32_t) "\xef\x80\x8b" },
|
||||
{ "$SYMBOL_LOOP", (int32_t) "\xef\x81\xb9" },
|
||||
{ "$SYMBOL_MINUS", (int32_t) "\xef\x81\xa8" },
|
||||
{ "$SYMBOL_MUTE", (int32_t) "\xef\x80\xa6" },
|
||||
{ "$SYMBOL_NEW_LINE", (int32_t) "\xef\xA2\xA2" },
|
||||
{ "$SYMBOL_NEXT", (int32_t) "\xef\x81\x91" },
|
||||
{ "$SYMBOL_OK", (int32_t) "\xef\x80\x8c" },
|
||||
{ "$SYMBOL_PASTE", (int32_t) "\xef\x83\xAA" },
|
||||
{ "$SYMBOL_PAUSE", (int32_t) "\xef\x81\x8c" },
|
||||
{ "$SYMBOL_PLAY", (int32_t) "\xef\x81\x8b" },
|
||||
{ "$SYMBOL_PLUS", (int32_t) "\xef\x81\xa7" },
|
||||
{ "$SYMBOL_POWER", (int32_t) "\xef\x80\x91" },
|
||||
{ "$SYMBOL_PREV", (int32_t) "\xef\x81\x88" },
|
||||
{ "$SYMBOL_REFRESH", (int32_t) "\xef\x80\xa1" },
|
||||
{ "$SYMBOL_RIGHT", (int32_t) "\xef\x81\x94" },
|
||||
{ "$SYMBOL_SAVE", (int32_t) "\xef\x83\x87" },
|
||||
{ "$SYMBOL_SD_CARD", (int32_t) "\xef\x9F\x82" },
|
||||
{ "$SYMBOL_SETTINGS", (int32_t) "\xef\x80\x93" },
|
||||
{ "$SYMBOL_SHUFFLE", (int32_t) "\xef\x81\xb4" },
|
||||
{ "$SYMBOL_STOP", (int32_t) "\xef\x81\x8d" },
|
||||
{ "$SYMBOL_TRASH", (int32_t) "\xef\x8B\xAD" },
|
||||
{ "$SYMBOL_UP", (int32_t) "\xef\x81\xb7" },
|
||||
{ "$SYMBOL_UPLOAD", (int32_t) "\xef\x82\x93" },
|
||||
{ "$SYMBOL_USB", (int32_t) "\xef\x8a\x87" },
|
||||
{ "$SYMBOL_VIDEO", (int32_t) "\xef\x80\x88" },
|
||||
{ "$SYMBOL_VOLUME_MAX", (int32_t) "\xef\x80\xa8" },
|
||||
{ "$SYMBOL_VOLUME_MID", (int32_t) "\xef\x80\xa7" },
|
||||
{ "$SYMBOL_WARNING", (int32_t) "\xef\x81\xb1" },
|
||||
{ "$SYMBOL_WIFI", (int32_t) "\xef\x87\xab" },
|
||||
{ "TABLE_CELL_CTRL_CUSTOM_1", LV_TABLE_CELL_CTRL_CUSTOM_1 },
|
||||
{ "TABLE_CELL_CTRL_CUSTOM_2", LV_TABLE_CELL_CTRL_CUSTOM_2 },
|
||||
{ "TABLE_CELL_CTRL_CUSTOM_3", LV_TABLE_CELL_CTRL_CUSTOM_3 },
|
||||
{ "TABLE_CELL_CTRL_CUSTOM_4", LV_TABLE_CELL_CTRL_CUSTOM_4 },
|
||||
{ "TABLE_CELL_CTRL_MERGE_RIGHT", LV_TABLE_CELL_CTRL_MERGE_RIGHT },
|
||||
{ "TABLE_CELL_CTRL_TEXT_CROP", LV_TABLE_CELL_CTRL_TEXT_CROP },
|
||||
{ "TEXTAREA_CURSOR_LAST", LV_TEXTAREA_CURSOR_LAST },
|
||||
{ "TEXT_ALIGN_AUTO", LV_TEXT_ALIGN_AUTO },
|
||||
{ "TEXT_ALIGN_CENTER", LV_TEXT_ALIGN_CENTER },
|
||||
{ "TEXT_ALIGN_LEFT", LV_TEXT_ALIGN_LEFT },
|
||||
{ "TEXT_ALIGN_RIGHT", LV_TEXT_ALIGN_RIGHT },
|
||||
{ "TEXT_CMD_STATE_IN", LV_TEXT_CMD_STATE_IN },
|
||||
{ "TEXT_CMD_STATE_PAR", LV_TEXT_CMD_STATE_PAR },
|
||||
{ "TEXT_CMD_STATE_WAIT", LV_TEXT_CMD_STATE_WAIT },
|
||||
{ "TEXT_DECOR_NONE", LV_TEXT_DECOR_NONE },
|
||||
{ "TEXT_DECOR_STRIKETHROUGH", LV_TEXT_DECOR_STRIKETHROUGH },
|
||||
{ "TEXT_DECOR_UNDERLINE", LV_TEXT_DECOR_UNDERLINE },
|
||||
{ "TEXT_FLAG_EXPAND", LV_TEXT_FLAG_EXPAND },
|
||||
{ "TEXT_FLAG_FIT", LV_TEXT_FLAG_FIT },
|
||||
{ "TEXT_FLAG_NONE", LV_TEXT_FLAG_NONE },
|
||||
{ "TEXT_FLAG_RECOLOR", LV_TEXT_FLAG_RECOLOR },
|
||||
{ "&font_montserrat", (int32_t) &lv0_load_montserrat_font },
|
||||
{ "&font_robotocondensed_latin1", (int32_t) &lv0_load_robotocondensed_latin1_font },
|
||||
{ "&font_seg7", (int32_t) &lv0_load_seg7_font },
|
||||
{ "&load_font", (int32_t) &lv0_load_font },
|
||||
{ "&load_freetype_font", (int32_t) &lv0_load_freetype_font },
|
||||
{ "&montserrat_font", (int32_t) &lv0_load_montserrat_font },
|
||||
{ "®ister_button_encoder", (int32_t) &lv0_register_button_encoder },
|
||||
{ "&screenshot", (int32_t) &lv0_screenshot },
|
||||
{ "&seg7_font", (int32_t) &lv0_load_seg7_font },
|
||||
|
||||
};
|
||||
|
||||
const size_t lv0_constants_size = sizeof(lv0_constants)/sizeof(lv0_constants[0]);
|
||||
|
||||
/* generated */
|
||||
be_local_module(lv,
|
||||
"lv",
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lv0_member) },
|
||||
{ be_nested_key("start", 1697318111, 5, 0), be_const_func(lv0_start) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(lv);
|
||||
|
||||
#endif // USE_LVGL
|
||||
|
||||
/********************************************************************/
|
|
@ -0,0 +1,434 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_percentage
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_arcs_set_percentage, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(percentage),
|
||||
/* K1 */ be_const_int(0),
|
||||
/* K2 */ be_nested_str(invalidate),
|
||||
}),
|
||||
&be_const_str_set_percentage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[18]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x540E0018, // 0001 LDINT R3 25
|
||||
0x0C080403, // 0002 DIV R2 R2 R3
|
||||
0x540E0063, // 0003 LDINT R3 100
|
||||
0x240C0203, // 0004 GT R3 R1 R3
|
||||
0x780E0000, // 0005 JMPF R3 #0007
|
||||
0x54060063, // 0006 LDINT R1 100
|
||||
0x140C0301, // 0007 LT R3 R1 K1
|
||||
0x780E0000, // 0008 JMPF R3 #000A
|
||||
0x58040001, // 0009 LDCONST R1 K1
|
||||
0x90020001, // 000A SETMBR R0 K0 R1
|
||||
0x540E0018, // 000B LDINT R3 25
|
||||
0x0C0C0203, // 000C DIV R3 R1 R3
|
||||
0x200C0403, // 000D NE R3 R2 R3
|
||||
0x780E0001, // 000E JMPF R3 #0011
|
||||
0x8C0C0102, // 000F GETMET R3 R0 K2
|
||||
0x7C0C0200, // 0010 CALL R3 1
|
||||
0x80000000, // 0011 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_arcs_init, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[10]) { /* constants */
|
||||
/* K0 */ be_nested_str(_lvgl),
|
||||
/* K1 */ be_nested_str(create_custom_widget),
|
||||
/* K2 */ be_nested_str(percentage),
|
||||
/* K3 */ be_nested_str(p1),
|
||||
/* K4 */ be_nested_str(lv),
|
||||
/* K5 */ be_nested_str(point),
|
||||
/* K6 */ be_nested_str(p2),
|
||||
/* K7 */ be_nested_str(area),
|
||||
/* K8 */ be_nested_str(line_dsc),
|
||||
/* K9 */ be_nested_str(draw_line_dsc),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[24]) { /* code */
|
||||
0xB80A0000, // 0000 GETNGBL R2 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x5C100000, // 0002 MOVE R4 R0
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x7C080600, // 0004 CALL R2 3
|
||||
0x540A0063, // 0005 LDINT R2 100
|
||||
0x90020402, // 0006 SETMBR R0 K2 R2
|
||||
0xB80A0800, // 0007 GETNGBL R2 K4
|
||||
0x8C080505, // 0008 GETMET R2 R2 K5
|
||||
0x7C080200, // 0009 CALL R2 1
|
||||
0x90020602, // 000A SETMBR R0 K3 R2
|
||||
0xB80A0800, // 000B GETNGBL R2 K4
|
||||
0x8C080505, // 000C GETMET R2 R2 K5
|
||||
0x7C080200, // 000D CALL R2 1
|
||||
0x90020C02, // 000E SETMBR R0 K6 R2
|
||||
0xB80A0800, // 000F GETNGBL R2 K4
|
||||
0x8C080507, // 0010 GETMET R2 R2 K7
|
||||
0x7C080200, // 0011 CALL R2 1
|
||||
0x90020E02, // 0012 SETMBR R0 K7 R2
|
||||
0xB80A0800, // 0013 GETNGBL R2 K4
|
||||
0x8C080509, // 0014 GETMET R2 R2 K9
|
||||
0x7C080200, // 0015 CALL R2 1
|
||||
0x90021002, // 0016 SETMBR R0 K8 R2
|
||||
0x80000000, // 0017 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: widget_event
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_arcs_widget_event, /* name */
|
||||
be_nested_proto(
|
||||
28, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
1, /* has sup protos */
|
||||
( &(const struct bproto*[ 1]) {
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_atleast1,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x28040100, // 0000 GE R1 R0 K0
|
||||
0x78060001, // 0001 JMPF R1 #0004
|
||||
0x80040000, // 0002 RET 1 R0
|
||||
0x70020000, // 0003 JMP #0005
|
||||
0x80060000, // 0004 RET 1 K0
|
||||
0x80000000, // 0005 RET 0
|
||||
})
|
||||
),
|
||||
}),
|
||||
1, /* has constants */
|
||||
( &(const bvalue[35]) { /* constants */
|
||||
/* K0 */ be_nested_str(lv),
|
||||
/* K1 */ be_nested_str(obj_event_base),
|
||||
/* K2 */ be_nested_str(RES_OK),
|
||||
/* K3 */ be_nested_str(code),
|
||||
/* K4 */ be_nested_str(math),
|
||||
/* K5 */ be_nested_str(get_height),
|
||||
/* K6 */ be_nested_str(get_width),
|
||||
/* K7 */ be_const_int(2),
|
||||
/* K8 */ be_const_int(3),
|
||||
/* K9 */ be_nested_str(EVENT_DRAW_MAIN),
|
||||
/* K10 */ be_nested_str(area),
|
||||
/* K11 */ be_nested_str(param),
|
||||
/* K12 */ be_nested_str(get_coords),
|
||||
/* K13 */ be_nested_str(x1),
|
||||
/* K14 */ be_nested_str(y1),
|
||||
/* K15 */ be_nested_str(draw_line_dsc_init),
|
||||
/* K16 */ be_nested_str(line_dsc),
|
||||
/* K17 */ be_nested_str(init_draw_line_dsc),
|
||||
/* K18 */ be_nested_str(PART_MAIN),
|
||||
/* K19 */ be_nested_str(round_start),
|
||||
/* K20 */ be_const_int(1),
|
||||
/* K21 */ be_nested_str(round_end),
|
||||
/* K22 */ be_nested_str(width),
|
||||
/* K23 */ be_nested_str(get_style_line_color),
|
||||
/* K24 */ be_nested_str(STATE_DEFAULT),
|
||||
/* K25 */ be_nested_str(get_style_bg_color),
|
||||
/* K26 */ be_nested_str(deg),
|
||||
/* K27 */ be_nested_str(acos),
|
||||
/* K28 */ be_nested_str(p1),
|
||||
/* K29 */ be_nested_str(x),
|
||||
/* K30 */ be_nested_str(y),
|
||||
/* K31 */ be_nested_str(color),
|
||||
/* K32 */ be_nested_str(percentage),
|
||||
/* K33 */ be_nested_str(draw_arc),
|
||||
/* K34 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_widget_event,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[182]) { /* code */
|
||||
0xB80E0000, // 0000 GETNGBL R3 K0
|
||||
0x8C0C0701, // 0001 GETMET R3 R3 K1
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0x5C180400, // 0003 MOVE R6 R2
|
||||
0x7C0C0600, // 0004 CALL R3 3
|
||||
0xB8120000, // 0005 GETNGBL R4 K0
|
||||
0x88100902, // 0006 GETMBR R4 R4 K2
|
||||
0x200C0604, // 0007 NE R3 R3 R4
|
||||
0x780E0000, // 0008 JMPF R3 #000A
|
||||
0x80000600, // 0009 RET 0
|
||||
0x880C0503, // 000A GETMBR R3 R2 K3
|
||||
0xA4120800, // 000B IMPORT R4 K4
|
||||
0x84140000, // 000C CLOSURE R5 P0
|
||||
0x8C180105, // 000D GETMET R6 R0 K5
|
||||
0x7C180200, // 000E CALL R6 1
|
||||
0x8C1C0106, // 000F GETMET R7 R0 K6
|
||||
0x7C1C0200, // 0010 CALL R7 1
|
||||
0x5C200A00, // 0011 MOVE R8 R5
|
||||
0x54260007, // 0012 LDINT R9 8
|
||||
0x0C240C09, // 0013 DIV R9 R6 R9
|
||||
0x7C200200, // 0014 CALL R8 1
|
||||
0x5C240A00, // 0015 MOVE R9 R5
|
||||
0x08281107, // 0016 MUL R10 R8 K7
|
||||
0x04280C0A, // 0017 SUB R10 R6 R10
|
||||
0x0C281508, // 0018 DIV R10 R10 K8
|
||||
0x7C240200, // 0019 CALL R9 1
|
||||
0x0C281307, // 001A DIV R10 R9 K7
|
||||
0xB82E0000, // 001B GETNGBL R11 K0
|
||||
0x882C1709, // 001C GETMBR R11 R11 K9
|
||||
0x1C2C060B, // 001D EQ R11 R3 R11
|
||||
0x782E0095, // 001E JMPF R11 #00B5
|
||||
0xB82E0000, // 001F GETNGBL R11 K0
|
||||
0x8C2C170A, // 0020 GETMET R11 R11 K10
|
||||
0x8834050B, // 0021 GETMBR R13 R2 K11
|
||||
0x7C2C0400, // 0022 CALL R11 2
|
||||
0x8C30010C, // 0023 GETMET R12 R0 K12
|
||||
0x8838010A, // 0024 GETMBR R14 R0 K10
|
||||
0x7C300400, // 0025 CALL R12 2
|
||||
0x8830010A, // 0026 GETMBR R12 R0 K10
|
||||
0x8830190D, // 0027 GETMBR R12 R12 K13
|
||||
0x8834010A, // 0028 GETMBR R13 R0 K10
|
||||
0x88341B0E, // 0029 GETMBR R13 R13 K14
|
||||
0xB83A0000, // 002A GETNGBL R14 K0
|
||||
0x8C381D0F, // 002B GETMET R14 R14 K15
|
||||
0x88400110, // 002C GETMBR R16 R0 K16
|
||||
0x7C380400, // 002D CALL R14 2
|
||||
0x8C380111, // 002E GETMET R14 R0 K17
|
||||
0xB8420000, // 002F GETNGBL R16 K0
|
||||
0x88402112, // 0030 GETMBR R16 R16 K18
|
||||
0x88440110, // 0031 GETMBR R17 R0 K16
|
||||
0x7C380600, // 0032 CALL R14 3
|
||||
0x88380110, // 0033 GETMBR R14 R0 K16
|
||||
0x903A2714, // 0034 SETMBR R14 K19 K20
|
||||
0x88380110, // 0035 GETMBR R14 R0 K16
|
||||
0x903A2B14, // 0036 SETMBR R14 K21 K20
|
||||
0x88380110, // 0037 GETMBR R14 R0 K16
|
||||
0x083C1308, // 0038 MUL R15 R9 K8
|
||||
0x003C1F14, // 0039 ADD R15 R15 K20
|
||||
0x54420003, // 003A LDINT R16 4
|
||||
0x0C3C1E10, // 003B DIV R15 R15 R16
|
||||
0x903A2C0F, // 003C SETMBR R14 K22 R15
|
||||
0x8C380117, // 003D GETMET R14 R0 K23
|
||||
0xB8420000, // 003E GETNGBL R16 K0
|
||||
0x88402112, // 003F GETMBR R16 R16 K18
|
||||
0xB8460000, // 0040 GETNGBL R17 K0
|
||||
0x88442318, // 0041 GETMBR R17 R17 K24
|
||||
0x30402011, // 0042 OR R16 R16 R17
|
||||
0x7C380400, // 0043 CALL R14 2
|
||||
0x8C3C0119, // 0044 GETMET R15 R0 K25
|
||||
0xB8460000, // 0045 GETNGBL R17 K0
|
||||
0x88442312, // 0046 GETMBR R17 R17 K18
|
||||
0xB84A0000, // 0047 GETNGBL R18 K0
|
||||
0x88482518, // 0048 GETMBR R18 R18 K24
|
||||
0x30442212, // 0049 OR R17 R17 R18
|
||||
0x7C3C0400, // 004A CALL R15 2
|
||||
0x04400C09, // 004B SUB R16 R6 R9
|
||||
0x0C440F07, // 004C DIV R17 R7 K7
|
||||
0x0444220A, // 004D SUB R17 R17 R10
|
||||
0x60480009, // 004E GETGBL R18 G9
|
||||
0x544E0059, // 004F LDINT R19 90
|
||||
0x8C50091A, // 0050 GETMET R20 R4 K26
|
||||
0x8C58091B, // 0051 GETMET R22 R4 K27
|
||||
0x6060000A, // 0052 GETGBL R24 G10
|
||||
0x5C642200, // 0053 MOVE R25 R17
|
||||
0x7C600200, // 0054 CALL R24 1
|
||||
0x6064000A, // 0055 GETGBL R25 G10
|
||||
0x5C682000, // 0056 MOVE R26 R16
|
||||
0x7C640200, // 0057 CALL R25 1
|
||||
0x0C603019, // 0058 DIV R24 R24 R25
|
||||
0x7C580400, // 0059 CALL R22 2
|
||||
0x7C500400, // 005A CALL R20 2
|
||||
0x044C2614, // 005B SUB R19 R19 R20
|
||||
0x7C480200, // 005C CALL R18 1
|
||||
0x544E002C, // 005D LDINT R19 45
|
||||
0x244C2413, // 005E GT R19 R18 R19
|
||||
0x784E0000, // 005F JMPF R19 #0061
|
||||
0x544A002C, // 0060 LDINT R18 45
|
||||
0x884C011C, // 0061 GETMBR R19 R0 K28
|
||||
0x0C500F07, // 0062 DIV R20 R7 K7
|
||||
0x00501814, // 0063 ADD R20 R12 R20
|
||||
0x904E3A14, // 0064 SETMBR R19 K29 R20
|
||||
0x884C011C, // 0065 GETMBR R19 R0 K28
|
||||
0x00501A06, // 0066 ADD R20 R13 R6
|
||||
0x04502914, // 0067 SUB R20 R20 K20
|
||||
0x0450280A, // 0068 SUB R20 R20 R10
|
||||
0x904E3C14, // 0069 SETMBR R19 K30 R20
|
||||
0x884C0110, // 006A GETMBR R19 R0 K16
|
||||
0x88500120, // 006B GETMBR R20 R0 K32
|
||||
0x54560018, // 006C LDINT R21 25
|
||||
0x28502815, // 006D GE R20 R20 R21
|
||||
0x78520001, // 006E JMPF R20 #0071
|
||||
0x5C501C00, // 006F MOVE R20 R14
|
||||
0x70020000, // 0070 JMP #0072
|
||||
0x5C501E00, // 0071 MOVE R20 R15
|
||||
0x904E3E14, // 0072 SETMBR R19 K31 R20
|
||||
0xB84E0000, // 0073 GETNGBL R19 K0
|
||||
0x8C4C2721, // 0074 GETMET R19 R19 K33
|
||||
0x8854011C, // 0075 GETMBR R21 R0 K28
|
||||
0x88542B1D, // 0076 GETMBR R21 R21 K29
|
||||
0x8858011C, // 0077 GETMBR R22 R0 K28
|
||||
0x88582D1E, // 0078 GETMBR R22 R22 K30
|
||||
0x005C1208, // 0079 ADD R23 R9 R8
|
||||
0x085E4417, // 007A MUL R23 K34 R23
|
||||
0x005C2E0A, // 007B ADD R23 R23 R10
|
||||
0x58600022, // 007C LDCONST R24 K34
|
||||
0x54660167, // 007D LDINT R25 360
|
||||
0x5C681600, // 007E MOVE R26 R11
|
||||
0x886C0110, // 007F GETMBR R27 R0 K16
|
||||
0x7C4C1000, // 0080 CALL R19 8
|
||||
0x884C0110, // 0081 GETMBR R19 R0 K16
|
||||
0x88500120, // 0082 GETMBR R20 R0 K32
|
||||
0x54560031, // 0083 LDINT R21 50
|
||||
0x28502815, // 0084 GE R20 R20 R21
|
||||
0x78520001, // 0085 JMPF R20 #0088
|
||||
0x5C501C00, // 0086 MOVE R20 R14
|
||||
0x70020000, // 0087 JMP #0089
|
||||
0x5C501E00, // 0088 MOVE R20 R15
|
||||
0x904E3E14, // 0089 SETMBR R19 K31 R20
|
||||
0xB84E0000, // 008A GETNGBL R19 K0
|
||||
0x8C4C2721, // 008B GETMET R19 R19 K33
|
||||
0x8854011C, // 008C GETMBR R21 R0 K28
|
||||
0x88542B1D, // 008D GETMBR R21 R21 K29
|
||||
0x8858011C, // 008E GETMBR R22 R0 K28
|
||||
0x88582D1E, // 008F GETMBR R22 R22 K30
|
||||
0x005C1208, // 0090 ADD R23 R9 R8
|
||||
0x085E2817, // 0091 MUL R23 K20 R23
|
||||
0x005C2E0A, // 0092 ADD R23 R23 R10
|
||||
0x045C2F14, // 0093 SUB R23 R23 K20
|
||||
0x5462010D, // 0094 LDINT R24 270
|
||||
0x04603012, // 0095 SUB R24 R24 R18
|
||||
0x5466010D, // 0096 LDINT R25 270
|
||||
0x00643212, // 0097 ADD R25 R25 R18
|
||||
0x5C681600, // 0098 MOVE R26 R11
|
||||
0x886C0110, // 0099 GETMBR R27 R0 K16
|
||||
0x7C4C1000, // 009A CALL R19 8
|
||||
0x884C0110, // 009B GETMBR R19 R0 K16
|
||||
0x88500120, // 009C GETMBR R20 R0 K32
|
||||
0x5456004A, // 009D LDINT R21 75
|
||||
0x28502815, // 009E GE R20 R20 R21
|
||||
0x78520001, // 009F JMPF R20 #00A2
|
||||
0x5C501C00, // 00A0 MOVE R20 R14
|
||||
0x70020000, // 00A1 JMP #00A3
|
||||
0x5C501E00, // 00A2 MOVE R20 R15
|
||||
0x904E3E14, // 00A3 SETMBR R19 K31 R20
|
||||
0xB84E0000, // 00A4 GETNGBL R19 K0
|
||||
0x8C4C2721, // 00A5 GETMET R19 R19 K33
|
||||
0x8854011C, // 00A6 GETMBR R21 R0 K28
|
||||
0x88542B1D, // 00A7 GETMBR R21 R21 K29
|
||||
0x8858011C, // 00A8 GETMBR R22 R0 K28
|
||||
0x88582D1E, // 00A9 GETMBR R22 R22 K30
|
||||
0x005C1208, // 00AA ADD R23 R9 R8
|
||||
0x085E0E17, // 00AB MUL R23 K7 R23
|
||||
0x005C2E0A, // 00AC ADD R23 R23 R10
|
||||
0x045C2F07, // 00AD SUB R23 R23 K7
|
||||
0x5462010D, // 00AE LDINT R24 270
|
||||
0x04603012, // 00AF SUB R24 R24 R18
|
||||
0x5466010D, // 00B0 LDINT R25 270
|
||||
0x00643212, // 00B1 ADD R25 R25 R18
|
||||
0x5C681600, // 00B2 MOVE R26 R11
|
||||
0x886C0110, // 00B3 GETMBR R27 R0 K16
|
||||
0x7C4C1000, // 00B4 CALL R19 8
|
||||
0x80000000, // 00B5 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_percentage
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_arcs_get_percentage, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(percentage),
|
||||
}),
|
||||
&be_const_str_get_percentage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x80040200, // 0001 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_signal_arcs
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_obj;
|
||||
be_local_class(lv_signal_arcs,
|
||||
5,
|
||||
&be_class_lv_obj,
|
||||
be_nested_map(9,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(percentage, 4), be_const_var(0) },
|
||||
{ be_const_key(p1, 3), be_const_var(1) },
|
||||
{ be_const_key(p2, -1), be_const_var(2) },
|
||||
{ be_const_key(area, -1), be_const_var(3) },
|
||||
{ be_const_key(line_dsc, -1), be_const_var(4) },
|
||||
{ be_const_key(set_percentage, -1), be_const_closure(lv_signal_arcs_set_percentage_closure) },
|
||||
{ be_const_key(init, -1), be_const_closure(lv_signal_arcs_init_closure) },
|
||||
{ be_const_key(widget_event, -1), be_const_closure(lv_signal_arcs_widget_event_closure) },
|
||||
{ be_const_key(get_percentage, 5), be_const_closure(lv_signal_arcs_get_percentage_closure) },
|
||||
})),
|
||||
be_str_literal("lv_signal_arcs")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_signal_arcs_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_signal_arcs);
|
||||
be_setglobal(vm, "lv_signal_arcs");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,392 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_percentage
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_bars_set_percentage, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(percentage),
|
||||
/* K1 */ be_const_int(0),
|
||||
/* K2 */ be_nested_str(invalidate),
|
||||
}),
|
||||
&be_const_str_set_percentage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[18]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x540E0013, // 0001 LDINT R3 20
|
||||
0x0C080403, // 0002 DIV R2 R2 R3
|
||||
0x540E0063, // 0003 LDINT R3 100
|
||||
0x240C0203, // 0004 GT R3 R1 R3
|
||||
0x780E0000, // 0005 JMPF R3 #0007
|
||||
0x54060063, // 0006 LDINT R1 100
|
||||
0x140C0301, // 0007 LT R3 R1 K1
|
||||
0x780E0000, // 0008 JMPF R3 #000A
|
||||
0x58040001, // 0009 LDCONST R1 K1
|
||||
0x90020001, // 000A SETMBR R0 K0 R1
|
||||
0x540E0013, // 000B LDINT R3 20
|
||||
0x0C0C0203, // 000C DIV R3 R1 R3
|
||||
0x200C0403, // 000D NE R3 R2 R3
|
||||
0x780E0001, // 000E JMPF R3 #0011
|
||||
0x8C0C0102, // 000F GETMET R3 R0 K2
|
||||
0x7C0C0200, // 0010 CALL R3 1
|
||||
0x80000000, // 0011 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_bars_init, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[10]) { /* constants */
|
||||
/* K0 */ be_nested_str(_lvgl),
|
||||
/* K1 */ be_nested_str(create_custom_widget),
|
||||
/* K2 */ be_nested_str(percentage),
|
||||
/* K3 */ be_nested_str(p1),
|
||||
/* K4 */ be_nested_str(lv),
|
||||
/* K5 */ be_nested_str(point),
|
||||
/* K6 */ be_nested_str(p2),
|
||||
/* K7 */ be_nested_str(area),
|
||||
/* K8 */ be_nested_str(line_dsc),
|
||||
/* K9 */ be_nested_str(draw_line_dsc),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[24]) { /* code */
|
||||
0xB80A0000, // 0000 GETNGBL R2 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x5C100000, // 0002 MOVE R4 R0
|
||||
0x5C140200, // 0003 MOVE R5 R1
|
||||
0x7C080600, // 0004 CALL R2 3
|
||||
0x540A0063, // 0005 LDINT R2 100
|
||||
0x90020402, // 0006 SETMBR R0 K2 R2
|
||||
0xB80A0800, // 0007 GETNGBL R2 K4
|
||||
0x8C080505, // 0008 GETMET R2 R2 K5
|
||||
0x7C080200, // 0009 CALL R2 1
|
||||
0x90020602, // 000A SETMBR R0 K3 R2
|
||||
0xB80A0800, // 000B GETNGBL R2 K4
|
||||
0x8C080505, // 000C GETMET R2 R2 K5
|
||||
0x7C080200, // 000D CALL R2 1
|
||||
0x90020C02, // 000E SETMBR R0 K6 R2
|
||||
0xB80A0800, // 000F GETNGBL R2 K4
|
||||
0x8C080507, // 0010 GETMET R2 R2 K7
|
||||
0x7C080200, // 0011 CALL R2 1
|
||||
0x90020E02, // 0012 SETMBR R0 K7 R2
|
||||
0xB80A0800, // 0013 GETNGBL R2 K4
|
||||
0x8C080509, // 0014 GETMET R2 R2 K9
|
||||
0x7C080200, // 0015 CALL R2 1
|
||||
0x90021002, // 0016 SETMBR R0 K8 R2
|
||||
0x80000000, // 0017 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: widget_event
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_bars_widget_event, /* name */
|
||||
be_nested_proto(
|
||||
23, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
1, /* has sup protos */
|
||||
( &(const struct bproto*[ 1]) {
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_atleast1,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x28040100, // 0000 GE R1 R0 K0
|
||||
0x78060001, // 0001 JMPF R1 #0004
|
||||
0x80040000, // 0002 RET 1 R0
|
||||
0x70020000, // 0003 JMP #0005
|
||||
0x80060000, // 0004 RET 1 K0
|
||||
0x80000000, // 0005 RET 0
|
||||
})
|
||||
),
|
||||
}),
|
||||
1, /* has constants */
|
||||
( &(const bvalue[37]) { /* constants */
|
||||
/* K0 */ be_nested_str(lv),
|
||||
/* K1 */ be_nested_str(obj_event_base),
|
||||
/* K2 */ be_nested_str(RES_OK),
|
||||
/* K3 */ be_nested_str(code),
|
||||
/* K4 */ be_nested_str(get_height),
|
||||
/* K5 */ be_nested_str(get_width),
|
||||
/* K6 */ be_const_int(3),
|
||||
/* K7 */ be_const_int(2),
|
||||
/* K8 */ be_nested_str(EVENT_DRAW_MAIN),
|
||||
/* K9 */ be_nested_str(area),
|
||||
/* K10 */ be_nested_str(param),
|
||||
/* K11 */ be_nested_str(get_coords),
|
||||
/* K12 */ be_nested_str(x1),
|
||||
/* K13 */ be_nested_str(y1),
|
||||
/* K14 */ be_nested_str(draw_line_dsc_init),
|
||||
/* K15 */ be_nested_str(line_dsc),
|
||||
/* K16 */ be_nested_str(init_draw_line_dsc),
|
||||
/* K17 */ be_nested_str(PART_MAIN),
|
||||
/* K18 */ be_nested_str(round_start),
|
||||
/* K19 */ be_const_int(1),
|
||||
/* K20 */ be_nested_str(round_end),
|
||||
/* K21 */ be_nested_str(width),
|
||||
/* K22 */ be_nested_str(get_style_line_color),
|
||||
/* K23 */ be_nested_str(STATE_DEFAULT),
|
||||
/* K24 */ be_nested_str(get_style_bg_color),
|
||||
/* K25 */ be_nested_str(event_send),
|
||||
/* K26 */ be_nested_str(EVENT_DRAW_PART_BEGIN),
|
||||
/* K27 */ be_const_int(0),
|
||||
/* K28 */ be_nested_str(color),
|
||||
/* K29 */ be_nested_str(percentage),
|
||||
/* K30 */ be_nested_str(p1),
|
||||
/* K31 */ be_nested_str(y),
|
||||
/* K32 */ be_nested_str(x),
|
||||
/* K33 */ be_nested_str(p2),
|
||||
/* K34 */ be_nested_str(draw_line),
|
||||
/* K35 */ be_nested_str(stop_iteration),
|
||||
/* K36 */ be_nested_str(EVENT_DRAW_PART_END),
|
||||
}),
|
||||
&be_const_str_widget_event,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[138]) { /* code */
|
||||
0xB80E0000, // 0000 GETNGBL R3 K0
|
||||
0x8C0C0701, // 0001 GETMET R3 R3 K1
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0x5C180400, // 0003 MOVE R6 R2
|
||||
0x7C0C0600, // 0004 CALL R3 3
|
||||
0xB8120000, // 0005 GETNGBL R4 K0
|
||||
0x88100902, // 0006 GETMBR R4 R4 K2
|
||||
0x200C0604, // 0007 NE R3 R3 R4
|
||||
0x780E0000, // 0008 JMPF R3 #000A
|
||||
0x80000600, // 0009 RET 0
|
||||
0x880C0503, // 000A GETMBR R3 R2 K3
|
||||
0x84100000, // 000B CLOSURE R4 P0
|
||||
0x8C140104, // 000C GETMET R5 R0 K4
|
||||
0x7C140200, // 000D CALL R5 1
|
||||
0x8C180105, // 000E GETMET R6 R0 K5
|
||||
0x7C180200, // 000F CALL R6 1
|
||||
0x5C1C0800, // 0010 MOVE R7 R4
|
||||
0x5422000E, // 0011 LDINT R8 15
|
||||
0x0C200C08, // 0012 DIV R8 R6 R8
|
||||
0x7C1C0200, // 0013 CALL R7 1
|
||||
0x5C200800, // 0014 MOVE R8 R4
|
||||
0x08240F06, // 0015 MUL R9 R7 K6
|
||||
0x04240C09, // 0016 SUB R9 R6 R9
|
||||
0x542A0003, // 0017 LDINT R10 4
|
||||
0x0C24120A, // 0018 DIV R9 R9 R10
|
||||
0x7C200200, // 0019 CALL R8 1
|
||||
0x0C241107, // 001A DIV R9 R8 K7
|
||||
0xB82A0000, // 001B GETNGBL R10 K0
|
||||
0x88281508, // 001C GETMBR R10 R10 K8
|
||||
0x1C28060A, // 001D EQ R10 R3 R10
|
||||
0x782A0069, // 001E JMPF R10 #0089
|
||||
0xB82A0000, // 001F GETNGBL R10 K0
|
||||
0x8C281509, // 0020 GETMET R10 R10 K9
|
||||
0x8830050A, // 0021 GETMBR R12 R2 K10
|
||||
0x7C280400, // 0022 CALL R10 2
|
||||
0x8C2C010B, // 0023 GETMET R11 R0 K11
|
||||
0x88340109, // 0024 GETMBR R13 R0 K9
|
||||
0x7C2C0400, // 0025 CALL R11 2
|
||||
0x882C0109, // 0026 GETMBR R11 R0 K9
|
||||
0x882C170C, // 0027 GETMBR R11 R11 K12
|
||||
0x88300109, // 0028 GETMBR R12 R0 K9
|
||||
0x8830190D, // 0029 GETMBR R12 R12 K13
|
||||
0xB8360000, // 002A GETNGBL R13 K0
|
||||
0x8C341B0E, // 002B GETMET R13 R13 K14
|
||||
0x883C010F, // 002C GETMBR R15 R0 K15
|
||||
0x7C340400, // 002D CALL R13 2
|
||||
0x8C340110, // 002E GETMET R13 R0 K16
|
||||
0xB83E0000, // 002F GETNGBL R15 K0
|
||||
0x883C1F11, // 0030 GETMBR R15 R15 K17
|
||||
0x8840010F, // 0031 GETMBR R16 R0 K15
|
||||
0x7C340600, // 0032 CALL R13 3
|
||||
0x8834010F, // 0033 GETMBR R13 R0 K15
|
||||
0x90362513, // 0034 SETMBR R13 K18 K19
|
||||
0x8834010F, // 0035 GETMBR R13 R0 K15
|
||||
0x90362913, // 0036 SETMBR R13 K20 K19
|
||||
0x8834010F, // 0037 GETMBR R13 R0 K15
|
||||
0x90362A08, // 0038 SETMBR R13 K21 R8
|
||||
0x8C340116, // 0039 GETMET R13 R0 K22
|
||||
0xB83E0000, // 003A GETNGBL R15 K0
|
||||
0x883C1F11, // 003B GETMBR R15 R15 K17
|
||||
0xB8420000, // 003C GETNGBL R16 K0
|
||||
0x88402117, // 003D GETMBR R16 R16 K23
|
||||
0x303C1E10, // 003E OR R15 R15 R16
|
||||
0x7C340400, // 003F CALL R13 2
|
||||
0x8C380118, // 0040 GETMET R14 R0 K24
|
||||
0xB8420000, // 0041 GETNGBL R16 K0
|
||||
0x88402111, // 0042 GETMBR R16 R16 K17
|
||||
0xB8460000, // 0043 GETNGBL R17 K0
|
||||
0x88442317, // 0044 GETMBR R17 R17 K23
|
||||
0x30402011, // 0045 OR R16 R16 R17
|
||||
0x7C380400, // 0046 CALL R14 2
|
||||
0xB83E0000, // 0047 GETNGBL R15 K0
|
||||
0x8C3C1F19, // 0048 GETMET R15 R15 K25
|
||||
0x5C440000, // 0049 MOVE R17 R0
|
||||
0xB84A0000, // 004A GETNGBL R18 K0
|
||||
0x8848251A, // 004B GETMBR R18 R18 K26
|
||||
0x884C010F, // 004C GETMBR R19 R0 K15
|
||||
0x7C3C0800, // 004D CALL R15 4
|
||||
0x603C0010, // 004E GETGBL R15 G16
|
||||
0x40423706, // 004F CONNECT R16 K27 K6
|
||||
0x7C3C0200, // 0050 CALL R15 1
|
||||
0xA802002C, // 0051 EXBLK 0 #007F
|
||||
0x5C401E00, // 0052 MOVE R16 R15
|
||||
0x7C400000, // 0053 CALL R16 0
|
||||
0x8844010F, // 0054 GETMBR R17 R0 K15
|
||||
0x8848011D, // 0055 GETMBR R18 R0 K29
|
||||
0x004C2113, // 0056 ADD R19 R16 K19
|
||||
0x54520013, // 0057 LDINT R20 20
|
||||
0x084C2614, // 0058 MUL R19 R19 R20
|
||||
0x28482413, // 0059 GE R18 R18 R19
|
||||
0x784A0001, // 005A JMPF R18 #005D
|
||||
0x5C481A00, // 005B MOVE R18 R13
|
||||
0x70020000, // 005C JMP #005E
|
||||
0x5C481C00, // 005D MOVE R18 R14
|
||||
0x90463812, // 005E SETMBR R17 K28 R18
|
||||
0x8844011E, // 005F GETMBR R17 R0 K30
|
||||
0x00481805, // 0060 ADD R18 R12 R5
|
||||
0x04482513, // 0061 SUB R18 R18 K19
|
||||
0x04482409, // 0062 SUB R18 R18 R9
|
||||
0x90463E12, // 0063 SETMBR R17 K31 R18
|
||||
0x8844011E, // 0064 GETMBR R17 R0 K30
|
||||
0x00481007, // 0065 ADD R18 R8 R7
|
||||
0x08482012, // 0066 MUL R18 R16 R18
|
||||
0x00481612, // 0067 ADD R18 R11 R18
|
||||
0x00482409, // 0068 ADD R18 R18 R9
|
||||
0x90464012, // 0069 SETMBR R17 K32 R18
|
||||
0x88440121, // 006A GETMBR R17 R0 K33
|
||||
0x044A0C10, // 006B SUB R18 K6 R16
|
||||
0x044C0A08, // 006C SUB R19 R5 R8
|
||||
0x08482413, // 006D MUL R18 R18 R19
|
||||
0x544E0003, // 006E LDINT R19 4
|
||||
0x0C482413, // 006F DIV R18 R18 R19
|
||||
0x00481812, // 0070 ADD R18 R12 R18
|
||||
0x00482409, // 0071 ADD R18 R18 R9
|
||||
0x90463E12, // 0072 SETMBR R17 K31 R18
|
||||
0x88440121, // 0073 GETMBR R17 R0 K33
|
||||
0x8848011E, // 0074 GETMBR R18 R0 K30
|
||||
0x88482520, // 0075 GETMBR R18 R18 K32
|
||||
0x90464012, // 0076 SETMBR R17 K32 R18
|
||||
0xB8460000, // 0077 GETNGBL R17 K0
|
||||
0x8C442322, // 0078 GETMET R17 R17 K34
|
||||
0x884C011E, // 0079 GETMBR R19 R0 K30
|
||||
0x88500121, // 007A GETMBR R20 R0 K33
|
||||
0x5C541400, // 007B MOVE R21 R10
|
||||
0x8858010F, // 007C GETMBR R22 R0 K15
|
||||
0x7C440A00, // 007D CALL R17 5
|
||||
0x7001FFD2, // 007E JMP #0052
|
||||
0x583C0023, // 007F LDCONST R15 K35
|
||||
0xAC3C0200, // 0080 CATCH R15 1 0
|
||||
0xB0080000, // 0081 RAISE 2 R0 R0
|
||||
0xB83E0000, // 0082 GETNGBL R15 K0
|
||||
0x8C3C1F19, // 0083 GETMET R15 R15 K25
|
||||
0x5C440000, // 0084 MOVE R17 R0
|
||||
0xB84A0000, // 0085 GETNGBL R18 K0
|
||||
0x88482524, // 0086 GETMBR R18 R18 K36
|
||||
0x884C010F, // 0087 GETMBR R19 R0 K15
|
||||
0x7C3C0800, // 0088 CALL R15 4
|
||||
0x80000000, // 0089 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_percentage
|
||||
********************************************************************/
|
||||
be_local_closure(lv_signal_bars_get_percentage, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str(percentage),
|
||||
}),
|
||||
&be_const_str_get_percentage,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x88040100, // 0000 GETMBR R1 R0 K0
|
||||
0x80040200, // 0001 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_signal_bars
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_obj;
|
||||
be_local_class(lv_signal_bars,
|
||||
5,
|
||||
&be_class_lv_obj,
|
||||
be_nested_map(9,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(percentage, 4), be_const_var(0) },
|
||||
{ be_const_key(p1, 3), be_const_var(1) },
|
||||
{ be_const_key(p2, -1), be_const_var(2) },
|
||||
{ be_const_key(area, -1), be_const_var(3) },
|
||||
{ be_const_key(line_dsc, -1), be_const_var(4) },
|
||||
{ be_const_key(set_percentage, -1), be_const_closure(lv_signal_bars_set_percentage_closure) },
|
||||
{ be_const_key(init, -1), be_const_closure(lv_signal_bars_init_closure) },
|
||||
{ be_const_key(widget_event, -1), be_const_closure(lv_signal_bars_widget_event_closure) },
|
||||
{ be_const_key(get_percentage, 5), be_const_closure(lv_signal_bars_get_percentage_closure) },
|
||||
})),
|
||||
be_str_literal("lv_signal_bars")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_signal_bars_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_signal_bars);
|
||||
be_setglobal(vm, "lv_signal_bars");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,140 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_arcs_icon_init, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[18]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(set_style_line_color),
|
||||
/* K2 */ be_nested_str(lv),
|
||||
/* K3 */ be_nested_str(color),
|
||||
/* K4 */ be_nested_str(COLOR_WHITE),
|
||||
/* K5 */ be_nested_str(PART_MAIN),
|
||||
/* K6 */ be_nested_str(STATE_DEFAULT),
|
||||
/* K7 */ be_nested_str(set_style_bg_color),
|
||||
/* K8 */ be_nested_str(COLOR_BLACK),
|
||||
/* K9 */ be_nested_str(get_height),
|
||||
/* K10 */ be_nested_str(get_style_pad_right),
|
||||
/* K11 */ be_nested_str(set_height),
|
||||
/* K12 */ be_const_int(3),
|
||||
/* K13 */ be_nested_str(set_width),
|
||||
/* K14 */ be_nested_str(set_x),
|
||||
/* K15 */ be_nested_str(get_width),
|
||||
/* K16 */ be_nested_str(set_style_pad_right),
|
||||
/* K17 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[67]) { /* code */
|
||||
0x60080003, // 0000 GETGBL R2 G3
|
||||
0x5C0C0000, // 0001 MOVE R3 R0
|
||||
0x7C080200, // 0002 CALL R2 1
|
||||
0x8C080500, // 0003 GETMET R2 R2 K0
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x8C080101, // 0006 GETMET R2 R0 K1
|
||||
0xB8120400, // 0007 GETNGBL R4 K2
|
||||
0x8C100903, // 0008 GETMET R4 R4 K3
|
||||
0xB81A0400, // 0009 GETNGBL R6 K2
|
||||
0x88180D04, // 000A GETMBR R6 R6 K4
|
||||
0x7C100400, // 000B CALL R4 2
|
||||
0xB8160400, // 000C GETNGBL R5 K2
|
||||
0x88140B05, // 000D GETMBR R5 R5 K5
|
||||
0xB81A0400, // 000E GETNGBL R6 K2
|
||||
0x88180D06, // 000F GETMBR R6 R6 K6
|
||||
0x30140A06, // 0010 OR R5 R5 R6
|
||||
0x7C080600, // 0011 CALL R2 3
|
||||
0x8C080107, // 0012 GETMET R2 R0 K7
|
||||
0xB8120400, // 0013 GETNGBL R4 K2
|
||||
0x8C100903, // 0014 GETMET R4 R4 K3
|
||||
0xB81A0400, // 0015 GETNGBL R6 K2
|
||||
0x88180D08, // 0016 GETMBR R6 R6 K8
|
||||
0x7C100400, // 0017 CALL R4 2
|
||||
0xB8160400, // 0018 GETNGBL R5 K2
|
||||
0x88140B05, // 0019 GETMBR R5 R5 K5
|
||||
0xB81A0400, // 001A GETNGBL R6 K2
|
||||
0x88180D06, // 001B GETMBR R6 R6 K6
|
||||
0x30140A06, // 001C OR R5 R5 R6
|
||||
0x7C080600, // 001D CALL R2 3
|
||||
0x4C080000, // 001E LDNIL R2
|
||||
0x20080202, // 001F NE R2 R1 R2
|
||||
0x780A0020, // 0020 JMPF R2 #0042
|
||||
0x8C080309, // 0021 GETMET R2 R1 K9
|
||||
0x7C080200, // 0022 CALL R2 1
|
||||
0x8C0C030A, // 0023 GETMET R3 R1 K10
|
||||
0xB8160400, // 0024 GETNGBL R5 K2
|
||||
0x88140B05, // 0025 GETMBR R5 R5 K5
|
||||
0xB81A0400, // 0026 GETNGBL R6 K2
|
||||
0x88180D06, // 0027 GETMBR R6 R6 K6
|
||||
0x30140A06, // 0028 OR R5 R5 R6
|
||||
0x7C0C0400, // 0029 CALL R3 2
|
||||
0x8C10010B, // 002A GETMET R4 R0 K11
|
||||
0x5C180400, // 002B MOVE R6 R2
|
||||
0x7C100400, // 002C CALL R4 2
|
||||
0x54120003, // 002D LDINT R4 4
|
||||
0x08100404, // 002E MUL R4 R2 R4
|
||||
0x0C10090C, // 002F DIV R4 R4 K12
|
||||
0x8C14010D, // 0030 GETMET R5 R0 K13
|
||||
0x5C1C0800, // 0031 MOVE R7 R4
|
||||
0x7C140400, // 0032 CALL R5 2
|
||||
0x8C14010E, // 0033 GETMET R5 R0 K14
|
||||
0x8C1C030F, // 0034 GETMET R7 R1 K15
|
||||
0x7C1C0200, // 0035 CALL R7 1
|
||||
0x041C0E04, // 0036 SUB R7 R7 R4
|
||||
0x041C0E03, // 0037 SUB R7 R7 R3
|
||||
0x7C140400, // 0038 CALL R5 2
|
||||
0x8C140310, // 0039 GETMET R5 R1 K16
|
||||
0x001C0604, // 003A ADD R7 R3 R4
|
||||
0x001C0F11, // 003B ADD R7 R7 K17
|
||||
0xB8220400, // 003C GETNGBL R8 K2
|
||||
0x88201105, // 003D GETMBR R8 R8 K5
|
||||
0xB8260400, // 003E GETNGBL R9 K2
|
||||
0x88241306, // 003F GETMBR R9 R9 K6
|
||||
0x30201009, // 0040 OR R8 R8 R9
|
||||
0x7C140600, // 0041 CALL R5 3
|
||||
0x80000000, // 0042 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_wifi_arcs_icon
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_wifi_arcs;
|
||||
be_local_class(lv_wifi_arcs_icon,
|
||||
0,
|
||||
&be_class_lv_wifi_arcs,
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(lv_wifi_arcs_icon_init_closure) },
|
||||
})),
|
||||
be_str_literal("lv_wifi_arcs_icon")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_wifi_arcs_icon_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_wifi_arcs_icon);
|
||||
be_setglobal(vm, "lv_wifi_arcs_icon");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,167 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: every_second
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_arcs_every_second, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(wifi),
|
||||
/* K2 */ be_nested_str(find),
|
||||
/* K3 */ be_nested_str(quality),
|
||||
/* K4 */ be_nested_str(ip),
|
||||
/* K5 */ be_nested_str(set_percentage),
|
||||
/* K6 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_every_second,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[23]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x7C040200, // 0002 CALL R1 1
|
||||
0x8C080302, // 0003 GETMET R2 R1 K2
|
||||
0x58100003, // 0004 LDCONST R4 K3
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x8C0C0302, // 0006 GETMET R3 R1 K2
|
||||
0x58140004, // 0007 LDCONST R5 K4
|
||||
0x7C0C0400, // 0008 CALL R3 2
|
||||
0x4C100000, // 0009 LDNIL R4
|
||||
0x1C100604, // 000A EQ R4 R3 R4
|
||||
0x78120003, // 000B JMPF R4 #0010
|
||||
0x8C100105, // 000C GETMET R4 R0 K5
|
||||
0x58180006, // 000D LDCONST R6 K6
|
||||
0x7C100400, // 000E CALL R4 2
|
||||
0x70020005, // 000F JMP #0016
|
||||
0x4C100000, // 0010 LDNIL R4
|
||||
0x20100404, // 0011 NE R4 R2 R4
|
||||
0x78120002, // 0012 JMPF R4 #0016
|
||||
0x8C100105, // 0013 GETMET R4 R0 K5
|
||||
0x5C180400, // 0014 MOVE R6 R2
|
||||
0x7C100400, // 0015 CALL R4 2
|
||||
0x80000000, // 0016 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_arcs_init, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(add_driver),
|
||||
/* K3 */ be_nested_str(set_percentage),
|
||||
/* K4 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[14]) { /* code */
|
||||
0x60080003, // 0000 GETGBL R2 G3
|
||||
0x5C0C0000, // 0001 MOVE R3 R0
|
||||
0x7C080200, // 0002 CALL R2 1
|
||||
0x8C080500, // 0003 GETMET R2 R2 K0
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0xB80A0200, // 0006 GETNGBL R2 K1
|
||||
0x8C080502, // 0007 GETMET R2 R2 K2
|
||||
0x5C100000, // 0008 MOVE R4 R0
|
||||
0x7C080400, // 0009 CALL R2 2
|
||||
0x8C080103, // 000A GETMET R2 R0 K3
|
||||
0x58100004, // 000B LDCONST R4 K4
|
||||
0x7C080400, // 000C CALL R2 2
|
||||
0x80000000, // 000D RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: del
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_arcs_del, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(del),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(remove_driver),
|
||||
}),
|
||||
&be_const_str_del,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[10]) { /* code */
|
||||
0x60040003, // 0000 GETGBL R1 G3
|
||||
0x5C080000, // 0001 MOVE R2 R0
|
||||
0x7C040200, // 0002 CALL R1 1
|
||||
0x8C040300, // 0003 GETMET R1 R1 K0
|
||||
0x7C040200, // 0004 CALL R1 1
|
||||
0xB8060200, // 0005 GETNGBL R1 K1
|
||||
0x8C040302, // 0006 GETMET R1 R1 K2
|
||||
0x5C0C0000, // 0007 MOVE R3 R0
|
||||
0x7C040400, // 0008 CALL R1 2
|
||||
0x80000000, // 0009 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_wifi_arcs
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_signal_arcs;
|
||||
be_local_class(lv_wifi_arcs,
|
||||
0,
|
||||
&be_class_lv_signal_arcs,
|
||||
be_nested_map(3,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(every_second, 1), be_const_closure(lv_wifi_arcs_every_second_closure) },
|
||||
{ be_const_key(init, -1), be_const_closure(lv_wifi_arcs_init_closure) },
|
||||
{ be_const_key(del, -1), be_const_closure(lv_wifi_arcs_del_closure) },
|
||||
})),
|
||||
be_str_literal("lv_wifi_arcs")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_wifi_arcs_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_wifi_arcs);
|
||||
be_setglobal(vm, "lv_wifi_arcs");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,136 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_bars_icon_init, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[17]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(set_style_line_color),
|
||||
/* K2 */ be_nested_str(lv),
|
||||
/* K3 */ be_nested_str(color),
|
||||
/* K4 */ be_nested_str(COLOR_WHITE),
|
||||
/* K5 */ be_nested_str(PART_MAIN),
|
||||
/* K6 */ be_nested_str(STATE_DEFAULT),
|
||||
/* K7 */ be_nested_str(set_style_bg_color),
|
||||
/* K8 */ be_nested_str(COLOR_BLACK),
|
||||
/* K9 */ be_nested_str(get_height),
|
||||
/* K10 */ be_nested_str(get_style_pad_right),
|
||||
/* K11 */ be_nested_str(set_height),
|
||||
/* K12 */ be_nested_str(set_width),
|
||||
/* K13 */ be_nested_str(set_x),
|
||||
/* K14 */ be_nested_str(get_width),
|
||||
/* K15 */ be_nested_str(set_style_pad_right),
|
||||
/* K16 */ be_const_int(1),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[64]) { /* code */
|
||||
0x60080003, // 0000 GETGBL R2 G3
|
||||
0x5C0C0000, // 0001 MOVE R3 R0
|
||||
0x7C080200, // 0002 CALL R2 1
|
||||
0x8C080500, // 0003 GETMET R2 R2 K0
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x8C080101, // 0006 GETMET R2 R0 K1
|
||||
0xB8120400, // 0007 GETNGBL R4 K2
|
||||
0x8C100903, // 0008 GETMET R4 R4 K3
|
||||
0xB81A0400, // 0009 GETNGBL R6 K2
|
||||
0x88180D04, // 000A GETMBR R6 R6 K4
|
||||
0x7C100400, // 000B CALL R4 2
|
||||
0xB8160400, // 000C GETNGBL R5 K2
|
||||
0x88140B05, // 000D GETMBR R5 R5 K5
|
||||
0xB81A0400, // 000E GETNGBL R6 K2
|
||||
0x88180D06, // 000F GETMBR R6 R6 K6
|
||||
0x30140A06, // 0010 OR R5 R5 R6
|
||||
0x7C080600, // 0011 CALL R2 3
|
||||
0x8C080107, // 0012 GETMET R2 R0 K7
|
||||
0xB8120400, // 0013 GETNGBL R4 K2
|
||||
0x8C100903, // 0014 GETMET R4 R4 K3
|
||||
0xB81A0400, // 0015 GETNGBL R6 K2
|
||||
0x88180D08, // 0016 GETMBR R6 R6 K8
|
||||
0x7C100400, // 0017 CALL R4 2
|
||||
0xB8160400, // 0018 GETNGBL R5 K2
|
||||
0x88140B05, // 0019 GETMBR R5 R5 K5
|
||||
0xB81A0400, // 001A GETNGBL R6 K2
|
||||
0x88180D06, // 001B GETMBR R6 R6 K6
|
||||
0x30140A06, // 001C OR R5 R5 R6
|
||||
0x7C080600, // 001D CALL R2 3
|
||||
0x4C080000, // 001E LDNIL R2
|
||||
0x20080202, // 001F NE R2 R1 R2
|
||||
0x780A001D, // 0020 JMPF R2 #003F
|
||||
0x8C080309, // 0021 GETMET R2 R1 K9
|
||||
0x7C080200, // 0022 CALL R2 1
|
||||
0x8C0C030A, // 0023 GETMET R3 R1 K10
|
||||
0xB8160400, // 0024 GETNGBL R5 K2
|
||||
0x88140B05, // 0025 GETMBR R5 R5 K5
|
||||
0xB81A0400, // 0026 GETNGBL R6 K2
|
||||
0x88180D06, // 0027 GETMBR R6 R6 K6
|
||||
0x30140A06, // 0028 OR R5 R5 R6
|
||||
0x7C0C0400, // 0029 CALL R3 2
|
||||
0x8C10010B, // 002A GETMET R4 R0 K11
|
||||
0x5C180400, // 002B MOVE R6 R2
|
||||
0x7C100400, // 002C CALL R4 2
|
||||
0x8C10010C, // 002D GETMET R4 R0 K12
|
||||
0x5C180400, // 002E MOVE R6 R2
|
||||
0x7C100400, // 002F CALL R4 2
|
||||
0x8C10010D, // 0030 GETMET R4 R0 K13
|
||||
0x8C18030E, // 0031 GETMET R6 R1 K14
|
||||
0x7C180200, // 0032 CALL R6 1
|
||||
0x04180C02, // 0033 SUB R6 R6 R2
|
||||
0x04180C03, // 0034 SUB R6 R6 R3
|
||||
0x7C100400, // 0035 CALL R4 2
|
||||
0x8C10030F, // 0036 GETMET R4 R1 K15
|
||||
0x00180602, // 0037 ADD R6 R3 R2
|
||||
0x00180D10, // 0038 ADD R6 R6 K16
|
||||
0xB81E0400, // 0039 GETNGBL R7 K2
|
||||
0x881C0F05, // 003A GETMBR R7 R7 K5
|
||||
0xB8220400, // 003B GETNGBL R8 K2
|
||||
0x88201106, // 003C GETMBR R8 R8 K6
|
||||
0x301C0E08, // 003D OR R7 R7 R8
|
||||
0x7C100600, // 003E CALL R4 3
|
||||
0x80000000, // 003F RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_wifi_bars_icon
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_wifi_bars;
|
||||
be_local_class(lv_wifi_bars_icon,
|
||||
0,
|
||||
&be_class_lv_wifi_bars,
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(lv_wifi_bars_icon_init_closure) },
|
||||
})),
|
||||
be_str_literal("lv_wifi_bars_icon")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_wifi_bars_icon_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_wifi_bars_icon);
|
||||
be_setglobal(vm, "lv_wifi_bars_icon");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,167 @@
|
|||
/********************************************************************
|
||||
* Tasmota LVGL lv_signal_bars widget
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_LVGL
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: every_second
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_bars_every_second, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(wifi),
|
||||
/* K2 */ be_nested_str(find),
|
||||
/* K3 */ be_nested_str(quality),
|
||||
/* K4 */ be_nested_str(ip),
|
||||
/* K5 */ be_nested_str(set_percentage),
|
||||
/* K6 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_every_second,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[23]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x7C040200, // 0002 CALL R1 1
|
||||
0x8C080302, // 0003 GETMET R2 R1 K2
|
||||
0x58100003, // 0004 LDCONST R4 K3
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x8C0C0302, // 0006 GETMET R3 R1 K2
|
||||
0x58140004, // 0007 LDCONST R5 K4
|
||||
0x7C0C0400, // 0008 CALL R3 2
|
||||
0x4C100000, // 0009 LDNIL R4
|
||||
0x1C100604, // 000A EQ R4 R3 R4
|
||||
0x78120003, // 000B JMPF R4 #0010
|
||||
0x8C100105, // 000C GETMET R4 R0 K5
|
||||
0x58180006, // 000D LDCONST R6 K6
|
||||
0x7C100400, // 000E CALL R4 2
|
||||
0x70020005, // 000F JMP #0016
|
||||
0x4C100000, // 0010 LDNIL R4
|
||||
0x20100404, // 0011 NE R4 R2 R4
|
||||
0x78120002, // 0012 JMPF R4 #0016
|
||||
0x8C100105, // 0013 GETMET R4 R0 K5
|
||||
0x5C180400, // 0014 MOVE R6 R2
|
||||
0x7C100400, // 0015 CALL R4 2
|
||||
0x80000000, // 0016 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_bars_init, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(init),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(add_driver),
|
||||
/* K3 */ be_nested_str(set_percentage),
|
||||
/* K4 */ be_const_int(0),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[14]) { /* code */
|
||||
0x60080003, // 0000 GETGBL R2 G3
|
||||
0x5C0C0000, // 0001 MOVE R3 R0
|
||||
0x7C080200, // 0002 CALL R2 1
|
||||
0x8C080500, // 0003 GETMET R2 R2 K0
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0xB80A0200, // 0006 GETNGBL R2 K1
|
||||
0x8C080502, // 0007 GETMET R2 R2 K2
|
||||
0x5C100000, // 0008 MOVE R4 R0
|
||||
0x7C080400, // 0009 CALL R2 2
|
||||
0x8C080103, // 000A GETMET R2 R0 K3
|
||||
0x58100004, // 000B LDCONST R4 K4
|
||||
0x7C080400, // 000C CALL R2 2
|
||||
0x80000000, // 000D RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: del
|
||||
********************************************************************/
|
||||
be_local_closure(lv_wifi_bars_del, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(del),
|
||||
/* K1 */ be_nested_str(tasmota),
|
||||
/* K2 */ be_nested_str(remove_driver),
|
||||
}),
|
||||
&be_const_str_del,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[10]) { /* code */
|
||||
0x60040003, // 0000 GETGBL R1 G3
|
||||
0x5C080000, // 0001 MOVE R2 R0
|
||||
0x7C040200, // 0002 CALL R1 1
|
||||
0x8C040300, // 0003 GETMET R1 R1 K0
|
||||
0x7C040200, // 0004 CALL R1 1
|
||||
0xB8060200, // 0005 GETNGBL R1 K1
|
||||
0x8C040302, // 0006 GETMET R1 R1 K2
|
||||
0x5C0C0000, // 0007 MOVE R3 R0
|
||||
0x7C040400, // 0008 CALL R1 2
|
||||
0x80000000, // 0009 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_wifi_bars
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_signal_bars;
|
||||
be_local_class(lv_wifi_bars,
|
||||
0,
|
||||
&be_class_lv_signal_bars,
|
||||
be_nested_map(3,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(every_second, 1), be_const_closure(lv_wifi_bars_every_second_closure) },
|
||||
{ be_const_key(init, -1), be_const_closure(lv_wifi_bars_init_closure) },
|
||||
{ be_const_key(del, -1), be_const_closure(lv_wifi_bars_del_closure) },
|
||||
})),
|
||||
be_str_literal("lv_wifi_bars")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_lv_wifi_bars_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_lv_wifi_bars);
|
||||
be_setglobal(vm, "lv_wifi_bars");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
#endif // USE_LVGL
|
|
@ -0,0 +1,30 @@
|
|||
/********************************************************************
|
||||
* Berry module `webserver`
|
||||
*
|
||||
* To use: `import webserver`
|
||||
*
|
||||
* Allows to respond to HTTP request
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
extern int m_md5_init(bvm *vm);
|
||||
extern int m_md5_update(bvm *vm);
|
||||
extern int m_md5_finish(bvm *vm);
|
||||
|
||||
#include "../generate/be_fixed_be_class_md5.h"
|
||||
|
||||
void be_load_md5_lib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_md5);
|
||||
be_setglobal(vm, "MD5");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_md5 (scope: global, name: MD5) {
|
||||
.p, var
|
||||
|
||||
init, func(m_md5_init)
|
||||
update, func(m_md5_update)
|
||||
finish, func(m_md5_finish)
|
||||
}
|
||||
@const_object_info_end */
|
|
@ -0,0 +1,230 @@
|
|||
/********************************************************************
|
||||
** Copyright (c) 2018-2020 Guan Wenliang
|
||||
** This file is part of the Berry default interpreter.
|
||||
** skiars@qq.com, https://github.com/Skiars/berry
|
||||
** See Copyright Notice in the LICENSE file or at
|
||||
** https://github.com/Skiars/berry/blob/master/LICENSE
|
||||
********************************************************************/
|
||||
#include "berry.h"
|
||||
|
||||
/* this file contains the declaration of the module table. */
|
||||
|
||||
/* default modules declare */
|
||||
be_extern_native_module(string);
|
||||
be_extern_native_module(json);
|
||||
be_extern_native_module(math);
|
||||
be_extern_native_module(time);
|
||||
be_extern_native_module(os);
|
||||
be_extern_native_module(global);
|
||||
be_extern_native_module(sys);
|
||||
be_extern_native_module(debug);
|
||||
be_extern_native_module(gc);
|
||||
be_extern_native_module(solidify);
|
||||
be_extern_native_module(introspect);
|
||||
be_extern_native_module(strict);
|
||||
|
||||
/* Berry extensions */
|
||||
#include "be_mapping.h"
|
||||
be_extern_native_module(cb);
|
||||
|
||||
/* Tasmota specific */
|
||||
be_extern_native_module(python_compat);
|
||||
be_extern_native_module(re);
|
||||
be_extern_native_module(persist);
|
||||
be_extern_native_module(autoconf);
|
||||
be_extern_native_module(tapp);
|
||||
be_extern_native_module(light);
|
||||
be_extern_native_module(gpio);
|
||||
be_extern_native_module(display);
|
||||
be_extern_native_module(energy);
|
||||
be_extern_native_module(webserver);
|
||||
be_extern_native_module(flash);
|
||||
be_extern_native_module(path);
|
||||
be_extern_native_module(unishox);
|
||||
be_extern_native_module(animate);
|
||||
#ifdef USE_LVGL
|
||||
be_extern_native_module(lv);
|
||||
#endif // USE_LVGL
|
||||
|
||||
/* user-defined modules declare start */
|
||||
|
||||
/* user-defined modules declare end */
|
||||
|
||||
/* module list declaration */
|
||||
BERRY_LOCAL const bntvmodule* const be_module_table[] = {
|
||||
/* default modules register */
|
||||
#if BE_USE_STRING_MODULE
|
||||
&be_native_module(string),
|
||||
#endif
|
||||
#if BE_USE_JSON_MODULE
|
||||
&be_native_module(json),
|
||||
#endif
|
||||
#if BE_USE_MATH_MODULE
|
||||
&be_native_module(math),
|
||||
#endif
|
||||
#if BE_USE_TIME_MODULE
|
||||
&be_native_module(time),
|
||||
#endif
|
||||
#if BE_USE_OS_MODULE
|
||||
&be_native_module(os),
|
||||
#endif
|
||||
#if BE_USE_GLOBAL_MODULE
|
||||
&be_native_module(global),
|
||||
#endif
|
||||
#if BE_USE_SYS_MODULE
|
||||
&be_native_module(sys),
|
||||
#endif
|
||||
#if BE_USE_DEBUG_MODULE
|
||||
&be_native_module(debug),
|
||||
#endif
|
||||
#if BE_USE_GC_MODULE
|
||||
&be_native_module(gc),
|
||||
#endif
|
||||
#if BE_USE_SOLIDIFY_MODULE
|
||||
&be_native_module(solidify),
|
||||
#endif
|
||||
#if BE_USE_INTROSPECT_MODULE
|
||||
&be_native_module(introspect),
|
||||
#endif
|
||||
#if BE_USE_STRICT_MODULE
|
||||
&be_native_module(strict),
|
||||
#endif
|
||||
|
||||
/* Berry extensions */
|
||||
&be_native_module(cb),
|
||||
|
||||
/* user-defined modules register start */
|
||||
|
||||
&be_native_module(python_compat),
|
||||
&be_native_module(re),
|
||||
&be_native_module(path),
|
||||
&be_native_module(persist),
|
||||
#ifdef USE_AUTOCONF
|
||||
&be_native_module(autoconf),
|
||||
#endif // USE_AUTOCONF
|
||||
&be_native_module(tapp),
|
||||
&be_native_module(gpio),
|
||||
#ifdef USE_DISPLAY
|
||||
&be_native_module(display),
|
||||
#endif // USE_DISPLAY
|
||||
#ifdef USE_LIGHT
|
||||
&be_native_module(light),
|
||||
#endif
|
||||
|
||||
#ifdef USE_UNISHOX_COMPRESSION
|
||||
&be_native_module(unishox),
|
||||
#endif // USE_UNISHOX_COMPRESSION
|
||||
&be_native_module(animate),
|
||||
|
||||
#ifdef USE_LVGL
|
||||
&be_native_module(lv),
|
||||
#endif // USE_LVGL
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
&be_native_module(energy),
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
#ifdef USE_WEBSERVER
|
||||
&be_native_module(webserver),
|
||||
#endif // USE_WEBSERVER
|
||||
&be_native_module(flash),
|
||||
|
||||
|
||||
/* user-defined modules register end */
|
||||
NULL /* do not remove */
|
||||
};
|
||||
|
||||
#ifdef ESP32
|
||||
extern void be_load_tasmota_ntvlib(bvm *vm);
|
||||
extern void be_load_wirelib(bvm *vm);
|
||||
extern void be_load_onewirelib(bvm *vm);
|
||||
extern void be_load_serial_lib(bvm *vm);
|
||||
extern void be_load_Driver_class(bvm *vm);
|
||||
extern void be_load_Timer_class(bvm *vm);
|
||||
extern void be_load_I2C_Driver_class(bvm *vm);
|
||||
extern void be_load_AXP192_class(bvm *vm);
|
||||
extern void be_load_md5_lib(bvm *vm);
|
||||
extern void be_load_webclient_lib(bvm *vm);
|
||||
extern void be_load_tcpclient_lib(bvm *vm);
|
||||
extern void be_load_crypto_lib(bvm *vm);
|
||||
extern void be_load_Leds_ntv_class(bvm *vm);
|
||||
extern void be_load_Leds_class(bvm *vm);
|
||||
extern void be_load_Leds_animator_class(bvm *vm);
|
||||
|
||||
extern void be_load_ctypes_lib(bvm *vm);
|
||||
extern void be_load_ctypes_energy_definitions_lib(bvm *vm);
|
||||
|
||||
#ifdef USE_I2S_AUDIO_BERRY
|
||||
extern void be_load_driver_audio_lib(bvm *vm);
|
||||
#endif
|
||||
|
||||
#ifdef USE_LVGL
|
||||
extern void be_load_lv_color_class(bvm *vm);
|
||||
extern void be_load_lv_font_class(bvm *vm);
|
||||
extern void be_load_LVGL_glob_class(bvm *vm);
|
||||
// custom widgets
|
||||
extern void be_load_lv_signal_bars_class(bvm *vm);
|
||||
extern void be_load_lv_wifi_bars_class(bvm *vm);
|
||||
extern void be_load_lv_wifi_bars_icon_class(bvm *vm);
|
||||
extern void be_load_lv_signal_arcs_class(bvm *vm);
|
||||
extern void be_load_lv_wifi_arcs_class(bvm *vm);
|
||||
extern void be_load_lv_wifi_arcs_icon_class(bvm *vm);
|
||||
extern void be_load_lv_clock_icon_class(bvm *vm);
|
||||
#endif// USE_LVGL
|
||||
|
||||
/* this code loads the native class definitions */
|
||||
BERRY_API void be_load_custom_libs(bvm *vm)
|
||||
{
|
||||
(void)vm; /* prevent a compiler warning */
|
||||
|
||||
/* add here custom libs */
|
||||
#if !BE_USE_PRECOMPILED_OBJECT
|
||||
/* be_load_xxxlib(vm); */
|
||||
#endif
|
||||
be_load_Timer_class(vm);
|
||||
be_load_tasmota_ntvlib(vm);
|
||||
be_load_Driver_class(vm);
|
||||
be_load_md5_lib(vm);
|
||||
be_load_serial_lib(vm);
|
||||
be_load_ctypes_lib(vm);
|
||||
#ifdef USE_ALEXA_AVS
|
||||
be_load_crypto_lib(vm);
|
||||
#endif
|
||||
#ifdef USE_I2C
|
||||
be_load_wirelib(vm);
|
||||
be_load_I2C_Driver_class(vm);
|
||||
be_load_AXP192_class(vm);
|
||||
#endif // USE_I2C
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
be_load_ctypes_energy_definitions_lib(vm);
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
#ifdef USE_WEBCLIENT
|
||||
be_load_webclient_lib(vm);
|
||||
be_load_tcpclient_lib(vm);
|
||||
#endif // USE_WEBCLIENT
|
||||
#if defined(USE_ONEWIRE) || defined(USE_DS18x20)
|
||||
be_load_onewirelib(vm);
|
||||
#endif
|
||||
#ifdef USE_WS2812
|
||||
be_load_Leds_ntv_class(vm);
|
||||
be_load_Leds_class(vm);
|
||||
be_load_Leds_animator_class(vm);
|
||||
#endif // USE_WS2812
|
||||
#ifdef USE_I2S_AUDIO_BERRY
|
||||
be_load_driver_audio_lib(vm);
|
||||
#endif
|
||||
#ifdef USE_LVGL
|
||||
// LVGL
|
||||
be_load_lv_color_class(vm);
|
||||
be_load_lv_font_class(vm);
|
||||
|
||||
be_load_LVGL_glob_class(vm);
|
||||
// custom widgets
|
||||
be_load_lv_signal_bars_class(vm);
|
||||
be_load_lv_wifi_bars_class(vm);
|
||||
be_load_lv_wifi_bars_icon_class(vm);
|
||||
be_load_lv_signal_arcs_class(vm);
|
||||
be_load_lv_wifi_arcs_class(vm);
|
||||
be_load_lv_wifi_arcs_icon_class(vm);
|
||||
be_load_lv_clock_icon_class(vm);
|
||||
#endif // USE_LVGL
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import wire`
|
||||
*
|
||||
* 2 wire communication - I2C
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#if defined(USE_ONEWIRE) || defined(USE_DS18x20)
|
||||
|
||||
extern int b_onewire_init(bvm *vm);
|
||||
extern int b_onewire_deinit(bvm *vm);
|
||||
|
||||
extern int b_onewire_reset(bvm *vm);
|
||||
extern int b_onewire_select(bvm *vm);
|
||||
extern int b_onewire_skip(bvm *vm);
|
||||
extern int b_onewire_depower(bvm *vm);
|
||||
|
||||
extern int b_onewire_write(bvm *vm);
|
||||
extern int b_onewire_read(bvm *vm);
|
||||
|
||||
extern int b_onewire_reset_search(bvm *vm);
|
||||
extern int b_onewire_target_search(bvm *vm);
|
||||
extern int b_onewire_search(bvm *vm);
|
||||
|
||||
#include "../generate/be_fixed_be_class_tasmota_onewire.h"
|
||||
|
||||
void be_load_onewirelib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_tasmota_onewire);
|
||||
be_setglobal(vm, "OneWire");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_tasmota_onewire (scope: global, name: OneWire) {
|
||||
.p, var
|
||||
|
||||
init, func(b_onewire_init)
|
||||
deinit, func(b_onewire_deinit)
|
||||
|
||||
reset, func(b_onewire_reset)
|
||||
select, func(b_onewire_select)
|
||||
skip, func(b_onewire_skip)
|
||||
depower, func(b_onewire_depower)
|
||||
|
||||
write, func(b_onewire_write)
|
||||
read, func(b_onewire_read)
|
||||
|
||||
reset_search, func(b_onewire_reset_search)
|
||||
target_search, func(b_onewire_target_search)
|
||||
search, func(b_onewire_search)
|
||||
}
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // defined(USE_ONEWIRE) || defined(USE_DS18x20)
|
|
@ -0,0 +1,70 @@
|
|||
/********************************************************************
|
||||
** Copyright (c) 2018-2020 Guan Wenliang
|
||||
** This file is part of the Berry default interpreter.
|
||||
** skiars@qq.com, https://github.com/Skiars/berry
|
||||
** See Copyright Notice in the LICENSE file or at
|
||||
** https://github.com/Skiars/berry/blob/master/LICENSE
|
||||
********************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
* Berry module `path`
|
||||
*
|
||||
* Minimal version of `import path`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_object.h"
|
||||
#include "be_strlib.h"
|
||||
#include "be_mem.h"
|
||||
#include "be_sys.h"
|
||||
#include <time.h>
|
||||
|
||||
extern int m_path_listdir(bvm *vm);
|
||||
|
||||
static int m_path_exists(bvm *vm)
|
||||
{
|
||||
const char *path = NULL;
|
||||
if (be_top(vm) >= 1 && be_isstring(vm, 1)) {
|
||||
path = be_tostring(vm, 1);
|
||||
be_pushbool(vm, be_isexist(path));
|
||||
} else {
|
||||
be_pushbool(vm, bfalse);
|
||||
}
|
||||
be_return(vm);
|
||||
}
|
||||
extern time_t be_last_modified(void *hfile);
|
||||
|
||||
static int m_path_last_modified(bvm *vm)
|
||||
{
|
||||
if (be_top(vm) >= 1 && be_isstring(vm, 1)) {
|
||||
const char *path = be_tostring(vm, 1);
|
||||
void * f = be_fopen(path, "r");
|
||||
if (f) {
|
||||
be_pushint(vm, be_last_modified(f));
|
||||
be_fclose(f);
|
||||
be_return(vm);
|
||||
}
|
||||
}
|
||||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
static int m_path_remove(bvm *vm)
|
||||
{
|
||||
const char *path = NULL;
|
||||
if (be_top(vm) >= 1 && be_isstring(vm, 1)) {
|
||||
path = be_tostring(vm, 1);
|
||||
be_pushbool(vm, be_unlink(path));
|
||||
} else {
|
||||
be_pushbool(vm, bfalse);
|
||||
}
|
||||
be_return(vm);
|
||||
}
|
||||
|
||||
/* @const_object_info_begin
|
||||
module path (scope: global, file: tasmota_path) {
|
||||
exists, func(m_path_exists)
|
||||
last_modified, func(m_path_last_modified)
|
||||
listdir, func(m_path_listdir)
|
||||
remove, func(m_path_remove)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "../generate/be_fixed_tasmota_path.h"
|
|
@ -0,0 +1,703 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import power`
|
||||
*
|
||||
* read power values
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: json_fdump_map
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_json_fdump_map, /* name */
|
||||
be_nested_proto(
|
||||
13, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[10]) { /* constants */
|
||||
/* K0 */ be_nested_str(json),
|
||||
/* K1 */ be_nested_str(write),
|
||||
/* K2 */ be_nested_str(_X7B),
|
||||
/* K3 */ be_nested_str(keys),
|
||||
/* K4 */ be_nested_str(dump),
|
||||
/* K5 */ be_nested_str(_X3A),
|
||||
/* K6 */ be_nested_str(json_fdump_any),
|
||||
/* K7 */ be_nested_str(_X2C),
|
||||
/* K8 */ be_nested_str(stop_iteration),
|
||||
/* K9 */ be_nested_str(_X7D),
|
||||
}),
|
||||
&be_const_str_json_fdump_map,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[41]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0x8C100301, // 0001 GETMET R4 R1 K1
|
||||
0x58180002, // 0002 LDCONST R6 K2
|
||||
0x7C100400, // 0003 CALL R4 2
|
||||
0x4C100000, // 0004 LDNIL R4
|
||||
0x60140010, // 0005 GETGBL R5 G16
|
||||
0x8C180503, // 0006 GETMET R6 R2 K3
|
||||
0x7C180200, // 0007 CALL R6 1
|
||||
0x7C140200, // 0008 CALL R5 1
|
||||
0xA8020017, // 0009 EXBLK 0 #0022
|
||||
0x5C180A00, // 000A MOVE R6 R5
|
||||
0x7C180000, // 000B CALL R6 0
|
||||
0x4C1C0000, // 000C LDNIL R7
|
||||
0x201C0807, // 000D NE R7 R4 R7
|
||||
0x781E0002, // 000E JMPF R7 #0012
|
||||
0x8C1C0301, // 000F GETMET R7 R1 K1
|
||||
0x5C240800, // 0010 MOVE R9 R4
|
||||
0x7C1C0400, // 0011 CALL R7 2
|
||||
0x8C1C0301, // 0012 GETMET R7 R1 K1
|
||||
0x8C240704, // 0013 GETMET R9 R3 K4
|
||||
0x602C0008, // 0014 GETGBL R11 G8
|
||||
0x5C300C00, // 0015 MOVE R12 R6
|
||||
0x7C2C0200, // 0016 CALL R11 1
|
||||
0x7C240400, // 0017 CALL R9 2
|
||||
0x7C1C0400, // 0018 CALL R7 2
|
||||
0x8C1C0301, // 0019 GETMET R7 R1 K1
|
||||
0x58240005, // 001A LDCONST R9 K5
|
||||
0x7C1C0400, // 001B CALL R7 2
|
||||
0x8C1C0106, // 001C GETMET R7 R0 K6
|
||||
0x5C240200, // 001D MOVE R9 R1
|
||||
0x94280406, // 001E GETIDX R10 R2 R6
|
||||
0x7C1C0600, // 001F CALL R7 3
|
||||
0x58100007, // 0020 LDCONST R4 K7
|
||||
0x7001FFE7, // 0021 JMP #000A
|
||||
0x58140008, // 0022 LDCONST R5 K8
|
||||
0xAC140200, // 0023 CATCH R5 1 0
|
||||
0xB0080000, // 0024 RAISE 2 R0 R0
|
||||
0x8C140301, // 0025 GETMET R5 R1 K1
|
||||
0x581C0009, // 0026 LDCONST R7 K9
|
||||
0x7C140400, // 0027 CALL R5 2
|
||||
0x80000000, // 0028 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: setmember
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_setmember, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(_p),
|
||||
/* K1 */ be_nested_str(_dirty),
|
||||
}),
|
||||
&be_const_str_setmember,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x880C0100, // 0000 GETMBR R3 R0 K0
|
||||
0x980C0202, // 0001 SETIDX R3 R1 R2
|
||||
0x500C0200, // 0002 LDBOOL R3 1 0
|
||||
0x90020203, // 0003 SETMBR R0 K1 R3
|
||||
0x80000000, // 0004 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: zero
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_zero, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(_p),
|
||||
/* K1 */ be_nested_str(_dirty),
|
||||
}),
|
||||
&be_const_str_zero,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x60040013, // 0000 GETGBL R1 G19
|
||||
0x7C040000, // 0001 CALL R1 0
|
||||
0x90020001, // 0002 SETMBR R0 K0 R1
|
||||
0x50040200, // 0003 LDBOOL R1 1 0
|
||||
0x90020201, // 0004 SETMBR R0 K1 R1
|
||||
0x80000000, // 0005 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: member
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_member, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(_p),
|
||||
/* K1 */ be_nested_str(find),
|
||||
}),
|
||||
&be_const_str_member,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x5C100200, // 0002 MOVE R4 R1
|
||||
0x7C080400, // 0003 CALL R2 2
|
||||
0x80040400, // 0004 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: json_fdump
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_json_fdump, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(json),
|
||||
/* K1 */ be_nested_str(_p),
|
||||
/* K2 */ be_nested_str(json_fdump_map),
|
||||
/* K3 */ be_nested_str(internal_error),
|
||||
/* K4 */ be_nested_str(persist_X2E_p_X20is_X20not_X20a_X20map),
|
||||
}),
|
||||
&be_const_str_json_fdump,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[13]) { /* code */
|
||||
0xA40A0000, // 0000 IMPORT R2 K0
|
||||
0x600C000F, // 0001 GETGBL R3 G15
|
||||
0x88100101, // 0002 GETMBR R4 R0 K1
|
||||
0x60140013, // 0003 GETGBL R5 G19
|
||||
0x7C0C0400, // 0004 CALL R3 2
|
||||
0x780E0004, // 0005 JMPF R3 #000B
|
||||
0x8C0C0102, // 0006 GETMET R3 R0 K2
|
||||
0x5C140200, // 0007 MOVE R5 R1
|
||||
0x88180101, // 0008 GETMBR R6 R0 K1
|
||||
0x7C0C0600, // 0009 CALL R3 3
|
||||
0x70020000, // 000A JMP #000C
|
||||
0xB0060704, // 000B RAISE 1 K3 K4
|
||||
0x80000000, // 000C RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: remove
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_remove, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(_p),
|
||||
/* K1 */ be_nested_str(remove),
|
||||
/* K2 */ be_nested_str(_dirty),
|
||||
}),
|
||||
&be_const_str_remove,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x5C100200, // 0002 MOVE R4 R1
|
||||
0x7C080400, // 0003 CALL R2 2
|
||||
0x50080200, // 0004 LDBOOL R2 1 0
|
||||
0x90020402, // 0005 SETMBR R0 K2 R2
|
||||
0x80000000, // 0006 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: json_fdump_any
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_json_fdump_any, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(json),
|
||||
/* K1 */ be_nested_str(json_fdump_map),
|
||||
/* K2 */ be_nested_str(json_fdump_list),
|
||||
/* K3 */ be_nested_str(write),
|
||||
/* K4 */ be_nested_str(dump),
|
||||
}),
|
||||
&be_const_str_json_fdump_any,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[27]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0x6010000F, // 0001 GETGBL R4 G15
|
||||
0x5C140400, // 0002 MOVE R5 R2
|
||||
0x60180013, // 0003 GETGBL R6 G19
|
||||
0x7C100400, // 0004 CALL R4 2
|
||||
0x78120004, // 0005 JMPF R4 #000B
|
||||
0x8C100101, // 0006 GETMET R4 R0 K1
|
||||
0x5C180200, // 0007 MOVE R6 R1
|
||||
0x5C1C0400, // 0008 MOVE R7 R2
|
||||
0x7C100600, // 0009 CALL R4 3
|
||||
0x7002000E, // 000A JMP #001A
|
||||
0x6010000F, // 000B GETGBL R4 G15
|
||||
0x5C140400, // 000C MOVE R5 R2
|
||||
0x60180012, // 000D GETGBL R6 G18
|
||||
0x7C100400, // 000E CALL R4 2
|
||||
0x78120004, // 000F JMPF R4 #0015
|
||||
0x8C100102, // 0010 GETMET R4 R0 K2
|
||||
0x5C180200, // 0011 MOVE R6 R1
|
||||
0x5C1C0400, // 0012 MOVE R7 R2
|
||||
0x7C100600, // 0013 CALL R4 3
|
||||
0x70020004, // 0014 JMP #001A
|
||||
0x8C100303, // 0015 GETMET R4 R1 K3
|
||||
0x8C180704, // 0016 GETMET R6 R3 K4
|
||||
0x5C200400, // 0017 MOVE R8 R2
|
||||
0x7C180400, // 0018 CALL R6 2
|
||||
0x7C100400, // 0019 CALL R4 2
|
||||
0x80000000, // 001A RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: save
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_save, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 7]) { /* constants */
|
||||
/* K0 */ be_nested_str(_filename),
|
||||
/* K1 */ be_nested_str(w),
|
||||
/* K2 */ be_nested_str(json_fdump),
|
||||
/* K3 */ be_nested_str(close),
|
||||
/* K4 */ be_nested_str(write),
|
||||
/* K5 */ be_nested_str(_X7B_X7D),
|
||||
/* K6 */ be_nested_str(_dirty),
|
||||
}),
|
||||
&be_const_str_save,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[37]) { /* code */
|
||||
0x4C040000, // 0000 LDNIL R1
|
||||
0xA802000B, // 0001 EXBLK 0 #000E
|
||||
0x60080011, // 0002 GETGBL R2 G17
|
||||
0x880C0100, // 0003 GETMBR R3 R0 K0
|
||||
0x58100001, // 0004 LDCONST R4 K1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0x5C040400, // 0006 MOVE R1 R2
|
||||
0x8C080102, // 0007 GETMET R2 R0 K2
|
||||
0x5C100200, // 0008 MOVE R4 R1
|
||||
0x7C080400, // 0009 CALL R2 2
|
||||
0x8C080303, // 000A GETMET R2 R1 K3
|
||||
0x7C080200, // 000B CALL R2 1
|
||||
0xA8040001, // 000C EXBLK 1 1
|
||||
0x70020013, // 000D JMP #0022
|
||||
0xAC080002, // 000E CATCH R2 0 2
|
||||
0x70020010, // 000F JMP #0021
|
||||
0x4C100000, // 0010 LDNIL R4
|
||||
0x20100204, // 0011 NE R4 R1 R4
|
||||
0x78120001, // 0012 JMPF R4 #0015
|
||||
0x8C100303, // 0013 GETMET R4 R1 K3
|
||||
0x7C100200, // 0014 CALL R4 1
|
||||
0x60100011, // 0015 GETGBL R4 G17
|
||||
0x88140100, // 0016 GETMBR R5 R0 K0
|
||||
0x58180001, // 0017 LDCONST R6 K1
|
||||
0x7C100400, // 0018 CALL R4 2
|
||||
0x5C040800, // 0019 MOVE R1 R4
|
||||
0x8C100304, // 001A GETMET R4 R1 K4
|
||||
0x58180005, // 001B LDCONST R6 K5
|
||||
0x7C100400, // 001C CALL R4 2
|
||||
0x8C100303, // 001D GETMET R4 R1 K3
|
||||
0x7C100200, // 001E CALL R4 1
|
||||
0xB0040403, // 001F RAISE 1 R2 R3
|
||||
0x70020000, // 0020 JMP #0022
|
||||
0xB0080000, // 0021 RAISE 2 R0 R0
|
||||
0x50080000, // 0022 LDBOOL R2 0 0
|
||||
0x90020C02, // 0023 SETMBR R0 K6 R2
|
||||
0x80000000, // 0024 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: load
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_load, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[12]) { /* constants */
|
||||
/* K0 */ be_nested_str(json),
|
||||
/* K1 */ be_nested_str(path),
|
||||
/* K2 */ be_nested_str(exists),
|
||||
/* K3 */ be_nested_str(_filename),
|
||||
/* K4 */ be_nested_str(r),
|
||||
/* K5 */ be_nested_str(load),
|
||||
/* K6 */ be_nested_str(read),
|
||||
/* K7 */ be_nested_str(close),
|
||||
/* K8 */ be_nested_str(_p),
|
||||
/* K9 */ be_nested_str(BRY_X3A_X20failed_X20to_X20load_X20_persist_X2Ejson),
|
||||
/* K10 */ be_nested_str(_dirty),
|
||||
/* K11 */ be_nested_str(save),
|
||||
}),
|
||||
&be_const_str_load,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[49]) { /* code */
|
||||
0xA4060000, // 0000 IMPORT R1 K0
|
||||
0xA40A0200, // 0001 IMPORT R2 K1
|
||||
0x4C0C0000, // 0002 LDNIL R3
|
||||
0x4C100000, // 0003 LDNIL R4
|
||||
0x8C140502, // 0004 GETMET R5 R2 K2
|
||||
0x881C0103, // 0005 GETMBR R7 R0 K3
|
||||
0x7C140400, // 0006 CALL R5 2
|
||||
0x78160025, // 0007 JMPF R5 #002E
|
||||
0xA802000D, // 0008 EXBLK 0 #0017
|
||||
0x60140011, // 0009 GETGBL R5 G17
|
||||
0x88180103, // 000A GETMBR R6 R0 K3
|
||||
0x581C0004, // 000B LDCONST R7 K4
|
||||
0x7C140400, // 000C CALL R5 2
|
||||
0x5C0C0A00, // 000D MOVE R3 R5
|
||||
0x8C140305, // 000E GETMET R5 R1 K5
|
||||
0x8C1C0706, // 000F GETMET R7 R3 K6
|
||||
0x7C1C0200, // 0010 CALL R7 1
|
||||
0x7C140400, // 0011 CALL R5 2
|
||||
0x5C100A00, // 0012 MOVE R4 R5
|
||||
0x8C140707, // 0013 GETMET R5 R3 K7
|
||||
0x7C140200, // 0014 CALL R5 1
|
||||
0xA8040001, // 0015 EXBLK 1 1
|
||||
0x70020009, // 0016 JMP #0021
|
||||
0xAC140002, // 0017 CATCH R5 0 2
|
||||
0x70020006, // 0018 JMP #0020
|
||||
0x4C1C0000, // 0019 LDNIL R7
|
||||
0x201C0607, // 001A NE R7 R3 R7
|
||||
0x781E0001, // 001B JMPF R7 #001E
|
||||
0x8C1C0707, // 001C GETMET R7 R3 K7
|
||||
0x7C1C0200, // 001D CALL R7 1
|
||||
0xB0040A06, // 001E RAISE 1 R5 R6
|
||||
0x70020000, // 001F JMP #0021
|
||||
0xB0080000, // 0020 RAISE 2 R0 R0
|
||||
0x6014000F, // 0021 GETGBL R5 G15
|
||||
0x5C180800, // 0022 MOVE R6 R4
|
||||
0x601C0013, // 0023 GETGBL R7 G19
|
||||
0x7C140400, // 0024 CALL R5 2
|
||||
0x78160001, // 0025 JMPF R5 #0028
|
||||
0x90021004, // 0026 SETMBR R0 K8 R4
|
||||
0x70020002, // 0027 JMP #002B
|
||||
0x60140001, // 0028 GETGBL R5 G1
|
||||
0x58180009, // 0029 LDCONST R6 K9
|
||||
0x7C140200, // 002A CALL R5 1
|
||||
0x50140000, // 002B LDBOOL R5 0 0
|
||||
0x90021405, // 002C SETMBR R0 K10 R5
|
||||
0x70020001, // 002D JMP #0030
|
||||
0x8C14010B, // 002E GETMET R5 R0 K11
|
||||
0x7C140200, // 002F CALL R5 1
|
||||
0x80000000, // 0030 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: find
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_find, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(_p),
|
||||
/* K1 */ be_nested_str(find),
|
||||
}),
|
||||
&be_const_str_find,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
0x880C0100, // 0000 GETMBR R3 R0 K0
|
||||
0x8C0C0701, // 0001 GETMET R3 R3 K1
|
||||
0x5C140200, // 0002 MOVE R5 R1
|
||||
0x5C180400, // 0003 MOVE R6 R2
|
||||
0x7C0C0600, // 0004 CALL R3 3
|
||||
0x80040600, // 0005 RET 1 R3
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_init, /* name */
|
||||
be_nested_proto(
|
||||
6, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(_filename),
|
||||
/* K1 */ be_nested_str(_persist_X2Ejson),
|
||||
/* K2 */ be_nested_str(_p),
|
||||
/* K3 */ be_nested_str(copy),
|
||||
/* K4 */ be_nested_str(load),
|
||||
/* K5 */ be_nested_str(_dirty),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[20]) { /* code */
|
||||
0x90020101, // 0000 SETMBR R0 K0 K1
|
||||
0x6008000F, // 0001 GETGBL R2 G15
|
||||
0x5C0C0200, // 0002 MOVE R3 R1
|
||||
0x60100013, // 0003 GETGBL R4 G19
|
||||
0x7C080400, // 0004 CALL R2 2
|
||||
0x780A0003, // 0005 JMPF R2 #000A
|
||||
0x8C080303, // 0006 GETMET R2 R1 K3
|
||||
0x7C080200, // 0007 CALL R2 1
|
||||
0x90020402, // 0008 SETMBR R0 K2 R2
|
||||
0x70020002, // 0009 JMP #000D
|
||||
0x60080013, // 000A GETGBL R2 G19
|
||||
0x7C080000, // 000B CALL R2 0
|
||||
0x90020402, // 000C SETMBR R0 K2 R2
|
||||
0x8C080104, // 000D GETMET R2 R0 K4
|
||||
0x88100102, // 000E GETMBR R4 R0 K2
|
||||
0x88140100, // 000F GETMBR R5 R0 K0
|
||||
0x7C080600, // 0010 CALL R2 3
|
||||
0x50080000, // 0011 LDBOOL R2 0 0
|
||||
0x90020A02, // 0012 SETMBR R0 K5 R2
|
||||
0x80000000, // 0013 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: json_fdump_list
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_json_fdump_list, /* name */
|
||||
be_nested_proto(
|
||||
9, /* nstack */
|
||||
3, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 8]) { /* constants */
|
||||
/* K0 */ be_nested_str(json),
|
||||
/* K1 */ be_nested_str(write),
|
||||
/* K2 */ be_nested_str(_X5B),
|
||||
/* K3 */ be_const_int(0),
|
||||
/* K4 */ be_nested_str(_X2C),
|
||||
/* K5 */ be_nested_str(json_fdump_any),
|
||||
/* K6 */ be_const_int(1),
|
||||
/* K7 */ be_nested_str(_X5D),
|
||||
}),
|
||||
&be_const_str_json_fdump_list,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[25]) { /* code */
|
||||
0xA40E0000, // 0000 IMPORT R3 K0
|
||||
0x8C100301, // 0001 GETMET R4 R1 K1
|
||||
0x58180002, // 0002 LDCONST R6 K2
|
||||
0x7C100400, // 0003 CALL R4 2
|
||||
0x58100003, // 0004 LDCONST R4 K3
|
||||
0x6014000C, // 0005 GETGBL R5 G12
|
||||
0x5C180400, // 0006 MOVE R6 R2
|
||||
0x7C140200, // 0007 CALL R5 1
|
||||
0x14140805, // 0008 LT R5 R4 R5
|
||||
0x7816000A, // 0009 JMPF R5 #0015
|
||||
0x24140903, // 000A GT R5 R4 K3
|
||||
0x78160002, // 000B JMPF R5 #000F
|
||||
0x8C140301, // 000C GETMET R5 R1 K1
|
||||
0x581C0004, // 000D LDCONST R7 K4
|
||||
0x7C140400, // 000E CALL R5 2
|
||||
0x8C140105, // 000F GETMET R5 R0 K5
|
||||
0x5C1C0200, // 0010 MOVE R7 R1
|
||||
0x94200404, // 0011 GETIDX R8 R2 R4
|
||||
0x7C140600, // 0012 CALL R5 3
|
||||
0x00100906, // 0013 ADD R4 R4 K6
|
||||
0x7001FFEF, // 0014 JMP #0005
|
||||
0x8C140301, // 0015 GETMET R5 R1 K1
|
||||
0x581C0007, // 0016 LDCONST R7 K7
|
||||
0x7C140400, // 0017 CALL R5 2
|
||||
0x80000000, // 0018 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: has
|
||||
********************************************************************/
|
||||
be_local_closure(Persist_has, /* name */
|
||||
be_nested_proto(
|
||||
5, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(_p),
|
||||
/* K1 */ be_nested_str(has),
|
||||
}),
|
||||
&be_const_str_has,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x8C080501, // 0001 GETMET R2 R2 K1
|
||||
0x5C100200, // 0002 MOVE R4 R1
|
||||
0x7C080400, // 0003 CALL R2 2
|
||||
0x80040400, // 0004 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Persist
|
||||
********************************************************************/
|
||||
be_local_class(Persist,
|
||||
3,
|
||||
NULL,
|
||||
be_nested_map(16,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(has, 6), be_const_closure(Persist_has_closure) },
|
||||
{ be_const_key(setmember, -1), be_const_closure(Persist_setmember_closure) },
|
||||
{ be_const_key(remove, -1), be_const_closure(Persist_remove_closure) },
|
||||
{ be_const_key(zero, 0), be_const_closure(Persist_zero_closure) },
|
||||
{ be_const_key(json_fdump, -1), be_const_closure(Persist_json_fdump_closure) },
|
||||
{ be_const_key(json_fdump_list, 2), be_const_closure(Persist_json_fdump_list_closure) },
|
||||
{ be_const_key(init, 15), be_const_closure(Persist_init_closure) },
|
||||
{ be_const_key(find, -1), be_const_closure(Persist_find_closure) },
|
||||
{ be_const_key(save, -1), be_const_closure(Persist_save_closure) },
|
||||
{ be_const_key(json_fdump_any, 12), be_const_closure(Persist_json_fdump_any_closure) },
|
||||
{ be_const_key(_p, 7), be_const_var(1) },
|
||||
{ be_const_key(_filename, -1), be_const_var(0) },
|
||||
{ be_const_key(load, -1), be_const_closure(Persist_load_closure) },
|
||||
{ be_const_key(json_fdump_map, 5), be_const_closure(Persist_json_fdump_map_closure) },
|
||||
{ be_const_key(_dirty, -1), be_const_var(2) },
|
||||
{ be_const_key(member, -1), be_const_closure(Persist_member_closure) },
|
||||
})),
|
||||
be_str_literal("Persist")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: _anonymous_
|
||||
********************************************************************/
|
||||
be_local_closure(persist__anonymous_, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_const_class(be_class_Persist),
|
||||
}),
|
||||
&be_const_str__anonymous_,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x58040000, // 0000 LDCONST R1 K0
|
||||
0xB4000000, // 0001 CLASS K0
|
||||
0x5C080200, // 0002 MOVE R2 R1
|
||||
0x7C080000, // 0003 CALL R2 0
|
||||
0x80040400, // 0004 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: persist
|
||||
********************************************************************/
|
||||
be_local_module(persist,
|
||||
"persist",
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(persist__anonymous__closure) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(persist);
|
||||
/********************************************************************/
|
|
@ -0,0 +1,574 @@
|
|||
/********************************************************************
|
||||
** Copyright (c) 2018-2020 Guan Wenliang
|
||||
** This file is part of the Berry default interpreter.
|
||||
** skiars@qq.com, https://github.com/Skiars/berry
|
||||
** See Copyright Notice in the LICENSE file or at
|
||||
** https://github.com/Skiars/berry/blob/master/LICENSE
|
||||
********************************************************************/
|
||||
#include "berry.h"
|
||||
#include "be_mem.h"
|
||||
#include "be_sys.h"
|
||||
// #include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// from https://github.com/eyalroz/cpp-static-block
|
||||
#include "static_block.hpp"
|
||||
|
||||
// Local pointer for file managment
|
||||
#ifdef USE_UFILESYS
|
||||
#include <FS.h>
|
||||
#include "ZipReadFS.h"
|
||||
extern FS *ffsp;
|
||||
FS zip_ufsp(ZipReadFSImplPtr(new ZipReadFSImpl(&ffsp)));
|
||||
#endif // USE_UFILESYS
|
||||
|
||||
/* this file contains configuration for the file system. */
|
||||
|
||||
/* standard input and output */
|
||||
extern "C" {
|
||||
int strncmp_PP(const char * str1P, const char * str2P, size_t size)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
char ch1 = pgm_read_byte(str1P++);
|
||||
char ch2 = pgm_read_byte(str2P++);
|
||||
result = ch1 - ch2;
|
||||
if (result != 0 || ch2 == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
size--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
char * strchr_P(const char *s, int c) {
|
||||
do {
|
||||
if (pgm_read_byte(s) == c) {
|
||||
return (char*)s;
|
||||
}
|
||||
} while (pgm_read_byte(s++));
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to create a local buffer, since we might mess up mqtt_data
|
||||
#ifndef BERRY_LOGSZ
|
||||
#define BERRY_LOGSZ 700
|
||||
#endif
|
||||
|
||||
static char * log_berry_buffer = nullptr;
|
||||
static_block {
|
||||
log_berry_buffer = (char*) malloc(BERRY_LOGSZ);
|
||||
if (log_berry_buffer) log_berry_buffer[0] = 0;
|
||||
}
|
||||
extern void berry_log(const char * berry_buf);
|
||||
|
||||
BERRY_API void be_writebuffer(const char *buffer, size_t length)
|
||||
{
|
||||
if (!log_berry_buffer) return;
|
||||
if (buffer == nullptr || length == 0) { return; }
|
||||
uint32_t idx = 0;
|
||||
while (idx < length) {
|
||||
int32_t cr_pos = -1;
|
||||
// find next occurence of '\n' or '\r'
|
||||
for (uint32_t i = idx; i < length; i++) {
|
||||
if ((pgm_read_byte(&buffer[i]) == '\n') || (pgm_read_byte(&buffer[i]) == '\r')) {
|
||||
cr_pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint32_t chars_to_append = (cr_pos >= 0) ? cr_pos - idx : length - idx; // note cr_pos < length
|
||||
snprintf(log_berry_buffer, BERRY_LOGSZ, "%s%.*s", log_berry_buffer, chars_to_append, &buffer[idx]); // append at most `length` chars
|
||||
if (cr_pos >= 0) {
|
||||
// flush
|
||||
berry_log(log_berry_buffer);
|
||||
log_berry_buffer[0] = 0; // clear string
|
||||
}
|
||||
idx += chars_to_append + 1; // skip '\n'
|
||||
}
|
||||
// Serial.write(buffer, length);
|
||||
// be_fwrite(stdout, buffer, length);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
int m_path_listdir(bvm *vm)
|
||||
{
|
||||
if (be_top(vm) >= 1 && be_isstring(vm, 1)) {
|
||||
const char *path = be_tostring(vm, 1);
|
||||
be_newobject(vm, "list");
|
||||
|
||||
File dir = ffsp->open(path, "r");
|
||||
if (dir) {
|
||||
dir.rewindDirectory();
|
||||
while (1) {
|
||||
File entry = dir.openNextFile();
|
||||
if (!entry) {
|
||||
break;
|
||||
}
|
||||
const char * fn = entry.name();
|
||||
if (strcmp(fn, ".") && strcmp(fn, "..")) {
|
||||
be_pushstring(vm, fn);
|
||||
be_data_push(vm, -2);
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
be_pop(vm, 1);
|
||||
be_return(vm);
|
||||
|
||||
}
|
||||
be_return_nil(vm);
|
||||
}
|
||||
}
|
||||
|
||||
BERRY_API char* be_readstring(char *buffer, size_t size)
|
||||
{
|
||||
return be_fgets(stdin, buffer, (int)size);
|
||||
}
|
||||
|
||||
/* use the standard library implementation file API. */
|
||||
|
||||
void* be_fopen(const char *filename, const char *modes)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
if (filename != nullptr && modes != nullptr) {
|
||||
char fname2[strlen(filename) + 2];
|
||||
if (filename[0] == '/') {
|
||||
strcpy(fname2, filename); // copy unchanged
|
||||
} else {
|
||||
fname2[0] = '/';
|
||||
strcpy(fname2 + 1, filename); // prepend with '/'
|
||||
}
|
||||
// Serial.printf("be_fopen filename=%s, modes=%s\n", filename, modes);
|
||||
File f = zip_ufsp.open(fname2, modes); // returns an object, not a pointer
|
||||
if (f) {
|
||||
File * f_ptr = new File(f); // copy to dynamic object
|
||||
*f_ptr = f; // TODO is this necessary?
|
||||
return f_ptr;
|
||||
}
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return nullptr;
|
||||
// return fopen(filename, modes);
|
||||
}
|
||||
|
||||
// Tasmota specific, get the underlying Arduino File
|
||||
File * be_get_arduino_file(void *hfile)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
return f_ptr;
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return nullptr;
|
||||
// return fopen(filename, modes);
|
||||
}
|
||||
|
||||
int be_fclose(void *hfile)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_fclose\n");
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
f_ptr->close();
|
||||
delete f_ptr;
|
||||
return 0;
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return -1;
|
||||
// return fclose(hfile);
|
||||
}
|
||||
|
||||
size_t be_fwrite(void *hfile, const void *buffer, size_t length)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_fwrite %d\n", length);
|
||||
if (hfile != nullptr && buffer != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
return f_ptr->write((const uint8_t*) buffer, length);
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
// return fwrite(buffer, 1, length, hfile);
|
||||
}
|
||||
|
||||
size_t be_fread(void *hfile, void *buffer, size_t length)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_fread %d\n", length);
|
||||
if (hfile != nullptr && buffer != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
int32_t ret = f_ptr->read((uint8_t*) buffer, length);
|
||||
if (ret >= 0) {
|
||||
// Serial.printf("be_fread ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
// return fread(buffer, 1, length, hfile);
|
||||
}
|
||||
|
||||
char* be_fgets(void *hfile, void *buffer, int size)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
if (size <= 2) { return nullptr; } // can't work if size is 2 or less
|
||||
// Serial.printf("be_fgets size=%d hfile=%p buf=%p\n", size, hfile, buffer);
|
||||
uint8_t * buf = (uint8_t*) buffer;
|
||||
if (hfile != nullptr && buffer != nullptr && size > 0) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
int ret = f_ptr->readBytesUntil('\n', buf, size - 2);
|
||||
// Serial.printf("be_fgets ret=%d\n", ret);
|
||||
if (ret >= 0) {
|
||||
buf[ret] = 0; // add string terminator
|
||||
if (ret > 0 && ret < size - 2) {
|
||||
buf[ret] = '\n';
|
||||
buf[ret+1] = 0;
|
||||
}
|
||||
return (char*) buffer;
|
||||
}
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return nullptr;
|
||||
// return fgets(buffer, size, hfile);
|
||||
}
|
||||
|
||||
int be_fseek(void *hfile, long offset)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_fseek %d\n", offset);
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
if (f_ptr->seek(offset)) {
|
||||
return 0; // success
|
||||
}
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return -1;
|
||||
// return fseek(hfile, offset, SEEK_SET);
|
||||
}
|
||||
|
||||
long int be_ftell(void *hfile)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_ftell\n");
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
return f_ptr->position();
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
// return ftell(hfile);
|
||||
}
|
||||
|
||||
long int be_fflush(void *hfile)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_fflush\n");
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
f_ptr->flush();
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
// return fflush(hfile);
|
||||
}
|
||||
|
||||
size_t be_fsize(void *hfile)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
// Serial.printf("be_fsize\n");
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
return f_ptr->size();
|
||||
}
|
||||
// long int size, offset = be_ftell(hfile);
|
||||
// fseek(hfile, 0L, SEEK_END);
|
||||
// size = ftell(hfile);
|
||||
// fseek(hfile, offset, SEEK_SET);
|
||||
// return size;
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" time_t be_last_modified(void *hfile)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
if (hfile != nullptr) {
|
||||
File * f_ptr = (File*) hfile;
|
||||
return f_ptr->getLastWrite();
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
}
|
||||
|
||||
int be_isexist(const char *filename)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
char fname2[strlen(filename) + 2];
|
||||
if (filename[0] == '/') {
|
||||
strcpy(fname2, filename); // copy unchanged
|
||||
} else {
|
||||
fname2[0] = '/';
|
||||
strcpy(fname2 + 1, filename); // prepend with '/'
|
||||
}
|
||||
return zip_ufsp.exists(fname2);
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
}
|
||||
|
||||
int be_unlink(const char *filename)
|
||||
{
|
||||
#ifdef USE_UFILESYS
|
||||
char fname2[strlen(filename) + 2];
|
||||
if (filename[0] == '/') {
|
||||
strcpy(fname2, filename); // copy unchanged
|
||||
} else {
|
||||
fname2[0] = '/';
|
||||
strcpy(fname2 + 1, filename); // prepend with '/'
|
||||
}
|
||||
return zip_ufsp.remove(fname2);
|
||||
#endif // USE_UFILESYS
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if BE_USE_FILE_SYSTEM
|
||||
#if defined(USE_FATFS) /* FatFs */
|
||||
|
||||
int be_isdir(const char *path)
|
||||
{
|
||||
FILINFO fno;
|
||||
FRESULT fr = f_stat(path, &fno);
|
||||
return fr == FR_OK && fno.fattrib & AM_DIR;
|
||||
}
|
||||
|
||||
int be_isfile(const char *path)
|
||||
{
|
||||
FILINFO fno;
|
||||
FRESULT fr = f_stat(path, &fno);
|
||||
return fr == FR_OK && !(fno.fattrib & AM_DIR);
|
||||
}
|
||||
|
||||
int be_isexist(const char *path)
|
||||
{
|
||||
FILINFO fno;
|
||||
return f_stat(path, &fno) == FR_OK;
|
||||
}
|
||||
|
||||
char* be_getcwd(char *buf, size_t size)
|
||||
{
|
||||
FRESULT fr = f_getcwd(buf, (UINT)size);
|
||||
return fr == FR_OK ? buf : NULL;
|
||||
}
|
||||
|
||||
int be_chdir(const char *path)
|
||||
{
|
||||
return f_chdir(path);
|
||||
}
|
||||
|
||||
int be_mkdir(const char *path)
|
||||
{
|
||||
return f_mkdir(path);
|
||||
}
|
||||
|
||||
int be_unlink(const char *filename)
|
||||
{
|
||||
return f_unlink(filename);
|
||||
}
|
||||
|
||||
int be_dirfirst(bdirinfo *info, const char *path)
|
||||
{
|
||||
info->dir = be_os_malloc(sizeof(DIR));
|
||||
info->file = be_os_malloc(sizeof(FILINFO));
|
||||
if (info->dir && info->file) {
|
||||
FRESULT fr = f_opendir(info->dir, path);
|
||||
return fr == FR_OK ? be_dirnext(info) : 1;
|
||||
}
|
||||
be_os_free(info->dir);
|
||||
be_os_free(info->file);
|
||||
info->dir = NULL;
|
||||
info->file = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int be_dirnext(bdirinfo *info)
|
||||
{
|
||||
FRESULT fr = f_readdir(info->dir, info->file);
|
||||
info->name = ((FILINFO *)info->file)->fname;
|
||||
return fr != FR_OK || *info->name == '\0';
|
||||
}
|
||||
|
||||
int be_dirclose(bdirinfo *info)
|
||||
{
|
||||
if (info->dir) {
|
||||
int res = f_closedir(info->dir) != FR_OK;
|
||||
be_os_free(info->dir);
|
||||
be_os_free(info->file);
|
||||
return res;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) /* MSVC*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
|
||||
int be_isdir(const char *path)
|
||||
{
|
||||
DWORD type = GetFileAttributes(path);
|
||||
return type != INVALID_FILE_ATTRIBUTES
|
||||
&& (type & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
int be_isfile(const char *path)
|
||||
{
|
||||
DWORD type = GetFileAttributes(path);
|
||||
return type != INVALID_FILE_ATTRIBUTES
|
||||
&& (type & FILE_ATTRIBUTE_DIRECTORY) == 0;
|
||||
}
|
||||
|
||||
int be_isexist(const char *path)
|
||||
{
|
||||
return GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
|
||||
char* be_getcwd(char *buf, size_t size)
|
||||
{
|
||||
return _getcwd(buf, (int)size);
|
||||
}
|
||||
|
||||
int be_chdir(const char *path)
|
||||
{
|
||||
return _chdir(path);
|
||||
}
|
||||
|
||||
int be_mkdir(const char *path)
|
||||
{
|
||||
return _mkdir(path);
|
||||
}
|
||||
|
||||
int be_unlink(const char *filename)
|
||||
{
|
||||
return remove(filename);
|
||||
}
|
||||
|
||||
int be_dirfirst(bdirinfo *info, const char *path)
|
||||
{
|
||||
char *buf = be_os_malloc(strlen(path) + 3);
|
||||
info->file = be_os_malloc(sizeof(struct _finddata_t));
|
||||
info->dir = NULL;
|
||||
if (buf && info->file) {
|
||||
struct _finddata_t *cfile = info->file;
|
||||
strcat(strcpy(buf, path), "/*");
|
||||
info->dir = (void *)_findfirst(buf, cfile);
|
||||
info->name = cfile->name;
|
||||
be_os_free(buf);
|
||||
return (intptr_t)info->dir == -1;
|
||||
}
|
||||
be_os_free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int be_dirnext(bdirinfo *info)
|
||||
{
|
||||
struct _finddata_t *cfile = info->file;
|
||||
int res = _findnext((intptr_t)info->dir, cfile) != 0;
|
||||
info->name = cfile->name;
|
||||
return res;
|
||||
}
|
||||
|
||||
int be_dirclose(bdirinfo *info)
|
||||
{
|
||||
be_os_free(info->file);
|
||||
return _findclose((intptr_t)info->dir) != 0;
|
||||
}
|
||||
|
||||
#else /* must be POSIX */
|
||||
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int be_isdir(const char *path)
|
||||
{
|
||||
struct stat path_stat;
|
||||
int res = stat(path, &path_stat);
|
||||
return res == 0 && S_ISDIR(path_stat.st_mode);
|
||||
}
|
||||
|
||||
int be_isfile(const char *path)
|
||||
{
|
||||
struct stat path_stat;
|
||||
int res = stat(path, &path_stat);
|
||||
return res == 0 && !S_ISDIR(path_stat.st_mode);
|
||||
}
|
||||
|
||||
int be_isexist(const char *path)
|
||||
{
|
||||
struct stat path_stat;
|
||||
return stat(path, &path_stat) == 0;
|
||||
}
|
||||
|
||||
char* be_getcwd(char *buf, size_t size)
|
||||
{
|
||||
return getcwd(buf, size);
|
||||
}
|
||||
|
||||
int be_chdir(const char *path)
|
||||
{
|
||||
return chdir(path);
|
||||
}
|
||||
|
||||
int be_mkdir(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return mkdir(path);
|
||||
#else
|
||||
return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#endif
|
||||
}
|
||||
|
||||
int be_unlink(const char *filename)
|
||||
{
|
||||
return remove(filename);
|
||||
}
|
||||
|
||||
int be_dirfirst(bdirinfo *info, const char *path)
|
||||
{
|
||||
info->dir = opendir(path);
|
||||
if (info->dir) {
|
||||
return be_dirnext(info);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int be_dirnext(bdirinfo *info)
|
||||
{
|
||||
struct dirent *file;
|
||||
info->file = file = readdir(info->dir);
|
||||
if (file) {
|
||||
info->name = file->d_name;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int be_dirclose(bdirinfo *info)
|
||||
{
|
||||
return closedir(info->dir) != 0;
|
||||
}
|
||||
|
||||
#endif /* POSIX */
|
||||
#endif /* BE_USE_OS_MODULE || BE_USE_FILE_SYSTEM */
|
|
@ -0,0 +1,58 @@
|
|||
/********************************************************************
|
||||
* Berry python compatibility module
|
||||
*
|
||||
* `import python_compat`
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: _anonymous_
|
||||
********************************************************************/
|
||||
be_local_closure(python_compat__anonymous_, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 5]) { /* constants */
|
||||
/* K0 */ be_nested_str(global),
|
||||
/* K1 */ be_nested_str(True),
|
||||
/* K2 */ be_nested_str(False),
|
||||
/* K3 */ be_nested_str(None),
|
||||
/* K4 */ be_nested_str(b),
|
||||
}),
|
||||
&be_const_str__anonymous_,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[10]) { /* code */
|
||||
0xA4060000, // 0000 IMPORT R1 K0
|
||||
0x50080200, // 0001 LDBOOL R2 1 0
|
||||
0x90060202, // 0002 SETMBR R1 K1 R2
|
||||
0x50080000, // 0003 LDBOOL R2 0 0
|
||||
0x90060402, // 0004 SETMBR R1 K2 R2
|
||||
0x4C080000, // 0005 LDNIL R2
|
||||
0x90060602, // 0006 SETMBR R1 K3 R2
|
||||
0x60080015, // 0007 GETGBL R2 G21
|
||||
0x90060802, // 0008 SETMBR R1 K4 R2
|
||||
0x80040000, // 0009 RET 1 R0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: python_compat
|
||||
********************************************************************/
|
||||
be_local_module(python_compat,
|
||||
"python_compat",
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(python_compat__anonymous__closure) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(python_compat);
|
||||
/********************************************************************/
|
|
@ -0,0 +1,254 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import re`
|
||||
*
|
||||
* Regex using re1.5
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
#include "be_mem.h"
|
||||
#include "re1.5.h"
|
||||
|
||||
/********************************************************************
|
||||
# Berry skeleton for `re` module
|
||||
#
|
||||
|
||||
class re_pattern
|
||||
var _p # comobj containing the compiled bytecode for the pattern
|
||||
|
||||
def search() end
|
||||
def match() end
|
||||
def split() end
|
||||
end
|
||||
|
||||
re = module("re")
|
||||
|
||||
re.compile = def (regex_str) end # native
|
||||
re.match = def (regex_str, str) end # native
|
||||
re.search = def (regex_str, str) end # native
|
||||
re.split = def (regex_str, str) end # native
|
||||
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
extern const bclass be_class_re_pattern;
|
||||
|
||||
int be_free_comobj(bvm* vm) {
|
||||
int argc = be_top(vm);
|
||||
if (argc > 0) {
|
||||
void * obj = be_tocomptr(vm, 1);
|
||||
if (obj != NULL) { be_os_free(obj); }
|
||||
}
|
||||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
// Native functions be_const_func()
|
||||
// Berry: `re.compile(pattern:string) -> instance(be_pattern)`
|
||||
int be_re_compile(bvm *vm) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 1 && be_isstring(vm, 1)) {
|
||||
const char * regex_str = be_tostring(vm, 1);
|
||||
int sz = re1_5_sizecode(regex_str);
|
||||
if (sz < 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
be_pushntvclass(vm, &be_class_re_pattern);
|
||||
be_call(vm, 0);
|
||||
be_newcomobj(vm, code, &be_free_comobj);
|
||||
be_setmember(vm, -2, "_p");
|
||||
be_pop(vm, 1);
|
||||
be_return(vm);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
||||
|
||||
int be_re_match_search_run(bvm *vm, ByteProg *code, const char *hay, bbool is_anchored) {
|
||||
Subject subj = {hay, hay + strlen(hay)};
|
||||
|
||||
int sub_els = (code->sub + 1) * 2;
|
||||
const char *sub[sub_els];
|
||||
|
||||
if (!re1_5_recursiveloopprog(code, &subj, sub, sub_els, is_anchored)) {
|
||||
be_return_nil(vm); // no match
|
||||
}
|
||||
|
||||
be_newobject(vm, "list");
|
||||
int k;
|
||||
for(k = sub_els; k > 0; k--)
|
||||
if(sub[k-1])
|
||||
break;
|
||||
for (int i = 0; i < k; i += 2) {
|
||||
be_pushnstring(vm, sub[i], sub[i+1] - sub[i]);
|
||||
be_data_push(vm, -2);
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
be_pop(vm, 1); // remove list
|
||||
be_return(vm); // return list object
|
||||
}
|
||||
|
||||
int be_re_match_search(bvm *vm, bbool is_anchored) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 2 && be_isstring(vm, 1) && be_isstring(vm, 2)) {
|
||||
const char * regex_str = be_tostring(vm, 1);
|
||||
const char * hay = be_tostring(vm, 2);
|
||||
int sz = re1_5_sizecode(regex_str);
|
||||
if (sz < 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
return be_re_match_search_run(vm, code, hay, is_anchored);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
||||
// Berry: `re.match(value:int | s:string) -> nil`
|
||||
int be_re_match(bvm *vm) {
|
||||
return be_re_match_search(vm, btrue);
|
||||
}
|
||||
// Berry: `re.search(value:int | s:string) -> nil`
|
||||
int be_re_search(bvm *vm) {
|
||||
return be_re_match_search(vm, bfalse);
|
||||
}
|
||||
|
||||
// Berry: `re_pattern.search(s:string) -> list(string)`
|
||||
int re_pattern_search(bvm *vm) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 2 && be_isstring(vm, 2)) {
|
||||
const char * hay = be_tostring(vm, 2);
|
||||
be_getmember(vm, 1, "_p");
|
||||
ByteProg * code = (ByteProg*) be_tocomptr(vm, -1);
|
||||
return be_re_match_search_run(vm, code, hay, bfalse);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
||||
// Berry: `re_pattern.match(s:string) -> list(string)`
|
||||
int re_pattern_match(bvm *vm) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 2 && be_isstring(vm, 2)) {
|
||||
const char * hay = be_tostring(vm, 2);
|
||||
be_getmember(vm, 1, "_p");
|
||||
ByteProg * code = (ByteProg*) be_tocomptr(vm, -1);
|
||||
return be_re_match_search_run(vm, code, hay, btrue);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
||||
|
||||
int re_pattern_split_run(bvm *vm, ByteProg *code, const char *hay, int split_limit) {
|
||||
Subject subj = {hay, hay + strlen(hay)};
|
||||
|
||||
int sub_els = (code->sub + 1) * 2;
|
||||
const char *sub[sub_els];
|
||||
|
||||
be_newobject(vm, "list");
|
||||
while (1) {
|
||||
if (split_limit == 0 || !re1_5_recursiveloopprog(code, &subj, sub, sub_els, bfalse)) {
|
||||
be_pushnstring(vm, subj.begin, subj.end - subj.begin);
|
||||
be_data_push(vm, -2);
|
||||
be_pop(vm, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (sub[0] == NULL || sub[1] == NULL || sub[0] == sub[1]) {
|
||||
be_raise(vm, "internal_error", "can't match");
|
||||
}
|
||||
be_pushnstring(vm, subj.begin, sub[0] - subj.begin);
|
||||
be_data_push(vm, -2);
|
||||
be_pop(vm, 1);
|
||||
subj.begin = sub[1];
|
||||
split_limit--;
|
||||
}
|
||||
be_pop(vm, 1); // remove list
|
||||
be_return(vm); // return list object
|
||||
}
|
||||
|
||||
// Berry: `re_pattern.split(s:string [, split_limit:int]) -> list(string)`
|
||||
int re_pattern_split(bvm *vm) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 2 && be_isstring(vm, 2)) {
|
||||
int split_limit = -1;
|
||||
if (argc >= 3) {
|
||||
split_limit = be_toint(vm, 3);
|
||||
}
|
||||
const char * hay = be_tostring(vm, 2);
|
||||
be_getmember(vm, 1, "_p");
|
||||
ByteProg * code = (ByteProg*) be_tocomptr(vm, -1);
|
||||
|
||||
return re_pattern_split_run(vm, code, hay, split_limit);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
||||
// Berry: `re.split(pattern:string, s:string [, split_limit:int]) -> list(string)`
|
||||
int be_re_split(bvm *vm) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 2 && be_isstring(vm, 1) && be_isstring(vm, 2)) {
|
||||
const char * regex_str = be_tostring(vm, 1);
|
||||
const char * hay = be_tostring(vm, 2);
|
||||
int split_limit = -1;
|
||||
if (argc >= 3) {
|
||||
split_limit = be_toint(vm, 3);
|
||||
}
|
||||
int sz = re1_5_sizecode(regex_str);
|
||||
if (sz < 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
|
||||
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
|
||||
int ret = re1_5_compilecode(code, regex_str);
|
||||
if (ret != 0) {
|
||||
be_raise(vm, "internal_error", "error in regex");
|
||||
}
|
||||
return re_pattern_split_run(vm, code, hay, split_limit);
|
||||
}
|
||||
be_raise(vm, "type_error", NULL);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: re
|
||||
********************************************************************/
|
||||
be_local_module(re,
|
||||
"re",
|
||||
be_nested_map(4,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("compile", 1000265118, 7, -1), be_const_func(be_re_compile) },
|
||||
{ be_nested_key("search", -2144130903, 6, -1), be_const_func(be_re_search) },
|
||||
{ be_nested_key("match", 2116038550, 5, 0), be_const_func(be_re_match) },
|
||||
{ be_nested_key("split", -2017972765, 5, -1), be_const_func(be_re_split) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(re);
|
||||
/********************************************************************/
|
||||
|
||||
// ===================================================================
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: re_pattern
|
||||
********************************************************************/
|
||||
be_local_class(re_pattern,
|
||||
1,
|
||||
NULL,
|
||||
be_nested_map(4,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
|
||||
{ be_nested_key("search", -2144130903, 6, -1), be_const_func(re_pattern_search) },
|
||||
{ be_nested_key("match", 2116038550, 5, 0), be_const_func(re_pattern_match) },
|
||||
{ be_nested_key("split", -2017972765, 5, -1), be_const_func(re_pattern_split) },
|
||||
})),
|
||||
(be_nested_const_str("re_pattern", 2041968961, 10))
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import wire`
|
||||
*
|
||||
* 2 wire communication - I2C
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#include "esp32-hal.h"
|
||||
|
||||
extern int b_serial_init(bvm *vm);
|
||||
extern int b_serial_deinit(bvm *vm);
|
||||
|
||||
extern int b_serial_write(bvm *vm);
|
||||
extern int b_serial_read(bvm *vm);
|
||||
extern int b_serial_available(bvm *vm);
|
||||
extern int b_serial_flush(bvm *vm);
|
||||
|
||||
#include "../generate/be_fixed_be_class_tasmota_serial.h"
|
||||
|
||||
void be_load_serial_lib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_tasmota_serial);
|
||||
be_setglobal(vm, "serial");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_tasmota_serial (scope: global, name: serial) {
|
||||
.p, var
|
||||
|
||||
SERIAL_5N1, int(SERIAL_5N1)
|
||||
SERIAL_6N1, int(SERIAL_6N1)
|
||||
SERIAL_7N1, int(SERIAL_7N1)
|
||||
SERIAL_8N1, int(SERIAL_8N1)
|
||||
SERIAL_5N2, int(SERIAL_5N2)
|
||||
SERIAL_6N2, int(SERIAL_6N2)
|
||||
SERIAL_7N2, int(SERIAL_7N2)
|
||||
SERIAL_8N2, int(SERIAL_8N2)
|
||||
SERIAL_5E1, int(SERIAL_5E1)
|
||||
SERIAL_6E1, int(SERIAL_6E1)
|
||||
SERIAL_7E1, int(SERIAL_7E1)
|
||||
SERIAL_8E1, int(SERIAL_8E1)
|
||||
SERIAL_5E2, int(SERIAL_5E2)
|
||||
SERIAL_6E2, int(SERIAL_6E2)
|
||||
SERIAL_7E2, int(SERIAL_7E2)
|
||||
SERIAL_8E2, int(SERIAL_8E2)
|
||||
SERIAL_5O1, int(SERIAL_5O1)
|
||||
SERIAL_6O1, int(SERIAL_6O1)
|
||||
SERIAL_7O1, int(SERIAL_7O1)
|
||||
SERIAL_8O1, int(SERIAL_8O1)
|
||||
SERIAL_5O2, int(SERIAL_5O2)
|
||||
SERIAL_6O2, int(SERIAL_6O2)
|
||||
SERIAL_7O2, int(SERIAL_7O2)
|
||||
SERIAL_8O2, int(SERIAL_8O2)
|
||||
|
||||
init, func(b_serial_init)
|
||||
deinit, func(b_serial_deinit)
|
||||
|
||||
write, func(b_serial_write)
|
||||
read, func(b_serial_read)
|
||||
available, func(b_serial_available)
|
||||
flush, func(b_serial_flush)
|
||||
}
|
||||
@const_object_info_end */
|
|
@ -0,0 +1,168 @@
|
|||
/********************************************************************
|
||||
* Tasmota App manager
|
||||
*
|
||||
* To use: `import tapp`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Tapp_init, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str(tasmota),
|
||||
/* K1 */ be_nested_str(add_driver),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0xB8060000, // 0000 GETNGBL R1 K0
|
||||
0x8C040301, // 0001 GETMET R1 R1 K1
|
||||
0x5C0C0000, // 0002 MOVE R3 R0
|
||||
0x7C040400, // 0003 CALL R1 2
|
||||
0x80000000, // 0004 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: autoexec
|
||||
********************************************************************/
|
||||
be_local_closure(Tapp_autoexec, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[15]) { /* constants */
|
||||
/* K0 */ be_nested_str(path),
|
||||
/* K1 */ be_nested_str(string),
|
||||
/* K2 */ be_nested_str(listdir),
|
||||
/* K3 */ be_nested_str(_X2F),
|
||||
/* K4 */ be_nested_str(find),
|
||||
/* K5 */ be_nested_str(_X2Etapp),
|
||||
/* K6 */ be_const_int(0),
|
||||
/* K7 */ be_nested_str(tasmota),
|
||||
/* K8 */ be_nested_str(log),
|
||||
/* K9 */ be_nested_str(format),
|
||||
/* K10 */ be_nested_str(TAP_X3A_X20found_X20Tasmota_X20App_X20_X27_X25s_X27),
|
||||
/* K11 */ be_const_int(2),
|
||||
/* K12 */ be_nested_str(load),
|
||||
/* K13 */ be_nested_str(_X23autoexec_X2Ebe),
|
||||
/* K14 */ be_nested_str(stop_iteration),
|
||||
}),
|
||||
&be_const_str_autoexec,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[34]) { /* code */
|
||||
0xA4060000, // 0000 IMPORT R1 K0
|
||||
0xA40A0200, // 0001 IMPORT R2 K1
|
||||
0x8C0C0302, // 0002 GETMET R3 R1 K2
|
||||
0x58140003, // 0003 LDCONST R5 K3
|
||||
0x7C0C0400, // 0004 CALL R3 2
|
||||
0x60100010, // 0005 GETGBL R4 G16
|
||||
0x5C140600, // 0006 MOVE R5 R3
|
||||
0x7C100200, // 0007 CALL R4 1
|
||||
0xA8020014, // 0008 EXBLK 0 #001E
|
||||
0x5C140800, // 0009 MOVE R5 R4
|
||||
0x7C140000, // 000A CALL R5 0
|
||||
0x8C180504, // 000B GETMET R6 R2 K4
|
||||
0x5C200A00, // 000C MOVE R8 R5
|
||||
0x58240005, // 000D LDCONST R9 K5
|
||||
0x7C180600, // 000E CALL R6 3
|
||||
0x24180D06, // 000F GT R6 R6 K6
|
||||
0x781A000B, // 0010 JMPF R6 #001D
|
||||
0xB81A0E00, // 0011 GETNGBL R6 K7
|
||||
0x8C180D08, // 0012 GETMET R6 R6 K8
|
||||
0x8C200509, // 0013 GETMET R8 R2 K9
|
||||
0x5828000A, // 0014 LDCONST R10 K10
|
||||
0x5C2C0A00, // 0015 MOVE R11 R5
|
||||
0x7C200600, // 0016 CALL R8 3
|
||||
0x5824000B, // 0017 LDCONST R9 K11
|
||||
0x7C180600, // 0018 CALL R6 3
|
||||
0xB81A0E00, // 0019 GETNGBL R6 K7
|
||||
0x8C180D0C, // 001A GETMET R6 R6 K12
|
||||
0x00200B0D, // 001B ADD R8 R5 K13
|
||||
0x7C180400, // 001C CALL R6 2
|
||||
0x7001FFEA, // 001D JMP #0009
|
||||
0x5810000E, // 001E LDCONST R4 K14
|
||||
0xAC100200, // 001F CATCH R4 1 0
|
||||
0xB0080000, // 0020 RAISE 2 R0 R0
|
||||
0x80000000, // 0021 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Tapp
|
||||
********************************************************************/
|
||||
be_local_class(Tapp,
|
||||
0,
|
||||
NULL,
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(autoexec, -1), be_const_closure(Tapp_autoexec_closure) },
|
||||
{ be_const_key(init, 0), be_const_closure(Tapp_init_closure) },
|
||||
})),
|
||||
be_str_literal("Tapp")
|
||||
);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: _anonymous_
|
||||
********************************************************************/
|
||||
be_local_closure(tapp__anonymous_, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_const_class(be_class_Tapp),
|
||||
}),
|
||||
&be_const_str__anonymous_,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 5]) { /* code */
|
||||
0x58040000, // 0000 LDCONST R1 K0
|
||||
0xB4000000, // 0001 CLASS K0
|
||||
0x5C080200, // 0002 MOVE R2 R1
|
||||
0x7C080000, // 0003 CALL R2 0
|
||||
0x80040400, // 0004 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: tapp
|
||||
********************************************************************/
|
||||
be_local_module(tapp,
|
||||
"tapp",
|
||||
be_nested_map(1,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(init, -1), be_const_closure(tapp__anonymous__closure) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(tapp);
|
||||
/********************************************************************/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,48 @@
|
|||
/********************************************************************
|
||||
* Webclient mapped to Arduino framework
|
||||
*
|
||||
* To use: `d = webclient()`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_WEBCLIENT
|
||||
|
||||
extern int wc_tcp_init(bvm *vm);
|
||||
extern int wc_tcp_deinit(bvm *vm);
|
||||
|
||||
extern int wc_tcp_connect(bvm *vm);
|
||||
extern int wc_tcp_connected(bvm *vm);
|
||||
extern int wc_tcp_close(bvm *vm);
|
||||
extern int wc_tcp_available(bvm *vm);
|
||||
|
||||
extern int wc_tcp_write(bvm *vm);
|
||||
extern int wc_tcp_read(bvm *vm);
|
||||
extern int wc_tcp_readbytes(bvm *vm);
|
||||
|
||||
#include "../generate/be_fixed_be_class_tcpclient.h"
|
||||
|
||||
void be_load_tcpclient_lib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_tcpclient);
|
||||
be_setglobal(vm, "tcpclient");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_tcpclient (scope: global, name: tcpclient) {
|
||||
.w, var
|
||||
init, func(wc_tcp_init)
|
||||
deinit, func(wc_tcp_deinit)
|
||||
|
||||
connect, func(wc_tcp_connect)
|
||||
connected, func(wc_tcp_connected)
|
||||
close, func(wc_tcp_close)
|
||||
available, func(wc_tcp_available)
|
||||
|
||||
write, func(wc_tcp_write)
|
||||
read, func(wc_tcp_read)
|
||||
readbytes, func(wc_tcp_readbytes)
|
||||
}
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // USE_WEBCLIENT
|
|
@ -0,0 +1,110 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* class Timer
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: tostring
|
||||
********************************************************************/
|
||||
be_local_closure(Timer_tostring, /* name */
|
||||
be_nested_proto(
|
||||
10, /* nstack */
|
||||
1, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(string),
|
||||
/* K1 */ be_nested_str(format),
|
||||
/* K2 */ be_nested_str(_X3Cinstance_X3A_X20_X25s_X28_X25s_X2C_X20_X25s_X2C_X20_X25s_X29),
|
||||
/* K3 */ be_nested_str(due),
|
||||
/* K4 */ be_nested_str(f),
|
||||
/* K5 */ be_nested_str(id),
|
||||
}),
|
||||
&be_const_str_tostring,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[19]) { /* code */
|
||||
0xA4060000, // 0000 IMPORT R1 K0
|
||||
0x8C080301, // 0001 GETMET R2 R1 K1
|
||||
0x58100002, // 0002 LDCONST R4 K2
|
||||
0x60140008, // 0003 GETGBL R5 G8
|
||||
0x60180006, // 0004 GETGBL R6 G6
|
||||
0x5C1C0000, // 0005 MOVE R7 R0
|
||||
0x7C180200, // 0006 CALL R6 1
|
||||
0x7C140200, // 0007 CALL R5 1
|
||||
0x60180008, // 0008 GETGBL R6 G8
|
||||
0x881C0103, // 0009 GETMBR R7 R0 K3
|
||||
0x7C180200, // 000A CALL R6 1
|
||||
0x601C0008, // 000B GETGBL R7 G8
|
||||
0x88200104, // 000C GETMBR R8 R0 K4
|
||||
0x7C1C0200, // 000D CALL R7 1
|
||||
0x60200008, // 000E GETGBL R8 G8
|
||||
0x88240105, // 000F GETMBR R9 R0 K5
|
||||
0x7C200200, // 0010 CALL R8 1
|
||||
0x7C080C00, // 0011 CALL R2 6
|
||||
0x80040400, // 0012 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: init
|
||||
********************************************************************/
|
||||
be_local_closure(Timer_init, /* name */
|
||||
be_nested_proto(
|
||||
4, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(due),
|
||||
/* K1 */ be_nested_str(f),
|
||||
/* K2 */ be_nested_str(id),
|
||||
}),
|
||||
&be_const_str_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 4]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x90020202, // 0001 SETMBR R0 K1 R2
|
||||
0x90020403, // 0002 SETMBR R0 K2 R3
|
||||
0x80000000, // 0003 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: Timer
|
||||
********************************************************************/
|
||||
be_local_class(Timer,
|
||||
3,
|
||||
NULL,
|
||||
be_nested_map(5,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(tostring, 4), be_const_closure(Timer_tostring_closure) },
|
||||
{ be_const_key(id, 2), be_const_var(2) },
|
||||
{ be_const_key(f, -1), be_const_var(1) },
|
||||
{ be_const_key(due, -1), be_const_var(0) },
|
||||
{ be_const_key(init, -1), be_const_closure(Timer_init_closure) },
|
||||
})),
|
||||
be_str_literal("Timer")
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
void be_load_Timer_class(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_Timer);
|
||||
be_setglobal(vm, "Timer");
|
||||
be_pop(vm, 1);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/********************************************************************
|
||||
* Berry module `unishox`
|
||||
*
|
||||
* To use: `import unishox`
|
||||
*
|
||||
* Allows to respond to HTTP request
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_UNISHOX_COMPRESSION
|
||||
|
||||
extern int be_ntv_unishox_decompress(bvm *vm);
|
||||
extern int be_ntv_unishox_compress(bvm *vm);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified module: unishox
|
||||
********************************************************************/
|
||||
be_local_module(unishox,
|
||||
"unishox",
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key(decompress, -1), be_const_func(be_ntv_unishox_decompress) },
|
||||
{ be_const_key(compress, -1), be_const_func(be_ntv_unishox_compress) },
|
||||
}))
|
||||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(unishox);
|
||||
|
||||
#endif // USE_UNISHOX_COMPRESSION
|
|
@ -0,0 +1,57 @@
|
|||
/********************************************************************
|
||||
* Webclient mapped to Arduino framework
|
||||
*
|
||||
* To use: `d = webclient()`
|
||||
*
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_WEBCLIENT
|
||||
|
||||
extern int wc_init(bvm *vm);
|
||||
extern int wc_deinit(bvm *vm);
|
||||
extern int wc_urlencode(bvm *vm);
|
||||
extern int wc_begin(bvm *vm);
|
||||
extern int wc_set_timeouts(bvm *vm);
|
||||
extern int wc_set_useragent(bvm *vm);
|
||||
extern int wc_set_auth(bvm *vm);
|
||||
extern int wc_connected(bvm *vm);
|
||||
extern int wc_close(bvm *vm);
|
||||
extern int wc_addheader(bvm *vm);
|
||||
extern int wc_GET(bvm *vm);
|
||||
extern int wc_POST(bvm *vm);
|
||||
extern int wc_getstring(bvm *vm);
|
||||
extern int wc_writefile(bvm *vm);
|
||||
extern int wc_getsize(bvm *vm);
|
||||
|
||||
#include "../generate/be_fixed_be_class_webclient.h"
|
||||
|
||||
void be_load_webclient_lib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_webclient);
|
||||
be_setglobal(vm, "webclient");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_webclient (scope: global, name: webclient) {
|
||||
.p, var
|
||||
.w, var
|
||||
init, func(wc_init)
|
||||
deinit, func(wc_deinit)
|
||||
url_encode, func(wc_urlencode)
|
||||
|
||||
begin, func(wc_begin)
|
||||
set_timeouts, func(wc_set_timeouts)
|
||||
set_useragent, func(wc_set_useragent)
|
||||
set_auth, func(wc_set_auth)
|
||||
close, func(wc_close)
|
||||
add_header, func(wc_addheader)
|
||||
GET, func(wc_GET)
|
||||
POST, func(wc_POST)
|
||||
get_string, func(wc_getstring)
|
||||
write_file, func(wc_writefile)
|
||||
get_size, func(wc_getsize)
|
||||
}
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // USE_WEBCLIENT
|
|
@ -0,0 +1,55 @@
|
|||
/********************************************************************
|
||||
* Berry module `webserver`
|
||||
*
|
||||
* To use: `import webserver`
|
||||
*
|
||||
* Allows to respond to HTTP request
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
|
||||
extern int w_webserver_member(bvm *vm);
|
||||
extern int w_webserver_on(bvm *vm);
|
||||
extern int w_webserver_state(bvm *vm);
|
||||
|
||||
extern int w_webserver_check_privileged_access(bvm *vm);
|
||||
extern int w_webserver_redirect(bvm *vm);
|
||||
extern int w_webserver_content_start(bvm *vm);
|
||||
extern int w_webserver_content_send(bvm *vm);
|
||||
extern int w_webserver_content_send_style(bvm *vm);
|
||||
extern int w_webserver_content_flush(bvm *vm);
|
||||
extern int w_webserver_content_stop(bvm *vm);
|
||||
extern int w_webserver_content_button(bvm *vm);
|
||||
|
||||
extern int w_webserver_argsize(bvm *vm);
|
||||
extern int w_webserver_arg(bvm *vm);
|
||||
extern int w_webserver_arg_name(bvm *vm);
|
||||
extern int w_webserver_has_arg(bvm *vm);
|
||||
|
||||
|
||||
/* @const_object_info_begin
|
||||
module webserver (scope: global) {
|
||||
member, func(w_webserver_member)
|
||||
|
||||
on, func(w_webserver_on)
|
||||
state, func(w_webserver_state)
|
||||
|
||||
check_privileged_access, func(w_webserver_check_privileged_access)
|
||||
redirect, func(w_webserver_redirect)
|
||||
content_send, func(w_webserver_content_send)
|
||||
content_send_style, func(w_webserver_content_send_style)
|
||||
content_flush, func(w_webserver_content_flush)
|
||||
content_start, func(w_webserver_content_start)
|
||||
content_stop, func(w_webserver_content_stop)
|
||||
content_button, func(w_webserver_content_button)
|
||||
|
||||
arg_size, func(w_webserver_argsize)
|
||||
arg, func(w_webserver_arg)
|
||||
arg_name, func(w_webserver_arg_name)
|
||||
has_arg, func(w_webserver_has_arg)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "../generate/be_fixed_webserver.h"
|
||||
|
||||
#endif // USE_WEBSERVER
|
|
@ -0,0 +1,151 @@
|
|||
/********************************************************************
|
||||
* Tasmota lib
|
||||
*
|
||||
* To use: `import wire`
|
||||
*
|
||||
* 2 wire communication - I2C
|
||||
*******************************************************************/
|
||||
#include "be_constobj.h"
|
||||
|
||||
#ifdef USE_I2C
|
||||
|
||||
extern int b_wire_init(bvm *vm);
|
||||
|
||||
extern int b_wire_begintransmission(bvm *vm);
|
||||
extern int b_wire_endtransmission(bvm *vm);
|
||||
extern int b_wire_requestfrom(bvm *vm);
|
||||
extern int b_wire_available(bvm *vm);
|
||||
extern int b_wire_write(bvm *vm);
|
||||
extern int b_wire_read(bvm *vm);
|
||||
|
||||
extern int b_wire_scan(bvm *vm);
|
||||
|
||||
extern int b_wire_validwrite(bvm *vm);
|
||||
extern int b_wire_validread(bvm *vm);
|
||||
extern int b_wire_detect(bvm *vm);
|
||||
extern int b_wire_enabled(bvm *vm);
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: write_bytes
|
||||
********************************************************************/
|
||||
be_local_closure(write_bytes, /* name */
|
||||
be_nested_proto(
|
||||
7, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(_begin_transmission),
|
||||
/* K1 */ be_nested_str(_write),
|
||||
/* K2 */ be_nested_str(_end_transmission),
|
||||
}),
|
||||
&be_const_str_write_bytes,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[12]) { /* code */
|
||||
0x8C100100, // 0000 GETMET R4 R0 K0
|
||||
0x5C180200, // 0001 MOVE R6 R1
|
||||
0x7C100400, // 0002 CALL R4 2
|
||||
0x8C100101, // 0003 GETMET R4 R0 K1
|
||||
0x5C180400, // 0004 MOVE R6 R2
|
||||
0x7C100400, // 0005 CALL R4 2
|
||||
0x8C100101, // 0006 GETMET R4 R0 K1
|
||||
0x5C180600, // 0007 MOVE R6 R3
|
||||
0x7C100400, // 0008 CALL R4 2
|
||||
0x8C100102, // 0009 GETMET R4 R0 K2
|
||||
0x7C100200, // 000A CALL R4 1
|
||||
0x80000000, // 000B RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: read_bytes
|
||||
********************************************************************/
|
||||
be_local_closure(read_bytes, /* name */
|
||||
be_nested_proto(
|
||||
8, /* nstack */
|
||||
4, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 6]) { /* constants */
|
||||
/* K0 */ be_nested_str(_begin_transmission),
|
||||
/* K1 */ be_nested_str(_write),
|
||||
/* K2 */ be_nested_str(_end_transmission),
|
||||
/* K3 */ be_nested_str(_request_from),
|
||||
/* K4 */ be_nested_str(_available),
|
||||
/* K5 */ be_nested_str(_read),
|
||||
}),
|
||||
&be_const_str_read_bytes,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[24]) { /* code */
|
||||
0x8C100100, // 0000 GETMET R4 R0 K0
|
||||
0x5C180200, // 0001 MOVE R6 R1
|
||||
0x7C100400, // 0002 CALL R4 2
|
||||
0x8C100101, // 0003 GETMET R4 R0 K1
|
||||
0x5C180400, // 0004 MOVE R6 R2
|
||||
0x7C100400, // 0005 CALL R4 2
|
||||
0x8C100102, // 0006 GETMET R4 R0 K2
|
||||
0x50180000, // 0007 LDBOOL R6 0 0
|
||||
0x7C100400, // 0008 CALL R4 2
|
||||
0x8C100103, // 0009 GETMET R4 R0 K3
|
||||
0x5C180200, // 000A MOVE R6 R1
|
||||
0x5C1C0600, // 000B MOVE R7 R3
|
||||
0x7C100600, // 000C CALL R4 3
|
||||
0x60100015, // 000D GETGBL R4 G21
|
||||
0x5C140600, // 000E MOVE R5 R3
|
||||
0x7C100200, // 000F CALL R4 1
|
||||
0x8C140104, // 0010 GETMET R5 R0 K4
|
||||
0x7C140200, // 0011 CALL R5 1
|
||||
0x78160003, // 0012 JMPF R5 #0017
|
||||
0x8C140105, // 0013 GETMET R5 R0 K5
|
||||
0x7C140200, // 0014 CALL R5 1
|
||||
0x40140805, // 0015 CONNECT R5 R4 R5
|
||||
0x7001FFF8, // 0016 JMP #0010
|
||||
0x80040800, // 0017 RET 1 R4
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
#include "../generate/be_fixed_be_class_tasmota_wire.h"
|
||||
|
||||
void be_load_wirelib(bvm *vm) {
|
||||
be_pushntvclass(vm, &be_class_tasmota_wire);
|
||||
be_setglobal(vm, "Wire");
|
||||
be_pop(vm, 1);
|
||||
}
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_tasmota_wire (scope: global, name: Wire) {
|
||||
bus, var
|
||||
|
||||
init, func(b_wire_init)
|
||||
_begin_transmission, func(b_wire_begintransmission)
|
||||
_end_transmission, func(b_wire_endtransmission)
|
||||
_request_from, func(b_wire_requestfrom)
|
||||
_available, func(b_wire_available)
|
||||
_write, func(b_wire_write)
|
||||
_read, func(b_wire_read)
|
||||
scan, func(b_wire_scan)
|
||||
write, func(b_wire_validwrite)
|
||||
read, func(b_wire_validread)
|
||||
detect, func(b_wire_detect)
|
||||
enabled, func(b_wire_enabled)
|
||||
|
||||
read_bytes, closure(read_bytes_closure)
|
||||
write_bytes, closure(write_bytes_closure)
|
||||
}
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // USE_I2C
|
|
@ -0,0 +1,247 @@
|
|||
/********************************************************************
|
||||
** Copyright (c) 2018-2020 Guan Wenliang
|
||||
** This file is part of the Berry default interpreter.
|
||||
** skiars@qq.com, https://github.com/Skiars/berry
|
||||
** See Copyright Notice in the LICENSE file or at
|
||||
** https://github.com/Skiars/berry/blob/master/LICENSE
|
||||
********************************************************************/
|
||||
#ifndef BERRY_CONF_H
|
||||
#define BERRY_CONF_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef COMPILE_BERRY_LIB
|
||||
#include "my_user_config.h"
|
||||
#include "tasmota_configurations.h"
|
||||
#endif
|
||||
|
||||
/* Macro: BE_DEBUG
|
||||
* Berry interpreter debug switch.
|
||||
* Default: 0
|
||||
**/
|
||||
#ifndef BE_DEBUG
|
||||
#define BE_DEBUG 0
|
||||
#endif
|
||||
|
||||
/* Macro: BE_LONGLONG_INT
|
||||
* Select integer length.
|
||||
* If the value is 0, use an integer of type int, use a long
|
||||
* integer type when the value is 1, and use a long long integer
|
||||
* type when the value is 2.
|
||||
* Default: 2
|
||||
*/
|
||||
#define BE_INTGER_TYPE 1 // use long int = uint32_t
|
||||
|
||||
/* Macro: BE_USE_SINGLE_FLOAT
|
||||
* Select floating point precision.
|
||||
* Use double-precision floating-point numbers when the value
|
||||
* is 0 (default), otherwise use single-precision floating-point
|
||||
* numbers.
|
||||
* Default: 0
|
||||
**/
|
||||
#define BE_USE_SINGLE_FLOAT 1 // use `float` not `double`
|
||||
|
||||
/* Macro: BE_USE_PRECOMPILED_OBJECT
|
||||
* Use precompiled objects to avoid creating these objects at
|
||||
* runtime. Enable this macro can greatly optimize RAM usage.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_USE_PRECOMPILED_OBJECT 1
|
||||
|
||||
/* Macro: BE_DEBUG_RUNTIME_INFO
|
||||
* Set runtime error debugging information.
|
||||
* 0: unable to output source file and line number at runtime.
|
||||
* 1: output source file and line number information at runtime.
|
||||
* 2: the information use uint16_t type (save space).
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_DEBUG_RUNTIME_INFO 0
|
||||
|
||||
/* Macro: BE_DEBUG_VAR_INFO
|
||||
* Set variable debugging tracking information.
|
||||
* 0: disable variable debugging tracking information at runtime.
|
||||
* 1: enable variable debugging tracking information at runtime.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_DEBUG_VAR_INFO 0
|
||||
|
||||
/* Macro: BE_USE_PERF_COUNTERS
|
||||
* Use the obshook function to report low-level actions.
|
||||
* Default: 0
|
||||
**/
|
||||
#define BE_USE_PERF_COUNTERS 1
|
||||
|
||||
/* Macro: BE_VM_OBSERVABILITY_SAMPLING
|
||||
* If BE_USE_PERF_COUNTERS == 1
|
||||
* then the observability hook is called regularly in the VM loop
|
||||
* allowing to stop infinite loops or too-long running code.
|
||||
* The value is a power of 2.
|
||||
* Default: 20 - which translates to 2^20 or ~1 million instructions
|
||||
**/
|
||||
#define BE_VM_OBSERVABILITY_SAMPLING 20
|
||||
|
||||
/* Macro: BE_STACK_TOTAL_MAX
|
||||
* Set the maximum total stack size.
|
||||
* Default: 20000
|
||||
**/
|
||||
#define BE_STACK_TOTAL_MAX 8000
|
||||
|
||||
/* Macro: BE_STACK_FREE_MIN
|
||||
* Set the minimum free count of the stack. The stack idles will
|
||||
* be checked when a function is called, and the stack will be
|
||||
* expanded if the number of free is less than BE_STACK_FREE_MIN.
|
||||
* Default: 10
|
||||
**/
|
||||
#define BE_STACK_FREE_MIN 20
|
||||
|
||||
/* Macro: BE_STACK_START
|
||||
* Set the starting size of the stack at VM creation.
|
||||
* Default: 50
|
||||
**/
|
||||
#define BE_STACK_START 100
|
||||
|
||||
/* Macro: BE_CONST_SEARCH_SIZE
|
||||
* Constants in function are limited to 255. However the compiler
|
||||
* will look for a maximum of pre-existing constants to avoid
|
||||
* performance degradation. This may cause the number of constants
|
||||
* to be higher than required.
|
||||
* Increase is you need to solidify functions.
|
||||
* Default: 50
|
||||
**/
|
||||
#define BE_CONST_SEARCH_SIZE 150
|
||||
|
||||
/* Macro: BE_STACK_FREE_MIN
|
||||
* The short string will hold the hash value when the value is
|
||||
* true. It may be faster but requires more RAM.
|
||||
* Default: 0
|
||||
**/
|
||||
#define BE_USE_STR_HASH_CACHE 0
|
||||
|
||||
/* Macro: BE_USE_FILE_SYSTEM
|
||||
* The file system interface will be used when this macro is true
|
||||
* or when using the OS module. Otherwise the file system interface
|
||||
* will not be used.
|
||||
* Default: 0
|
||||
**/
|
||||
#define BE_USE_FILE_SYSTEM 0
|
||||
|
||||
/* Macro: BE_USE_SCRIPT_COMPILER
|
||||
* Enable compiler when BE_USE_SCRIPT_COMPILER is not 0, otherwise
|
||||
* disable the compiler.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_USE_SCRIPT_COMPILER 1
|
||||
|
||||
/* Macro: BE_USE_BYTECODE_SAVER
|
||||
* Enable save bytecode to file when BE_USE_BYTECODE_SAVER is not 0,
|
||||
* otherwise disable the feature.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_USE_BYTECODE_SAVER 1
|
||||
|
||||
/* Macro: BE_USE_BYTECODE_LOADER
|
||||
* Enable load bytecode from file when BE_USE_BYTECODE_LOADER is not 0,
|
||||
* otherwise disable the feature.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_USE_BYTECODE_LOADER 1
|
||||
|
||||
/* Macro: BE_USE_SHARED_LIB
|
||||
* Enable shared library when BE_USE_SHARED_LIB is not 0,
|
||||
* otherwise disable the feature.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_USE_SHARED_LIB 0
|
||||
|
||||
/* Macro: BE_USE_OVERLOAD_HASH
|
||||
* Allows instances to overload hash methods for use in the
|
||||
* built-in Map class. Disable this feature to crop the code
|
||||
* size.
|
||||
* Default: 1
|
||||
**/
|
||||
#define BE_USE_OVERLOAD_HASH 1
|
||||
|
||||
/* Macro: BE_USE_DEBUG_HOOK
|
||||
* Berry debug hook switch.
|
||||
* Default: 0
|
||||
**/
|
||||
#define BE_USE_DEBUG_HOOK 0
|
||||
|
||||
/* Macro: BE_USE_DEBUG_GC
|
||||
* Enable GC debug mode. This causes an actual gc after each
|
||||
* allocation. It's much slower and should not be used
|
||||
* in production code.
|
||||
* Default: 0
|
||||
**/
|
||||
#define BE_USE_DEBUG_GC 0
|
||||
|
||||
/* Macro: BE_USE_XXX_MODULE
|
||||
* These macros control whether the related module is compiled.
|
||||
* When they are true, they will enable related modules. At this
|
||||
* point you can use the import statement to import the module.
|
||||
* They will not compile related modules when they are false.
|
||||
**/
|
||||
#define BE_USE_STRING_MODULE 1
|
||||
#define BE_USE_JSON_MODULE 1
|
||||
#define BE_USE_MATH_MODULE 1
|
||||
#define BE_USE_TIME_MODULE 0
|
||||
#define BE_USE_OS_MODULE 0
|
||||
#define BE_USE_GLOBAL_MODULE 1
|
||||
#define BE_USE_SYS_MODULE 1
|
||||
#define BE_USE_DEBUG_MODULE 0
|
||||
#define BE_USE_GC_MODULE 1
|
||||
#define BE_USE_SOLIDIFY_MODULE 0
|
||||
#define BE_USE_INTROSPECT_MODULE 1
|
||||
#define BE_USE_STRICT_MODULE 1
|
||||
|
||||
#ifdef USE_BERRY_DEBUG
|
||||
#undef BE_USE_DEBUG_MODULE
|
||||
#undef BE_USE_SOLIDIFY_MODULE
|
||||
#define BE_USE_DEBUG_MODULE 1
|
||||
#define BE_USE_SOLIDIFY_MODULE 1
|
||||
#endif // USE_BERRY_DEBUG
|
||||
|
||||
/* Macro: BE_EXPLICIT_XXX
|
||||
* If these macros are defined, the corresponding function will
|
||||
* use the version defined by these macros. These macro definitions
|
||||
* are not required.
|
||||
* The default is to use the functions in the standard library.
|
||||
**/
|
||||
#ifdef USE_BERRY_PSRAM
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void *berry_malloc(size_t size);
|
||||
extern void berry_free(void *ptr);
|
||||
extern void *berry_realloc(void *ptr, size_t size);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#define BE_EXPLICIT_MALLOC berry_malloc
|
||||
#define BE_EXPLICIT_FREE berry_free
|
||||
#define BE_EXPLICIT_REALLOC berry_realloc
|
||||
#else
|
||||
#define BE_EXPLICIT_MALLOC malloc
|
||||
#define BE_EXPLICIT_FREE free
|
||||
#define BE_EXPLICIT_REALLOC realloc
|
||||
#endif // USE_BERRY_PSRAM
|
||||
|
||||
#define BE_EXPLICIT_ABORT abort
|
||||
#define BE_EXPLICIT_EXIT exit
|
||||
// #define BE_EXPLICIT_MALLOC malloc
|
||||
// #define BE_EXPLICIT_FREE free
|
||||
// #define BE_EXPLICIT_REALLOC realloc
|
||||
|
||||
/* Macro: be_assert
|
||||
* Berry debug assertion. Only enabled when BE_DEBUG is active.
|
||||
* Default: use the assert() function of the standard library.
|
||||
**/
|
||||
#define be_assert(expr) assert(expr)
|
||||
|
||||
/* Tasmota debug specific */
|
||||
#ifdef USE_BERRY_DEBUG
|
||||
#undef BE_DEBUG_RUNTIME_INFO
|
||||
#define BE_DEBUG_RUNTIME_INFO 2 /* record line information in 16 bits */
|
||||
#endif // USE_BERRY_DEBUG
|
||||
|
||||
#endif
|
|
@ -0,0 +1,189 @@
|
|||
#
|
||||
# class Animate
|
||||
#
|
||||
# Animation framework
|
||||
#
|
||||
|
||||
animate = module("animate")
|
||||
|
||||
# state-machine: from val a to b
|
||||
class Animate_ins_ramp
|
||||
var a # starting value
|
||||
var b # end value
|
||||
var duration # duration in milliseconds
|
||||
|
||||
def init(a,b,duration)
|
||||
self.a = a
|
||||
self.b = b
|
||||
self.duration = duration
|
||||
end
|
||||
end
|
||||
animate.ins_ramp = Animate_ins_ramp
|
||||
|
||||
# state-machine: pause and goto
|
||||
class Animate_ins_goto
|
||||
var pc_rel # relative PC, -1 previous instruction, 1 next instruction, 0 means see pc_abs
|
||||
var pc_abs # absolute PC, only if pc_rel == 0, address if next instruction
|
||||
var duration # pause in milliseconds before goto, -1 means infinite (state-machine can be changed externally)
|
||||
|
||||
def init(pc_rel, pc_abs, duration)
|
||||
self.pc_rel = pc_rel
|
||||
self.pc_abs = pc_abs
|
||||
self.duration = duration
|
||||
end
|
||||
end
|
||||
animate.ins_goto = Animate_ins_goto
|
||||
|
||||
class Animate_engine
|
||||
var code # array of state-machine instructions
|
||||
var closure # closure to call with the new value
|
||||
var pc # program-counter
|
||||
var ins_time # absolute time when the current instruction started
|
||||
var running # is the animation running? allows fast return
|
||||
var value # current value
|
||||
|
||||
def init()
|
||||
self.code = []
|
||||
self.pc = 0 # start at instruction 0
|
||||
self.ins_time = 0
|
||||
self.running = false # not running by default
|
||||
#
|
||||
end
|
||||
|
||||
# run but needs external calls to `animate()`
|
||||
# cur_time:int (opt) current timestamp in ms, defaults to `tasmota.millis()`
|
||||
# val:int (opt) starting value, default to `nil`
|
||||
def run(cur_time, val)
|
||||
if cur_time == nil cur_time = tasmota.millis() end
|
||||
if (val != nil) self.value = val end
|
||||
self.ins_time = cur_time
|
||||
|
||||
self.running = true
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
# runs autonomously in the Tasmota event loop
|
||||
def autorun(cur_time, val)
|
||||
self.run(cur_time, val)
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
def stop()
|
||||
self.running = false
|
||||
tasmota.remove_driver(self)
|
||||
end
|
||||
|
||||
def is_running()
|
||||
return self.running
|
||||
end
|
||||
|
||||
def every_50ms()
|
||||
self.animate()
|
||||
end
|
||||
|
||||
def animate(cur_time) # time in milliseconds, optional, defaults to `tasmota.millis()`
|
||||
if !self.running return end
|
||||
if cur_time == nil cur_time = tasmota.millis() end
|
||||
# run through instructions
|
||||
while true
|
||||
var sub_index = cur_time - self.ins_time # time since the beginning of current instruction
|
||||
#
|
||||
# make sure PC is valid
|
||||
if self.pc >= size(self.code)
|
||||
self.running = false
|
||||
break
|
||||
end
|
||||
#
|
||||
if self.pc < 0 raise "internal_error", "Animate pc is out of range" end
|
||||
var ins = self.code[self.pc]
|
||||
|
||||
# Instruction Ramp
|
||||
if isinstance(ins, animate.ins_ramp)
|
||||
var f = self.closure # assign to a local variable to not call a method
|
||||
if sub_index < ins.duration
|
||||
# we're still in the ramp
|
||||
self.value = tasmota.scale_uint(sub_index, 0, ins.duration, ins.a, ins.b)
|
||||
# call closure
|
||||
if f f(self.value) end # call closure, need try? TODO
|
||||
break
|
||||
else
|
||||
self.value = ins.b
|
||||
if f f(self.value) end # set to last value
|
||||
self.pc += 1 # next instruction
|
||||
self.ins_time = cur_time - (sub_index - ins.duration)
|
||||
end
|
||||
|
||||
# Instruction Goto
|
||||
elif isinstance(ins, animate.ins_goto)
|
||||
if sub_index < ins.duration
|
||||
break
|
||||
else
|
||||
if ins.pc_rel != 0
|
||||
self.pc += ins.pc_rel
|
||||
else
|
||||
self.pc = ins.pc_abs
|
||||
end
|
||||
self.ins_time = cur_time - (sub_index - ins.duration)
|
||||
end
|
||||
|
||||
# Invalid
|
||||
else
|
||||
raise "internal_error", "unknown instruction"
|
||||
end
|
||||
end
|
||||
return self.value
|
||||
|
||||
end
|
||||
end
|
||||
animate.engine = Animate_engine
|
||||
|
||||
class Animate_from_to : Animate_engine
|
||||
|
||||
def init(closure, from, to, duration)
|
||||
super(self).init()
|
||||
self.closure = closure
|
||||
self.code.push(animate.ins_ramp(from, to, duration))
|
||||
end
|
||||
|
||||
end
|
||||
animate.from_to = Animate_from_to
|
||||
|
||||
#-
|
||||
a=Animate_from_to(nil, 0, 100, 5000)
|
||||
a.autorun()
|
||||
-#
|
||||
|
||||
class Animate_rotate : Animate_engine
|
||||
|
||||
def init(closure, from, to, duration)
|
||||
super(self).init()
|
||||
self.closure = closure
|
||||
self.code.push(animate.ins_ramp(from, to, duration))
|
||||
self.code.push(animate.ins_goto(0, 0, 0)) # goto abs pc = 0 without any pause
|
||||
end
|
||||
|
||||
end
|
||||
animate.rotate = Animate_rotate
|
||||
|
||||
#-
|
||||
a=Animate_rotate(nil, 0, 100, 5000)
|
||||
a.autorun()
|
||||
-#
|
||||
|
||||
class Animate_back_forth : Animate_engine
|
||||
|
||||
def init(closure, from, to, duration)
|
||||
super(self).init()
|
||||
self.closure = closure
|
||||
self.code.push(animate.ins_ramp(from, to, duration / 2))
|
||||
self.code.push(animate.ins_ramp(to, from, duration / 2))
|
||||
self.code.push(animate.ins_goto(0, 0, 0)) # goto abs pc = 0 without any pause
|
||||
end
|
||||
|
||||
end
|
||||
animate.back_forth = Animate_back_forth
|
||||
|
||||
#-
|
||||
a=Animate_back_forth(nil, 0, 100, 5000)
|
||||
a.autorun()
|
||||
-#
|
|
@ -0,0 +1,29 @@
|
|||
#- Native code used for testing and code solidification -#
|
||||
#- Do not use it -#
|
||||
|
||||
class Driver
|
||||
var every_second
|
||||
var every_100ms
|
||||
var web_add_handler
|
||||
var web_add_button
|
||||
var web_add_main_button
|
||||
var web_add_management_button
|
||||
var web_add_config_button
|
||||
var web_add_console_button
|
||||
var save_before_restart
|
||||
var web_sensor
|
||||
var json_append
|
||||
var button_pressed
|
||||
var display
|
||||
|
||||
def init()
|
||||
end
|
||||
|
||||
def get_tasmota()
|
||||
return tasmota
|
||||
end
|
||||
|
||||
def add_cmd(c, f)
|
||||
tasmota.add_cmd(c, / cmd, idx, payload, payload_json -> f(self, cmd, idx, payload, payload_json))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,577 @@
|
|||
#- Native code used for testing and code solidification -#
|
||||
#- Do not use it -#
|
||||
|
||||
class Timer
|
||||
var due, f, id
|
||||
def init(due, f, id)
|
||||
self.due = due
|
||||
self.f = f
|
||||
self.id = id
|
||||
end
|
||||
def tostring()
|
||||
import string
|
||||
return string.format("<instance: %s(%s, %s, %s)", str(classof(self)),
|
||||
str(self.due), str(self.f), str(self.id))
|
||||
end
|
||||
end
|
||||
|
||||
tasmota = nil
|
||||
class Tasmota
|
||||
var _rules
|
||||
var _timers
|
||||
var _ccmd
|
||||
var _drivers
|
||||
var wire1
|
||||
var wire2
|
||||
var cmd_res # store the command result, nil if disables, true if capture enabled, contains return value
|
||||
var global # mapping to TasmotaGlobal
|
||||
var settings
|
||||
var wd # when load() is called, `tasmota.wd` contains the name of the archive. Ex: `/M5StickC.autoconf#`
|
||||
var _debug_present # is `import debug` present?
|
||||
|
||||
def init()
|
||||
# instanciate the mapping object to TasmotaGlobal
|
||||
self.global = ctypes_bytes_dyn(self._global_addr, self._global_def)
|
||||
import introspect
|
||||
var settings_addr = bytes(self._settings_ptr, 4).get(0,4)
|
||||
if settings_addr
|
||||
self.settings = ctypes_bytes_dyn(introspect.toptr(settings_addr), self._settings_def)
|
||||
end
|
||||
self.wd = ""
|
||||
self._debug_present = false
|
||||
try
|
||||
import debug
|
||||
self._debug_present = true
|
||||
except ..
|
||||
end
|
||||
end
|
||||
|
||||
# create a specific sub-class for rules: pattern(string) -> closure
|
||||
# Classs KV has two members k and v
|
||||
def kv(k, v)
|
||||
class KV
|
||||
var k, v
|
||||
def init(k,v)
|
||||
self.k = k
|
||||
self.v = v
|
||||
end
|
||||
end
|
||||
|
||||
return KV(k, v)
|
||||
end
|
||||
|
||||
# add `chars_in_string(s:string,c:string) -> int``
|
||||
# looks for any char in c, and return the position of the first char
|
||||
# or -1 if not found
|
||||
# inv is optional and inverses the behavior, i.e. look for chars not in the list
|
||||
def chars_in_string(s,c,inv)
|
||||
var inverted = inv ? true : false
|
||||
var i = 0
|
||||
while i < size(s)
|
||||
# for i:0..size(s)-1
|
||||
var found = false
|
||||
var j = 0
|
||||
while j < size(c)
|
||||
# for j:0..size(c)-1
|
||||
if s[i] == c[j] found = true end
|
||||
j += 1
|
||||
end
|
||||
if inverted != found return i end
|
||||
i += 1
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
# find a key in map, case insensitive, return actual key or nil if not found
|
||||
def find_key_i(m,keyi)
|
||||
import string
|
||||
var keyu = string.toupper(keyi)
|
||||
if isinstance(m, map)
|
||||
for k:m.keys()
|
||||
if string.toupper(k)==keyu || keyi=='?'
|
||||
return k
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# split the item when there is an operator, returns a list of (left,op,right)
|
||||
# ex: "Dimmer>50" -> ["Dimmer",tasmota_gt,"50"]
|
||||
def find_op(item)
|
||||
import string
|
||||
var op_chars = '=<>!'
|
||||
var pos = self.chars_in_string(item, op_chars)
|
||||
if pos >= 0
|
||||
var op_split = string.split(item,pos)
|
||||
var op_left = op_split[0]
|
||||
var op_rest = op_split[1]
|
||||
pos = self.chars_in_string(op_rest, op_chars, true)
|
||||
if pos >= 0
|
||||
var op_split2 = string.split(op_rest,pos)
|
||||
var op_middle = op_split2[0]
|
||||
var op_right = op_split2[1]
|
||||
return [op_left,op_middle,op_right]
|
||||
end
|
||||
end
|
||||
return [item, nil, nil]
|
||||
end
|
||||
|
||||
# Rules
|
||||
def add_rule(pat,f)
|
||||
if !self._rules
|
||||
self._rules=[]
|
||||
end
|
||||
if type(f) == 'function'
|
||||
self._rules.push(self.kv(pat, f))
|
||||
else
|
||||
raise 'value_error', 'the second argument is not a function'
|
||||
end
|
||||
end
|
||||
|
||||
def remove_rule(pat)
|
||||
if self._rules
|
||||
var i = 0
|
||||
while i < size(self._rules)
|
||||
if self._rules[i].k == pat
|
||||
self._rules.remove(i) #- don't increment i since we removed the object -#
|
||||
else
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Rules trigger if match. return true if match, false if not
|
||||
def try_rule(event, rule, f)
|
||||
import string
|
||||
var rl_list = self.find_op(rule)
|
||||
var sub_event = event
|
||||
var rl = string.split(rl_list[0],'#')
|
||||
var i = 0
|
||||
while i < size(rl)
|
||||
# for it:rl
|
||||
var it = rl[i]
|
||||
var found=self.find_key_i(sub_event,it)
|
||||
if found == nil return false end
|
||||
sub_event = sub_event[found]
|
||||
i += 1
|
||||
end
|
||||
var op=rl_list[1]
|
||||
var op2=rl_list[2]
|
||||
if op
|
||||
if op=='=='
|
||||
if str(sub_event) != str(op2) return false end
|
||||
elif op=='!=='
|
||||
if str(sub_event) == str(op2) return false end
|
||||
elif op=='='
|
||||
if real(sub_event) != real(op2) return false end
|
||||
elif op=='!='
|
||||
if real(sub_event) == real(op2) return false end
|
||||
elif op=='>'
|
||||
if real(sub_event) <= real(op2) return false end
|
||||
elif op=='>='
|
||||
if real(sub_event) < real(op2) return false end
|
||||
elif op=='<'
|
||||
if real(sub_event) >= real(op2) return false end
|
||||
elif op=='<='
|
||||
if real(sub_event) > real(op2) return false end
|
||||
end
|
||||
end
|
||||
f(sub_event, rl_list[0], event)
|
||||
return true
|
||||
end
|
||||
|
||||
# Run rules, i.e. check each individual rule
|
||||
# Returns true if at least one rule matched, false if none
|
||||
def exec_rules(ev_json)
|
||||
if self._rules || self.cmd_res != nil # if there is a rule handler, or we record rule results
|
||||
import json
|
||||
var ev = json.load(ev_json) # returns nil if invalid JSON
|
||||
var ret = false
|
||||
if ev == nil
|
||||
self.log('BRY: ERROR, bad json: '+ev_json, 3)
|
||||
ev = ev_json # revert to string
|
||||
end
|
||||
# record the rule payload for tasmota.cmd()
|
||||
if self.cmd_res != nil
|
||||
self.cmd_res = ev
|
||||
end
|
||||
# try all rule handlers
|
||||
if self._rules
|
||||
var i = 0
|
||||
while i < size(self._rules)
|
||||
var kv = self._rules[i]
|
||||
ret = self.try_rule(ev,kv.k,kv.v) || ret #- call should be first to avoid evaluation shortcut if ret is already true -#
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Run tele rules
|
||||
def exec_tele(ev_json)
|
||||
if self._rules
|
||||
import json
|
||||
var ev = json.load(ev_json) # returns nil if invalid JSON
|
||||
var ret = false
|
||||
if ev == nil
|
||||
self.log('BRY: ERROR, bad json: '+ev_json, 3)
|
||||
ev = ev_json # revert to string
|
||||
end
|
||||
# insert tele prefix
|
||||
ev = { "Tele": ev }
|
||||
|
||||
var i = 0
|
||||
while i < size(self._rules)
|
||||
var kv = self._rules[i]
|
||||
ret = self.try_rule(ev,kv.k,kv.v) || ret #- call should be first to avoid evaluation shortcut -#
|
||||
i += 1
|
||||
end
|
||||
return ret
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def set_timer(delay,f,id)
|
||||
if !self._timers self._timers=[] end
|
||||
self._timers.push(Timer(self.millis(delay),f,id))
|
||||
end
|
||||
|
||||
# run every 50ms tick
|
||||
def run_deferred()
|
||||
if self._timers
|
||||
var i=0
|
||||
while i<self._timers.size()
|
||||
if self.time_reached(self._timers[i].due)
|
||||
var f=self._timers[i].f
|
||||
self._timers.remove(i)
|
||||
f()
|
||||
else
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# remove timers by id
|
||||
def remove_timer(id)
|
||||
if tasmota._timers
|
||||
var i=0
|
||||
while i<tasmota._timers.size()
|
||||
if self._timers[i].id == id
|
||||
self._timers.remove(i)
|
||||
else
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Add command to list
|
||||
def add_cmd(c,f)
|
||||
if !self._ccmd
|
||||
self._ccmd={}
|
||||
end
|
||||
if type(f) == 'function'
|
||||
self._ccmd[c]=f
|
||||
else
|
||||
raise 'value_error', 'the second argument is not a function'
|
||||
end
|
||||
end
|
||||
|
||||
# Remove command from list
|
||||
def remove_cmd(c)
|
||||
if self._ccmd
|
||||
self._ccmd.remove(c)
|
||||
end
|
||||
end
|
||||
|
||||
# Execute custom command
|
||||
def exec_cmd(cmd, idx, payload)
|
||||
if self._ccmd
|
||||
import json
|
||||
var payload_json = json.load(payload)
|
||||
var cmd_found = self.find_key_i(self._ccmd, cmd)
|
||||
if cmd_found != nil
|
||||
self.resolvecmnd(cmd_found) # set the command name in XdrvMailbox.command
|
||||
self._ccmd[cmd_found](cmd_found, idx, payload, payload_json)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Force gc and return allocated memory
|
||||
def gc()
|
||||
import gc
|
||||
gc.collect()
|
||||
return gc.allocated()
|
||||
end
|
||||
|
||||
# tasmota.wire_scan(addr:int [, index:int]) -> wire1 or wire2 or nil
|
||||
# scan for the first occurrence of the addr, starting with bus1 then bus2
|
||||
# optional: skip if index is disabled via I2CEnable
|
||||
def wire_scan(addr,idx)
|
||||
# skip if the I2C index is disabled
|
||||
if idx != nil && !self.i2c_enabled(idx) return nil end
|
||||
if self.wire1.enabled() && self.wire1.detect(addr) return self.wire1 end
|
||||
if self.wire2.enabled() && self.wire2.detect(addr) return self.wire2 end
|
||||
return nil
|
||||
end
|
||||
|
||||
def time_str(time)
|
||||
import string
|
||||
var tm = self.time_dump(time)
|
||||
return string.format("%04d-%02d-%02dT%02d:%02d:%02d", tm['year'], tm['month'], tm['day'], tm['hour'], tm['min'], tm['sec'])
|
||||
end
|
||||
|
||||
def load(f)
|
||||
# embedded functions
|
||||
# puth_path: adds the current archive to sys.path
|
||||
def push_path(p)
|
||||
import sys
|
||||
var path = sys.path()
|
||||
if path.find(p) == nil # append only if it's not already there
|
||||
path.push(p)
|
||||
end
|
||||
end
|
||||
# pop_path: removes the path
|
||||
def pop_path(p)
|
||||
import sys
|
||||
var path = sys.path()
|
||||
var idx = path.find(p)
|
||||
if idx != nil
|
||||
path.remove(idx)
|
||||
end
|
||||
end
|
||||
|
||||
import string
|
||||
import path
|
||||
|
||||
# fail if empty string
|
||||
if size(f) == 0 return false end
|
||||
# Ex: f = 'app.zip#autoexec'
|
||||
|
||||
# add leading '/' if absent
|
||||
if f[0] != '/' f = '/' + f end
|
||||
# Ex: f = '/app.zip#autoexec'
|
||||
|
||||
var f_items = string.split(f, '#')
|
||||
var f_prefix = f_items[0]
|
||||
var f_suffix = f_items[-1] # last token
|
||||
var f_archive = size(f_items) > 1 # is the file in an archive
|
||||
|
||||
# if no dot, add the default '.be' extension
|
||||
if string.find(f_suffix, '.') < 0 # does the final file has a '.'
|
||||
f += ".be"
|
||||
f_suffix += ".be"
|
||||
end
|
||||
# Ex: f = '/app.zip#autoexec.be'
|
||||
|
||||
# if the filename has no '.' append '.be'
|
||||
var suffix_be = f_suffix[-3..-1] == '.be'
|
||||
var suffix_bec = f_suffix[-4..-1] == '.bec'
|
||||
# Ex: f = '/app.zip#autoexec.be', f_suffix = 'autoexec.be', suffix_be = true, suffix_bec = false
|
||||
|
||||
# check that the file ends with '.be' of '.bec'
|
||||
if !suffix_be && !suffix_bec
|
||||
raise "io_error", "file extension is not '.be' or '.bec'"
|
||||
end
|
||||
|
||||
var f_time = path.last_modified(f_prefix)
|
||||
|
||||
if suffix_bec
|
||||
if f_time == nil return false end # file does not exist
|
||||
# f is the right file, continue
|
||||
else
|
||||
var f_time_bc = path.last_modified(f + "c") # timestamp for bytecode
|
||||
if f_time == nil && f_time_bc == nil return false end
|
||||
if f_time_bc != nil && (f_time == nil || f_time_bc >= f_time)
|
||||
# bytecode exists and is more recent than berry source, use bytecode
|
||||
##### temporarily disable loading from bec file
|
||||
# f = f + "c" # use bytecode name
|
||||
suffix_bec = true
|
||||
end
|
||||
end
|
||||
|
||||
# recall the working directory
|
||||
if f_archive
|
||||
self.wd = f_prefix + "#"
|
||||
push_path(self.wd)
|
||||
else
|
||||
self.wd = ""
|
||||
end
|
||||
|
||||
var c = compile(f, 'file')
|
||||
# save the compiled bytecode
|
||||
if !suffix_bec && !f_archive
|
||||
try
|
||||
self.save(f + 'c', c)
|
||||
except .. as e
|
||||
print(string.format('BRY: could not save compiled file %s (%s)',f+'c',e))
|
||||
end
|
||||
end
|
||||
# call the compiled code
|
||||
c()
|
||||
# call successfuls
|
||||
|
||||
# remove path prefix
|
||||
if f_archive
|
||||
pop_path(f_prefix + "#")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
def event(event_type, cmd, idx, payload, raw)
|
||||
import introspect
|
||||
import string
|
||||
if event_type=='every_50ms' self.run_deferred() end #- first run deferred events -#
|
||||
|
||||
var done = false
|
||||
if event_type=='cmd' return self.exec_cmd(cmd, idx, payload)
|
||||
elif event_type=='tele' return self.exec_tele(payload)
|
||||
elif event_type=='rule' return self.exec_rules(payload)
|
||||
elif event_type=='gc' return self.gc()
|
||||
elif self._drivers
|
||||
var i = 0
|
||||
while i < size(self._drivers)
|
||||
#for d:self._drivers
|
||||
var d = self._drivers[i]
|
||||
var f = introspect.get(d, event_type) # try to match a function or method with the same name
|
||||
if type(f) == 'function'
|
||||
try
|
||||
done = f(d, cmd, idx, payload, raw)
|
||||
if done break end
|
||||
except .. as e,m
|
||||
print(string.format("BRY: Exception> '%s' - %s", e, m))
|
||||
if self._debug_present
|
||||
import debug
|
||||
debug.traceback()
|
||||
end
|
||||
end
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
|
||||
# save persist
|
||||
if event_type=='save_before_restart'
|
||||
import persist
|
||||
persist.save()
|
||||
end
|
||||
|
||||
return done
|
||||
end
|
||||
|
||||
def add_driver(d)
|
||||
if self._drivers
|
||||
self._drivers.push(d)
|
||||
else
|
||||
self._drivers = [d]
|
||||
end
|
||||
end
|
||||
|
||||
def remove_driver(d)
|
||||
if self._drivers
|
||||
var idx = self._drivers.find(d)
|
||||
if idx != nil
|
||||
self._drivers.pop(idx)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# cmd high-level function
|
||||
def cmd(command)
|
||||
self.cmd_res = true # signal buffer capture
|
||||
|
||||
self._cmd(command)
|
||||
|
||||
var ret = nil
|
||||
if self.cmd_res != true # unchanged
|
||||
ret = self.cmd_res
|
||||
end
|
||||
self.cmd_res = nil # clear buffer
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
# set_light and get_light deprecetaion
|
||||
def get_light(l)
|
||||
print('tasmota.get_light() is deprecated, use light.get()')
|
||||
import light
|
||||
if l != nil
|
||||
return light.get(l)
|
||||
else
|
||||
return light.get()
|
||||
end
|
||||
end
|
||||
def set_light(v,l)
|
||||
print('tasmota.set_light() is deprecated, use light.set()')
|
||||
import light
|
||||
if l != nil
|
||||
return light.set(v,l)
|
||||
else
|
||||
return light.set(v)
|
||||
end
|
||||
end
|
||||
|
||||
#- generate a new C callback and record the associated Berry closure -#
|
||||
def gen_cb(f)
|
||||
# DEPRECATED
|
||||
import cb
|
||||
return cb.gen_cb(f)
|
||||
end
|
||||
|
||||
#- convert hue/sat to rgb -#
|
||||
#- hue:int in range 0..359 -#
|
||||
#- sat:int (optional) in range 0..255 -#
|
||||
#- returns int: 0xRRGGBB -#
|
||||
def hs2rgb(hue,sat)
|
||||
if sat == nil sat = 255 end
|
||||
var r = 255 # default to white
|
||||
var b = 255
|
||||
var g = 255
|
||||
# we take brightness at 100%, brightness should be set separately
|
||||
hue = hue % 360 # normalize to 0..359
|
||||
|
||||
if sat > 0
|
||||
var i = hue / 60 # quadrant 0..5
|
||||
var f = hue % 60 # 0..59
|
||||
var p = 255 - sat
|
||||
var q = tasmota.scale_uint(f, 0, 60, 255, p) # 0..59
|
||||
var t = tasmota.scale_uint(f, 0, 60, p, 255)
|
||||
|
||||
if i == 0
|
||||
# r = 255
|
||||
g = t
|
||||
b = p
|
||||
elif i == 1
|
||||
r = q
|
||||
# g = 255
|
||||
b = p
|
||||
elif i == 2
|
||||
r = p
|
||||
#g = 255
|
||||
b = t
|
||||
elif i == 3
|
||||
r = p
|
||||
g = q
|
||||
#b = 255
|
||||
elif i == 4
|
||||
r = t
|
||||
g = p
|
||||
#b = 255
|
||||
else
|
||||
#r = 255
|
||||
g = p
|
||||
b = q
|
||||
end
|
||||
end
|
||||
|
||||
return (r << 16) | (g << 8) | b
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
#- Native code used for testing and code solidification -#
|
||||
#- Do not use it -#
|
||||
|
||||
class Wire
|
||||
var bus
|
||||
|
||||
def read_bytes(addr,reg,size)
|
||||
self._begin_transmission(addr)
|
||||
self._write(reg)
|
||||
self._end_transmission(false)
|
||||
self._request_from(addr,size)
|
||||
var ret=bytes(size)
|
||||
while (self._available())
|
||||
ret..self._read()
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def write_bytes(addr,reg,b)
|
||||
self._begin_transmission(addr)
|
||||
self._write(reg)
|
||||
self._write(b)
|
||||
self._end_transmission()
|
||||
end
|
||||
end
|
|
@ -0,0 +1,389 @@
|
|||
#- autocong module for Berry -#
|
||||
#- -#
|
||||
#- To solidify: -#
|
||||
#-
|
||||
# load only persis_module and persist_module.init
|
||||
import autoconf
|
||||
solidify.dump(autoconf_module)
|
||||
# copy and paste into `be_autoconf_lib.c`
|
||||
-#
|
||||
#-
|
||||
|
||||
# For external compile:
|
||||
|
||||
display = module("display")
|
||||
self = nil
|
||||
tasmota = nil
|
||||
def load() end
|
||||
|
||||
-#
|
||||
|
||||
var autoconf_module = module("autoconf")
|
||||
|
||||
autoconf_module.init = def (m)
|
||||
|
||||
class Autoconf
|
||||
var _archive
|
||||
var _error
|
||||
|
||||
def init()
|
||||
import path
|
||||
import string
|
||||
|
||||
var dir = path.listdir("/")
|
||||
var entry
|
||||
tasmota.add_driver(self)
|
||||
|
||||
var i = 0
|
||||
while i < size(dir)
|
||||
if string.find(dir[i], ".autoconf") > 0 # does the file contain '*.autoconf', >0 to skip `.autoconf`
|
||||
if entry != nil
|
||||
# we have multiple configuration files, not allowed
|
||||
print(string.format("CFG: multiple autoconf files found, aborting ('%s' + '%s')", entry, dir[i]))
|
||||
self._error = true
|
||||
return nil
|
||||
end
|
||||
entry = dir[i]
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
||||
if entry == nil
|
||||
tasmota.log("CFG: no '*.autoconf' file found", 2)
|
||||
return nil
|
||||
end
|
||||
|
||||
self._archive = entry
|
||||
end
|
||||
|
||||
|
||||
# ####################################################################################################
|
||||
# Manage first time marker
|
||||
# ####################################################################################################
|
||||
def is_first_time()
|
||||
import path
|
||||
return !path.exists("/.autoconf")
|
||||
end
|
||||
def set_first_time()
|
||||
var f = open("/.autoconf", "w")
|
||||
f.close()
|
||||
end
|
||||
def clear_first_time()
|
||||
import path
|
||||
path.remove("/.autoconf")
|
||||
end
|
||||
|
||||
# ####################################################################################################
|
||||
# Delete all autoconfig files present
|
||||
# ####################################################################################################
|
||||
def delete_all_configs()
|
||||
import path
|
||||
import string
|
||||
var dir = path.listdir("/")
|
||||
|
||||
for d:dir
|
||||
if string.find(d, ".autoconf") > 0 # does the file contain '*.autoconf'
|
||||
path.remove(d)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# ####################################################################################################
|
||||
# Get current module
|
||||
# contains the name of the archive without leading `/`, ex: `M5Stack_Fire.autoconf`
|
||||
# or `nil` if none
|
||||
# ####################################################################################################
|
||||
def get_current_module_path()
|
||||
return self._archive
|
||||
end
|
||||
def get_current_module_name()
|
||||
return self._archive[0..-10]
|
||||
end
|
||||
|
||||
# ####################################################################################################
|
||||
# Load templates from Github
|
||||
# ####################################################################################################
|
||||
def load_templates()
|
||||
import string
|
||||
import json
|
||||
try
|
||||
var url = string.format("https://raw.githubusercontent.com/tasmota/autoconf/main/%s_manifest.json", tasmota.arch())
|
||||
tasmota.log(string.format("CFG: loading '%s'", url), 3)
|
||||
# load the template
|
||||
var cl = webclient()
|
||||
cl.begin(url)
|
||||
var r = cl.GET()
|
||||
if r != 200
|
||||
tasmota.log(string.format("CFG: return_code=%i", r), 2)
|
||||
return nil
|
||||
end
|
||||
var s = cl.get_string()
|
||||
cl.close()
|
||||
# convert to json
|
||||
var j = json.load(s)
|
||||
tasmota.log(string.format("CFG: loaded '%s'", str(j)), 3)
|
||||
|
||||
var t = j.find("files")
|
||||
if isinstance(t, list)
|
||||
return t
|
||||
end
|
||||
|
||||
return nil
|
||||
except .. as e, m
|
||||
tasmota.log(string.format("CFG: exception '%s' - '%s'", e, m), 2)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
# ####################################################################################################
|
||||
# Init web handlers
|
||||
# ####################################################################################################
|
||||
# Displays a "Autocong" button on the configuration page
|
||||
def web_add_config_button()
|
||||
import webserver
|
||||
webserver.content_send("<p><form id=ac action='ac' style='display: block;' method='get'><button>🪄 Auto-configuration</button></form></p>")
|
||||
end
|
||||
|
||||
|
||||
# This HTTP GET manager controls which web controls are displayed
|
||||
def page_autoconf_mgr()
|
||||
import webserver
|
||||
import string
|
||||
if !webserver.check_privileged_access() return nil end
|
||||
|
||||
webserver.content_start('Auto-configuration')
|
||||
webserver.content_send_style()
|
||||
webserver.content_send("<p><small> (This feature requires an internet connection)</small></p>")
|
||||
|
||||
var cur_module = self.get_current_module_path()
|
||||
var cur_module_display = cur_module ? string.tr(self.get_current_module_name(), "_", " ") : self._error ? "<Error: apply new or remove>" : "<None>"
|
||||
|
||||
webserver.content_send("<fieldset><style>.bdis{background:#888;}.bdis:hover{background:#888;}</style>")
|
||||
webserver.content_send(string.format("<legend><b title='Autoconfiguration'> Current auto-configuration</b></legend>"))
|
||||
webserver.content_send(string.format("<p>Current configuration: </p><p><b>%s</b></p>", cur_module_display))
|
||||
|
||||
if cur_module
|
||||
# add button to reapply template
|
||||
webserver.content_send("<p><form id=reapply style='display: block;' action='/ac' method='post' ")
|
||||
webserver.content_send("onsubmit='return confirm(\"This will cause a restart.\");'>")
|
||||
webserver.content_send("<button name='reapply' class='button bgrn'>Re-apply current configuration</button>")
|
||||
webserver.content_send("</form></p>")
|
||||
end
|
||||
webserver.content_send("<p></p></fieldset><p></p>")
|
||||
|
||||
webserver.content_send("<fieldset><style>.bdis{background:#888;}.bdis:hover{background:#888;}</style>")
|
||||
webserver.content_send(string.format("<legend><b title='New autoconf'> Select new auto-configuration</b></legend>"))
|
||||
|
||||
webserver.content_send("<p><form id=zip style='display: block;' action='/ac' method='post' ")
|
||||
webserver.content_send("onsubmit='return confirm(\"This will change the current configuration and cause a restart.\");'>")
|
||||
webserver.content_send("<label>Choose a device configuration:</label><br>")
|
||||
webserver.content_send("<select name='zip'>")
|
||||
|
||||
var templates = self.load_templates()
|
||||
webserver.content_send("<option value='reset'><Remove autoconf></option>")
|
||||
for t:templates
|
||||
webserver.content_send(string.format("<option value='%s'>%s</option>", t, string.tr(t, "_", " ")))
|
||||
end
|
||||
|
||||
webserver.content_send("</select><p></p>")
|
||||
|
||||
webserver.content_send("<button name='zipapply' class='button bgrn'>Apply configuration</button>")
|
||||
# webserver.content_send(string.format("<input name='ota' type='hidden' value='%d'>", ota_num))
|
||||
webserver.content_send("</form></p>")
|
||||
|
||||
|
||||
webserver.content_send("<p></p></fieldset><p></p>")
|
||||
webserver.content_button(webserver.BUTTON_CONFIGURATION)
|
||||
webserver.content_stop()
|
||||
end
|
||||
|
||||
# ####################################################################################################
|
||||
# Web controller
|
||||
#
|
||||
# Applies the changes and restart
|
||||
# ####################################################################################################
|
||||
# This HTTP POST manager handles the submitted web form data
|
||||
def page_autoconf_ctl()
|
||||
import webserver
|
||||
import string
|
||||
import path
|
||||
if !webserver.check_privileged_access() return nil end
|
||||
|
||||
try
|
||||
if webserver.has_arg("reapply")
|
||||
tasmota.log("CFG: removing first time marker", 2);
|
||||
# print("CFG: removing first time marker")
|
||||
self.clear_first_time()
|
||||
#- and force restart -#
|
||||
webserver.redirect("/?rst=")
|
||||
|
||||
elif webserver.has_arg("zip")
|
||||
# remove any remaining autoconf file
|
||||
tasmota.log("CFG: removing autoconf files", 2);
|
||||
# print("CFG: removing autoconf files")
|
||||
self.delete_all_configs()
|
||||
|
||||
# get the name of the configuration file
|
||||
var arch_name = webserver.arg("zip")
|
||||
|
||||
if arch_name != "reset"
|
||||
var url = string.format("https://raw.githubusercontent.com/tasmota/autoconf/main/%s/%s.autoconf", tasmota.arch(), arch_name)
|
||||
tasmota.log(string.format("CFG: downloading '%s'", url), 2);
|
||||
|
||||
var local_file = string.format("%s.autoconf", arch_name)
|
||||
|
||||
# download file and write directly to file system
|
||||
var cl = webclient()
|
||||
cl.begin(url)
|
||||
var r = cl.GET()
|
||||
if r != 200 raise "connection_error", string.format("return code=%i", r) end
|
||||
cl.write_file(local_file)
|
||||
cl.close()
|
||||
end
|
||||
|
||||
# remove marker to reapply template
|
||||
self.clear_first_time()
|
||||
|
||||
#- and force restart -#
|
||||
webserver.redirect("/?rst=")
|
||||
else
|
||||
raise "value_error", "Unknown command"
|
||||
end
|
||||
except .. as e, m
|
||||
print(string.format("CFG: Exception> '%s' - %s", e, m))
|
||||
#- display error page -#
|
||||
webserver.content_start("Parameter error") #- title of the web page -#
|
||||
webserver.content_send_style() #- send standard Tasmota styles -#
|
||||
|
||||
webserver.content_send(string.format("<p style='width:340px;'><b>Exception:</b><br>'%s'<br>%s</p>", e, m))
|
||||
|
||||
webserver.content_button(webserver.BUTTON_CONFIGURATION) #- button back to management page -#
|
||||
webserver.content_stop() #- end of web page -#
|
||||
end
|
||||
end
|
||||
|
||||
# Add HTTP POST and GET handlers
|
||||
def web_add_handler()
|
||||
import webserver
|
||||
webserver.on('/ac', / -> self.page_autoconf_mgr(), webserver.HTTP_GET)
|
||||
webserver.on('/ac', / -> self.page_autoconf_ctl(), webserver.HTTP_POST)
|
||||
end
|
||||
|
||||
|
||||
# reset the configuration information (but don't restart)
|
||||
# i.e. remove any autoconf file
|
||||
def reset()
|
||||
import path
|
||||
import string
|
||||
|
||||
var dir = path.listdir("/")
|
||||
var entry
|
||||
|
||||
var i = 0
|
||||
while i < size(dir)
|
||||
var fname = dir[i]
|
||||
if string.find(fname, ".autoconf") > 0 # does the file contain '*.autoconf'
|
||||
path.remove(fname)
|
||||
print(string.format("CFG: removed file '%s'", fname))
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
||||
self._archive = nil
|
||||
self._error = nil
|
||||
end
|
||||
|
||||
# called by the synthetic event `preinit`
|
||||
def preinit()
|
||||
if self._archive == nil return end
|
||||
# try to launch `preinit.be`
|
||||
import path
|
||||
|
||||
var fname = self._archive + '#preinit.be'
|
||||
if path.exists(fname)
|
||||
tasmota.log("CFG: loading "+fname, 3)
|
||||
load(fname)
|
||||
tasmota.log("CFG: loaded "+fname, 3)
|
||||
end
|
||||
end
|
||||
|
||||
def run_bat(fname) # read a '*.bat' file and run each command
|
||||
import string
|
||||
var f
|
||||
try
|
||||
f = open(fname, "r") # open file in read-only mode, it is expected to exist
|
||||
while true
|
||||
var line = f.readline() # read each line, can contain a terminal '\n', empty if end of file
|
||||
if size(line) == 0 break end # end of file
|
||||
|
||||
if line[-1] == "\n" line = line[0..-2] end # remove any trailing '\n'
|
||||
if size(line) > 0
|
||||
tasmota.cmd(line) # run the command
|
||||
end
|
||||
end
|
||||
f.close() # close, we don't expect exception with read-only, could be added later though
|
||||
except .. as e, m
|
||||
print(string.format('CFG: could not run %s (%s - %s)', fname, e, m))
|
||||
f.close()
|
||||
end
|
||||
end
|
||||
|
||||
# called by the synthetic event `autoexec`
|
||||
def autoexec()
|
||||
if self._archive == nil return end
|
||||
# try to launch `preinit.be`
|
||||
import path
|
||||
|
||||
# Step 1. if first run, only apply `init.bat`
|
||||
var fname = self._archive + '#init.bat'
|
||||
if self.is_first_time() && path.exists(fname)
|
||||
# create the '.autoconf' file to avoid running it again, even if it crashed
|
||||
self.set_first_time()
|
||||
|
||||
# if path.exists(fname) # we know it exists from initial test
|
||||
self.run_bat(fname)
|
||||
tasmota.log("CFG: 'init.bat' done, restarting", 2)
|
||||
tasmota.cmd("Restart 1")
|
||||
return # if init was run, force a restart anyways and don't run the remaining code
|
||||
# end
|
||||
end
|
||||
|
||||
# Step 2. if 'display.ini' is present, launch Universal Display
|
||||
fname = self._archive + '#display.ini'
|
||||
if gpio.pin_used(gpio.OPTION_A, 2) && path.exists(fname)
|
||||
if path.exists("display.ini")
|
||||
tasmota.log("CFG: skipping 'display.ini' because already present in file-system", 2)
|
||||
else
|
||||
import display
|
||||
var f = open(fname,"r")
|
||||
var desc = f.read()
|
||||
f.close()
|
||||
display.start(desc)
|
||||
end
|
||||
end
|
||||
|
||||
# Step 3. if 'autoexec.bat' is present, run it
|
||||
fname = self._archive + '#autoexec.bat'
|
||||
if path.exists(fname)
|
||||
tasmota.log("CFG: running "+fname, 3)
|
||||
self.run_bat(fname)
|
||||
tasmota.log("CFG: ran "+fname, 3)
|
||||
end
|
||||
|
||||
# Step 4. if 'autoexec.be' is present, load it
|
||||
fname = self._archive + '#autoexec.be'
|
||||
if path.exists(fname)
|
||||
tasmota.log("CFG: loading "+fname, 3)
|
||||
load(fname)
|
||||
tasmota.log("CFG: loaded "+fname, 3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Autoconf() # return an instance of this class
|
||||
end
|
||||
|
||||
aa = autoconf_module.init(autoconf_module)
|
||||
import webserver
|
||||
webserver.on('/ac2', / -> aa.page_autoconf_mgr(), webserver.HTTP_GET)
|
||||
return autoconf_module
|
|
@ -0,0 +1,176 @@
|
|||
#-------------------------------------------------------------
|
||||
- Generic driver for AXP192 - solidified
|
||||
-------------------------------------------------------------#
|
||||
class AXP192 : I2C_Driver
|
||||
def init()
|
||||
super(self, I2C_Driver).init("AXP192", 0x34)
|
||||
end
|
||||
|
||||
# Return True = Battery Exist
|
||||
def battery_present()
|
||||
if self.wire.read(self.addr, 0x01, 1) & 0x20 return true
|
||||
else return false
|
||||
end
|
||||
end
|
||||
|
||||
# Input Power Status ???
|
||||
def get_input_power_status()
|
||||
return self.wire.read(self.addr, 0x00, 1)
|
||||
end
|
||||
|
||||
# Battery Charging Status
|
||||
def get_battery_chargin_status()
|
||||
return self.wire.read(self.addr, 0x01, 1)
|
||||
end
|
||||
|
||||
# AXP chip temperature in °C
|
||||
def get_temp()
|
||||
return self.read12(0x5E) * 0.1 - 144.7
|
||||
end
|
||||
|
||||
def get_bat_power()
|
||||
return self.read24(0x70) * 0.00055
|
||||
end
|
||||
|
||||
def get_bat_voltage()
|
||||
return self.read12(0x78) * 0.0011
|
||||
end
|
||||
def get_bat_current()
|
||||
return (self.read13(0x7A) - self.read13(0x7C)) * 0.5
|
||||
end
|
||||
def get_bat_charge_current()
|
||||
return self.read13(0x7A) * 0.5
|
||||
end
|
||||
def get_aps_voltage()
|
||||
return self.read12(0x7E) * 0.0014
|
||||
end
|
||||
def get_vbus_voltage()
|
||||
return self.read12(0x5A) * 0.0017
|
||||
end
|
||||
def get_vbus_current()
|
||||
return self.read12(0x5C) * 0.375
|
||||
end
|
||||
|
||||
# set LDO voltage
|
||||
# ldo: 2/3
|
||||
# voltage: (mV) 1800mV - 3300mV in 100mV steps
|
||||
def set_ldo_voltage(ldo, voltage)
|
||||
if voltage > 3300 voltage = 15
|
||||
else voltage = (voltage / 100) - 18
|
||||
end
|
||||
|
||||
if ldo == 2
|
||||
self.write8(0x28, self.read8(0x28) & 0x0F | ((voltage & 0x0F) << 4))
|
||||
end
|
||||
if ldo == 3
|
||||
self.write8(0x28, self.read8(0x28) & 0xF0 | (voltage & 0x0F))
|
||||
end
|
||||
end
|
||||
|
||||
# set DCDC enable, 1/2/3
|
||||
def set_dcdc_enable(dcdc, state)
|
||||
if dcdc == 1 self.write_bit(0x12, 0, state) end
|
||||
if dcdc == 2 self.write_bit(0x12, 4, state) end
|
||||
if dcdc == 3 self.write_bit(0x12, 1, state) end
|
||||
end
|
||||
|
||||
# set LDO enable, 2/3 (LDO 1 is always on)
|
||||
def set_ldo_enable(ldo, state)
|
||||
if ldo == 2 self.write_bit(0x12, 2, state) end
|
||||
if ldo == 3 self.write_bit(0x12, 3, state) end
|
||||
end
|
||||
|
||||
# set GPIO output state 0/1/2 and 3/4
|
||||
def write_gpio(gpio, state)
|
||||
if gpio >= 0 && gpio <= 2
|
||||
self.write_bit(0x94, gpio, state)
|
||||
elif gpio >= 3 && gpio <= 4
|
||||
self.write_bit(0x96, gpio - 3, state)
|
||||
end
|
||||
end
|
||||
|
||||
# Set voltage on DC-DC1/2/3
|
||||
# dcdc: 1/2/3 (warning some C libs start at 0)
|
||||
# voltage:
|
||||
def set_dc_voltage(dcdc, voltage)
|
||||
if dcdc < 1 || dcdc > 3 return end
|
||||
var v
|
||||
if voltage < 700 v = 0
|
||||
elif voltage > 3500 v = 112
|
||||
elif dcdc == 2 && voltage > 2275 v = 63 # dcdc2 is limited to 2.275V
|
||||
else v = (voltage - 700) / 25
|
||||
end
|
||||
|
||||
var addr = 0x26
|
||||
if dcdc == 3 addr = 0x27
|
||||
elif dcdc == 2 addr = 0x23
|
||||
end
|
||||
|
||||
self.write8(addr, self.read8(addr) & 0x80 | (v & 0x7F))
|
||||
end
|
||||
|
||||
# Set charging current
|
||||
# 100mA = 0
|
||||
# 190mA = 1
|
||||
# 280mA = 2
|
||||
# 360mA = 3
|
||||
# 450mA = 4
|
||||
# 550mA = 5
|
||||
# 630mA = 6
|
||||
# 700mA = 7
|
||||
# 780mA = 8
|
||||
# 880mA = 9
|
||||
# 960mA = 10
|
||||
# 1000mA = 11
|
||||
# 1080mA = 12
|
||||
# 1160mA = 13
|
||||
# 1240mA = 14
|
||||
# 1320mA = 15
|
||||
def set_chg_current(current_code)
|
||||
self.write8(0x33, self.read8(0x33) & 0xF0 | (current_code & 0x0F))
|
||||
end
|
||||
|
||||
# // Low Volt Level 1, when APS Volt Output < 3.4496 V
|
||||
# // Low Volt Level 2, when APS Volt Output < 3.3992 V, then this flag is SET (0x01)
|
||||
# // Flag will reset once battery volt is charged above Low Volt Level 1
|
||||
# // Note: now AXP192 have the Shutdown Voltage of 3.0V (B100) Def in REG 31H
|
||||
def get_warning_level()
|
||||
return self.read12(0x47) & 1
|
||||
end
|
||||
|
||||
#- trigger a read every second -#
|
||||
# def every_second()
|
||||
# if !self.wire return nil end #- exit if not initialized -#
|
||||
# end
|
||||
|
||||
#- display sensor value in the web UI -#
|
||||
def web_sensor()
|
||||
if !self.wire return nil end #- exit if not initialized -#
|
||||
import string
|
||||
var msg = string.format(
|
||||
"{s}VBus Voltage{m}%.3f V{e}"..
|
||||
"{s}VBus Current{m}%.1f mA{e}"..
|
||||
"{s}Batt Voltage{m}%.3f V{e}"..
|
||||
"{s}Batt Current{m}%.1f mA{e}"..
|
||||
#"{s}Batt Power{m}%.3f{e}"..
|
||||
"{s}Temp AXP{m}%.1f °C{e}",
|
||||
self.get_vbus_voltage(), self.get_vbus_voltage(),
|
||||
self.get_bat_voltage(), self.get_bat_current(),
|
||||
#self.get_bat_power(),
|
||||
self.get_temp()
|
||||
)
|
||||
tasmota.web_send_decimal(msg)
|
||||
end
|
||||
|
||||
#- add sensor value to teleperiod -#
|
||||
def json_append()
|
||||
if !self.wire return nil end #- exit if not initialized -#
|
||||
# import string
|
||||
# var ax = int(self.accel[0] * 1000)
|
||||
# var ay = int(self.accel[1] * 1000)
|
||||
# var az = int(self.accel[2] * 1000)
|
||||
# var msg = string.format(",\"MPU6886\":{\"AX\":%i,\"AY\":%i,\"AZ\":%i,\"GX\":%i,\"GY\":%i,\"GZ\":%i}",
|
||||
# ax, ay, az, self.gyro[0], self.gyro[1], self.gyro[2])
|
||||
# tasmota.response_append(msg)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,104 @@
|
|||
#-------------------------------------------------------------
|
||||
- IMPORTANT
|
||||
- THIS CLASS IS ALREADY BAKED IN TASMOTA
|
||||
-
|
||||
- It is here for debugging and documentation purpose only
|
||||
-------------------------------------------------------------#
|
||||
|
||||
#-------------------------------------------------------------
|
||||
- I2C_Driver class to simplify development of I2C drivers
|
||||
-
|
||||
- I2C_Driver(name, addr [, i2c_index]) -> nil
|
||||
- name: name of I2C device for logging, or function to detect the model
|
||||
- addr: I2C address of device, will probe all I2C buses for it
|
||||
- i2c_index: (optional) check is the device is not disabled
|
||||
-------------------------------------------------------------#
|
||||
|
||||
class I2C_Driver
|
||||
var wire #- wire object to reach the device, if nil then the module is not initialized -#
|
||||
var addr #- I2C address of the device -#
|
||||
var name #- model namme of the device, cannot be nil -#
|
||||
|
||||
#- Init and look for device
|
||||
- Input:
|
||||
- name_or_detect : name of the device (if string)
|
||||
or function to detect the precise model(if function)
|
||||
the function is passed a single argument `self`
|
||||
and must return a string, or `nil` if the device is invalid
|
||||
- addr : I2C address of device (int 0..255)
|
||||
- i2c_index : Tasmota I2C index, see `I2CDEVICES.md` (int)
|
||||
--#
|
||||
def init(name_or_detect, addr, i2c_index)
|
||||
var tasmota = self.get_tasmota() #- retrieve the 'tasmota' singleton -#
|
||||
|
||||
#- check if the i2c index is disabled by Tasmota configuration -#
|
||||
if i2c_index != nil && !tasmota.i2c_enabled(i2c_index) return end
|
||||
|
||||
self.addr = addr #- address for AXP192 -#
|
||||
self.wire = tasmota.wire_scan(self.addr) #- get the right I2C bus -#
|
||||
|
||||
if self.wire
|
||||
#- find name of device, can be a string or a method -#
|
||||
if type(name_or_detect) == 'function'
|
||||
self.name = name_or_detect(self)
|
||||
else
|
||||
self.name = name_or_detect
|
||||
end
|
||||
#- if name is invalid, it means we can't detect device, abort -#
|
||||
if self.name == nil self.wire = nil end
|
||||
|
||||
if self.wire
|
||||
print("I2C:", self.name, "detected on bus", self.wire.bus)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#- write register with 8 bits value -#
|
||||
def write8(reg, val)
|
||||
return self.wire.write(self.addr, reg, val, 1)
|
||||
end
|
||||
|
||||
# Set or clear a specific bit in a register
|
||||
# write_bit(reg:int, bit:int, state:bool) -> nil
|
||||
# reg: I2C register number (0..255)
|
||||
# bit: bit of I2C register to change (0..7)
|
||||
# state: boolean value to write to specified bit
|
||||
def write_bit(reg, bit, state)
|
||||
if bit < 0 || bit > 7 return end
|
||||
var mark = 1 << bit
|
||||
if state self.write8(reg, self.read8(reg) | mark)
|
||||
else self.write8(reg, self.read8(reg) & (0xFF - mark))
|
||||
end
|
||||
end
|
||||
|
||||
# read 8 bits
|
||||
def read8(reg)
|
||||
return self.wire.read(self.addr, reg, 1)
|
||||
end
|
||||
# read 12 bits
|
||||
def read12(reg)
|
||||
var buf = self.wire.read_bytes(self.addr, reg, 2)
|
||||
return (buf[0] << 4) + buf[1]
|
||||
end
|
||||
# read 13 bits
|
||||
def read13(reg)
|
||||
var buf = self.wire.read_bytes(self.addr, reg, 2)
|
||||
return (buf[0] << 5) + buf[1]
|
||||
end
|
||||
# read 24 bits
|
||||
def read24(reg)
|
||||
var buf = self.wire.read_bytes(self.addr, reg, 3)
|
||||
return (buf[0] << 16) + (buf[1] << 8) + buf[2]
|
||||
end
|
||||
# read 32 bits
|
||||
def read32(reg)
|
||||
var buf = self.wire.read_bytes(self.addr, reg, 4)
|
||||
return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]
|
||||
end
|
||||
end
|
||||
|
||||
#- Example
|
||||
|
||||
d = I2C_Driver("MPU", 0x68, 58)
|
||||
|
||||
-#
|
|
@ -0,0 +1,338 @@
|
|||
# class Leds
|
||||
#
|
||||
# for adressable leds like NoePixel
|
||||
|
||||
|
||||
# Native commands
|
||||
# 00 : ctor (leds:int, gpio:int) -> void
|
||||
# 01 : begin void -> void
|
||||
# 02 : show void -> void
|
||||
# 03 : CanShow void -> bool
|
||||
# 04 : IsDirty void -> bool
|
||||
# 05 : Dirty void -> void
|
||||
# 06 : Pixels void -> bytes() (mapped to the buffer)
|
||||
# 07 : PixelSize void -> int
|
||||
# 08 : PixelCount void -> int
|
||||
# 09 : ClearTo (color:??) -> void
|
||||
# 10 : SetPixelColor (idx:int, color:??) -> void
|
||||
# 11 : GetPixelColor (idx:int) -> color:??
|
||||
# 20 : RotateLeft (rot:int [, first:int, last:int]) -> void
|
||||
# 21 : RotateRight (rot:int [, first:int, last:int]) -> void
|
||||
# 22 : ShiftLeft (rot:int [, first:int, last:int]) -> void
|
||||
# 23 : ShiftRight (rot:int [, first:int, last:int]) -> void
|
||||
|
||||
|
||||
class Leds : Leds_ntv
|
||||
var gamma # if true, apply gamma (true is default)
|
||||
var leds # number of leds
|
||||
# leds:int = number of leds of the strip
|
||||
# gpio:int (optional) = GPIO for NeoPixel. If not specified, takes the WS2812 gpio
|
||||
# type:int (optional) = Type of LED, defaults to WS2812 RGB
|
||||
# rmt:int (optional) = RMT hardware channel to use, leave default unless you have a good reason
|
||||
def init(leds, gpio, type, rmt) # rmt is optional
|
||||
self.gamma = true # gamma is enabled by default, it should be disabled explicitly if needed
|
||||
self.leds = int(leds)
|
||||
|
||||
if gpio == nil && gpio.pin(gpio.WS2812) >= 0
|
||||
gpio = gpio.pin(gpio.WS2812)
|
||||
end
|
||||
|
||||
# if no GPIO, abort
|
||||
if gpio == nil
|
||||
raise "valuer_error", "no GPIO specified for neopixelbus"
|
||||
end
|
||||
|
||||
# initialize the structure
|
||||
self.ctor(self.leds, gpio, type, rmt)
|
||||
|
||||
if self._p == nil raise "internal_error", "couldn't not initialize noepixelbus" end
|
||||
|
||||
# call begin
|
||||
self.begin()
|
||||
|
||||
end
|
||||
|
||||
def clear()
|
||||
self.clear_to(0x000000)
|
||||
self.show()
|
||||
end
|
||||
|
||||
def ctor(leds, gpio, rmt)
|
||||
if rmt == nil
|
||||
self.call_native(0, leds, gpio)
|
||||
else
|
||||
self.call_native(0, leds, gpio, rmt)
|
||||
end
|
||||
end
|
||||
def begin()
|
||||
self.call_native(1)
|
||||
end
|
||||
def show()
|
||||
self.call_native(2)
|
||||
end
|
||||
def can_show()
|
||||
return self.call_native(3)
|
||||
end
|
||||
def is_dirty()
|
||||
return self.call_native(4)
|
||||
end
|
||||
def dirty()
|
||||
self.call_native(5)
|
||||
end
|
||||
def pixels_buffer()
|
||||
return self.call_native(6)
|
||||
end
|
||||
def pixel_size()
|
||||
return self.call_native(7)
|
||||
end
|
||||
def pixel_count()
|
||||
return self.call_native(8)
|
||||
end
|
||||
def clear_to(col, bri)
|
||||
self.call_native(9, self.to_gamma(col, bri))
|
||||
end
|
||||
def set_pixel_color(idx, col, bri)
|
||||
self.call_native(10, idx, self.to_gamma(col, bri))
|
||||
end
|
||||
def get_pixel_color(idx)
|
||||
return self.call_native(11, idx)
|
||||
end
|
||||
# def rotate_left(rot, first, last)
|
||||
# self.call_native(20, rot, first, last)
|
||||
# end
|
||||
# def rotate_right(rot, first, last)
|
||||
# self.call_native(21, rot, first, last)
|
||||
# end
|
||||
# def shift_left(rot, first, last)
|
||||
# self.call_native(22, rot, first, last)
|
||||
# end
|
||||
# def shift_right(rot, first, last)
|
||||
# self.call_native(22, rot, first, last)
|
||||
# end
|
||||
|
||||
# apply gamma and bri
|
||||
def to_gamma(rgbw, bri)
|
||||
bri = (bri != nil) ? bri : 100
|
||||
var r = tasmota.scale_uint(bri, 0, 100, 0, (rgbw & 0xFF0000) >> 16)
|
||||
var g = tasmota.scale_uint(bri, 0, 100, 0, (rgbw & 0x00FF00) >> 8)
|
||||
var b = tasmota.scale_uint(bri, 0, 100, 0, (rgbw & 0x0000FF))
|
||||
if self.gamma
|
||||
return light.gamma8(r) << 16 |
|
||||
light.gamma8(g) << 8 |
|
||||
light.gamma8(b)
|
||||
else
|
||||
return r << 16 |
|
||||
g << 8 |
|
||||
b
|
||||
end
|
||||
end
|
||||
|
||||
# `segment`
|
||||
# create a new `strip` object that maps a part of the current strip
|
||||
def create_segment(offset, leds)
|
||||
if int(offset) + int(leds) > self.leds || offset < 0 || leds < 0
|
||||
raise "value_error", "out of range"
|
||||
end
|
||||
|
||||
# inner class
|
||||
class Leds_segment
|
||||
var strip
|
||||
var offset, leds
|
||||
|
||||
def init(strip, offset, leds)
|
||||
self.strip = strip
|
||||
self.offset = int(offset)
|
||||
self.leds = int(leds)
|
||||
end
|
||||
|
||||
def clear()
|
||||
self.clear_to(0x000000)
|
||||
self.show()
|
||||
end
|
||||
|
||||
def begin()
|
||||
# do nothing, already being handled by physical strip
|
||||
end
|
||||
def show(force)
|
||||
# don't trigger on segment, you will need to trigger on full strip instead
|
||||
if bool(force) || (self.offset == 0 && self.leds == self.strip.leds)
|
||||
self.strip.show()
|
||||
end
|
||||
end
|
||||
def can_show()
|
||||
return self.strip.can_show()
|
||||
end
|
||||
def is_dirty()
|
||||
return self.strip.is_dirty()
|
||||
end
|
||||
def dirty()
|
||||
self.strip.dirty()
|
||||
end
|
||||
def pixels_buffer()
|
||||
return nil
|
||||
end
|
||||
def pixel_size()
|
||||
return self.strip.pixel_size()
|
||||
end
|
||||
def pixel_count()
|
||||
return self.leds
|
||||
end
|
||||
def clear_to(col, bri)
|
||||
var i = 0
|
||||
while i < self.leds
|
||||
self.strip.set_pixel_color(i + self.offset, col, bri)
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
def set_pixel_color(idx, col, bri)
|
||||
self.strip.set_pixel_color(idx + self.offset, col, bri)
|
||||
end
|
||||
def get_pixel_color(idx)
|
||||
return self.strip.get_pixel_color(idx + self.offseta)
|
||||
end
|
||||
end
|
||||
|
||||
return Leds_segment(self, offset, leds)
|
||||
|
||||
end
|
||||
|
||||
def create_matrix(w, h, offset)
|
||||
offset = int(offset)
|
||||
w = int(w)
|
||||
h = int(h)
|
||||
if offset == nil offset = 0 end
|
||||
if w * h + offset > self.leds || h < 0 || w < 0 || offset < 0
|
||||
raise "value_error", "out of range"
|
||||
end
|
||||
|
||||
# inner class
|
||||
class Leds_matrix
|
||||
var strip
|
||||
var offset
|
||||
var h, w
|
||||
var alternate # are rows in alternate mode (even/odd are reversed)
|
||||
|
||||
def init(strip, w, h, offset)
|
||||
self.strip = strip
|
||||
self.offset = offset
|
||||
self.h = h
|
||||
self.w = w
|
||||
self.alternate = false
|
||||
end
|
||||
|
||||
def clear()
|
||||
self.clear_to(0x000000)
|
||||
self.show()
|
||||
end
|
||||
|
||||
def begin()
|
||||
# do nothing, already being handled by physical strip
|
||||
end
|
||||
def show(force)
|
||||
# don't trigger on segment, you will need to trigger on full strip instead
|
||||
if bool(force) || (self.offset == 0 && self.w * self.h == self.strip.leds)
|
||||
self.strip.show()
|
||||
end
|
||||
end
|
||||
def can_show()
|
||||
return self.strip.can_show()
|
||||
end
|
||||
def is_dirty()
|
||||
return self.strip.is_dirty()
|
||||
end
|
||||
def dirty()
|
||||
self.strip.dirty()
|
||||
end
|
||||
def pixels_buffer()
|
||||
return nil
|
||||
end
|
||||
def pixel_size()
|
||||
return self.strip.pixel_size()
|
||||
end
|
||||
def pixel_count()
|
||||
return self.w * self.h
|
||||
end
|
||||
def clear_to(col, bri)
|
||||
var i = 0
|
||||
while i < self.w * self.h
|
||||
self.strip.set_pixel_color(i + self.offset, col, bri)
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
def set_pixel_color(idx, col, bri)
|
||||
self.strip.set_pixel_color(idx + self.offset, col, bri)
|
||||
end
|
||||
def get_pixel_color(idx)
|
||||
return self.strip.get_pixel_color(idx + self.offseta)
|
||||
end
|
||||
|
||||
# Leds_matrix specific
|
||||
def set_alternate(alt)
|
||||
self.alternate = alt
|
||||
end
|
||||
def get_alternate()
|
||||
return self.alternate
|
||||
end
|
||||
|
||||
def set_matrix_pixel_color(x, y, col, bri)
|
||||
if self.alternate && x % 2
|
||||
# reversed line
|
||||
self.strip.set_pixel_color(x * self.w + self.h - y - 1 + self.offset, col, bri)
|
||||
else
|
||||
self.strip.set_pixel_color(x * self.w + y + self.offset, col, bri)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Leds_matrix(self, w, h, offset)
|
||||
|
||||
end
|
||||
|
||||
static def matrix(w, h, gpio, rmt)
|
||||
var strip = Leds(w * h, gpio, rmt)
|
||||
var matrix = strip.create_matrix(w, h, 0)
|
||||
return matrix
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#-
|
||||
|
||||
var s = Leds(25, gpio.pin(gpio.WS2812, 1))
|
||||
s.clear_to(0x300000)
|
||||
s.show()
|
||||
i = 0
|
||||
|
||||
def anim()
|
||||
s.clear_to(0x300000)
|
||||
s.set_pixel_color(i, 0x004000)
|
||||
s.show()
|
||||
i = (i + 1) % 25
|
||||
tasmota.set_timer(200, anim)
|
||||
end
|
||||
anim()
|
||||
|
||||
-#
|
||||
|
||||
#-
|
||||
|
||||
var s = Leds_matrix(5, 5, gpio.pin(gpio.WS2812, 1))
|
||||
s.set_alternate(true)
|
||||
s.clear_to(0x300000)
|
||||
s.show()
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
def anim()
|
||||
s.clear_to(0x300000)
|
||||
s.set_matrix_pixel_color(x, y, 0x004000)
|
||||
s.show()
|
||||
y = (y + 1) % 5
|
||||
if y == 0
|
||||
x = (x + 1) % 5
|
||||
end
|
||||
tasmota.set_timer(200, anim)
|
||||
end
|
||||
anim()
|
||||
|
||||
-#
|
|
@ -0,0 +1,70 @@
|
|||
# class Leds_animator
|
||||
|
||||
class Leds_animator
|
||||
var strip # neopixelbus object
|
||||
var pixel_count # number of pixels in the strip
|
||||
var bri # brightness of the animation, 0..100, default 50
|
||||
var running # is the animation running
|
||||
var animators # animators list
|
||||
|
||||
def init(strip)
|
||||
self.strip = strip
|
||||
self.bri = 50 # percentage of brightness 0..100
|
||||
self.running = false
|
||||
self.pixel_count = strip.pixel_count()
|
||||
self.animators = []
|
||||
#
|
||||
self.clear() # clear all leds first
|
||||
#
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
def add_anim(anim)
|
||||
self.animators.push(anim)
|
||||
anim.run() # start the animator
|
||||
end
|
||||
|
||||
def clear()
|
||||
self.stop()
|
||||
self.strip.clear()
|
||||
end
|
||||
def start()
|
||||
self.running = true
|
||||
end
|
||||
def stop()
|
||||
self.running = false
|
||||
end
|
||||
|
||||
def set_bri(bri)
|
||||
self.bri = bri
|
||||
end
|
||||
def get_bri(bri)
|
||||
return self.bri
|
||||
end
|
||||
|
||||
def every_50ms()
|
||||
if self.running
|
||||
# run animators first
|
||||
var i = 0
|
||||
while i < size(self.animators)
|
||||
var anim = self.animators[i]
|
||||
if anim.is_running()
|
||||
anim.animate()
|
||||
i += 1
|
||||
else
|
||||
self.animators.remove(i) # remove any finished animator
|
||||
end
|
||||
end
|
||||
# tirgger animate and display
|
||||
self.animate()
|
||||
end
|
||||
end
|
||||
|
||||
def animate()
|
||||
# placeholder - do nothing by default
|
||||
end
|
||||
|
||||
def remove()
|
||||
tasmota.remove_driver(self)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,54 @@
|
|||
#- LVGL lv_clock_icon
|
||||
-
|
||||
--#
|
||||
|
||||
class lv_clock_icon: lv.label
|
||||
var hour, minute, sec
|
||||
|
||||
def init(parent)
|
||||
super(self).init(parent)
|
||||
var f_s7_16 = lv.seg7_font(16)
|
||||
if f_s7_16 != nil self.set_style_text_font(f_s7_16, lv.PART_MAIN | lv.STATE_DEFAULT) end
|
||||
|
||||
if parent != nil
|
||||
var parent_height = parent.get_height()
|
||||
|
||||
self.set_text("--:--")
|
||||
self.refr_size()
|
||||
var w = self.get_width()
|
||||
self.set_y((parent.get_height() - self.get_height()) / 2) # center vertically
|
||||
|
||||
var pad_right = parent.get_style_pad_right(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
self.set_x(parent.get_width() - w - pad_right - 3)
|
||||
parent.set_style_pad_right(pad_right + w + 6, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
|
||||
self.set_style_bg_color(lv.color(lv.COLOR_BLACK), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
def set_time(hour, minute, sec)
|
||||
import string
|
||||
if hour != self.hour || minute != self.minute || sec != self.sec
|
||||
var txt = string.format("%02d%s%02d", hour, sec % 2 ? ":" : " ", minute)
|
||||
self.hour = hour
|
||||
self.minute = minute
|
||||
self.sec = sec
|
||||
#if txt[0] == '0' txt = '!' .. string.split(txt,1)[1] end # replace first char with '!'
|
||||
self.set_text(txt)
|
||||
end
|
||||
end
|
||||
|
||||
def every_second()
|
||||
var now = tasmota.time_dump(tasmota.rtc()['local'])
|
||||
if now['year'] != 1970
|
||||
self.set_time(now['hour'], now['min'], now['sec'])
|
||||
end
|
||||
end
|
||||
|
||||
def del()
|
||||
super(self).del()
|
||||
tasmota.remove_driver(self)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,133 @@
|
|||
#- LVGL lv_signal_bars and lv_wifi_bars
|
||||
-
|
||||
--#
|
||||
|
||||
class lv_signal_arcs : lv.obj
|
||||
var percentage # value to display, range 0..100
|
||||
var p1, p2, area, line_dsc # instances of objects kept to avoid re-instanciating at each call
|
||||
|
||||
def init(parent)
|
||||
# init custom widget (don't call super constructor)
|
||||
_lvgl.create_custom_widget(self, parent)
|
||||
# own values
|
||||
self.percentage = 100
|
||||
# pre-allocate buffers
|
||||
self.p1 = lv.point()
|
||||
self.p2 = lv.point()
|
||||
self.area = lv.area()
|
||||
self.line_dsc = lv.draw_line_dsc()
|
||||
end
|
||||
|
||||
def widget_event(cl, event)
|
||||
# Call the ancestor's event handler
|
||||
if lv.obj_event_base(cl, event) != lv.RES_OK return end
|
||||
var code = event.code
|
||||
|
||||
import math
|
||||
def atleast1(x) if x >= 1 return x else return 1 end end
|
||||
# the model is that we have 4 bars and inter-bar (1/4 of width)
|
||||
var height = self.get_height()
|
||||
var width = self.get_width()
|
||||
|
||||
var inter_bar = atleast1(height / 8)
|
||||
var bar = atleast1((height - inter_bar * 2) / 3)
|
||||
var bar_offset = bar / 2
|
||||
#print("inter_bar", inter_bar, "bar", bar, "bar_offset", bar_offset)
|
||||
|
||||
if code == lv.EVENT_DRAW_MAIN
|
||||
var clip_area = lv.area(event.param)
|
||||
|
||||
# get coordinates of object
|
||||
self.get_coords(self.area)
|
||||
var x_ofs = self.area.x1
|
||||
var y_ofs = self.area.y1
|
||||
|
||||
lv.draw_line_dsc_init(self.line_dsc) # initialize lv.draw_line_dsc structure
|
||||
self.init_draw_line_dsc(lv.PART_MAIN, self.line_dsc) # copy the current values
|
||||
|
||||
self.line_dsc.round_start = 1
|
||||
self.line_dsc.round_end = 1
|
||||
self.line_dsc.width = (bar * 3 + 1) / 4
|
||||
var on_color = self.get_style_line_color(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
var off_color = self.get_style_bg_color(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
|
||||
# initial calculation, but does not take into account bounding box
|
||||
# var angle = int(math.deg(math.atan2(width / 2, height)))
|
||||
|
||||
# better calculation
|
||||
var hypotenuse = height - bar # center if at bar/2 from bottom and circle stops at bar/2 from top
|
||||
var adjacent = width / 2 - bar_offset # stop at bar_offset from side
|
||||
var angle = int(90 - math.deg(math.acos(real(adjacent) / real(hypotenuse))))
|
||||
if (angle > 45) angle = 45 end
|
||||
|
||||
# print("hypotenuse",hypotenuse,"adjacent",adjacent,"angle",angle)
|
||||
self.p1.x = x_ofs + width / 2
|
||||
self.p1.y = y_ofs + height - 1 - bar_offset
|
||||
|
||||
self.line_dsc.color = self.percentage >= 25 ? on_color : off_color
|
||||
lv.draw_arc(self.p1.x, self.p1.y, 0 * (bar + inter_bar) + bar_offset, 0, 360, clip_area, self.line_dsc)
|
||||
self.line_dsc.color = self.percentage >= 50 ? on_color : off_color
|
||||
lv.draw_arc(self.p1.x, self.p1.y, 1 * (bar + inter_bar) + bar_offset - 1, 270 - angle, 270 + angle, clip_area, self.line_dsc)
|
||||
self.line_dsc.color = self.percentage >= 75 ? on_color : off_color
|
||||
lv.draw_arc(self.p1.x, self.p1.y, 2 * (bar + inter_bar) + bar_offset - 2, 270 - angle, 270 + angle, clip_area, self.line_dsc)
|
||||
|
||||
#elif mode == lv.DESIGN_DRAW_POST # commented since we don't want a frame around this object
|
||||
# self.ancestor_design.call(self, clip_area, mode)
|
||||
end
|
||||
end
|
||||
|
||||
def set_percentage(v)
|
||||
var old_bars = self.percentage / 25
|
||||
if v > 100 v = 100 end
|
||||
if v < 0 v = 0 end
|
||||
self.percentage = v
|
||||
if old_bars != v / 25
|
||||
self.invalidate() # be frugal and avoid updating the widget if it's not needed
|
||||
end
|
||||
end
|
||||
|
||||
def get_percentage()
|
||||
return self.percentage
|
||||
end
|
||||
end
|
||||
|
||||
class lv_wifi_arcs: lv_signal_arcs
|
||||
def init(parent)
|
||||
super(self).init(parent)
|
||||
tasmota.add_driver(self)
|
||||
self.set_percentage(0) # we generally start with 0, meaning not connected
|
||||
end
|
||||
|
||||
def every_second()
|
||||
var wifi = tasmota.wifi()
|
||||
var quality = wifi.find("quality")
|
||||
var ip = wifi.find("ip")
|
||||
if ip == nil
|
||||
self.set_percentage(0)
|
||||
elif quality != nil
|
||||
self.set_percentage(quality)
|
||||
end
|
||||
end
|
||||
|
||||
def del()
|
||||
super(self).del()
|
||||
tasmota.remove_driver(self)
|
||||
end
|
||||
end
|
||||
|
||||
class lv_wifi_arcs_icon: lv_wifi_arcs
|
||||
def init(parent)
|
||||
super(self).init(parent)
|
||||
self.set_style_line_color(lv.color(lv.COLOR_WHITE), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
self.set_style_bg_color(lv.color(lv.COLOR_BLACK), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
if parent != nil
|
||||
var parent_height = parent.get_height()
|
||||
var pad_right = parent.get_style_pad_right(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
self.set_height(parent_height)
|
||||
var w = (parent_height*4)/3
|
||||
self.set_width(w) # 130%
|
||||
self.set_x(parent.get_width() - w - pad_right)
|
||||
parent.set_style_pad_right(pad_right + w + 1, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,118 @@
|
|||
#- LVGL lv_signal_bars and lv_wifi_bars
|
||||
-
|
||||
--#
|
||||
|
||||
class lv_signal_bars : lv.obj
|
||||
var percentage # value to display, range 0..100
|
||||
var p1, p2, area, line_dsc # instances of objects kept to avoid re-instanciating at each call
|
||||
|
||||
def init(parent)
|
||||
# init custom widget (don't call super constructor)
|
||||
_lvgl.create_custom_widget(self, parent)
|
||||
# own values
|
||||
self.percentage = 100
|
||||
# pre-allocate buffers
|
||||
self.p1 = lv.point()
|
||||
self.p2 = lv.point()
|
||||
self.area = lv.area()
|
||||
self.line_dsc = lv.draw_line_dsc()
|
||||
end
|
||||
|
||||
def widget_event(cl, event)
|
||||
# Call the ancestor's event handler
|
||||
if lv.obj_event_base(cl, event) != lv.RES_OK return end
|
||||
var code = event.code
|
||||
|
||||
def atleast1(x) if x >= 1 return x else return 1 end end
|
||||
# the model is that we have 4 bars and inter-bar (1/4 of width)
|
||||
var height = self.get_height()
|
||||
var width = self.get_width()
|
||||
|
||||
var inter_bar = atleast1(width / 15)
|
||||
var bar = atleast1((width - inter_bar * 3) / 4)
|
||||
var bar_offset = bar / 2
|
||||
|
||||
if code == lv.EVENT_DRAW_MAIN
|
||||
var clip_area = lv.area(event.param)
|
||||
|
||||
# get coordinates of object
|
||||
self.get_coords(self.area)
|
||||
var x_ofs = self.area.x1
|
||||
var y_ofs = self.area.y1
|
||||
|
||||
lv.draw_line_dsc_init(self.line_dsc) # initialize lv_draw_line_dsc structure
|
||||
self.init_draw_line_dsc(lv.PART_MAIN, self.line_dsc) # copy the current values
|
||||
|
||||
self.line_dsc.round_start = 1
|
||||
self.line_dsc.round_end = 1
|
||||
self.line_dsc.width = bar
|
||||
var on_color = self.get_style_line_color(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
var off_color = self.get_style_bg_color(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
|
||||
lv.event_send(self, lv.EVENT_DRAW_PART_BEGIN, self.line_dsc)
|
||||
for i:0..3 # 4 bars
|
||||
self.line_dsc.color = self.percentage >= (i+1)*20 ? on_color : off_color
|
||||
self.p1.y = y_ofs + height - 1 - bar_offset
|
||||
self.p1.x = x_ofs + i * (bar + inter_bar) + bar_offset
|
||||
self.p2.y = y_ofs + ((3 - i) * (height - bar)) / 4 + bar_offset
|
||||
self.p2.x = self.p1.x
|
||||
lv.draw_line(self.p1, self.p2, clip_area, self.line_dsc)
|
||||
end
|
||||
lv.event_send(self, lv.EVENT_DRAW_PART_END, self.line_dsc)
|
||||
end
|
||||
end
|
||||
|
||||
def set_percentage(v)
|
||||
var old_bars = self.percentage / 20
|
||||
if v > 100 v = 100 end
|
||||
if v < 0 v = 0 end
|
||||
self.percentage = v
|
||||
if old_bars != v / 20
|
||||
self.invalidate() # be frugal and avoid updating the widget if it's not needed
|
||||
end
|
||||
end
|
||||
|
||||
def get_percentage()
|
||||
return self.percentage
|
||||
end
|
||||
end
|
||||
|
||||
class lv_wifi_bars: lv_signal_bars
|
||||
def init(parent)
|
||||
super(self).init(parent)
|
||||
tasmota.add_driver(self)
|
||||
self.set_percentage(0) # we generally start with 0, meaning not connected
|
||||
end
|
||||
|
||||
def every_second()
|
||||
var wifi = tasmota.wifi()
|
||||
var quality = wifi.find("quality")
|
||||
var ip = wifi.find("ip")
|
||||
if ip == nil
|
||||
self.set_percentage(0)
|
||||
elif quality != nil
|
||||
self.set_percentage(quality)
|
||||
end
|
||||
end
|
||||
|
||||
def del()
|
||||
super(self).del()
|
||||
tasmota.remove_driver(self)
|
||||
end
|
||||
end
|
||||
|
||||
class lv_wifi_bars_icon: lv_wifi_bars
|
||||
def init(parent)
|
||||
super(self).init(parent)
|
||||
self.set_style_line_color(lv.color(lv.COLOR_WHITE), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
self.set_style_bg_color(lv.color(lv.COLOR_BLACK), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
if parent != nil
|
||||
var parent_height = parent.get_height()
|
||||
var pad_right = parent.get_style_pad_right(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
self.set_height(parent_height)
|
||||
self.set_width(parent_height)
|
||||
self.set_x(parent.get_width() - parent_height - pad_right)
|
||||
parent.set_style_pad_right(pad_right + parent_height + 1, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,256 @@
|
|||
#- embedded class for LVGL globals -#
|
||||
|
||||
#- This class stores all globals used by LVGL and cannot be stored in the solidified module -#
|
||||
#- this limits the globals to a single value '_lvgl' -#
|
||||
class LVGL_glob
|
||||
# all variables are lazily initialized to reduce the memory pressure. Until they are used, they consume zero memory
|
||||
var cb_obj # map between a native C pointer (as int) and the corresponding lv.lv_* berry object, also helps marking the objects as non-gc-able
|
||||
var cb_event_closure # mapping for event closures per LVGL native pointer (int)
|
||||
var event_cb # native callback for lv.lv_event
|
||||
|
||||
#- below are native callbacks mapped to a closure to a method of this instance -#
|
||||
var null_cb # cb called if type is not supported
|
||||
var widget_ctor_cb
|
||||
var widget_dtor_cb
|
||||
var widget_event_cb
|
||||
|
||||
var widget_struct_default
|
||||
var widget_struct_by_class
|
||||
|
||||
#- this is the fallback callback, if the event is unknown or unsupported -#
|
||||
static cb_do_nothing = def() print("LVG: call to unsupported callback") end
|
||||
|
||||
#- register an lv.lv_* object in the mapping -#
|
||||
def register_obj(obj)
|
||||
if self.cb_obj == nil self.cb_obj = {} end
|
||||
self.cb_obj[obj._p] = obj
|
||||
end
|
||||
|
||||
def get_object_from_ptr(ptr)
|
||||
if self.cb_obj != nil
|
||||
return self.cb_obj.find(ptr) # raise an exception if something is wrong
|
||||
end
|
||||
end
|
||||
|
||||
def lvgl_event_dispatch(event_ptr)
|
||||
import introspect
|
||||
|
||||
var event = lv.lv_event(introspect.toptr(event_ptr))
|
||||
|
||||
var target = event.target
|
||||
var f = self.cb_event_closure[target]
|
||||
var obj = self.get_object_from_ptr(target)
|
||||
#print('>> lvgl_event_dispatch', f, obj, event)
|
||||
f(obj, event)
|
||||
end
|
||||
|
||||
def gen_cb(name, f, obj, ptr)
|
||||
#print('>> gen_cb', name, obj, ptr)
|
||||
# record the object, whatever the callback
|
||||
|
||||
if name == "lv_event_cb"
|
||||
if self.cb_event_closure == nil self.cb_event_closure = {} end
|
||||
if self.event_cb == nil self.event_cb = tasmota.gen_cb(/ event_ptr -> self.lvgl_event_dispatch(event_ptr)) end # encapsulate 'self' in closure
|
||||
|
||||
self.register_obj(obj)
|
||||
self.cb_event_closure[ptr] = f
|
||||
return self.event_cb
|
||||
# elif name == "<other_cb>"
|
||||
else
|
||||
if self.null_cb == nil self.null_cb = tasmota.gen_cb(self.cb_do_nothing) end
|
||||
return self.null_cb
|
||||
end
|
||||
end
|
||||
|
||||
def widget_ctor_impl(cl_ptr, obj_ptr)
|
||||
import introspect
|
||||
var cl = lv.lv_obj_class(cl_ptr)
|
||||
var obj = self.get_object_from_ptr(obj_ptr)
|
||||
if self.cb_obj.find(obj) obj = self.cb_obj[obj] end
|
||||
# print("widget_ctor_impl", cl, obj)
|
||||
if type(obj) == 'instance' && introspect.get(obj, 'widget_constructor')
|
||||
obj.widget_constructor(cl)
|
||||
end
|
||||
end
|
||||
def widget_dtor_impl(cl_ptr, obj_ptr)
|
||||
import introspect
|
||||
var cl = lv.lv_obj_class(cl_ptr)
|
||||
var obj = self.get_object_from_ptr(obj_ptr)
|
||||
# print("widget_dtor_impl", cl, obj)
|
||||
if type(obj) == 'instance' && introspect.get(obj, 'widget_destructor')
|
||||
obj.widget_destructor(cl)
|
||||
end
|
||||
end
|
||||
def widget_event_impl(cl_ptr, e_ptr)
|
||||
import introspect
|
||||
var cl = lv.lv_obj_class(cl_ptr)
|
||||
var event = lv.lv_event(e_ptr)
|
||||
var obj_ptr = event.target
|
||||
var obj = self.get_object_from_ptr(obj_ptr)
|
||||
if type(obj) == 'instance' && introspect.get(obj, 'widget_event')
|
||||
obj.widget_event(cl, event)
|
||||
end
|
||||
# print("widget_event_impl", cl, obj_ptr, obj, event)
|
||||
end
|
||||
|
||||
|
||||
def widget_cb()
|
||||
if self.widget_ctor_cb == nil self.widget_ctor_cb = tasmota.gen_cb(/ cl, obj -> self.widget_ctor_impl(cl, obj)) end
|
||||
if self.widget_dtor_cb == nil self.widget_dtor_cb = tasmota.gen_cb(/ cl, obj -> self.widget_dtor_impl(cl, obj)) end
|
||||
if self.widget_event_cb == nil self.widget_event_cb = tasmota.gen_cb(/ cl, e -> self.widget_event_impl(cl, e)) end
|
||||
|
||||
if self.widget_struct_default == nil
|
||||
self.widget_struct_default = lv.lv_obj_class(lv.lv_obj._class).copy()
|
||||
self.widget_struct_default.base_class = lv.lv_obj._class # by default, inherit from base class `lv_obj`, this can be overriden
|
||||
self.widget_struct_default.constructor_cb = self.widget_ctor_cb # set the berry cb dispatchers
|
||||
self.widget_struct_default.destructor_cb = self.widget_dtor_cb
|
||||
self.widget_struct_default.event_cb = self.widget_event_cb
|
||||
end
|
||||
end
|
||||
|
||||
#- deregister_obj all information linked to a specific LVGL native object (int) -#
|
||||
def deregister_obj(obj)
|
||||
if self.cb_obj != nil self.cb_obj.remove(obj) end
|
||||
if self.cb_event_closure != nil self.cb_event_closure.remove(obj) end
|
||||
end
|
||||
|
||||
#- initialize a custom widget -#
|
||||
#- arg must be a subclass of lv.lv_obj -#
|
||||
def create_custom_widget(obj, parent)
|
||||
import introspect
|
||||
|
||||
if !isinstance(obj, lv.lv_obj) raise "value_error", "arg must be a subclass of lv_obj" end
|
||||
if self.widget_struct_by_class == nil self.widget_struct_by_class = {} end
|
||||
|
||||
var obj_classname = classname(obj)
|
||||
var obj_class_struct = self.widget_struct_by_class.find(obj_classname)
|
||||
# print("classname=",obj_classname,"_class",super(obj)._class)
|
||||
#- not already built, create a new one for this class -#
|
||||
if obj_class_struct == nil
|
||||
self.widget_cb() # set up all structures
|
||||
obj_class_struct = self.widget_struct_default.copy() # get a copy of the structure with pre-defined callbacks
|
||||
obj_class_struct.base_class = super(obj)._class
|
||||
if introspect.get(obj, 'widget_width_def') obj_class_struct.width_def = obj.widget_width_def end
|
||||
if introspect.get(obj, 'widget_height_def') obj_class_struct.height_def = obj.widget_height_def end
|
||||
if introspect.get(obj, 'widget_editable') obj_class_struct.editable = obj.widget_editable end
|
||||
if introspect.get(obj, 'widget_group_def') obj_class_struct.group_def = obj.widget_group_def end
|
||||
if introspect.get(obj, 'widget_instance_size') obj_class_struct.instance_size = obj.widget_instance_size end
|
||||
|
||||
#- keep a copy of the structure to avoid GC and reuse if needed -#
|
||||
self.widget_struct_by_class[obj_classname] = obj_class_struct
|
||||
end
|
||||
|
||||
var lv_obj_ptr = lv.obj_class_create_obj(obj_class_struct, parent)
|
||||
obj._p = lv_obj_ptr._p
|
||||
self.register_obj(obj)
|
||||
obj.class_init_obj()
|
||||
end
|
||||
end
|
||||
|
||||
_lvgl = LVGL_glob()
|
||||
|
||||
# class lv_custom_widget : lv.lv_obj
|
||||
# # static widget_width_def
|
||||
# # static widget_height_def
|
||||
# # static widget_editable
|
||||
# # static widget_group_def
|
||||
# # static widget_instance_size
|
||||
# #
|
||||
# var percentage # value to display, range 0..100
|
||||
# var p1, p2, area, line_dsc # instances of objects kept to avoid re-instanciating at each call
|
||||
|
||||
# def init(parent)
|
||||
# _lvgl.create_custom_widget(self, parent)
|
||||
# # own values
|
||||
# self.percentage = 100
|
||||
# # pre-allocate buffers
|
||||
# self.p1 = lv.lv_point()
|
||||
# self.p2 = lv.lv_point()
|
||||
# self.area = lv.lv_area()
|
||||
# self.line_dsc = lv.lv_draw_line_dsc()
|
||||
# end
|
||||
|
||||
# # def widget_constructor(cl)
|
||||
# # print("widget_constructor", cl)
|
||||
# # end
|
||||
|
||||
# # def widget_destructor(cl)
|
||||
# # print("widget_destructor", cl)
|
||||
# # end
|
||||
|
||||
# def widget_event(cl, event)
|
||||
# var res = lv.obj_event_base(cl, event)
|
||||
# if res != lv.RES_OK return end
|
||||
|
||||
# def atleast1(x) if x >= 1 return x else return 1 end end
|
||||
# # the model is that we have 4 bars and inter-bar (1/4 of width)
|
||||
# var height = self.get_height()
|
||||
# var width = self.get_width()
|
||||
|
||||
# var inter_bar = atleast1(width / 15)
|
||||
# var bar = atleast1((width - inter_bar * 3) / 4)
|
||||
# var bar_offset = bar / 2
|
||||
|
||||
# var code = event.code
|
||||
# if code == lv.EVENT_DRAW_MAIN
|
||||
# var clip_area = lv.lv_area(event.param)
|
||||
# print("widget_event DRAW", clip_area.tomap())
|
||||
# # lv.event_send(self, lv.EVENT_DRAW_MAIN, clip_area)
|
||||
|
||||
# # get coordinates of object
|
||||
# self.get_coords(self.area)
|
||||
# var x_ofs = self.area.x1
|
||||
# var y_ofs = self.area.y1
|
||||
|
||||
# lv.draw_line_dsc_init(self.line_dsc) # initialize lv.lv_draw_line_dsc structure
|
||||
# self.init_draw_line_dsc(lv.PART_MAIN, self.line_dsc)
|
||||
|
||||
# self.line_dsc.round_start = 1
|
||||
# self.line_dsc.round_end = 1
|
||||
# self.line_dsc.width = bar
|
||||
|
||||
# var on_color = self.get_style_line_color(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
# var off_color = self.get_style_bg_color(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
|
||||
# lv.event_send(self, lv.EVENT_DRAW_PART_BEGIN, self.line_dsc)
|
||||
# for i:0..3 # 4 bars
|
||||
# self.line_dsc.color = self.percentage >= (i+1)*20 ? on_color : off_color
|
||||
# self.p1.y = y_ofs + height - 1 - bar_offset
|
||||
# self.p1.x = x_ofs + i * (bar + inter_bar) + bar_offset
|
||||
# self.p2.y = y_ofs + ((3 - i) * (height - bar)) / 4 + bar_offset
|
||||
# self.p2.x = self.p1.x
|
||||
# lv.draw_line(self.p1, self.p2, clip_area, self.line_dsc)
|
||||
# end
|
||||
# lv.event_send(self, lv.EVENT_DRAW_PART_END, self.line_dsc)
|
||||
|
||||
# end
|
||||
# end
|
||||
|
||||
# def set_percentage(v)
|
||||
# var old_bars = self.percentage / 5
|
||||
# if v > 100 v = 100 end
|
||||
# if v < 0 v = 0 end
|
||||
# self.percentage = v
|
||||
# if old_bars != v / 5
|
||||
# self.invalidate() # be frugal and avoid updating the widget if it's not needed
|
||||
# end
|
||||
# end
|
||||
|
||||
# def get_percentage()
|
||||
# return self.percentage
|
||||
# end
|
||||
# end
|
||||
|
||||
# ########## ########## ########## ########## ########## ########## ########## ##########
|
||||
|
||||
# lv.start()
|
||||
|
||||
# hres = lv.get_hor_res() # should be 320
|
||||
# vres = lv.get_ver_res() # should be 240
|
||||
|
||||
# scr = lv.scr_act() # default screean object
|
||||
# f20 = lv.montserrat_font(20) # load embedded Montserrat 20
|
||||
|
||||
# scr.set_style_bg_color(lv.lv_color(0x0000A0), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
|
||||
# w = lv_custom_widget(scr)
|
|
@ -0,0 +1,764 @@
|
|||
import string
|
||||
import json
|
||||
|
||||
# lv.start()
|
||||
# scr = lv.scr_act() # default screean object
|
||||
# scr.set_style_bg_color(lv.color(0x0000A0), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
|
||||
lv.start()
|
||||
|
||||
hres = lv.get_hor_res() # should be 320
|
||||
vres = lv.get_ver_res() # should be 240
|
||||
|
||||
scr = lv.scr_act() # default screean object
|
||||
#f20 = lv.montserrat_font(20) # load embedded Montserrat 20
|
||||
r20 = lv.font_robotocondensed_latin1(20)
|
||||
r16 = lv.font_robotocondensed_latin1(16)
|
||||
|
||||
th2 = lv.theme_openhasp_init(0, lv.color(0xFF00FF), lv.color(0x303030), false, r16)
|
||||
scr.get_disp().set_theme(th2)
|
||||
# TODO
|
||||
scr.set_style_bg_color(lv.color(lv.COLOR_WHITE),0)
|
||||
|
||||
# apply theme to layer_top, but keep it transparent
|
||||
lv.theme_apply(lv.layer_top())
|
||||
lv.layer_top().set_style_bg_opa(0,0)
|
||||
|
||||
|
||||
# takes an attribute name and responds if it needs color conversion
|
||||
def is_color_attribute(t)
|
||||
import string
|
||||
t = str(t)
|
||||
# contains `color` but does not contain `color_`
|
||||
return (string.find(t, "color") >= 0) && (string.find(t, "color_") < 0)
|
||||
end
|
||||
|
||||
# parse hex string
|
||||
def parse_hex(s)
|
||||
import string
|
||||
s = string.toupper(s) # turn to uppercase
|
||||
var val = 0
|
||||
for i:0..size(s)-1
|
||||
var c = s[i]
|
||||
# var c_int = string.byte(c)
|
||||
if c == "#" continue end # skip '#' prefix if any
|
||||
if c == "x" || c == "X" continue end # skip 'x' or 'X'
|
||||
|
||||
if c >= "A" && c <= "F"
|
||||
val = (val << 4) | string.byte(c) - 55
|
||||
elif c >= "0" && c <= "9"
|
||||
val = (val << 4) | string.byte(c) - 48
|
||||
end
|
||||
end
|
||||
return val
|
||||
end
|
||||
|
||||
def parse_color(s)
|
||||
s = str(s)
|
||||
if s[0] == '#'
|
||||
return lv.color(parse_hex(s))
|
||||
else
|
||||
import string
|
||||
import introspect
|
||||
var col_name = "COLOR_" + string.toupper(s)
|
||||
var col_try = introspect.get(lv, col_name)
|
||||
if col_try != nil
|
||||
return lv.color(col_try)
|
||||
end
|
||||
end
|
||||
# fail safe with black color
|
||||
return lv.color(0x000000)
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Class `lvh_obj` encapsulating `lv_obj``
|
||||
|
||||
Provide a mapping for virtual members
|
||||
Stores the associated page and object id
|
||||
|
||||
Adds specific virtual members used by OpenHASP
|
||||
- ------------------------------------------------------------ -#
|
||||
class lvh_obj
|
||||
# _lv_class refers to the lvgl class encapsulated, and is overriden by subclasses
|
||||
static _lv_class = lv.obj
|
||||
static _lv_part2_selector # selector for secondary part (like knob of arc)
|
||||
|
||||
# attributes to ignore when set at object level (they are managed by page)
|
||||
static _attr_ignore = [
|
||||
"id",
|
||||
"obj",
|
||||
"page",
|
||||
"comment",
|
||||
"parentid",
|
||||
"auto_size", # TODO not sure it's still needed in LVGL8
|
||||
]
|
||||
#- mapping from OpenHASP attribute to LVGL attribute -#
|
||||
#- if mapping is null, we use set_X and get_X from our own class -#
|
||||
static _attr_map = {
|
||||
"x": "x",
|
||||
"y": "y",
|
||||
"w": "width",
|
||||
"h": "height",
|
||||
# arc
|
||||
"asjustable": nil,
|
||||
"mode": nil,
|
||||
"start_angle": "bg_start_angle",
|
||||
"start_angle1": "start_angle",
|
||||
"end_angle": "bg_end_angle",
|
||||
"end_angle1": "end_angle",
|
||||
"radius": "style_radius",
|
||||
"border_side": "style_border_side",
|
||||
"bg_opa": "style_bg_opa",
|
||||
"border_width": "style_border_width",
|
||||
"line_width": nil, # depebds on class
|
||||
"line_width1": nil, # depebds on class
|
||||
"action": nil, # store the action in self._action
|
||||
"hidden": nil, # apply to self
|
||||
"enabled": nil, # apply to self
|
||||
"click": nil, # synonym to enabled
|
||||
"toggle": nil,
|
||||
"bg_color": "style_bg_color",
|
||||
"bg_grad_color": "style_bg_grad_color",
|
||||
"type": nil,
|
||||
# below automatically create a sub-label
|
||||
"text": nil, # apply to self
|
||||
"value_str": nil, # synonym to 'text'
|
||||
"align": nil,
|
||||
"text_font": nil,
|
||||
"value_font": nil, # synonym to text_font
|
||||
"text_color": nil,
|
||||
"value_color": nil, # synonym to text_color
|
||||
"value_ofs_x": nil,
|
||||
"value_ofs_y": nil,
|
||||
#
|
||||
"min": nil,
|
||||
"max": nil,
|
||||
"val": "value",
|
||||
"rotation": "rotation",
|
||||
# img
|
||||
"src": "src",
|
||||
"image_recolor": "style_img_recolor",
|
||||
"image_recolor_opa": "style_img_recolor_opa",
|
||||
# spinner
|
||||
"angle": nil,
|
||||
"speed": nil,
|
||||
# padding of knob
|
||||
"pad_top2": nil,
|
||||
"pad_bottom2": nil,
|
||||
"pad_left2": nil,
|
||||
"pad_right2": nil,
|
||||
"pad_all2": nil,
|
||||
"radius2": nil,
|
||||
}
|
||||
|
||||
var _lv_obj # native lvgl object
|
||||
var _lv_label # sub-label if exists
|
||||
var _action # action for OpenHASP
|
||||
|
||||
# init
|
||||
# - create the LVGL encapsulated object
|
||||
# arg1: parent object
|
||||
# arg2: json line object
|
||||
def init(parent, jline)
|
||||
var obj_class = self._lv_class # need to assign to a var to distinguish from method call
|
||||
self._lv_obj = obj_class(parent) # instanciate LVGL object
|
||||
self.post_init()
|
||||
end
|
||||
|
||||
# post-init, to be overriden
|
||||
def post_init()
|
||||
end
|
||||
|
||||
# get LVGL encapsulated object
|
||||
def get_obj()
|
||||
return self._lv_obj
|
||||
end
|
||||
|
||||
def set_action(t)
|
||||
self._action = str(t)
|
||||
end
|
||||
def get_action()
|
||||
return self._action()
|
||||
end
|
||||
|
||||
def set_line_width(t)
|
||||
self._lv_obj.set_style_line_width(int(t), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_line_width()
|
||||
return self._lv_obj.get_style_line_width(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Mapping of synthetic attributes
|
||||
- text
|
||||
- hidden
|
||||
- enabled
|
||||
- ------------------------------------------------------------ -#
|
||||
#- `hidden` attributes mapped to OBJ_FLAG_HIDDEN -#
|
||||
def set_hidden(h)
|
||||
if h
|
||||
self._lv_obj.add_flag(lv.OBJ_FLAG_HIDDEN)
|
||||
else
|
||||
self._lv_obj.clear_flag(lv.OBJ_FLAG_HIDDEN)
|
||||
end
|
||||
end
|
||||
|
||||
def get_hidden()
|
||||
return self._lv_obj.has_flag(lv.OBJ_FLAG_HIDDEN)
|
||||
end
|
||||
|
||||
#- `enabled` attributes mapped to OBJ_FLAG_CLICKABLE -#
|
||||
def set_enabled(h)
|
||||
if h
|
||||
self._lv_obj.add_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
else
|
||||
self._lv_obj.clear_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
end
|
||||
end
|
||||
|
||||
def get_enabled()
|
||||
return self._lv_obj.has_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
end
|
||||
# click is synonym to enabled
|
||||
def set_click(t) self.set_enabled(t) end
|
||||
def get_click() return self.get_enabled() end
|
||||
|
||||
#- `toggle` attributes mapped to STATE_CHECKED -#
|
||||
def set_toggle(t)
|
||||
if t == "TRUE" t = true end
|
||||
if t == "FALSE" t = false end
|
||||
if t
|
||||
self._lv_obj.add_state(lv.STATE_CHECKED)
|
||||
else
|
||||
self._lv_obj.clear_state(lv.STATE_CHECKED)
|
||||
end
|
||||
end
|
||||
|
||||
def get_toggle()
|
||||
return self._lv_obj.has_state(lv.STATE_CHECKED)
|
||||
end
|
||||
|
||||
def set_adjustable(t)
|
||||
if t
|
||||
self._lv_obj.add_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
else
|
||||
self._lv_obj.clear_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
end
|
||||
end
|
||||
def get_adjustable()
|
||||
return self._lv_obj.has_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
end
|
||||
|
||||
#- set_text: create a `lv_label` sub object to the current object -#
|
||||
#- (default case, may be overriden by object that directly take text) -#
|
||||
def check_label()
|
||||
if self._lv_label == nil
|
||||
self._lv_label = lv.label(self.get_obj())
|
||||
self._lv_label.set_align(lv.ALIGN_CENTER);
|
||||
end
|
||||
end
|
||||
|
||||
def set_text(t)
|
||||
self.check_label()
|
||||
self._lv_label.set_text(str(t))
|
||||
end
|
||||
def set_value_str(t) self.set_text(t) end
|
||||
|
||||
def get_text()
|
||||
if self._lv_label == nil return nil end
|
||||
return self._lv_label.get_text()
|
||||
end
|
||||
def get_value_str() return self.get_text() end
|
||||
|
||||
def set_align(t)
|
||||
var align
|
||||
self.check_label()
|
||||
if t == 0 || t == "left"
|
||||
align = lv.TEXT_ALIGN_LEFT
|
||||
elif t == 1 || t == "center"
|
||||
align = lv.TEXT_ALIGN_CENTER
|
||||
elif t == 2 || t == "right"
|
||||
align = lv.TEXT_ALIGN_RIGHT
|
||||
end
|
||||
self._lv_label.set_style_text_align(align, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
|
||||
def get_align()
|
||||
if self._lv_label == nil return nil end
|
||||
var align self._lv_label.get_style_text_align(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
if align == lv.TEXT_ALIGN_LEFT
|
||||
return "left"
|
||||
elif align == lv.TEXT_ALIGN_CENTER
|
||||
return "center"
|
||||
elif align == lv.TEXT_ALIGN_RIGHT
|
||||
return "right"
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def set_text_font(t)
|
||||
self.check_label()
|
||||
var f = lv.font_robotocondensed_latin1(int(t))
|
||||
if f != nil
|
||||
self._lv_label.set_style_text_font(f, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
else
|
||||
print("HSP: Unsupported font size: robotocondensed-latin1", t)
|
||||
end
|
||||
end
|
||||
def get_text_font()
|
||||
end
|
||||
def set_value_font(t) self.set_text_font(t) end
|
||||
def get_value_font() return self.get_text_font() end
|
||||
|
||||
def set_text_color(t)
|
||||
self.check_label()
|
||||
self._lv_label.set_style_text_color(parse_color(t), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_text_color()
|
||||
return self._text_color
|
||||
end
|
||||
def set_value_color(t) self.set_text_color(t) end
|
||||
def get_value_color() return self.get_value_color() end
|
||||
|
||||
def set_value_ofs_x(t)
|
||||
self.check_label()
|
||||
self._lv_label.set_x(int(t))
|
||||
end
|
||||
def get_value_ofs_x()
|
||||
return self._lv_label.get_x()
|
||||
end
|
||||
def set_value_ofs_y(t)
|
||||
self.check_label()
|
||||
self._lv_label.set_y(int(t))
|
||||
end
|
||||
def get_value_ofs_y()
|
||||
return self._lv_label.get_y()
|
||||
end
|
||||
|
||||
# secondary element
|
||||
def set_pad_top2(t)
|
||||
if self._lv_part2_selector != nil
|
||||
self._lv_obj.set_style_pad_top(int(t), self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def set_pad_bottom2(t)
|
||||
if self._lv_part2_selector != nil
|
||||
self._lv_obj.set_style_pad_bottom(int(t), self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def set_pad_left2(t)
|
||||
if self._lv_part2_selector != nil
|
||||
self._lv_obj.set_style_pad_left(int(t), self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def set_pad_right2(t)
|
||||
if self._lv_part2_selector != nil
|
||||
self._lv_obj.set_style_pad_right(int(t), self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def set_pad_all2(t)
|
||||
if self._lv_part2_selector != nil
|
||||
self._lv_obj.set_style_pad_all(int(t), self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
|
||||
def get_pad_top()
|
||||
if self._lv_part2_selector != nil
|
||||
return self._lv_obj.get_style_pad_top(self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def get_pad_bottomo()
|
||||
if self._lv_part2_selector != nil
|
||||
return self._lv_obj.get_style_pad_bottom(self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def get_pad_left()
|
||||
if self._lv_part2_selector != nil
|
||||
return self._lv_obj.get_style_pad_left(self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def get_pad_right()
|
||||
if self._lv_part2_selector != nil
|
||||
return self._lv_obj.get_style_pad_right(self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def get_pad_all()
|
||||
end
|
||||
|
||||
def set_radius2(t)
|
||||
if self._lv_part2_selector != nil
|
||||
self._lv_obj.set_style_radius(int(t), self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
def get_radius2()
|
||||
if self._lv_part2_selector != nil
|
||||
return self._lv_obj.get_style_radius(self._lv_part2_selector | lv.STATE_DEFAULT)
|
||||
end
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Mapping of virtual attributes
|
||||
- ------------------------------------------------------------ -#
|
||||
def member(k)
|
||||
# tostring is a special case, we shouldn't raise an exception for it
|
||||
if k == 'tostring' return nil end
|
||||
#
|
||||
if self._attr_map.has(k)
|
||||
import introspect
|
||||
var kv = self._attr_map[k]
|
||||
if kv
|
||||
var f = introspect.get(self._lv_obj, "get_" + kv)
|
||||
if type(f) == 'function'
|
||||
return f(self._lv_obj)
|
||||
end
|
||||
else
|
||||
# call self method
|
||||
var f = introspect.get(self, "get_" + k)
|
||||
if type(f) == 'function'
|
||||
return f(self, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
raise "value_error", "unknown attribute " + str(k)
|
||||
end
|
||||
|
||||
def setmember(k, v)
|
||||
import string
|
||||
# print(">> setmember", k, v)
|
||||
# print(">>", classname(self), self._attr_map)
|
||||
if self._attr_ignore.find(k) != nil
|
||||
return
|
||||
elif self._attr_map.has(k)
|
||||
import introspect
|
||||
var kv = self._attr_map[k]
|
||||
if kv
|
||||
var f = introspect.get(self._lv_obj, "set_" + kv)
|
||||
# if the attribute contains 'color', convert to lv_color
|
||||
if type(kv) == 'string' && is_color_attribute(kv)
|
||||
v = parse_color(v)
|
||||
end
|
||||
# print("f=", f, v, kv, self._lv_obj, self)
|
||||
if type(f) == 'function'
|
||||
if string.find(kv, "style_") == 0
|
||||
# style function need a selector as second parameter
|
||||
f(self._lv_obj, v, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
else
|
||||
f(self._lv_obj, v)
|
||||
end
|
||||
return
|
||||
else
|
||||
print("HSP: Could not find function set_"+kv)
|
||||
end
|
||||
else
|
||||
# call self method
|
||||
var f = introspect.get(self, "set_" + k)
|
||||
# print("f==",f)
|
||||
if type(f) == 'function'
|
||||
f(self, v)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
print("HSP: unknown attribute:", k)
|
||||
end
|
||||
# silently ignore if the attribute name is not supported
|
||||
end
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Other widgets
|
||||
- ------------------------------------------------------------ -#
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
label
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_label : lvh_obj
|
||||
static _lv_class = lv.label
|
||||
# label do not need a sub-label
|
||||
def post_init()
|
||||
self._lv_label = self._lv_obj
|
||||
end
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
arc
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_arc : lvh_obj
|
||||
static _lv_class = lv.arc
|
||||
static _lv_part2_selector = lv.PART_KNOB
|
||||
|
||||
# line_width converts to arc_width
|
||||
def set_line_width(t)
|
||||
self._lv_obj.set_style_arc_width(int(t), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_line_width()
|
||||
return self._lv_obj.get_arc_line_width(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def set_line_width1(t)
|
||||
self._lv_obj.set_style_arc_width(int(t), lv.PART_INDICATOR | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_line_width1()
|
||||
return self._lv_obj.get_arc_line_width(lv.PART_INDICATOR | lv.STATE_DEFAULT)
|
||||
end
|
||||
|
||||
def set_min(t)
|
||||
self._lv_obj.set_range(int(t), self.get_max())
|
||||
end
|
||||
def set_max(t)
|
||||
self._lv_obj.set_range(self.get_min(), int(t))
|
||||
end
|
||||
def get_min()
|
||||
return self._lv_obj.get_min_value()
|
||||
end
|
||||
def get_max()
|
||||
return self._lv_obj.get_max_value()
|
||||
end
|
||||
def set_type(t)
|
||||
var mode
|
||||
if t == 0 mode = lv.ARC_MODE_NORMAL
|
||||
elif t == 1 mode = lv.ARC_MODE_REVERSE
|
||||
elif t == 2 mode = lv.ARC_MODE_SYMMETRICAL
|
||||
end
|
||||
if mode != nil
|
||||
self._lv_obj.set_mode(mode)
|
||||
end
|
||||
end
|
||||
def get_type()
|
||||
return self._lv_obj.get_mode()
|
||||
end
|
||||
# mode
|
||||
def set_mode(t)
|
||||
var mode
|
||||
if mode == "expand" self._lv_obj.set_width(lv.SIZE_CONTENT)
|
||||
elif mode == "break" mode = lv.LABEL_LONG_WRAP
|
||||
elif mode == "dots" mode = lv.LABEL_LONG_DOT
|
||||
elif mode == "scroll" mode = lv.LABEL_LONG_SCROLL
|
||||
elif mode == "loop" mode = lv.LABEL_LONG_SCROLL_CIRCULAR
|
||||
elif mode == "crop" mode = lv.LABEL_LONG_CLIP
|
||||
end
|
||||
if mode != nil
|
||||
self._lv_obj.lv_label_set_long_mode(mode)
|
||||
end
|
||||
end
|
||||
def get_mode()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
switch
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_switch : lvh_obj
|
||||
static _lv_class = lv.switch
|
||||
static _lv_part2_selector = lv.PART_KNOB
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
spinner
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_spinner : lvh_arc
|
||||
static _lv_class = lv.spinner
|
||||
|
||||
# init
|
||||
# - create the LVGL encapsulated object
|
||||
# arg1: parent object
|
||||
# arg2: json line object
|
||||
def init(parent, jline)
|
||||
var angle = jline.find("angle", 60)
|
||||
var speed = jline.find("speed", 1000)
|
||||
self._lv_obj = lv.spinner(parent, speed, angle)
|
||||
self.post_init()
|
||||
end
|
||||
|
||||
# ignore attributes, spinner can't be changed once created
|
||||
def set_angle(t) end
|
||||
def get_angle() end
|
||||
def set_speed(t) end
|
||||
def get_speed() end
|
||||
end
|
||||
|
||||
#- creat sub-classes of lvh_obj and map the LVGL class in static '_lv_class' attribute -#
|
||||
class lvh_bar : lvh_obj static _lv_class = lv.bar end
|
||||
class lvh_btn : lvh_obj static _lv_class = lv.btn end
|
||||
class lvh_btnmatrix : lvh_obj static _lv_class = lv.btnmatrix end
|
||||
class lvh_checkbox : lvh_obj static _lv_class = lv.checkbox end
|
||||
class lvh_dropdown : lvh_obj static _lv_class = lv.dropdown end
|
||||
class lvh_img : lvh_obj static _lv_class = lv.img end
|
||||
class lvh_line : lvh_obj static _lv_class = lv.line end
|
||||
class lvh_roller : lvh_obj static _lv_class = lv.roller end
|
||||
class lvh_slider : lvh_obj static _lv_class = lv.slider end
|
||||
class lvh_textarea : lvh_obj static _lv_class = lv.textarea end
|
||||
|
||||
#- ----------------------------------------------------------------------------
|
||||
Class `lvh_page` encapsulating `lv_obj` as screen (created with lv.obj(0))
|
||||
- ----------------------------------------------------------------------------- -#
|
||||
# ex of transition: lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, false)
|
||||
class lvh_page
|
||||
var _obj_id # (map) of objects by id numbers
|
||||
var _page_id # (int) id number of the page
|
||||
var _lv_scr # (lv_obj) lvgl screen object
|
||||
|
||||
#- init(page_number) -#
|
||||
def init(page_number)
|
||||
import global
|
||||
|
||||
# if no parameter, default to page #1
|
||||
if page_number == nil page_number = 1 end
|
||||
|
||||
self._page_id = page_number # remember our page_number
|
||||
self._obj_id = {} # init list of objects
|
||||
if page_number == 1
|
||||
self._lv_scr = lv.scr_act() # default screen
|
||||
elif page_number == 0
|
||||
self._lv_scr = lv.layer_top() # top layer, visible over all screens
|
||||
else
|
||||
self._lv_scr = lv.obj(0) # allocate a new screen
|
||||
# self._lv_scr.set_style_bg_color(lv.color(0x000000), lv.PART_MAIN | lv.STATE_DEFAULT) # set black background
|
||||
self._lv_scr.set_style_bg_color(lv.color(0xFFFFFF), lv.PART_MAIN | lv.STATE_DEFAULT) # set white background
|
||||
end
|
||||
|
||||
# create a global for this page of form p<page_number>, ex p1
|
||||
var glob_name = string.format("p%i", self._page_id)
|
||||
global.(glob_name) = self
|
||||
end
|
||||
|
||||
#- retrieve lvgl screen object for this page -#
|
||||
def get_scr()
|
||||
return self._lv_scr
|
||||
end
|
||||
|
||||
#- add an object to this page -#
|
||||
def set_obj(id, o)
|
||||
self._obj_id[id] = o
|
||||
end
|
||||
def get_obj(id)
|
||||
return self._obj_id.find(id)
|
||||
end
|
||||
|
||||
#- return id of this page -#
|
||||
def id()
|
||||
return self._page_id
|
||||
end
|
||||
|
||||
#- show this page, with animation -#
|
||||
def show(anim, duration)
|
||||
# ignore if there is no screen, like for id 0
|
||||
if self._lv_scr == nil return nil end
|
||||
# ignore if the screen is already active
|
||||
if self._lv_scr._p == lv.scr_act()._p return end # do nothing
|
||||
|
||||
# default animation is lv.SCR_LOAD_ANIM_MOVE_RIGHT
|
||||
if anim == nil anim = lv.SCR_LOAD_ANIM_MOVE_RIGHT end
|
||||
# default duration of 500ms
|
||||
if duration == nil duration = 500 end
|
||||
|
||||
# load new screen with anumation, no delay, 500ms transition time, no auto-delete
|
||||
lv.scr_load_anim(self._lv_scr, lv.SCR_LOAD_ANIM_MOVE_RIGHT, duration, 0, false)
|
||||
end
|
||||
end
|
||||
|
||||
#- pages -#
|
||||
var lvh_page_cur = lvh_page(1)
|
||||
var lvh_pages = { 1: lvh_page_cur } # always create page #1
|
||||
|
||||
f = open("pages.jsonl","r")
|
||||
var jsonl = string.split(f.read(), "\n")
|
||||
f.close()
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Parse page information
|
||||
|
||||
Create a new page object if required
|
||||
Change the active page
|
||||
- ------------------------------------------------------------ -#
|
||||
def parse_page(jline)
|
||||
if jline.has("page") && type(jline["page"]) == 'int'
|
||||
var page = int(jline["page"])
|
||||
# does the page already exist?
|
||||
if lvh_pages.has(page)
|
||||
# yes, just change the current page
|
||||
lvh_page_cur = lvh_pages[page]
|
||||
else
|
||||
# no, create a new page
|
||||
lvh_page_cur = lvh_page(page)
|
||||
lvh_pages[page] = lvh_page_cur
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Parse single object
|
||||
|
||||
- ------------------------------------------------------------ -#
|
||||
def parse_obj(jline, page)
|
||||
import global
|
||||
import introspect
|
||||
|
||||
# line must contain 'obj' and 'id', otherwise it is ignored
|
||||
if jline.has("obj") && jline.has("id") && type(jline["id"]) == 'int'
|
||||
# 'obj_id' must be between 1 and 254
|
||||
var obj_id = int(jline["id"])
|
||||
if obj_id < 1 || obj_id > 254
|
||||
raise "value error", "invalid id " + str(obj_id)
|
||||
end
|
||||
|
||||
# extract openhasp class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn`
|
||||
var obj_type = jline["obj"]
|
||||
|
||||
# extract parent
|
||||
var parent
|
||||
var parent_id = int(jline.find("parentid"))
|
||||
if parent_id != nil
|
||||
var parent_obj = lvh_page_cur.get_obj(parent_id)
|
||||
if parent_obj != nil
|
||||
parent = parent_obj._lv_obj
|
||||
end
|
||||
end
|
||||
if parent == nil
|
||||
parent = page.get_scr()
|
||||
end
|
||||
|
||||
# check if a class with the requested name exists
|
||||
var obj_class = introspect.get(global, "lvh_" + obj_type)
|
||||
if obj_class == nil
|
||||
raise "value error", "cannot find object of type " + str(obj_type)
|
||||
end
|
||||
|
||||
# instanciate the object, passing the lvgl screen as paren object
|
||||
var obj = obj_class(parent, jline)
|
||||
|
||||
# add object to page object
|
||||
lvh_page_cur.set_obj(obj_id, obj)
|
||||
# set attributes
|
||||
# try every attribute, if not supported it is silently ignored
|
||||
for k:jline.keys()
|
||||
# introspect.set(obj, k, jline[k])
|
||||
obj.(k) = jline[k]
|
||||
end
|
||||
|
||||
# create a global variable for this object of form p<page>b<id>, ex p1b2
|
||||
var glob_name = string.format("p%ib%i", lvh_page_cur.id(), obj_id)
|
||||
global.(glob_name) = obj
|
||||
end
|
||||
end
|
||||
|
||||
# ex:
|
||||
# {'page': 1, 'h': 50, 'obj': 'label', 'hidden': false, 'text': 'Hello', 'x': 5, 'id': 1, 'enabled': true, 'y': 5, 'w': 50}
|
||||
# {"page":1,"id":2,"obj":"btn","x":5,"y":90,"h":90,"w":50,"text":"World","enabled":false,"hidden":false}
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Parse jsonl file line by line
|
||||
|
||||
- ------------------------------------------------------------ -#
|
||||
tasmota.yield()
|
||||
for j:jsonl
|
||||
var jline = json.load(j)
|
||||
|
||||
# parse page first
|
||||
if type(jline) == 'instance'
|
||||
parse_page(jline)
|
||||
parse_obj(jline, lvh_page_cur)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,61 @@
|
|||
{"page":1,"comment":"---------- Page 1 ----------"}
|
||||
{"page":1,"id":0,"bg_color":"#FFFFFF","bg_grad_color":"#FFFFFF","text_color":"#000000","radius":0,"border_side":0}
|
||||
{"page":1,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"LIVING ROOM","value_font":24,"bg_color":"#2C3E50","bg_grad_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0}
|
||||
|
||||
{"page":1,"id":2,"obj":"arc","x":20,"y":65,"w":80,"h":100,"max":40,"border_side":0,"type":0,"rotation":0,"start_angle":180,"end_angle":0,"start_angle1":180,"value_font":12,"value_ofs_x":0,"value_ofs_y":-14,"bg_opa":0,"text":"21.2°C","min":-20,"max":50,"val":21}
|
||||
|
||||
{"page":1,"id":3,"obj":"arc","x":140,"y":65,"w":80,"h":100,"max":100,"border_side":0,"type":0,"start_angle":180,"end_angle":0,"start_angle1":180,"value_font":12,"value_color":"#000000","value_ofs_x":0,"value_ofs_y":-14,"bg_opa":0,"text":"44%","val":44}
|
||||
|
||||
{"page":1,"id":4,"obj":"label","x":0,"y":120,"w":240,"h":20,"text":"CO2 levels: 1483 ppm","radius":0,"border_side":0,"align":1}
|
||||
{"page":1,"id":5,"obj":"label","x":2,"y":35,"w":140,"text":"Temperature","align":1}
|
||||
{"page":1,"id":6,"obj":"label","x":140,"y":35,"w":95,"text":"Humidity","align":1}
|
||||
{"page":1,"id":7,"obj":"btn","x":0,"y":160,"w":240,"h":20,"text":"LIGHTS","bg_color":"#F1C40F","text_color":"#FFFFFF","radius":0,"border_side":0}
|
||||
{"page":1,"id":8,"obj":"label","x":20,"y":190,"w":140,"h":20,"text":"Ceiling Light"}
|
||||
{"page":1,"id":9,"obj":"switch","x":160,"y":190,"w":40,"h":20,"toggle":"TRUE"}
|
||||
{"page":1,"id":10,"obj":"label","x":20,"y":215,"w":140,"h":20,"text":"Wall Light"}
|
||||
{"page":1,"id":11,"obj":"switch","x":160,"y":215,"w":40,"h":20,"toggle":"TRUE"}
|
||||
{"page":1,"id":12,"obj":"label","x":20,"y":240,"w":200,"h":20,"text":"Ambient Light"}
|
||||
{"page":1,"id":13,"obj":"slider","x":30,"y":265,"w":200,"h":10}
|
||||
|
||||
{"page":2,"comment":"---------- Page 2 ----------"}
|
||||
{"page":2,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"ENTITIES","value_font":24,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
{"page":2,"id":2,"obj":"obj","x":5,"y":35,"w":230,"h":250,"click":0}
|
||||
|
||||
{"page":2,"id":11,"obj":"label","x":8,"y":33,"w":35,"h":35,"text":"\uE004","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":12,"obj":"label","x":48,"y":43,"w":130,"h":30,"text":"Presence override","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":13,"obj":"switch","x":177,"y":40,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":2,"id":21,"obj":"label","x":8,"y":69,"w":35,"h":35,"text":"\uF020","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":22,"obj":"label","x":48,"y":79,"w":130,"h":30,"text":"Front door light","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":23,"obj":"switch","x":177,"y":74,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":2,"id":31,"obj":"label","x":8,"y":103,"w":35,"h":35,"text":"\uF054","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":32,"obj":"label","x":48,"y":113,"w":130,"h":30,"text":"Back yard lights","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":33,"obj":"switch","x":177,"y":110,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":2,"id":41,"obj":"label","x":8,"y":138,"w":35,"h":35,"text":"\uEA7A","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":42,"obj":"label","x":48,"y":148,"w":130,"h":30,"text":"Trash service","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":43,"obj":"label","x":97,"y":148,"w":130,"h":30,"text":"in 6 days","align":2,"text_color":"black"}
|
||||
|
||||
{"page":2,"id":51,"obj":"label","x":8,"y":173,"w":35,"h":35,"text":"\uF39D","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":52,"obj":"label","x":48,"y":183,"w":130,"h":30,"text":"Selective trash","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":53,"obj":"label","x":97,"y":183,"w":130,"h":30,"text":"in 10 days","align":2,"text_color":"black"}
|
||||
|
||||
{"page":2,"id":61,"obj":"label","x":8,"y":208,"w":35,"h":35,"text":"\uE32A","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":62,"obj":"label","x":48,"y":218,"w":130,"h":30,"text":"Green energy active","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":63,"obj":"label","x":97,"y":218,"w":130,"h":30,"text":"Yes :)","align":2,"text_color":"black"}
|
||||
|
||||
{"page":2,"id":71,"obj":"label","x":8,"y":243,"w":35,"h":35,"text":"\uE957","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":72,"obj":"label","x":48,"y":253,"w":130,"h":30,"text":"Air quality","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":73,"obj":"label","x":97,"y":253,"w":130,"h":30,"text":"OK (29.58 µg/m³)","align":2,"text_color":"black"}
|
||||
|
||||
{"page":3,"comment":"---------- Page 3 ----------"}
|
||||
{"page":3,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"FAN STATUS","text_font":16,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
|
||||
{"page":3,"id":11,"obj":"img","src":"A:/noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":75,"image_recolor":"lime","image_recolor_opa":150}
|
||||
{"page":3,"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
|
||||
|
||||
{"page":0,"comment":"---------- All pages ----------"}
|
||||
{"page":0,"id":11,"obj":"btn","action":"prev","x":0,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE141","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
||||
{"page":0,"id":12,"obj":"btn","action":"back","x":80,"y":290,"w":80,"h":32,"bg_color":"#34495E","text":"\uE2DC","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":24}
|
||||
{"page":0,"id":13,"obj":"btn","action":"next","x":161,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE142","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
|
@ -0,0 +1,23 @@
|
|||
{"page":1,"comment":"---------- Page 1 ----------"}
|
||||
{"page":1,"id":0,"bg_color":"#FFFFFF","bg_grad_color":"#FFFFFF","text_color":"#000000","radius":0,"border_side":0}
|
||||
{"page":1,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"LIVING ROOM","value_font":22,"bg_color":"#2C3E50","bg_grad_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0}
|
||||
|
||||
{"page":1,"id":2,"obj":"arc","x":20,"y":65,"w":80,"h":100,"max":40,"border_side":0,"type":0,"rotation":0,"start_angle":180,"end_angle":0,"start_angle1":180,"value_font":12,"value_ofs_x":0,"value_ofs_y":-14,"bg_opa":0,"text":"21.2°C","min":-20,"max":50,"val":21}
|
||||
|
||||
{"page":1,"id":3,"obj":"arc","x":140,"y":65,"w":80,"h":100,"max":100,"border_side":0,"type":0,"start_angle":180,"end_angle":0,"start_angle1":180,"value_font":12,"value_color":"#000000","value_ofs_x":0,"value_ofs_y":-14,"bg_opa":0,"text":"44%","val":44}
|
||||
|
||||
{"page":1,"id":4,"obj":"label","x":0,"y":120,"w":240,"h":20,"text":"CO2 levels: 1483 ppm","radius":0,"border_side":0,"align":1}
|
||||
{"page":1,"id":5,"obj":"label","x":2,"y":35,"w":140,"text":"Temperature","align":1}
|
||||
{"page":1,"id":6,"obj":"label","x":140,"y":35,"w":95,"text":"Humidity","align":1}
|
||||
{"page":1,"id":7,"obj":"btn","x":0,"y":160,"w":240,"h":20,"text":"LIGHTS","bg_color":"#F1C40F","text_color":"#FFFFFF","radius":0,"border_side":0}
|
||||
{"page":1,"id":8,"obj":"label","x":20,"y":190,"w":140,"h":20,"text":"Ceiling Light"}
|
||||
{"page":1,"id":9,"obj":"switch","x":160,"y":190,"w":40,"h":20,"toggle":"TRUE"}
|
||||
{"page":1,"id":10,"obj":"label","x":20,"y":215,"w":140,"h":20,"text":"Wall Light"}
|
||||
{"page":1,"id":11,"obj":"switch","x":160,"y":215,"w":40,"h":20,"toggle":"TRUE"}
|
||||
{"page":1,"id":12,"obj":"label","x":20,"y":240,"w":200,"h":20,"text":"Ambient Light"}
|
||||
{"page":1,"id":13,"obj":"slider","x":30,"y":265,"w":200,"h":10}
|
||||
|
||||
{"page":0,"comment":"---------- All pages ----------"}
|
||||
{"page":0,"id":11,"obj":"btn","action":"prev","x":0,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE141","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
||||
{"page":0,"id":12,"obj":"btn","action":"back","x":80,"y":290,"w":80,"h":32,"bg_color":"#34495E","text":"\uE2DC","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":24}
|
||||
{"page":0,"id":13,"obj":"btn","action":"next","x":161,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE142","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
|
@ -0,0 +1,35 @@
|
|||
{"page":1,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"ENTITIES","value_font":22,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
{"page":1,"id":2,"obj":"obj","x":5,"y":35,"w":230,"h":250,"click":0}
|
||||
|
||||
{"page":1,"id":11,"obj":"label","x":8,"y":33,"w":35,"h":35,"text":"\uE004","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":12,"obj":"label","x":48,"y":43,"w":130,"h":30,"text":"Presence override","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":13,"obj":"switch","x":177,"y":40,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":1,"id":21,"obj":"label","x":8,"y":69,"w":35,"h":35,"text":"\uF020","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":22,"obj":"label","x":48,"y":79,"w":130,"h":30,"text":"Front door light","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":23,"obj":"switch","x":177,"y":74,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":1,"id":31,"obj":"label","x":8,"y":103,"w":35,"h":35,"text":"\uF054","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":32,"obj":"label","x":48,"y":113,"w":130,"h":30,"text":"Back yard lights","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":33,"obj":"switch","x":177,"y":110,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":1,"id":41,"obj":"label","x":8,"y":138,"w":35,"h":35,"text":"\uEA7A","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":42,"obj":"label","x":48,"y":148,"w":130,"h":30,"text":"Trash service","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":43,"obj":"label","x":97,"y":148,"w":130,"h":30,"text":"in 6 days","align":2,"text_color":"black"}
|
||||
|
||||
{"page":1,"id":51,"obj":"label","x":8,"y":173,"w":35,"h":35,"text":"\uF39D","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":52,"obj":"label","x":48,"y":183,"w":130,"h":30,"text":"Selective trash","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":53,"obj":"label","x":97,"y":183,"w":130,"h":30,"text":"in 10 days","align":2,"text_color":"black"}
|
||||
|
||||
{"page":1,"id":61,"obj":"label","x":8,"y":208,"w":35,"h":35,"text":"\uE32A","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":62,"obj":"label","x":48,"y":218,"w":130,"h":30,"text":"Green energy active","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":63,"obj":"label","x":97,"y":218,"w":130,"h":30,"text":"Yes :)","align":2,"text_color":"black"}
|
||||
|
||||
{"page":1,"id":71,"obj":"label","x":8,"y":243,"w":35,"h":35,"text":"\uE957","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":1,"id":72,"obj":"label","x":48,"y":253,"w":130,"h":30,"text":"Air quality","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":1,"id":73,"obj":"label","x":97,"y":253,"w":130,"h":30,"text":"OK (29.58 µg/m³)","align":2,"text_color":"black"}
|
||||
|
||||
{"page":0,"comment":"---------- All pages ----------"}
|
||||
{"page":0,"id":11,"obj":"btn","action":"prev","x":0,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE141","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
||||
{"page":0,"id":12,"obj":"btn","action":"back","x":80,"y":290,"w":80,"h":32,"bg_color":"#34495E","text":"\uE2DC","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":24}
|
||||
{"page":0,"id":13,"obj":"btn","action":"next","x":161,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE142","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
|
@ -0,0 +1,4 @@
|
|||
{"page":1,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"FAN STATUS","text_font":16,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
|
||||
{"page":1,"id":11,"obj":"img","src":"A:/noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":75,"image_recolor":"lime","image_recolor_opa":150}
|
||||
{"page":1,"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
|
|
@ -0,0 +1,161 @@
|
|||
#- persistance module for Berry -#
|
||||
#- -#
|
||||
#- To solidify: -#
|
||||
#-
|
||||
# load only persis_module and persist_module.init
|
||||
import solidify
|
||||
solidify.dump(persist_module.init)
|
||||
# copy and paste into `be_persist_lib.c`
|
||||
-#
|
||||
var persist_module = module("persist")
|
||||
|
||||
persist_module.init = def (m)
|
||||
|
||||
class Persist
|
||||
var _filename
|
||||
var _p
|
||||
var _dirty
|
||||
|
||||
#- persist can be initialized with pre-existing values. The map is not copied so any change will be reflected -#
|
||||
def init(m)
|
||||
# print("Persist init")
|
||||
self._filename = '_persist.json'
|
||||
if isinstance(m,map)
|
||||
self._p = m.copy() # need to copy instead?
|
||||
else
|
||||
self._p = {}
|
||||
end
|
||||
self.load(self._p, self._filename)
|
||||
self._dirty = false
|
||||
# print("Persist init")
|
||||
end
|
||||
|
||||
#- virtual member getter, if a key does not exists return `nil`-#
|
||||
def member(key)
|
||||
return self._p.find(key)
|
||||
end
|
||||
|
||||
#- virtual member setter -#
|
||||
def setmember(key, value)
|
||||
self._p[key] = value
|
||||
self._dirty = true
|
||||
end
|
||||
|
||||
#- clear all entries -#
|
||||
def zero()
|
||||
self._p = {}
|
||||
self._dirty = true
|
||||
end
|
||||
|
||||
def remove(k)
|
||||
self._p.remove(k)
|
||||
self._dirty = true
|
||||
end
|
||||
|
||||
def has(k)
|
||||
return self._p.has(k)
|
||||
end
|
||||
|
||||
def find(k, d)
|
||||
return self._p.find(k, d)
|
||||
end
|
||||
|
||||
def load()
|
||||
import json
|
||||
import path
|
||||
var f # file object
|
||||
var val # values loaded from json
|
||||
|
||||
if path.exists(self._filename)
|
||||
try
|
||||
f = open(self._filename, "r")
|
||||
val = json.load(f.read())
|
||||
f.close()
|
||||
except .. as e, m
|
||||
if f != nil f.close() end
|
||||
raise e, m
|
||||
end
|
||||
if isinstance(val, map)
|
||||
self._p = val # sucess
|
||||
else
|
||||
print("BRY: failed to load _persist.json")
|
||||
end
|
||||
self._dirty = false
|
||||
else
|
||||
self.save()
|
||||
end
|
||||
|
||||
# print("Loading")
|
||||
end
|
||||
|
||||
def save()
|
||||
var f # file object
|
||||
try
|
||||
f = open(self._filename, "w")
|
||||
self.json_fdump(f)
|
||||
f.close()
|
||||
except .. as e, m
|
||||
if f != nil f.close() end
|
||||
f = open(self._filename, "w")
|
||||
f.write('{}') # fallback write empty map
|
||||
f.close()
|
||||
raise e, m
|
||||
end
|
||||
self._dirty = false
|
||||
# print("Saving")
|
||||
end
|
||||
|
||||
def json_fdump_any(f, v)
|
||||
import json
|
||||
if isinstance(v, map)
|
||||
self.json_fdump_map(f, v)
|
||||
elif isinstance(v, list)v
|
||||
self.json_fdump_list(f, v)
|
||||
else
|
||||
f.write(json.dump(v))
|
||||
end
|
||||
end
|
||||
|
||||
def json_fdump_map(f, v)
|
||||
import json
|
||||
f.write('{')
|
||||
var sep = nil
|
||||
for k:v.keys()
|
||||
if sep != nil f.write(sep) end
|
||||
|
||||
f.write(json.dump(str(k)))
|
||||
f.write(':')
|
||||
self.json_fdump_any(f, v[k])
|
||||
|
||||
sep = ","
|
||||
end
|
||||
f.write('}')
|
||||
end
|
||||
|
||||
def json_fdump_list(f, v)
|
||||
import json
|
||||
f.write('[')
|
||||
var i = 0
|
||||
while i < size(v)
|
||||
if i > 0 f.write(',') end
|
||||
self.json_fdump_any(f, v[i])
|
||||
i += 1
|
||||
end
|
||||
f.write(']')
|
||||
end
|
||||
|
||||
def json_fdump(f)
|
||||
import json
|
||||
if isinstance(self._p, map)
|
||||
self.json_fdump_map(f, self._p)
|
||||
else
|
||||
raise "internal_error", "persist._p is not a map"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return Persist() # return an instance of this class
|
||||
end
|
||||
|
||||
return persist_module
|
|
@ -0,0 +1,35 @@
|
|||
#- Tasmota apps module for Berry -#
|
||||
#- -#
|
||||
|
||||
var tapp_module = module("tapp")
|
||||
|
||||
tapp_module.init = def (m)
|
||||
|
||||
class Tapp
|
||||
|
||||
def init()
|
||||
tasmota.add_driver(self)
|
||||
end
|
||||
|
||||
def autoexec()
|
||||
import path
|
||||
import string
|
||||
|
||||
var dir = path.listdir("/")
|
||||
|
||||
for d: dir
|
||||
if string.find(d, ".tapp") > 0
|
||||
tasmota.log(string.format("TAP: found Tasmota App '%s'", d), 2)
|
||||
tasmota.load(d + "#autoexec.be")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Tapp() # return an instance of this class
|
||||
end
|
||||
|
||||
# aa = autoconf_module.init(autoconf_module)
|
||||
# import webserver
|
||||
# webserver.on('/ac2', / -> aa.page_autoconf_mgr(), webserver.HTTP_GET)
|
||||
return tapp_module
|
|
@ -0,0 +1,30 @@
|
|||
ec = crypto.EC_C25519()
|
||||
|
||||
# Alice
|
||||
sk_A = bytes('77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a')
|
||||
pk_A = ec.public_key(sk_A)
|
||||
assert(pk_A == bytes('8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a'))
|
||||
|
||||
# Bob
|
||||
sk_B = bytes('5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb')
|
||||
pk_B = ec.public_key(sk_B)
|
||||
assert(pk_B == bytes('de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f'))
|
||||
|
||||
psk = ec.shared_key(sk_A, pk_B)
|
||||
assert(psk == bytes('4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742'))
|
||||
psk2 = ec.shared_key(sk_B, pk_A)
|
||||
assert(psk2 == bytes('4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742'))
|
||||
|
||||
#- test vectors from RFC77748
|
||||
|
||||
Alice's private key, a:
|
||||
77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a
|
||||
Alice's public key, X25519(a, 9):
|
||||
8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a
|
||||
Bob's private key, b:
|
||||
5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb
|
||||
Bob's public key, X25519(b, 9):
|
||||
de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f
|
||||
Their shared secret, K:
|
||||
4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742
|
||||
-#
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* static_block.hpp
|
||||
*
|
||||
* An implementation of a Java-style static block, in C++ (and potentially a
|
||||
* GCC/clang extension to avoid warnings). Almost, but not quite, valid C.
|
||||
* Partially inspired by Andrei Alexandrescu's Scope Guard and
|
||||
* discussions on stackoverflow.com
|
||||
*
|
||||
* By Eyal Rozenberg <eyalroz@technion.ac.il>
|
||||
*
|
||||
* Licensed under the Apache License v2.0:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef STATIC_BLOCK_HPP_
|
||||
#define STATIC_BLOCK_HPP_
|
||||
|
||||
#ifndef CONCATENATE
|
||||
#define CONCATENATE(s1, s2) s1##s2
|
||||
#define EXPAND_THEN_CONCATENATE(s1, s2) CONCATENATE(s1, s2)
|
||||
#endif /* CONCATENATE */
|
||||
|
||||
#ifndef UNIQUE_IDENTIFIER
|
||||
/**
|
||||
* This macro expands into a different identifier in every expansion.
|
||||
* Note that you _can_ clash with an invocation of UNIQUE_IDENTIFIER
|
||||
* by manually using the same identifier elsewhere; or by carefully
|
||||
* choosing another prefix etc.
|
||||
*/
|
||||
#ifdef __COUNTER__
|
||||
#define UNIQUE_IDENTIFIER(prefix) EXPAND_THEN_CONCATENATE(prefix, __COUNTER__)
|
||||
#else
|
||||
#define UNIQUE_IDENTIFIER(prefix) EXPAND_THEN_CONCATENATE(prefix, __LINE__)
|
||||
#endif /* COUNTER */
|
||||
#else
|
||||
#endif /* UNIQUE_IDENTIFIER */
|
||||
|
||||
/**
|
||||
* Following is a mechanism for executing code statically.
|
||||
*
|
||||
* @note Caveats:
|
||||
* - Your static block must be surround by curly braces.
|
||||
* - No need for a semicolon after the block (but it won't hurt).
|
||||
* - Do not put static blocks in files, as it might get compiled multiple
|
||||
* times ane execute multiple times.
|
||||
* - A static_block can only be used in file scope - not within any other block etc.
|
||||
* - Templated static blocks will probably not work. Avoid them.
|
||||
* - No other funny business, this is fragile.
|
||||
* - This does not having any threading issues (AFAICT) - as it has no static
|
||||
* initialization order issue. Of course, you have to _keep_ it safe with
|
||||
* your static code.
|
||||
* - Execution of the code is guaranteed to occur before main() executes,
|
||||
* but the relative order of statics being initialized is unknown/unclear. So,
|
||||
* do not call any method of an instance of a class which you expect to have been
|
||||
* constructed; it may not have been. Instead, you can use a static getInstance() method
|
||||
* (look this idiom up on the web, it's safe).
|
||||
* - Variables defined within the static block are not global; they will
|
||||
* go out of scope as soon as its execution concludes.
|
||||
*
|
||||
* Usage example:
|
||||
*
|
||||
* static_block {
|
||||
* do_stuff();
|
||||
* std::cout << "in the static block!\n";
|
||||
* }
|
||||
*
|
||||
*/
|
||||
#define static_block STATIC_BLOCK_IMPL1(UNIQUE_IDENTIFIER(_static_block_))
|
||||
|
||||
#define STATIC_BLOCK_IMPL1(prefix) \
|
||||
STATIC_BLOCK_IMPL2(CONCATENATE(prefix,_fn),CONCATENATE(prefix,_var))
|
||||
|
||||
#define STATIC_BLOCK_IMPL2(function_name,var_name) \
|
||||
static void function_name(); \
|
||||
static int var_name __attribute((unused)) = (function_name(), 0) ; \
|
||||
static void function_name()
|
||||
|
||||
|
||||
#endif // STATIC_BLOCK_HPP_
|
|
@ -0,0 +1,20 @@
|
|||
# anonymous function and closure
|
||||
def count(x)
|
||||
var arr = []
|
||||
for i : 0 .. x
|
||||
arr.push(
|
||||
def (n) # loop variable cannot be used directly as free variable
|
||||
return def ()
|
||||
return n * n
|
||||
end
|
||||
end (i) # define and call anonymous function
|
||||
)
|
||||
end
|
||||
return arr
|
||||
end
|
||||
|
||||
for xx : count(6)
|
||||
print(xx()) # 0, 1, 4 ... n * n
|
||||
end
|
||||
|
||||
return count
|
|
@ -0,0 +1,15 @@
|
|||
import time
|
||||
|
||||
c = time.clock()
|
||||
do
|
||||
i = 0
|
||||
while i < 100000000
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
print('while iteration 100000000 times', time.clock() - c, 's')
|
||||
|
||||
c = time.clock()
|
||||
for i : 1 .. 100000000
|
||||
end
|
||||
print('for iteration 100000000 times', time.clock() - c, 's')
|
|
@ -0,0 +1,60 @@
|
|||
# Reference from https://github.com/BerryMathDevelopmentTeam/BerryMath/blob/master/testscript/BinaryTree.bm
|
||||
|
||||
class node
|
||||
var v, l, r
|
||||
def init(v, l, r)
|
||||
self.v = v
|
||||
self.l = l
|
||||
self.r = r
|
||||
end
|
||||
def insert(v)
|
||||
if v < self.v
|
||||
if self.l
|
||||
self.l.insert(v)
|
||||
else
|
||||
self.l = node(v)
|
||||
end
|
||||
else
|
||||
if self.r
|
||||
self.r.insert(v)
|
||||
else
|
||||
self.r = node (v)
|
||||
end
|
||||
end
|
||||
end
|
||||
def sort(l)
|
||||
if (self.l) self.l.sort(l) end
|
||||
l.push(self.v)
|
||||
if (self.r) self.r.sort(l) end
|
||||
end
|
||||
end
|
||||
|
||||
class btree
|
||||
var root
|
||||
def insert(v)
|
||||
if self.root
|
||||
self.root.insert(v)
|
||||
else
|
||||
self.root = node(v)
|
||||
end
|
||||
end
|
||||
def sort()
|
||||
var l = []
|
||||
if self.root
|
||||
self.root.sort(l)
|
||||
end
|
||||
return l
|
||||
end
|
||||
end
|
||||
|
||||
var tree = btree()
|
||||
tree.insert(-100)
|
||||
tree.insert(5);
|
||||
tree.insert(3);
|
||||
tree.insert(9);
|
||||
tree.insert(10);
|
||||
tree.insert(10000000);
|
||||
tree.insert(1);
|
||||
tree.insert(-1);
|
||||
tree.insert(-10);
|
||||
print(tree.sort());
|
|
@ -0,0 +1,16 @@
|
|||
def cpi(n)
|
||||
i = 2
|
||||
pi = 3
|
||||
while i <= n
|
||||
term = 4.0 / (i * (i + 1) * (i + 2))
|
||||
if i % 4
|
||||
pi = pi + term
|
||||
else
|
||||
pi = pi - term
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
return pi
|
||||
end
|
||||
|
||||
print("pi =", cpi(100))
|
|
@ -0,0 +1,12 @@
|
|||
import debug
|
||||
|
||||
def test_func()
|
||||
try
|
||||
compile('def +() end')()
|
||||
except .. as e, v
|
||||
print('catch execption:', str(e) + ' >>>\n ' + str(v))
|
||||
debug.traceback()
|
||||
end
|
||||
end
|
||||
|
||||
test_func()
|
|
@ -0,0 +1,12 @@
|
|||
import time
|
||||
|
||||
def fib(x)
|
||||
if x <= 2
|
||||
return 1
|
||||
end
|
||||
return fib(x - 1) + fib(x - 2)
|
||||
end
|
||||
|
||||
c = time.clock()
|
||||
print("fib:", fib(38)) # minimum stack size: 78!!
|
||||
print("time:", time.clock() - c, 's')
|
|
@ -0,0 +1,26 @@
|
|||
import time
|
||||
import math
|
||||
|
||||
math.srand(time.time())
|
||||
res = math.rand() % 100
|
||||
max_test = 7
|
||||
test = -1
|
||||
idx = 1
|
||||
print('Guess a number between 0 and 99. You have', max_test, 'chances.')
|
||||
while test != res && idx <= max_test
|
||||
test = number(input(str(idx) + ': enter the number you guessed: '))
|
||||
if type(test) != 'int'
|
||||
print('This is not an integer. Continue!')
|
||||
continue
|
||||
elif test > res
|
||||
print('This number is too large.')
|
||||
elif test < res
|
||||
print('This number is too small.')
|
||||
end
|
||||
idx = idx + 1
|
||||
end
|
||||
if test == res
|
||||
print('You win!')
|
||||
else
|
||||
print('You failed, the correct answer is', res)
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
import json
|
||||
print(json.load('{"key": "value"}'))
|
||||
print(json.dump({'test key': nil}))
|
||||
print(json.dump({'key1': nil, 45: true}, 'format'))
|
|
@ -0,0 +1,8 @@
|
|||
# simple lambda example
|
||||
print((/a b c-> a * b + c)(2, 3, 4))
|
||||
|
||||
# Y-Combinator and factorial functions
|
||||
Y = /f-> (/x-> f(/n-> x(x)(n)))(/x-> f(/n-> x(x)(n)))
|
||||
F = /f-> /x-> x ? f(x - 1) * x : 1
|
||||
fact = Y(F)
|
||||
print('fact(10) == ' .. fact(10))
|
|
@ -0,0 +1,16 @@
|
|||
import os
|
||||
|
||||
def scandir(path)
|
||||
print('path: ' + path)
|
||||
for name : os.listdir(path)
|
||||
var fullname = os.path.join(path, name)
|
||||
if os.path.isfile(fullname)
|
||||
print('file: ' + fullname)
|
||||
else
|
||||
print('path: ' + fullname)
|
||||
scandir(fullname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scandir('.')
|
|
@ -0,0 +1,42 @@
|
|||
def qsort(data)
|
||||
# do once sort
|
||||
def once(left, right)
|
||||
var pivot = data[left] # use the 0th value as the pivot
|
||||
while left < right # check if sort is complete
|
||||
# put the value less than the pivot to the left
|
||||
while left < right && data[right] >= pivot
|
||||
right -= 1 # skip values greater than pivot
|
||||
end
|
||||
data[left] = data[right]
|
||||
# put the value greater than the pivot on the right
|
||||
while left < right && data[left] <= pivot
|
||||
left += 1 # skip values less than pivot
|
||||
end
|
||||
data[right] = data[left]
|
||||
end
|
||||
# now we have the index of the pivot, store it
|
||||
data[left] = pivot
|
||||
return left # return the index of the pivot
|
||||
end
|
||||
# recursive quick sort algorithm
|
||||
def _sort(left, right)
|
||||
if left < right # executed when the array is not empty
|
||||
var index = once(left, right) # get index of pivot for divide and conquer
|
||||
_sort(left, index - 1) # sort the data on the left
|
||||
_sort(index + 1, right) # sort the data on the right
|
||||
end
|
||||
end
|
||||
# start quick sort
|
||||
_sort(0, data.size() - 1)
|
||||
return data
|
||||
end
|
||||
|
||||
import time, math
|
||||
math.srand(time.time()) # sse system time as a random seed
|
||||
data = []
|
||||
# put 20 random numbers into the array
|
||||
for i : 1 .. 20
|
||||
data.push(math.rand() % 100)
|
||||
end
|
||||
# sort and print
|
||||
print(qsort(data))
|
|
@ -0,0 +1,61 @@
|
|||
do
|
||||
def ismult(msg)
|
||||
import string
|
||||
return string.split(msg, -5)[1] == '\'EOS\''
|
||||
end
|
||||
|
||||
def multline(src, msg)
|
||||
if !ismult(msg)
|
||||
print('syntax_error: ' + msg)
|
||||
return
|
||||
end
|
||||
while true
|
||||
try
|
||||
src += '\n' + input('>> ')
|
||||
return compile(src)
|
||||
except 'syntax_error' as e, m
|
||||
if !ismult(m)
|
||||
print('syntax_error: ' + m)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def parse()
|
||||
var fun, src = input('> ')
|
||||
try
|
||||
fun = compile('return (' + src + ')')
|
||||
except 'syntax_error' as e, m
|
||||
try
|
||||
fun = compile(src)
|
||||
except 'syntax_error' as e, m
|
||||
fun = multline(src, m)
|
||||
end
|
||||
end
|
||||
return fun
|
||||
end
|
||||
|
||||
def run(fun)
|
||||
try
|
||||
var res = fun()
|
||||
if res print(res) end
|
||||
except .. as e, m
|
||||
import debug
|
||||
print(e .. ': ' .. m)
|
||||
debug.traceback()
|
||||
end
|
||||
end
|
||||
|
||||
def repl()
|
||||
while true
|
||||
var fun = parse()
|
||||
if fun != nil
|
||||
run(fun)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print("Berry Berry REPL!")
|
||||
repl()
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
s = "This is a long string test. 0123456789 abcdefg ABCDEFG"
|
||||
print(s)
|
||||
|
||||
a = .5
|
||||
print(a)
|
||||
|
||||
import string as s
|
||||
|
||||
print(s.hex(0x45678ABCD, 16))
|
||||
|
||||
def bin(x, num)
|
||||
assert(type(x) == 'int', 'the type of \'x\' must be integer')
|
||||
# test the 'x' bits
|
||||
var bits = 1
|
||||
for i : 0 .. 62
|
||||
if x & (1 << 63 - i)
|
||||
bits = 64 - i
|
||||
break
|
||||
end
|
||||
end
|
||||
if type(num) == 'int' && num > 0 && num <= 64
|
||||
bits = bits < num ? num : bits
|
||||
end
|
||||
var result = ''
|
||||
bits -= 1
|
||||
for i : 0 .. bits
|
||||
result += x & (1 << (bits - i)) ? '1' : '0'
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
print(bin(33))
|
|
@ -0,0 +1,7 @@
|
|||
import string
|
||||
|
||||
print(string.format('%.3d', 12))
|
||||
print(string.format('%.3f', 12))
|
||||
print(string.format('%20.7f', 14.5))
|
||||
print(string.format('-- %-40s ---', 'this is a string format test'))
|
||||
print(string.format('-- %40s ---', 'this is a string format test'))
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
python3 tools/pycoc/main.py -o generate src default ../berry_mapping/src -c default/berry_conf.h
|
|
@ -0,0 +1,741 @@
|
|||
extern const bcstring be_const_str_;
|
||||
extern const bcstring be_const_str_AES_GCM;
|
||||
extern const bcstring be_const_str_AXP192;
|
||||
extern const bcstring be_const_str_Animate_X20pc_X20is_X20out_X20of_X20range;
|
||||
extern const bcstring be_const_str_AudioFileSource;
|
||||
extern const bcstring be_const_str_AudioFileSourceFS;
|
||||
extern const bcstring be_const_str_AudioGenerator;
|
||||
extern const bcstring be_const_str_AudioGeneratorMP3;
|
||||
extern const bcstring be_const_str_AudioGeneratorWAV;
|
||||
extern const bcstring be_const_str_AudioOutput;
|
||||
extern const bcstring be_const_str_AudioOutputI2S;
|
||||
extern const bcstring be_const_str_Auto_X2Dconfiguration;
|
||||
extern const bcstring be_const_str_BRY_X3A_X20ERROR_X2C_X20bad_X20json_X3A_X20;
|
||||
extern const bcstring be_const_str_BRY_X3A_X20Exception_X3E_X20_X27_X25s_X27_X20_X2D_X20_X25s;
|
||||
extern const bcstring be_const_str_BRY_X3A_X20could_X20not_X20save_X20compiled_X20file_X20_X25s_X20_X28_X25s_X29;
|
||||
extern const bcstring be_const_str_BRY_X3A_X20failed_X20to_X20load_X20_persist_X2Ejson;
|
||||
extern const bcstring be_const_str_BUTTON_CONFIGURATION;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20Exception_X3E_X20_X27_X25s_X27_X20_X2D_X20_X25s;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20_X27init_X2Ebat_X27_X20done_X2C_X20restarting;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20could_X20not_X20run_X20_X25s_X20_X28_X25s_X20_X2D_X20_X25s_X29;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20downloading_X20_X27_X25s_X27;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20exception_X20_X27_X25s_X27_X20_X2D_X20_X27_X25s_X27;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20loaded_X20_X20;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20loaded_X20_X27_X25s_X27;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20loading_X20;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20loading_X20_X27_X25s_X27;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20multiple_X20autoconf_X20files_X20found_X2C_X20aborting_X20_X28_X27_X25s_X27_X20_X2B_X20_X27_X25s_X27_X29;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20no_X20_X27_X2A_X2Eautoconf_X27_X20file_X20found;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20ran_X20_X20;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20removed_X20file_X20_X27_X25s_X27;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20removing_X20autoconf_X20files;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20removing_X20first_X20time_X20marker;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20return_code_X3D_X25i;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20running_X20;
|
||||
extern const bcstring be_const_str_CFG_X3A_X20skipping_X20_X27display_X2Eini_X27_X20because_X20already_X20present_X20in_X20file_X2Dsystem;
|
||||
extern const bcstring be_const_str_COLOR_BLACK;
|
||||
extern const bcstring be_const_str_COLOR_WHITE;
|
||||
extern const bcstring be_const_str_EC_C25519;
|
||||
extern const bcstring be_const_str_EVENT_DRAW_MAIN;
|
||||
extern const bcstring be_const_str_EVENT_DRAW_PART_BEGIN;
|
||||
extern const bcstring be_const_str_EVENT_DRAW_PART_END;
|
||||
extern const bcstring be_const_str_False;
|
||||
extern const bcstring be_const_str_GET;
|
||||
extern const bcstring be_const_str_HTTP_GET;
|
||||
extern const bcstring be_const_str_HTTP_POST;
|
||||
extern const bcstring be_const_str_I2C_Driver;
|
||||
extern const bcstring be_const_str_I2C_X3A;
|
||||
extern const bcstring be_const_str_LVG_X3A_X20call_X20to_X20unsupported_X20callback;
|
||||
extern const bcstring be_const_str_Leds;
|
||||
extern const bcstring be_const_str_MD5;
|
||||
extern const bcstring be_const_str_None;
|
||||
extern const bcstring be_const_str_OPTION_A;
|
||||
extern const bcstring be_const_str_OneWire;
|
||||
extern const bcstring be_const_str_PART_MAIN;
|
||||
extern const bcstring be_const_str_POST;
|
||||
extern const bcstring be_const_str_Parameter_X20error;
|
||||
extern const bcstring be_const_str_RES_OK;
|
||||
extern const bcstring be_const_str_Restart_X201;
|
||||
extern const bcstring be_const_str_SERIAL_5E1;
|
||||
extern const bcstring be_const_str_SERIAL_5E2;
|
||||
extern const bcstring be_const_str_SERIAL_5N1;
|
||||
extern const bcstring be_const_str_SERIAL_5N2;
|
||||
extern const bcstring be_const_str_SERIAL_5O1;
|
||||
extern const bcstring be_const_str_SERIAL_5O2;
|
||||
extern const bcstring be_const_str_SERIAL_6E1;
|
||||
extern const bcstring be_const_str_SERIAL_6E2;
|
||||
extern const bcstring be_const_str_SERIAL_6N1;
|
||||
extern const bcstring be_const_str_SERIAL_6N2;
|
||||
extern const bcstring be_const_str_SERIAL_6O1;
|
||||
extern const bcstring be_const_str_SERIAL_6O2;
|
||||
extern const bcstring be_const_str_SERIAL_7E1;
|
||||
extern const bcstring be_const_str_SERIAL_7E2;
|
||||
extern const bcstring be_const_str_SERIAL_7N1;
|
||||
extern const bcstring be_const_str_SERIAL_7N2;
|
||||
extern const bcstring be_const_str_SERIAL_7O1;
|
||||
extern const bcstring be_const_str_SERIAL_7O2;
|
||||
extern const bcstring be_const_str_SERIAL_8E1;
|
||||
extern const bcstring be_const_str_SERIAL_8E2;
|
||||
extern const bcstring be_const_str_SERIAL_8N1;
|
||||
extern const bcstring be_const_str_SERIAL_8N2;
|
||||
extern const bcstring be_const_str_SERIAL_8O1;
|
||||
extern const bcstring be_const_str_SERIAL_8O2;
|
||||
extern const bcstring be_const_str_SK6812_GRBW;
|
||||
extern const bcstring be_const_str_STATE_DEFAULT;
|
||||
extern const bcstring be_const_str_TAP_X3A_X20found_X20Tasmota_X20App_X20_X27_X25s_X27;
|
||||
extern const bcstring be_const_str_Tasmota;
|
||||
extern const bcstring be_const_str_Tele;
|
||||
extern const bcstring be_const_str_Timer;
|
||||
extern const bcstring be_const_str_True;
|
||||
extern const bcstring be_const_str_Unknown_X20command;
|
||||
extern const bcstring be_const_str_WS2812;
|
||||
extern const bcstring be_const_str_WS2812_GRB;
|
||||
extern const bcstring be_const_str_Wire;
|
||||
extern const bcstring be_const_str__;
|
||||
extern const bcstring be_const_str__X0A;
|
||||
extern const bcstring be_const_str__X20;
|
||||
extern const bcstring be_const_str__X21_X3D;
|
||||
extern const bcstring be_const_str__X21_X3D_X3D;
|
||||
extern const bcstring be_const_str__X23;
|
||||
extern const bcstring be_const_str__X23autoexec_X2Ebat;
|
||||
extern const bcstring be_const_str__X23autoexec_X2Ebe;
|
||||
extern const bcstring be_const_str__X23display_X2Eini;
|
||||
extern const bcstring be_const_str__X23init_X2Ebat;
|
||||
extern const bcstring be_const_str__X23preinit_X2Ebe;
|
||||
extern const bcstring be_const_str__X2502d_X25s_X2502d;
|
||||
extern const bcstring be_const_str__X2504d_X2D_X2502d_X2D_X2502dT_X2502d_X3A_X2502d_X3A_X2502d;
|
||||
extern const bcstring be_const_str__X25s_X2Eautoconf;
|
||||
extern const bcstring be_const_str__X26lt_X3BError_X3A_X20apply_X20new_X20or_X20remove_X26gt_X3B;
|
||||
extern const bcstring be_const_str__X26lt_X3BNone_X26gt_X3B;
|
||||
extern const bcstring be_const_str__X28_X29;
|
||||
extern const bcstring be_const_str__X2B;
|
||||
extern const bcstring be_const_str__X2C;
|
||||
extern const bcstring be_const_str__X2D_X2D_X3A_X2D_X2D;
|
||||
extern const bcstring be_const_str__X2E;
|
||||
extern const bcstring be_const_str__X2E_X2E;
|
||||
extern const bcstring be_const_str__X2Eautoconf;
|
||||
extern const bcstring be_const_str__X2Ebe;
|
||||
extern const bcstring be_const_str__X2Ebec;
|
||||
extern const bcstring be_const_str__X2Elen;
|
||||
extern const bcstring be_const_str__X2Ep;
|
||||
extern const bcstring be_const_str__X2Ep1;
|
||||
extern const bcstring be_const_str__X2Ep2;
|
||||
extern const bcstring be_const_str__X2Esize;
|
||||
extern const bcstring be_const_str__X2Etapp;
|
||||
extern const bcstring be_const_str__X2Ew;
|
||||
extern const bcstring be_const_str__X2F;
|
||||
extern const bcstring be_const_str__X2F_X2Eautoconf;
|
||||
extern const bcstring be_const_str__X2F_X3Frst_X3D;
|
||||
extern const bcstring be_const_str__X2Fac;
|
||||
extern const bcstring be_const_str__X3A;
|
||||
extern const bcstring be_const_str__X3C;
|
||||
extern const bcstring be_const_str__X3C_X2Fform_X3E_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3C_X3D;
|
||||
extern const bcstring be_const_str__X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E;
|
||||
extern const bcstring be_const_str__X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E;
|
||||
extern const bcstring be_const_str__X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E;
|
||||
extern const bcstring be_const_str__X3Cinstance_X3A_X20_X25s_X28_X25s_X2C_X20_X25s_X2C_X20_X25s_X29;
|
||||
extern const bcstring be_const_str__X3Clabel_X3EChoose_X20a_X20device_X20configuration_X3A_X3C_X2Flabel_X3E_X3Cbr_X3E;
|
||||
extern const bcstring be_const_str__X3Clambda_X3E;
|
||||
extern const bcstring be_const_str__X3Clegend_X3E_X3Cb_X20title_X3D_X27Autoconfiguration_X27_X3E_X26nbsp_X3BCurrent_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E;
|
||||
extern const bcstring be_const_str__X3Clegend_X3E_X3Cb_X20title_X3D_X27New_X20autoconf_X27_X3E_X26nbsp_X3BSelect_X20new_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E;
|
||||
extern const bcstring be_const_str__X3Coption_X20value_X3D_X27_X25s_X27_X3E_X25s_X3C_X2Foption_X3E;
|
||||
extern const bcstring be_const_str__X3Coption_X20value_X3D_X27reset_X27_X3E_X26lt_X3BRemove_X20autoconf_X26gt_X3B_X3C_X2Foption_X3E;
|
||||
extern const bcstring be_const_str__X3Cp_X20style_X3D_X27width_X3A340px_X3B_X27_X3E_X3Cb_X3EException_X3A_X3C_X2Fb_X3E_X3Cbr_X3E_X27_X25s_X27_X3Cbr_X3E_X25s_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3Cp_X3ECurrent_X20configuration_X3A_X20_X3C_X2Fp_X3E_X3Cp_X3E_X3Cb_X3E_X25s_X3C_X2Fb_X3E_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3Cp_X3E_X3C_X2Fp_X3E_X3C_X2Ffieldset_X3E_X3Cp_X3E_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3E_X26_X23129668_X3B_X20Auto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20;
|
||||
extern const bcstring be_const_str__X3Cp_X3E_X3Cform_X20id_X3Dzip_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20;
|
||||
extern const bcstring be_const_str__X3Cp_X3E_X3Csmall_X3E_X26nbsp_X3B_X28This_X20feature_X20requires_X20an_X20internet_X20connection_X29_X3C_X2Fsmall_X3E_X3C_X2Fp_X3E;
|
||||
extern const bcstring be_const_str__X3Cselect_X20name_X3D_X27zip_X27_X3E;
|
||||
extern const bcstring be_const_str__X3D;
|
||||
extern const bcstring be_const_str__X3D_X3C_X3E_X21;
|
||||
extern const bcstring be_const_str__X3D_X3D;
|
||||
extern const bcstring be_const_str__X3E;
|
||||
extern const bcstring be_const_str__X3E_X3D;
|
||||
extern const bcstring be_const_str__X3F;
|
||||
extern const bcstring be_const_str__X5B;
|
||||
extern const bcstring be_const_str__X5D;
|
||||
extern const bcstring be_const_str__X7B;
|
||||
extern const bcstring be_const_str__X7B_X7D;
|
||||
extern const bcstring be_const_str__X7Bs_X7DBatt_X20Current_X7Bm_X7D_X25_X2E1f_X20mA_X7Be_X7D;
|
||||
extern const bcstring be_const_str__X7Bs_X7DBatt_X20Voltage_X7Bm_X7D_X25_X2E3f_X20V_X7Be_X7D;
|
||||
extern const bcstring be_const_str__X7Bs_X7DTemp_X20AXP_X7Bm_X7D_X25_X2E1f_X20_XB0C_X7Be_X7D;
|
||||
extern const bcstring be_const_str__X7Bs_X7DVBus_X20Current_X7Bm_X7D_X25_X2E1f_X20mA_X7Be_X7D;
|
||||
extern const bcstring be_const_str__X7Bs_X7DVBus_X20Voltage_X7Bm_X7D_X25_X2E3f_X20V_X7Be_X7D;
|
||||
extern const bcstring be_const_str__X7D;
|
||||
extern const bcstring be_const_str___iterator__;
|
||||
extern const bcstring be_const_str___lower__;
|
||||
extern const bcstring be_const_str___upper__;
|
||||
extern const bcstring be_const_str__anonymous_;
|
||||
extern const bcstring be_const_str__archive;
|
||||
extern const bcstring be_const_str__available;
|
||||
extern const bcstring be_const_str__begin_transmission;
|
||||
extern const bcstring be_const_str__buffer;
|
||||
extern const bcstring be_const_str__ccmd;
|
||||
extern const bcstring be_const_str__class;
|
||||
extern const bcstring be_const_str__cmd;
|
||||
extern const bcstring be_const_str__debug_present;
|
||||
extern const bcstring be_const_str__def;
|
||||
extern const bcstring be_const_str__dirty;
|
||||
extern const bcstring be_const_str__drivers;
|
||||
extern const bcstring be_const_str__end_transmission;
|
||||
extern const bcstring be_const_str__energy;
|
||||
extern const bcstring be_const_str__error;
|
||||
extern const bcstring be_const_str__filename;
|
||||
extern const bcstring be_const_str__global_addr;
|
||||
extern const bcstring be_const_str__global_def;
|
||||
extern const bcstring be_const_str__lvgl;
|
||||
extern const bcstring be_const_str__p;
|
||||
extern const bcstring be_const_str__persist_X2Ejson;
|
||||
extern const bcstring be_const_str__ptr;
|
||||
extern const bcstring be_const_str__read;
|
||||
extern const bcstring be_const_str__request_from;
|
||||
extern const bcstring be_const_str__rules;
|
||||
extern const bcstring be_const_str__settings_def;
|
||||
extern const bcstring be_const_str__settings_ptr;
|
||||
extern const bcstring be_const_str__t;
|
||||
extern const bcstring be_const_str__timers;
|
||||
extern const bcstring be_const_str__write;
|
||||
extern const bcstring be_const_str_a;
|
||||
extern const bcstring be_const_str_abs;
|
||||
extern const bcstring be_const_str_acos;
|
||||
extern const bcstring be_const_str_add;
|
||||
extern const bcstring be_const_str_add_anim;
|
||||
extern const bcstring be_const_str_add_cmd;
|
||||
extern const bcstring be_const_str_add_driver;
|
||||
extern const bcstring be_const_str_add_header;
|
||||
extern const bcstring be_const_str_add_rule;
|
||||
extern const bcstring be_const_str_addr;
|
||||
extern const bcstring be_const_str_allocated;
|
||||
extern const bcstring be_const_str_alternate;
|
||||
extern const bcstring be_const_str_animate;
|
||||
extern const bcstring be_const_str_animators;
|
||||
extern const bcstring be_const_str_arch;
|
||||
extern const bcstring be_const_str_area;
|
||||
extern const bcstring be_const_str_arg;
|
||||
extern const bcstring be_const_str_arg_X20must_X20be_X20a_X20subclass_X20of_X20lv_obj;
|
||||
extern const bcstring be_const_str_arg_name;
|
||||
extern const bcstring be_const_str_arg_size;
|
||||
extern const bcstring be_const_str_as;
|
||||
extern const bcstring be_const_str_asin;
|
||||
extern const bcstring be_const_str_assert;
|
||||
extern const bcstring be_const_str_asstring;
|
||||
extern const bcstring be_const_str_atan;
|
||||
extern const bcstring be_const_str_atan2;
|
||||
extern const bcstring be_const_str_atleast1;
|
||||
extern const bcstring be_const_str_attrdump;
|
||||
extern const bcstring be_const_str_autoexec;
|
||||
extern const bcstring be_const_str_autorun;
|
||||
extern const bcstring be_const_str_available;
|
||||
extern const bcstring be_const_str_b;
|
||||
extern const bcstring be_const_str_back_forth;
|
||||
extern const bcstring be_const_str_base_class;
|
||||
extern const bcstring be_const_str_battery_present;
|
||||
extern const bcstring be_const_str_begin;
|
||||
extern const bcstring be_const_str_bool;
|
||||
extern const bcstring be_const_str_break;
|
||||
extern const bcstring be_const_str_bri;
|
||||
extern const bcstring be_const_str_bus;
|
||||
extern const bcstring be_const_str_button_pressed;
|
||||
extern const bcstring be_const_str_byte;
|
||||
extern const bcstring be_const_str_bytes;
|
||||
extern const bcstring be_const_str_c;
|
||||
extern const bcstring be_const_str_call;
|
||||
extern const bcstring be_const_str_call_native;
|
||||
extern const bcstring be_const_str_calldepth;
|
||||
extern const bcstring be_const_str_can_show;
|
||||
extern const bcstring be_const_str_cb;
|
||||
extern const bcstring be_const_str_cb_do_nothing;
|
||||
extern const bcstring be_const_str_cb_event_closure;
|
||||
extern const bcstring be_const_str_cb_obj;
|
||||
extern const bcstring be_const_str_ceil;
|
||||
extern const bcstring be_const_str_char;
|
||||
extern const bcstring be_const_str_chars_in_string;
|
||||
extern const bcstring be_const_str_check_privileged_access;
|
||||
extern const bcstring be_const_str_class;
|
||||
extern const bcstring be_const_str_class_init_obj;
|
||||
extern const bcstring be_const_str_classname;
|
||||
extern const bcstring be_const_str_classof;
|
||||
extern const bcstring be_const_str_clear;
|
||||
extern const bcstring be_const_str_clear_first_time;
|
||||
extern const bcstring be_const_str_clear_to;
|
||||
extern const bcstring be_const_str_close;
|
||||
extern const bcstring be_const_str_closure;
|
||||
extern const bcstring be_const_str_cmd;
|
||||
extern const bcstring be_const_str_cmd_res;
|
||||
extern const bcstring be_const_str_code;
|
||||
extern const bcstring be_const_str_codedump;
|
||||
extern const bcstring be_const_str_collect;
|
||||
extern const bcstring be_const_str_color;
|
||||
extern const bcstring be_const_str_compile;
|
||||
extern const bcstring be_const_str_compress;
|
||||
extern const bcstring be_const_str_concat;
|
||||
extern const bcstring be_const_str_connect;
|
||||
extern const bcstring be_const_str_connected;
|
||||
extern const bcstring be_const_str_connection_error;
|
||||
extern const bcstring be_const_str_constructor_cb;
|
||||
extern const bcstring be_const_str_contains;
|
||||
extern const bcstring be_const_str_content_button;
|
||||
extern const bcstring be_const_str_content_flush;
|
||||
extern const bcstring be_const_str_content_send;
|
||||
extern const bcstring be_const_str_content_send_style;
|
||||
extern const bcstring be_const_str_content_start;
|
||||
extern const bcstring be_const_str_content_stop;
|
||||
extern const bcstring be_const_str_continue;
|
||||
extern const bcstring be_const_str_copy;
|
||||
extern const bcstring be_const_str_cos;
|
||||
extern const bcstring be_const_str_cosh;
|
||||
extern const bcstring be_const_str_couldn_X27t_X20not_X20initialize_X20noepixelbus;
|
||||
extern const bcstring be_const_str_count;
|
||||
extern const bcstring be_const_str_counters;
|
||||
extern const bcstring be_const_str_create_custom_widget;
|
||||
extern const bcstring be_const_str_create_matrix;
|
||||
extern const bcstring be_const_str_create_segment;
|
||||
extern const bcstring be_const_str_ctor;
|
||||
extern const bcstring be_const_str_ctypes_bytes;
|
||||
extern const bcstring be_const_str_ctypes_bytes_dyn;
|
||||
extern const bcstring be_const_str_dac_voltage;
|
||||
extern const bcstring be_const_str_day;
|
||||
extern const bcstring be_const_str_debug;
|
||||
extern const bcstring be_const_str_decompress;
|
||||
extern const bcstring be_const_str_decrypt;
|
||||
extern const bcstring be_const_str_def;
|
||||
extern const bcstring be_const_str_deg;
|
||||
extern const bcstring be_const_str_deinit;
|
||||
extern const bcstring be_const_str_del;
|
||||
extern const bcstring be_const_str_delay;
|
||||
extern const bcstring be_const_str_delete_all_configs;
|
||||
extern const bcstring be_const_str_depower;
|
||||
extern const bcstring be_const_str_deregister_obj;
|
||||
extern const bcstring be_const_str_destructor_cb;
|
||||
extern const bcstring be_const_str_detect;
|
||||
extern const bcstring be_const_str_detected_X20on_X20bus;
|
||||
extern const bcstring be_const_str_digital_read;
|
||||
extern const bcstring be_const_str_digital_write;
|
||||
extern const bcstring be_const_str_dirty;
|
||||
extern const bcstring be_const_str_display;
|
||||
extern const bcstring be_const_str_display_X2Eini;
|
||||
extern const bcstring be_const_str_do;
|
||||
extern const bcstring be_const_str_draw_arc;
|
||||
extern const bcstring be_const_str_draw_line;
|
||||
extern const bcstring be_const_str_draw_line_dsc;
|
||||
extern const bcstring be_const_str_draw_line_dsc_init;
|
||||
extern const bcstring be_const_str_due;
|
||||
extern const bcstring be_const_str_dump;
|
||||
extern const bcstring be_const_str_duration;
|
||||
extern const bcstring be_const_str_editable;
|
||||
extern const bcstring be_const_str_elif;
|
||||
extern const bcstring be_const_str_else;
|
||||
extern const bcstring be_const_str_enabled;
|
||||
extern const bcstring be_const_str_encrypt;
|
||||
extern const bcstring be_const_str_end;
|
||||
extern const bcstring be_const_str_energy_struct;
|
||||
extern const bcstring be_const_str_engine;
|
||||
extern const bcstring be_const_str_erase;
|
||||
extern const bcstring be_const_str_escape;
|
||||
extern const bcstring be_const_str_eth;
|
||||
extern const bcstring be_const_str_event;
|
||||
extern const bcstring be_const_str_event_cb;
|
||||
extern const bcstring be_const_str_event_send;
|
||||
extern const bcstring be_const_str_every_100ms;
|
||||
extern const bcstring be_const_str_every_50ms;
|
||||
extern const bcstring be_const_str_every_second;
|
||||
extern const bcstring be_const_str_except;
|
||||
extern const bcstring be_const_str_exec_cmd;
|
||||
extern const bcstring be_const_str_exec_rules;
|
||||
extern const bcstring be_const_str_exec_tele;
|
||||
extern const bcstring be_const_str_exists;
|
||||
extern const bcstring be_const_str_exp;
|
||||
extern const bcstring be_const_str_f;
|
||||
extern const bcstring be_const_str_false;
|
||||
extern const bcstring be_const_str_file;
|
||||
extern const bcstring be_const_str_file_X20extension_X20is_X20not_X20_X27_X2Ebe_X27_X20or_X20_X27_X2Ebec_X27;
|
||||
extern const bcstring be_const_str_files;
|
||||
extern const bcstring be_const_str_find;
|
||||
extern const bcstring be_const_str_find_key_i;
|
||||
extern const bcstring be_const_str_find_op;
|
||||
extern const bcstring be_const_str_finish;
|
||||
extern const bcstring be_const_str_floor;
|
||||
extern const bcstring be_const_str_flush;
|
||||
extern const bcstring be_const_str_for;
|
||||
extern const bcstring be_const_str_format;
|
||||
extern const bcstring be_const_str_from_to;
|
||||
extern const bcstring be_const_str_fromb64;
|
||||
extern const bcstring be_const_str_fromptr;
|
||||
extern const bcstring be_const_str_fromstring;
|
||||
extern const bcstring be_const_str_function;
|
||||
extern const bcstring be_const_str_gamma;
|
||||
extern const bcstring be_const_str_gamma10;
|
||||
extern const bcstring be_const_str_gamma8;
|
||||
extern const bcstring be_const_str_gc;
|
||||
extern const bcstring be_const_str_gen_cb;
|
||||
extern const bcstring be_const_str_get;
|
||||
extern const bcstring be_const_str_get_alternate;
|
||||
extern const bcstring be_const_str_get_aps_voltage;
|
||||
extern const bcstring be_const_str_get_bat_charge_current;
|
||||
extern const bcstring be_const_str_get_bat_current;
|
||||
extern const bcstring be_const_str_get_bat_power;
|
||||
extern const bcstring be_const_str_get_bat_voltage;
|
||||
extern const bcstring be_const_str_get_battery_chargin_status;
|
||||
extern const bcstring be_const_str_get_bri;
|
||||
extern const bcstring be_const_str_get_cb_list;
|
||||
extern const bcstring be_const_str_get_coords;
|
||||
extern const bcstring be_const_str_get_current_module_name;
|
||||
extern const bcstring be_const_str_get_current_module_path;
|
||||
extern const bcstring be_const_str_get_free_heap;
|
||||
extern const bcstring be_const_str_get_height;
|
||||
extern const bcstring be_const_str_get_input_power_status;
|
||||
extern const bcstring be_const_str_get_light;
|
||||
extern const bcstring be_const_str_get_object_from_ptr;
|
||||
extern const bcstring be_const_str_get_option;
|
||||
extern const bcstring be_const_str_get_percentage;
|
||||
extern const bcstring be_const_str_get_pixel_color;
|
||||
extern const bcstring be_const_str_get_power;
|
||||
extern const bcstring be_const_str_get_size;
|
||||
extern const bcstring be_const_str_get_string;
|
||||
extern const bcstring be_const_str_get_style_bg_color;
|
||||
extern const bcstring be_const_str_get_style_line_color;
|
||||
extern const bcstring be_const_str_get_style_pad_right;
|
||||
extern const bcstring be_const_str_get_switch;
|
||||
extern const bcstring be_const_str_get_tasmota;
|
||||
extern const bcstring be_const_str_get_temp;
|
||||
extern const bcstring be_const_str_get_vbus_current;
|
||||
extern const bcstring be_const_str_get_vbus_voltage;
|
||||
extern const bcstring be_const_str_get_warning_level;
|
||||
extern const bcstring be_const_str_get_width;
|
||||
extern const bcstring be_const_str_getbits;
|
||||
extern const bcstring be_const_str_geti;
|
||||
extern const bcstring be_const_str_global;
|
||||
extern const bcstring be_const_str_gpio;
|
||||
extern const bcstring be_const_str_group_def;
|
||||
extern const bcstring be_const_str_h;
|
||||
extern const bcstring be_const_str_has;
|
||||
extern const bcstring be_const_str_has_arg;
|
||||
extern const bcstring be_const_str_height_def;
|
||||
extern const bcstring be_const_str_hex;
|
||||
extern const bcstring be_const_str_hour;
|
||||
extern const bcstring be_const_str_hs2rgb;
|
||||
extern const bcstring be_const_str_https_X3A_X2F_X2Fraw_X2Egithubusercontent_X2Ecom_X2Ftasmota_X2Fautoconf_X2Fmain_X2F_X25s_X2F_X25s_X2Eautoconf;
|
||||
extern const bcstring be_const_str_https_X3A_X2F_X2Fraw_X2Egithubusercontent_X2Ecom_X2Ftasmota_X2Fautoconf_X2Fmain_X2F_X25s_manifest_X2Ejson;
|
||||
extern const bcstring be_const_str_i2c_enabled;
|
||||
extern const bcstring be_const_str_id;
|
||||
extern const bcstring be_const_str_if;
|
||||
extern const bcstring be_const_str_imax;
|
||||
extern const bcstring be_const_str_imin;
|
||||
extern const bcstring be_const_str_import;
|
||||
extern const bcstring be_const_str_init;
|
||||
extern const bcstring be_const_str_init_draw_line_dsc;
|
||||
extern const bcstring be_const_str_input;
|
||||
extern const bcstring be_const_str_ins_goto;
|
||||
extern const bcstring be_const_str_ins_ramp;
|
||||
extern const bcstring be_const_str_ins_time;
|
||||
extern const bcstring be_const_str_insert;
|
||||
extern const bcstring be_const_str_instance;
|
||||
extern const bcstring be_const_str_instance_size;
|
||||
extern const bcstring be_const_str_int;
|
||||
extern const bcstring be_const_str_internal_error;
|
||||
extern const bcstring be_const_str_introspect;
|
||||
extern const bcstring be_const_str_invalidate;
|
||||
extern const bcstring be_const_str_io_error;
|
||||
extern const bcstring be_const_str_ip;
|
||||
extern const bcstring be_const_str_is_dirty;
|
||||
extern const bcstring be_const_str_is_first_time;
|
||||
extern const bcstring be_const_str_is_running;
|
||||
extern const bcstring be_const_str_isinstance;
|
||||
extern const bcstring be_const_str_isnan;
|
||||
extern const bcstring be_const_str_isrunning;
|
||||
extern const bcstring be_const_str_issubclass;
|
||||
extern const bcstring be_const_str_item;
|
||||
extern const bcstring be_const_str_iter;
|
||||
extern const bcstring be_const_str_json;
|
||||
extern const bcstring be_const_str_json_append;
|
||||
extern const bcstring be_const_str_json_fdump;
|
||||
extern const bcstring be_const_str_json_fdump_any;
|
||||
extern const bcstring be_const_str_json_fdump_list;
|
||||
extern const bcstring be_const_str_json_fdump_map;
|
||||
extern const bcstring be_const_str_k;
|
||||
extern const bcstring be_const_str_keys;
|
||||
extern const bcstring be_const_str_kv;
|
||||
extern const bcstring be_const_str_last_modified;
|
||||
extern const bcstring be_const_str_leds;
|
||||
extern const bcstring be_const_str_length_X20in_X20bits_X20must_X20be_X20between_X200_X20and_X2032;
|
||||
extern const bcstring be_const_str_light;
|
||||
extern const bcstring be_const_str_line_dsc;
|
||||
extern const bcstring be_const_str_list;
|
||||
extern const bcstring be_const_str_listdir;
|
||||
extern const bcstring be_const_str_load;
|
||||
extern const bcstring be_const_str_load_templates;
|
||||
extern const bcstring be_const_str_local;
|
||||
extern const bcstring be_const_str_log;
|
||||
extern const bcstring be_const_str_log10;
|
||||
extern const bcstring be_const_str_loop;
|
||||
extern const bcstring be_const_str_lower;
|
||||
extern const bcstring be_const_str_lv;
|
||||
extern const bcstring be_const_str_lv_event;
|
||||
extern const bcstring be_const_str_lv_event_cb;
|
||||
extern const bcstring be_const_str_lv_obj;
|
||||
extern const bcstring be_const_str_lv_obj_class;
|
||||
extern const bcstring be_const_str_lvgl_event_dispatch;
|
||||
extern const bcstring be_const_str_map;
|
||||
extern const bcstring be_const_str_math;
|
||||
extern const bcstring be_const_str_matrix;
|
||||
extern const bcstring be_const_str_member;
|
||||
extern const bcstring be_const_str_members;
|
||||
extern const bcstring be_const_str_memory;
|
||||
extern const bcstring be_const_str_millis;
|
||||
extern const bcstring be_const_str_min;
|
||||
extern const bcstring be_const_str_minute;
|
||||
extern const bcstring be_const_str_module;
|
||||
extern const bcstring be_const_str_month;
|
||||
extern const bcstring be_const_str_name;
|
||||
extern const bcstring be_const_str_nan;
|
||||
extern const bcstring be_const_str_nil;
|
||||
extern const bcstring be_const_str_no_X20GPIO_X20specified_X20for_X20neopixelbus;
|
||||
extern const bcstring be_const_str_null_cb;
|
||||
extern const bcstring be_const_str_number;
|
||||
extern const bcstring be_const_str_obj_class_create_obj;
|
||||
extern const bcstring be_const_str_obj_event_base;
|
||||
extern const bcstring be_const_str_offset;
|
||||
extern const bcstring be_const_str_offseta;
|
||||
extern const bcstring be_const_str_on;
|
||||
extern const bcstring be_const_str_onsubmit_X3D_X27return_X20confirm_X28_X22This_X20will_X20cause_X20a_X20restart_X2E_X22_X29_X3B_X27_X3E;
|
||||
extern const bcstring be_const_str_onsubmit_X3D_X27return_X20confirm_X28_X22This_X20will_X20change_X20the_X20current_X20configuration_X20and_X20cause_X20a_X20restart_X2E_X22_X29_X3B_X27_X3E;
|
||||
extern const bcstring be_const_str_open;
|
||||
extern const bcstring be_const_str_out_X20of_X20range;
|
||||
extern const bcstring be_const_str_p1;
|
||||
extern const bcstring be_const_str_p2;
|
||||
extern const bcstring be_const_str_page_autoconf_ctl;
|
||||
extern const bcstring be_const_str_page_autoconf_mgr;
|
||||
extern const bcstring be_const_str_param;
|
||||
extern const bcstring be_const_str_path;
|
||||
extern const bcstring be_const_str_pc;
|
||||
extern const bcstring be_const_str_pc_abs;
|
||||
extern const bcstring be_const_str_pc_rel;
|
||||
extern const bcstring be_const_str_percentage;
|
||||
extern const bcstring be_const_str_persist;
|
||||
extern const bcstring be_const_str_persist_X2E_p_X20is_X20not_X20a_X20map;
|
||||
extern const bcstring be_const_str_pi;
|
||||
extern const bcstring be_const_str_pin;
|
||||
extern const bcstring be_const_str_pin_mode;
|
||||
extern const bcstring be_const_str_pin_used;
|
||||
extern const bcstring be_const_str_pixel_count;
|
||||
extern const bcstring be_const_str_pixel_size;
|
||||
extern const bcstring be_const_str_pixels_buffer;
|
||||
extern const bcstring be_const_str_point;
|
||||
extern const bcstring be_const_str_pop;
|
||||
extern const bcstring be_const_str_pop_path;
|
||||
extern const bcstring be_const_str_pow;
|
||||
extern const bcstring be_const_str_preinit;
|
||||
extern const bcstring be_const_str_print;
|
||||
extern const bcstring be_const_str_public_key;
|
||||
extern const bcstring be_const_str_publish;
|
||||
extern const bcstring be_const_str_publish_result;
|
||||
extern const bcstring be_const_str_push;
|
||||
extern const bcstring be_const_str_push_path;
|
||||
extern const bcstring be_const_str_quality;
|
||||
extern const bcstring be_const_str_r;
|
||||
extern const bcstring be_const_str_rad;
|
||||
extern const bcstring be_const_str_raise;
|
||||
extern const bcstring be_const_str_rand;
|
||||
extern const bcstring be_const_str_range;
|
||||
extern const bcstring be_const_str_read;
|
||||
extern const bcstring be_const_str_read12;
|
||||
extern const bcstring be_const_str_read13;
|
||||
extern const bcstring be_const_str_read24;
|
||||
extern const bcstring be_const_str_read32;
|
||||
extern const bcstring be_const_str_read8;
|
||||
extern const bcstring be_const_str_read_bytes;
|
||||
extern const bcstring be_const_str_read_sensors;
|
||||
extern const bcstring be_const_str_readbytes;
|
||||
extern const bcstring be_const_str_readline;
|
||||
extern const bcstring be_const_str_real;
|
||||
extern const bcstring be_const_str_reapply;
|
||||
extern const bcstring be_const_str_redirect;
|
||||
extern const bcstring be_const_str_reduce;
|
||||
extern const bcstring be_const_str_refr_size;
|
||||
extern const bcstring be_const_str_register_obj;
|
||||
extern const bcstring be_const_str_remove;
|
||||
extern const bcstring be_const_str_remove_cmd;
|
||||
extern const bcstring be_const_str_remove_driver;
|
||||
extern const bcstring be_const_str_remove_rule;
|
||||
extern const bcstring be_const_str_remove_timer;
|
||||
extern const bcstring be_const_str_reset;
|
||||
extern const bcstring be_const_str_reset_search;
|
||||
extern const bcstring be_const_str_resize;
|
||||
extern const bcstring be_const_str_resolvecmnd;
|
||||
extern const bcstring be_const_str_resp_cmnd;
|
||||
extern const bcstring be_const_str_resp_cmnd_done;
|
||||
extern const bcstring be_const_str_resp_cmnd_error;
|
||||
extern const bcstring be_const_str_resp_cmnd_failed;
|
||||
extern const bcstring be_const_str_resp_cmnd_str;
|
||||
extern const bcstring be_const_str_response_append;
|
||||
extern const bcstring be_const_str_return;
|
||||
extern const bcstring be_const_str_return_X20code_X3D_X25i;
|
||||
extern const bcstring be_const_str_reverse;
|
||||
extern const bcstring be_const_str_reverse_gamma10;
|
||||
extern const bcstring be_const_str_rotate;
|
||||
extern const bcstring be_const_str_round_end;
|
||||
extern const bcstring be_const_str_round_start;
|
||||
extern const bcstring be_const_str_rtc;
|
||||
extern const bcstring be_const_str_rule;
|
||||
extern const bcstring be_const_str_run;
|
||||
extern const bcstring be_const_str_run_bat;
|
||||
extern const bcstring be_const_str_run_deferred;
|
||||
extern const bcstring be_const_str_running;
|
||||
extern const bcstring be_const_str_save;
|
||||
extern const bcstring be_const_str_save_before_restart;
|
||||
extern const bcstring be_const_str_scale_uint;
|
||||
extern const bcstring be_const_str_scan;
|
||||
extern const bcstring be_const_str_search;
|
||||
extern const bcstring be_const_str_sec;
|
||||
extern const bcstring be_const_str_seg7_font;
|
||||
extern const bcstring be_const_str_select;
|
||||
extern const bcstring be_const_str_serial;
|
||||
extern const bcstring be_const_str_set;
|
||||
extern const bcstring be_const_str_set_alternate;
|
||||
extern const bcstring be_const_str_set_auth;
|
||||
extern const bcstring be_const_str_set_bri;
|
||||
extern const bcstring be_const_str_set_chg_current;
|
||||
extern const bcstring be_const_str_set_dc_voltage;
|
||||
extern const bcstring be_const_str_set_dcdc_enable;
|
||||
extern const bcstring be_const_str_set_first_time;
|
||||
extern const bcstring be_const_str_set_height;
|
||||
extern const bcstring be_const_str_set_ldo_enable;
|
||||
extern const bcstring be_const_str_set_ldo_voltage;
|
||||
extern const bcstring be_const_str_set_light;
|
||||
extern const bcstring be_const_str_set_matrix_pixel_color;
|
||||
extern const bcstring be_const_str_set_percentage;
|
||||
extern const bcstring be_const_str_set_pixel_color;
|
||||
extern const bcstring be_const_str_set_power;
|
||||
extern const bcstring be_const_str_set_style_bg_color;
|
||||
extern const bcstring be_const_str_set_style_line_color;
|
||||
extern const bcstring be_const_str_set_style_pad_right;
|
||||
extern const bcstring be_const_str_set_style_text_font;
|
||||
extern const bcstring be_const_str_set_text;
|
||||
extern const bcstring be_const_str_set_time;
|
||||
extern const bcstring be_const_str_set_timeouts;
|
||||
extern const bcstring be_const_str_set_timer;
|
||||
extern const bcstring be_const_str_set_useragent;
|
||||
extern const bcstring be_const_str_set_width;
|
||||
extern const bcstring be_const_str_set_x;
|
||||
extern const bcstring be_const_str_set_y;
|
||||
extern const bcstring be_const_str_setbits;
|
||||
extern const bcstring be_const_str_seti;
|
||||
extern const bcstring be_const_str_setitem;
|
||||
extern const bcstring be_const_str_setmember;
|
||||
extern const bcstring be_const_str_setrange;
|
||||
extern const bcstring be_const_str_settings;
|
||||
extern const bcstring be_const_str_shared_key;
|
||||
extern const bcstring be_const_str_show;
|
||||
extern const bcstring be_const_str_sin;
|
||||
extern const bcstring be_const_str_sinh;
|
||||
extern const bcstring be_const_str_size;
|
||||
extern const bcstring be_const_str_skip;
|
||||
extern const bcstring be_const_str_solidified;
|
||||
extern const bcstring be_const_str_split;
|
||||
extern const bcstring be_const_str_sqrt;
|
||||
extern const bcstring be_const_str_srand;
|
||||
extern const bcstring be_const_str_start;
|
||||
extern const bcstring be_const_str_state;
|
||||
extern const bcstring be_const_str_static;
|
||||
extern const bcstring be_const_str_stop;
|
||||
extern const bcstring be_const_str_stop_iteration;
|
||||
extern const bcstring be_const_str_str;
|
||||
extern const bcstring be_const_str_strftime;
|
||||
extern const bcstring be_const_str_string;
|
||||
extern const bcstring be_const_str_strip;
|
||||
extern const bcstring be_const_str_strptime;
|
||||
extern const bcstring be_const_str_super;
|
||||
extern const bcstring be_const_str_sys;
|
||||
extern const bcstring be_const_str_tag;
|
||||
extern const bcstring be_const_str_tan;
|
||||
extern const bcstring be_const_str_tanh;
|
||||
extern const bcstring be_const_str_target;
|
||||
extern const bcstring be_const_str_target_search;
|
||||
extern const bcstring be_const_str_tasmota;
|
||||
extern const bcstring be_const_str_tasmota_X2Eget_light_X28_X29_X20is_X20deprecated_X2C_X20use_X20light_X2Eget_X28_X29;
|
||||
extern const bcstring be_const_str_tasmota_X2Eset_light_X28_X29_X20is_X20deprecated_X2C_X20use_X20light_X2Eset_X28_X29;
|
||||
extern const bcstring be_const_str_tcpclient;
|
||||
extern const bcstring be_const_str_tele;
|
||||
extern const bcstring be_const_str_the_X20second_X20argument_X20is_X20not_X20a_X20function;
|
||||
extern const bcstring be_const_str_time_dump;
|
||||
extern const bcstring be_const_str_time_reached;
|
||||
extern const bcstring be_const_str_time_str;
|
||||
extern const bcstring be_const_str_to_gamma;
|
||||
extern const bcstring be_const_str_tob64;
|
||||
extern const bcstring be_const_str_tolower;
|
||||
extern const bcstring be_const_str_tomap;
|
||||
extern const bcstring be_const_str_top;
|
||||
extern const bcstring be_const_str_toptr;
|
||||
extern const bcstring be_const_str_tostring;
|
||||
extern const bcstring be_const_str_toupper;
|
||||
extern const bcstring be_const_str_tr;
|
||||
extern const bcstring be_const_str_traceback;
|
||||
extern const bcstring be_const_str_true;
|
||||
extern const bcstring be_const_str_try;
|
||||
extern const bcstring be_const_str_try_rule;
|
||||
extern const bcstring be_const_str_type;
|
||||
extern const bcstring be_const_str_unknown_X20instruction;
|
||||
extern const bcstring be_const_str_update;
|
||||
extern const bcstring be_const_str_upper;
|
||||
extern const bcstring be_const_str_url_encode;
|
||||
extern const bcstring be_const_str_v;
|
||||
extern const bcstring be_const_str_value;
|
||||
extern const bcstring be_const_str_value_error;
|
||||
extern const bcstring be_const_str_valuer_error;
|
||||
extern const bcstring be_const_str_var;
|
||||
extern const bcstring be_const_str_w;
|
||||
extern const bcstring be_const_str_wd;
|
||||
extern const bcstring be_const_str_web_add_button;
|
||||
extern const bcstring be_const_str_web_add_config_button;
|
||||
extern const bcstring be_const_str_web_add_console_button;
|
||||
extern const bcstring be_const_str_web_add_handler;
|
||||
extern const bcstring be_const_str_web_add_main_button;
|
||||
extern const bcstring be_const_str_web_add_management_button;
|
||||
extern const bcstring be_const_str_web_send;
|
||||
extern const bcstring be_const_str_web_send_decimal;
|
||||
extern const bcstring be_const_str_web_sensor;
|
||||
extern const bcstring be_const_str_webclient;
|
||||
extern const bcstring be_const_str_webserver;
|
||||
extern const bcstring be_const_str_while;
|
||||
extern const bcstring be_const_str_widget_cb;
|
||||
extern const bcstring be_const_str_widget_constructor;
|
||||
extern const bcstring be_const_str_widget_ctor_cb;
|
||||
extern const bcstring be_const_str_widget_ctor_impl;
|
||||
extern const bcstring be_const_str_widget_destructor;
|
||||
extern const bcstring be_const_str_widget_dtor_cb;
|
||||
extern const bcstring be_const_str_widget_dtor_impl;
|
||||
extern const bcstring be_const_str_widget_editable;
|
||||
extern const bcstring be_const_str_widget_event;
|
||||
extern const bcstring be_const_str_widget_event_cb;
|
||||
extern const bcstring be_const_str_widget_event_impl;
|
||||
extern const bcstring be_const_str_widget_group_def;
|
||||
extern const bcstring be_const_str_widget_height_def;
|
||||
extern const bcstring be_const_str_widget_instance_size;
|
||||
extern const bcstring be_const_str_widget_struct_by_class;
|
||||
extern const bcstring be_const_str_widget_struct_default;
|
||||
extern const bcstring be_const_str_widget_width_def;
|
||||
extern const bcstring be_const_str_width;
|
||||
extern const bcstring be_const_str_width_def;
|
||||
extern const bcstring be_const_str_wifi;
|
||||
extern const bcstring be_const_str_wire;
|
||||
extern const bcstring be_const_str_wire1;
|
||||
extern const bcstring be_const_str_wire2;
|
||||
extern const bcstring be_const_str_wire_scan;
|
||||
extern const bcstring be_const_str_write;
|
||||
extern const bcstring be_const_str_write8;
|
||||
extern const bcstring be_const_str_write_bit;
|
||||
extern const bcstring be_const_str_write_bytes;
|
||||
extern const bcstring be_const_str_write_file;
|
||||
extern const bcstring be_const_str_write_gpio;
|
||||
extern const bcstring be_const_str_x;
|
||||
extern const bcstring be_const_str_x1;
|
||||
extern const bcstring be_const_str_y;
|
||||
extern const bcstring be_const_str_y1;
|
||||
extern const bcstring be_const_str_year;
|
||||
extern const bcstring be_const_str_yield;
|
||||
extern const bcstring be_const_str_zero;
|
||||
extern const bcstring be_const_str_zip;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_aes_gcm_map) {
|
||||
{ be_const_key(encrypt, 4), be_const_func(m_aes_gcm_encryt) },
|
||||
{ be_const_key(_X2Ep2, -1), be_const_var(0) },
|
||||
{ be_const_key(decrypt, -1), be_const_func(m_aes_gcm_decryt) },
|
||||
{ be_const_key(init, -1), be_const_func(m_aes_gcm_init) },
|
||||
{ be_const_key(_X2Ep1, -1), be_const_var(1) },
|
||||
{ be_const_key(tag, -1), be_const_func(m_aes_gcm_tag) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_aes_gcm_map,
|
||||
6
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_aes_gcm,
|
||||
2,
|
||||
NULL,
|
||||
AES_GCM
|
||||
);
|
|
@ -0,0 +1,17 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_file_source_map) {
|
||||
{ be_const_key(_X2Ep, -1), be_const_var(0) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_file_source_map,
|
||||
1
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_file_source,
|
||||
1,
|
||||
NULL,
|
||||
AudioFileSource
|
||||
);
|
|
@ -0,0 +1,18 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_file_source_fs_map) {
|
||||
{ be_const_key(deinit, -1), be_const_func(i2s_file_source_fs_deinit) },
|
||||
{ be_const_key(init, -1), be_const_func(i2s_file_source_fs_init) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_file_source_fs_map,
|
||||
2
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_file_source_fs,
|
||||
0,
|
||||
(bclass *)&be_class_audio_file_source,
|
||||
AudioFileSourceFS
|
||||
);
|
|
@ -0,0 +1,17 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_generator_map) {
|
||||
{ be_const_key(_X2Ep, -1), be_const_var(0) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_generator_map,
|
||||
1
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_generator,
|
||||
1,
|
||||
NULL,
|
||||
AudioGenerator
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_generator_mp3_map) {
|
||||
{ be_const_key(begin, -1), be_const_func(i2s_generator_mp3_begin) },
|
||||
{ be_const_key(loop, -1), be_const_func(i2s_generator_mp3_loop) },
|
||||
{ be_const_key(isrunning, -1), be_const_func(i2s_generator_mp3_isrunning) },
|
||||
{ be_const_key(init, 1), be_const_func(i2s_generator_mp3_init) },
|
||||
{ be_const_key(deinit, -1), be_const_func(i2s_generator_mp3_deinit) },
|
||||
{ be_const_key(stop, -1), be_const_func(i2s_generator_mp3_stop) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_generator_mp3_map,
|
||||
6
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_generator_mp3,
|
||||
0,
|
||||
(bclass *)&be_class_audio_generator,
|
||||
AudioGeneratorMP3
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_generator_wav_map) {
|
||||
{ be_const_key(begin, -1), be_const_func(i2s_generator_wav_begin) },
|
||||
{ be_const_key(loop, -1), be_const_func(i2s_generator_wav_loop) },
|
||||
{ be_const_key(isrunning, -1), be_const_func(i2s_generator_wav_isrunning) },
|
||||
{ be_const_key(init, 1), be_const_func(i2s_generator_wav_init) },
|
||||
{ be_const_key(deinit, -1), be_const_func(i2s_generator_wav_deinit) },
|
||||
{ be_const_key(stop, -1), be_const_func(i2s_generator_wav_stop) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_generator_wav_map,
|
||||
6
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_generator_wav,
|
||||
0,
|
||||
(bclass *)&be_class_audio_generator,
|
||||
AudioGeneratorWAV
|
||||
);
|
|
@ -0,0 +1,17 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_output_map) {
|
||||
{ be_const_key(_X2Ep, -1), be_const_var(0) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_output_map,
|
||||
1
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_output,
|
||||
1,
|
||||
NULL,
|
||||
AudioOutput
|
||||
);
|
|
@ -0,0 +1,19 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_audio_output_i2s_map) {
|
||||
{ be_const_key(init, -1), be_const_func(i2s_output_i2s_init) },
|
||||
{ be_const_key(deinit, -1), be_const_func(i2s_output_i2s_deinit) },
|
||||
{ be_const_key(stop, -1), be_const_func(i2s_output_i2s_stop) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_audio_output_i2s_map,
|
||||
3
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_audio_output_i2s,
|
||||
0,
|
||||
(bclass *)&be_class_audio_output,
|
||||
AudioOutputI2S
|
||||
);
|
|
@ -0,0 +1,44 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_bytes_map) {
|
||||
{ be_const_key(setitem, -1), be_const_func(m_setitem) },
|
||||
{ be_const_key(_X2E_X2E, -1), be_const_func(m_connect) },
|
||||
{ be_const_key(geti, -1), be_const_func(m_geti) },
|
||||
{ be_const_key(deinit, -1), be_const_func(m_deinit) },
|
||||
{ be_const_key(add, 18), be_const_func(m_add) },
|
||||
{ be_const_key(get, -1), be_const_func(m_getu) },
|
||||
{ be_const_key(asstring, 9), be_const_func(m_asstring) },
|
||||
{ be_const_key(_X2Ep, -1), be_const_var(0) },
|
||||
{ be_const_key(copy, 25), be_const_func(m_copy) },
|
||||
{ be_const_key(size, -1), be_const_func(m_size) },
|
||||
{ be_const_key(getbits, -1), be_const_closure(getbits_closure) },
|
||||
{ be_const_key(_X3D_X3D, -1), be_const_func(m_equal) },
|
||||
{ be_const_key(tob64, 3), be_const_func(m_tob64) },
|
||||
{ be_const_key(init, -1), be_const_func(m_init) },
|
||||
{ be_const_key(_X2B, -1), be_const_func(m_merge) },
|
||||
{ be_const_key(setbits, -1), be_const_closure(setbits_closure) },
|
||||
{ be_const_key(_buffer, -1), be_const_func(m_buffer) },
|
||||
{ be_const_key(tostring, -1), be_const_func(m_tostring) },
|
||||
{ be_const_key(_X2Elen, -1), be_const_var(1) },
|
||||
{ be_const_key(fromb64, 13), be_const_func(m_fromb64) },
|
||||
{ be_const_key(_X2Esize, 6), be_const_var(2) },
|
||||
{ be_const_key(resize, -1), be_const_func(m_resize) },
|
||||
{ be_const_key(seti, -1), be_const_func(m_set) },
|
||||
{ be_const_key(_X21_X3D, 5), be_const_func(m_nequal) },
|
||||
{ be_const_key(item, -1), be_const_func(m_item) },
|
||||
{ be_const_key(fromstring, -1), be_const_func(m_fromstring) },
|
||||
{ be_const_key(clear, 24), be_const_func(m_clear) },
|
||||
{ be_const_key(set, 10), be_const_func(m_set) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_bytes_map,
|
||||
28
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_bytes,
|
||||
3,
|
||||
NULL,
|
||||
bytes
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_ctypes_map) {
|
||||
{ be_const_key(_def, 5), be_const_nil() },
|
||||
{ be_const_key(setmember, 0), be_const_func(be_ctypes_setmember) },
|
||||
{ be_const_key(copy, -1), be_const_func(be_ctypes_copy) },
|
||||
{ be_const_key(init, -1), be_const_func(be_ctypes_init) },
|
||||
{ be_const_key(tomap, -1), be_const_func(be_ctypes_tomap) },
|
||||
{ be_const_key(member, -1), be_const_func(be_ctypes_member) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_ctypes_map,
|
||||
6
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_ctypes,
|
||||
0,
|
||||
(bclass *)&be_class_bytes,
|
||||
ctypes_bytes
|
||||
);
|
|
@ -0,0 +1,18 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(be_class_ctypes_dyn_map) {
|
||||
{ be_const_key(_def, -1), be_const_var(0) },
|
||||
{ be_const_key(init, 0), be_const_func(be_ctypes_dyn_init) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
be_class_ctypes_dyn_map,
|
||||
2
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_class(
|
||||
be_class_ctypes_dyn,
|
||||
1,
|
||||
(bclass *)&be_class_ctypes,
|
||||
ctypes_bytes_dyn
|
||||
);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue