mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of https://github.com/arendst/Tasmota into development
This commit is contained in:
commit
4e361538bc
|
@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Berry add support for `tcpclientasync` in `tcpserver` (#20401)
|
||||
- Berry add `tasmota.urlbecload(url:string) -> bool` (#20412)
|
||||
- GPIO Viewer to see realtime GPIO states. Enable with define USE_GPIO_VIEWER
|
||||
- Berry `gpio.read_pwm` and `gpio.read_pwm_resolution`
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
|
|
@ -342,6 +342,17 @@ uint8_t ledcReadResolution(uint8_t chan) {
|
|||
return res;
|
||||
}
|
||||
|
||||
// Version of ledcRead that works for both Core2 and Core3
|
||||
// Return -1 if pin is not configured as PWM
|
||||
int32_t ledcRead2(uint8_t pin) {
|
||||
int32_t chan = analogGetChannel2(pin);
|
||||
if (chan >= 0) {
|
||||
uint8_t group=(chan/8), channel=(chan%8);
|
||||
return ledc_get_duty((ledc_mode_t)group, (ledc_channel_t)channel);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// void analogWrite(uint8_t pin, int val);
|
||||
extern "C" void __wrap__Z11analogWritehi(uint8_t pin, int val) {
|
||||
analogWritePhase(pin, val, 0); // if unspecified, use phase = 0
|
||||
|
|
|
@ -98,6 +98,12 @@ void analogWrite(uint8_t pin, int val);
|
|||
// Extended version that also allows to change phase
|
||||
extern void analogWritePhase(uint8_t pin, uint32_t duty, uint32_t phase = 0);
|
||||
|
||||
//
|
||||
// ledcRead2 - read the value of PWM
|
||||
//
|
||||
// return -1 if pin is not assigned to ledc
|
||||
int32_t ledcRead2(uint8_t pin);
|
||||
|
||||
// return the channel assigned to a GPIO, or -1 if none
|
||||
extern int32_t analogGetChannel2(uint32_t pin);
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ extern int gp_pin(bvm *vm);
|
|||
// esp_err_tledc_set_duty_and_update(ledc_mode_tspeed_mode, ledc_channel_tchannel, uint32_t duty, uint32_t hpoint)
|
||||
extern void gp_set_duty(int32_t pin, int32_t duty, int32_t hpoint); BE_FUNC_CTYPE_DECLARE(gp_set_duty, "", "ii[i]");
|
||||
|
||||
extern int gp_get_duty(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty, "i", "i");
|
||||
extern int gp_get_duty_resolution(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty_resolution, "i", "i");
|
||||
|
||||
/* @const_object_info_begin
|
||||
module gpio (scope: global) {
|
||||
|
@ -42,6 +44,8 @@ module gpio (scope: global) {
|
|||
pin, func(gp_pin)
|
||||
|
||||
set_pwm, ctype_func(gp_set_duty)
|
||||
read_pwm, ctype_func(gp_get_duty)
|
||||
read_pwm_resolution, ctype_func(gp_get_duty_resolution)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "be_fixed_gpio.h"
|
||||
|
|
|
@ -30,6 +30,9 @@ const be_const_member_t lv_gpio_constants[] = {
|
|||
{ "AZ_RXD", (int32_t) GPIO_AZ_RXD },
|
||||
{ "AZ_TXD", (int32_t) GPIO_AZ_TXD },
|
||||
{ "BACKLIGHT", (int32_t) GPIO_BACKLIGHT },
|
||||
{ "BIOPDU_BIT", (int32_t) GPIO_BIOPDU_BIT },
|
||||
{ "BIOPDU_PZEM016_RX", (int32_t) GPIO_BIOPDU_PZEM016_RX },
|
||||
{ "BIOPDU_PZEM0XX_TX", (int32_t) GPIO_BIOPDU_PZEM0XX_TX },
|
||||
{ "BL0939_RX", (int32_t) GPIO_BL0939_RX },
|
||||
{ "BL0940_RX", (int32_t) GPIO_BL0940_RX },
|
||||
{ "BL0942_RX", (int32_t) GPIO_BL0942_RX },
|
||||
|
@ -65,6 +68,7 @@ const be_const_member_t lv_gpio_constants[] = {
|
|||
{ "DHT11_OUT", (int32_t) GPIO_DHT11_OUT },
|
||||
{ "DHT22", (int32_t) GPIO_DHT22 },
|
||||
{ "DI", (int32_t) GPIO_DI },
|
||||
{ "DINGTIAN_OE", (int32_t) GPIO_DINGTIAN_OE },
|
||||
{ "DSB", (int32_t) GPIO_DSB },
|
||||
{ "DSB_OUT", (int32_t) GPIO_DSB_OUT },
|
||||
{ "DYP_RX", (int32_t) GPIO_DYP_RX },
|
||||
|
@ -79,10 +83,13 @@ const be_const_member_t lv_gpio_constants[] = {
|
|||
{ "FALLING", FALLING },
|
||||
{ "FLOWRATEMETER_SIGNAL", (int32_t) GPIO_FLOWRATEMETER_IN },
|
||||
{ "FTC532", (int32_t) GPIO_FTC532 },
|
||||
{ "GM861_TX", (int32_t) GPIO_GM861_RX },
|
||||
{ "GPIO_INPUT", (int32_t) GPIO_INPUT },
|
||||
{ "GPS_RX", (int32_t) GPIO_GPS_RX },
|
||||
{ "GPS_TX", (int32_t) GPIO_GPS_TX },
|
||||
{ "HALLEFFECT", (int32_t) GPIO_HALLEFFECT },
|
||||
{ "HC8_RXD", (int32_t) GPIO_HC8_RXD },
|
||||
{ "HDMI_CEC", (int32_t) GPIO_HDMI_CEC },
|
||||
{ "HEARTBEAT", (int32_t) GPIO_HEARTBEAT },
|
||||
{ "HEARTBEAT_INV", (int32_t) GPIO_HEARTBEAT_INV },
|
||||
{ "HIGH", HIGH },
|
||||
|
@ -137,12 +144,15 @@ const be_const_member_t lv_gpio_constants[] = {
|
|||
{ "LEDLNK_INV", (int32_t) GPIO_LEDLNK_INV },
|
||||
{ "LMT01", (int32_t) GPIO_LMT01 },
|
||||
{ "LOW", LOW },
|
||||
{ "LOX_O2_RX", (int32_t) GPIO_LOX_O2_RX },
|
||||
{ "MAGIC_SWITCH", (int32_t) GPIO_MAGIC_SWITCH },
|
||||
{ "MAX31855CLK", (int32_t) GPIO_MAX31855CLK },
|
||||
{ "MAX31855CS", (int32_t) GPIO_MAX31855CS },
|
||||
{ "MAX31855DO", (int32_t) GPIO_MAX31855DO },
|
||||
{ "MAX7219CLK", (int32_t) GPIO_MAX7219CLK },
|
||||
{ "MAX7219CS", (int32_t) GPIO_MAX7219CS },
|
||||
{ "MAX7219DIN", (int32_t) GPIO_MAX7219DIN },
|
||||
{ "MAX_GPIO", (int32_t) MAX_GPIO_PIN },
|
||||
{ "MAX_RMT", MAX_RMT },
|
||||
{ "MBR_RX", (int32_t) GPIO_MBR_RX },
|
||||
{ "MBR_TX", (int32_t) GPIO_MBR_TX },
|
||||
|
@ -293,10 +303,10 @@ const be_const_member_t lv_gpio_constants[] = {
|
|||
{ "TM1638CLK", (int32_t) GPIO_TM1638CLK },
|
||||
{ "TM1638DIO", (int32_t) GPIO_TM1638DIO },
|
||||
{ "TM1638STB", (int32_t) GPIO_TM1638STB },
|
||||
{ "TUYA_RX", (int32_t) GPIO_TUYA_RX },
|
||||
{ "TUYA_TX", (int32_t) GPIO_TUYA_TX },
|
||||
{ "TUYAMCUBR_RX", (int32_t) GPIO_TUYAMCUBR_RX },
|
||||
{ "TUYAMCUBR_TX", (int32_t) GPIO_TUYAMCUBR_TX },
|
||||
{ "TUYA_RX", (int32_t) GPIO_TUYA_RX },
|
||||
{ "TUYA_TX", (int32_t) GPIO_TUYA_TX },
|
||||
{ "TX2X_TXD_BLACK", (int32_t) GPIO_TX2X_TXD_BLACK },
|
||||
{ "TXD", (int32_t) GPIO_TXD },
|
||||
{ "VINDRIKTNING_RX", (int32_t) GPIO_VINDRIKTNING_RX },
|
||||
|
|
|
@ -302,6 +302,30 @@ extern "C" {
|
|||
int gp_counter_add(bvm *vm) {
|
||||
return gp_counter_set_add(vm, true);
|
||||
}
|
||||
|
||||
// gpio.get_duty(pin:int) -> int
|
||||
//
|
||||
// Read the value of a PWM within resolution
|
||||
// Returns -1 if pin is not a PWM pin
|
||||
int gp_get_duty(int32_t pin);
|
||||
int gp_get_duty(int32_t pin) {
|
||||
return ledcRead2(pin);
|
||||
}
|
||||
|
||||
// gpio.get_duty_resolution(pin:int) -> int
|
||||
//
|
||||
// Read the resolution of a PWM
|
||||
// Returns -1 if pin is not a PWM pin
|
||||
int gp_get_duty_resolution(int32_t pin);
|
||||
int gp_get_duty_resolution(int32_t pin) {
|
||||
int32_t channel = analogGetChannel2(pin);
|
||||
if (channel >= 0) {
|
||||
return (1 << ledcReadResolution(channel));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
// extern void gp_get_duty(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty, "i", "i");
|
||||
// extern void gp_get_duty_resolution(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_duty_resolution, "i", "i");
|
||||
}
|
||||
|
||||
#endif // USE_BERRY
|
||||
|
|
|
@ -19,6 +19,8 @@ CHANGE
|
|||
|
||||
MAX_RMT
|
||||
|
||||
MAX_GPIO = MAX_GPIO_PIN
|
||||
|
||||
NONE = GPIO_NONE
|
||||
KEY1 = GPIO_KEY1
|
||||
KEY1_NP = GPIO_KEY1_NP
|
||||
|
@ -333,5 +335,11 @@ BIOPDU_PZEM0XX_TX = GPIO_BIOPDU_PZEM0XX_TX
|
|||
BIOPDU_PZEM016_RX = GPIO_BIOPDU_PZEM016_RX
|
||||
BIOPDU_BIT = GPIO_BIOPDU_BIT
|
||||
LOX_O2_RX = GPIO_LOX_O2_RX
|
||||
GM861_TX = GPIO_GM861_RX
|
||||
DINGTIAN_OE = GPIO_DINGTIAN_OE
|
||||
HDMI_CEC = GPIO_HDMI_CEC
|
||||
HC8_RXD = GPIO_HC8_RXD
|
||||
I2S_DAC = GPIO_I2S_DAC
|
||||
MAGIC_SWITCH = GPIO_MAGIC_SWITCH
|
||||
|
||||
SENSOR_END = GPIO_SENSOR_END
|
||||
|
|
Loading…
Reference in New Issue