mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 21:26:33 +00:00
Berry option to invert serial (#20707)
This commit is contained in:
parent
238013ba90
commit
710ed2e42c
@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Internal support for persistent JSON settings using single file
|
- Internal support for persistent JSON settings using single file
|
||||||
- Command ``SetOption158`` to publish or suppress ModbusReceived MQTT messages (#20678)
|
- Command ``SetOption158`` to publish or suppress ModbusReceived MQTT messages (#20678)
|
||||||
- ESP32 Core3 support for SPI ethernet on DM9051, W5500 and KSZ8851
|
- ESP32 Core3 support for SPI ethernet on DM9051, W5500 and KSZ8851
|
||||||
|
- Berry option to invert serial
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
- ESP32 LVGL library from v8.3.11 to v9.0.0, some small breaking changes in C, none in HASPmota (#20659)
|
- ESP32 LVGL library from v8.3.11 to v9.0.0, some small breaking changes in C, none in HASPmota (#20659)
|
||||||
|
@ -26,10 +26,7 @@
|
|||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Native functions mapped to Berry functions
|
* Native functions mapped to Berry functions
|
||||||
*
|
*
|
||||||
* import wire
|
* `ser = serial(4, 5, 9600, serial.SERIAL_7E1)`
|
||||||
*
|
|
||||||
* wire.get_free_heap() -> int
|
|
||||||
*
|
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
TasmotaSerial * b_serial_get(struct bvm *vm) {
|
TasmotaSerial * b_serial_get(struct bvm *vm) {
|
||||||
@ -39,7 +36,7 @@ extern "C" {
|
|||||||
return ow;
|
return ow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berry: `init(rx_gpio:int, tx_gpio:int, speed:int [, config:int])`
|
// Berry: `init(rx_gpio:int, tx_gpio:int, speed:int [, config:int, inverted:bool])`
|
||||||
int32_t b_serial_init(struct bvm *vm);
|
int32_t b_serial_init(struct bvm *vm);
|
||||||
int32_t b_serial_init(struct bvm *vm) {
|
int32_t b_serial_init(struct bvm *vm) {
|
||||||
int32_t argc = be_top(vm); // Get the number of arguments
|
int32_t argc = be_top(vm); // Get the number of arguments
|
||||||
@ -48,10 +45,14 @@ extern "C" {
|
|||||||
int32_t tx = be_toint(vm, 3);
|
int32_t tx = be_toint(vm, 3);
|
||||||
int32_t speed = be_toint(vm, 4);
|
int32_t speed = be_toint(vm, 4);
|
||||||
int32_t mode = SERIAL_8N1;
|
int32_t mode = SERIAL_8N1;
|
||||||
|
bool inverted = false;
|
||||||
if (argc >= 5 && be_isint(vm, 5)) {
|
if (argc >= 5 && be_isint(vm, 5)) {
|
||||||
mode = be_toint(vm, 5);
|
mode = be_toint(vm, 5);
|
||||||
}
|
}
|
||||||
TasmotaSerial * ser = new TasmotaSerial(rx, tx);
|
if (argc >= 6 && be_isbool(vm, 6)) {
|
||||||
|
inverted = be_tobool(vm, 6);
|
||||||
|
}
|
||||||
|
TasmotaSerial * ser = new TasmotaSerial(rx, tx, 0, 0, TM_SERIAL_BUFFER_SIZE, inverted);
|
||||||
bool ok = ser->begin(speed, mode);
|
bool ok = ser->begin(speed, mode);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
delete ser;
|
delete ser;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user