diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2e9d1d1..654c974aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ 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` +- Berry `gpio.get_pin_type` and `gpio.ger_pin_type_index` - Berry `gpio.read_pwm` and `gpio.read_pwm_resolution` (#20414) ### Breaking Changed diff --git a/lib/libesp32/berry_tasmota/src/be_gpio_lib.c b/lib/libesp32/berry_tasmota/src/be_gpio_lib.c index 0b10ca866..1742e2baf 100644 --- a/lib/libesp32/berry_tasmota/src/be_gpio_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_gpio_lib.c @@ -22,6 +22,9 @@ extern int gp_counter_add(bvm *vm); extern int gp_pin_used(bvm *vm); extern int gp_pin(bvm *vm); +extern int gp_get_pin(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_pin, "i", "i"); +extern int gp_get_pin_index(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp_get_pin_index, "i", "i"); + // 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]"); @@ -33,6 +36,8 @@ module gpio (scope: global) { member, func(gp_member) pin_mode, func(gp_pin_mode) + get_pin_type, ctype_func(gp_get_pin) + get_pin_type_index, ctype_func(gp_get_pin_index) digital_write, func(gp_digital_write) digital_read, func(gp_digital_read) dac_voltage, func(gp_dac_voltage) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino index e76f70432..c36dc3c00 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino @@ -324,8 +324,25 @@ extern "C" { } 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"); + + // gpio.get_pin_type(phy_gpio:int) -> int + // + // Get the type configured for physical GPIO + // Return 0 if GPIO is not configured + extern int gp_get_pin(int32_t pin); + extern int gp_get_pin(int32_t pin) { + return GetPin(pin) / 32; + } + + // gpio.get_pin_type_index(phy_gpio:int) -> int + // + // Get the sub-index for the type configured for physical GPIO + // Return 0 if GPIO is not configured + extern int gp_get_pin_index(int32_t pin); + extern int gp_get_pin_index(int32_t pin) { + return GetPin(pin) % 32; + } + } #endif // USE_BERRY