Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Berry gpio.get_pin_type and gpio.ger_pin_type_index #20415

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/libesp32/berry_tasmota/src/be_gpio_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]");

Expand All @@ -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)
Expand Down
21 changes: 19 additions & 2 deletions tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_gpio.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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