From 08f9b37b9975782c09387bf5859bad94cd36d1c1 Mon Sep 17 00:00:00 2001 From: Christian Baars Date: Tue, 7 May 2024 09:36:39 +0200 Subject: [PATCH] Berry add gpio.set_freq() (#21375) --- lib/libesp32/berry_tasmota/src/be_gpio_lib.c | 2 ++ tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/libesp32/berry_tasmota/src/be_gpio_lib.c b/lib/libesp32/berry_tasmota/src/be_gpio_lib.c index 1742e2baf..362647cc9 100644 --- a/lib/libesp32/berry_tasmota/src/be_gpio_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_gpio_lib.c @@ -27,6 +27,7 @@ extern int gp_get_pin_index(int32_t pin); BE_FUNC_CTYPE_DECLARE(gp // 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 void gp_set_frequency(int32_t pin, int32_t frequency); BE_FUNC_CTYPE_DECLARE(gp_set_frequency, "", "ii"); 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"); @@ -49,6 +50,7 @@ module gpio (scope: global) { pin, func(gp_pin) set_pwm, ctype_func(gp_set_duty) + set_pwm_freq, ctype_func(gp_set_frequency) read_pwm, ctype_func(gp_get_duty) read_pwm_resolution, ctype_func(gp_get_duty_resolution) } 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 c36dc3c00..cb222d808 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino @@ -241,6 +241,10 @@ extern "C" { analogWritePhase(pin, duty, hpoint); } + void gp_set_frequency(int32_t pin, int32_t frequency) { + analogWriteFreq(frequency, pin); + } + // gpio.counter_read(counter:int) -> int or nil // // Read counter value, or return nil if counter is not used