Skip to content

Commit

Permalink
Merge branch 'feature/add_knob_ext1_wakeup_v2.0' into 'release/v2.0'
Browse files Browse the repository at this point in the history
feat: add knob ext1_wakeup mode (v2.0)

See merge request ae_group/esp-iot-solution!1144
  • Loading branch information
leeebo committed Nov 15, 2024
2 parents c10f1a0 + 4a6fc0b commit e9fb383
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ The registered components in ESP-IoT-Solution are listed below:
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem/versions/0.2.1) | [![0.2.1](https://img.shields.io/badge/Beta-0.2.1-yellow)](https://components.espressif.com/components/espressif/iot_usbh_modem/versions/0.2.1) |
| [ir_learn](https://components.espressif.com/components/espressif/ir_learn/versions/0.2.0) | [![0.2.0](https://img.shields.io/badge/Beta-0.2.0-yellow)](https://components.espressif.com/components/espressif/ir_learn/versions/0.2.0) |
| [keyboard_button](https://components.espressif.com/components/espressif/keyboard_button/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/keyboard_button/versions/1.0.0) |
| [knob](https://components.espressif.com/components/espressif/knob/versions/0.1.5) | [![0.1.5](https://img.shields.io/badge/Beta-0.1.5-yellow)](https://components.espressif.com/components/espressif/knob/versions/0.1.5) |
| [knob](https://components.espressif.com/components/espressif/knob/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/knob/versions/1.0.0) |
| [led_indicator](https://components.espressif.com/components/espressif/led_indicator/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/led_indicator/versions/1.0.0) |
| [lightbulb_driver](https://components.espressif.com/components/espressif/lightbulb_driver/versions/1.3.3) | [![1.3.3](https://img.shields.io/badge/Stable-1.3.3-blue)](https://components.espressif.com/components/espressif/lightbulb_driver/versions/1.3.3) |
| [ntc_driver](https://components.espressif.com/components/espressif/ntc_driver/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/ntc_driver/versions/1.0.0) |
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ESP-IoT-Solution 中注册的组件如下:
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem/versions/0.2.1) | [![0.2.1](https://img.shields.io/badge/Beta-0.2.1-yellow)](https://components.espressif.com/components/espressif/iot_usbh_modem/versions/0.2.1) |
| [ir_learn](https://components.espressif.com/components/espressif/ir_learn/versions/0.2.0) | [![0.2.0](https://img.shields.io/badge/Beta-0.2.0-yellow)](https://components.espressif.com/components/espressif/ir_learn/versions/0.2.0) |
| [keyboard_button](https://components.espressif.com/components/espressif/keyboard_button/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/keyboard_button/versions/1.0.0) |
| [knob](https://components.espressif.com/components/espressif/knob/versions/0.1.5) | [![0.1.5](https://img.shields.io/badge/Beta-0.1.5-yellow)](https://components.espressif.com/components/espressif/knob/versions/0.1.5) |
| [knob](https://components.espressif.com/components/espressif/knob/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/knob/versions/1.0.0) |
| [led_indicator](https://components.espressif.com/components/espressif/led_indicator/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/led_indicator/versions/1.0.0) |
| [lightbulb_driver](https://components.espressif.com/components/espressif/lightbulb_driver/versions/1.3.3) | [![1.3.3](https://img.shields.io/badge/Stable-1.3.3-blue)](https://components.espressif.com/components/espressif/lightbulb_driver/versions/1.3.3) |
| [ntc_driver](https://components.espressif.com/components/espressif/ntc_driver/versions/1.0.0) | [![1.0.0](https://img.shields.io/badge/Stable-1.0.0-blue)](https://components.espressif.com/components/espressif/ntc_driver/versions/1.0.0) |
Expand Down
15 changes: 9 additions & 6 deletions components/knob/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# ChangeLog

## v1.0.0 - 2024-9-26

* Add ext1_wakeup mode for Knob when define CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y

## v0.1.5 - 2024-7-3

### Enhancements:
### Enhancements:

* Support power save mode

## v0.1.4 - 2023-11-23
Expand All @@ -11,7 +16,7 @@

## v0.1.3 - 2023-6-2

### Enhancements:
### Enhancements:

* Add power on knob position detection to avoid logical inversion caused by knob position
* Change test to test_apps project
Expand All @@ -34,10 +39,9 @@
### Enhancements:

* Initial version

* The following types of events are supported

| EVENT | 描述 |
| EVENT | 描述 |
| ---------- | -------------------------------------- |
| KNOB_LEFT | EVENT: Rotate to the left |
| KNOB_RIGHT | EVENT: Rotate to the right |
Expand All @@ -46,5 +50,4 @@
| KNOB_ZERO | EVENT: Count back to 0 |

* Support for defining multiple knobs

* Support binding callback functions for each event and adding user-data
* Support binding callback functions for each event and adding user-data
4 changes: 2 additions & 2 deletions components/knob/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: "0.1.5"
description: Knob driver implemented through software quadrature decoding.
version: "1.0.0"
description: Knob driver implemented through software pcnt
url: https://github.com/espressif/esp-iot-solution/tree/master/components/knob
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/input_device/knob.html
issues: https://github.com/espressif/esp-iot-solution/issues
Expand Down
35 changes: 34 additions & 1 deletion components/knob/knob_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,53 @@ esp_err_t knob_gpio_wake_up_control(uint32_t gpio_num, uint8_t wake_up_level, bo
{
esp_err_t ret;
if (enable) {
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
#if SOC_PM_SUPPORT_EXT1_WAKEUP
ret = esp_sleep_enable_ext1_wakeup_io((1ULL << gpio_num), wake_up_level == 0 ? ESP_EXT1_WAKEUP_ANY_LOW : ESP_EXT1_WAKEUP_ANY_HIGH);
#else
/*!< Not support etc: esp32c2, esp32c3. Target must support ext1 wakeup */
ret = ESP_FAIL;
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "Target must support ext1 wakeup");
#endif
#endif
/* Enable wake up from GPIO */
ret = gpio_wakeup_enable(gpio_num, wake_up_level == 0 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL);
} else {
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
#if SOC_PM_SUPPORT_EXT1_WAKEUP
ret = esp_sleep_disable_ext1_wakeup_io(1ULL << gpio_num);
#endif
#endif
ret = gpio_wakeup_disable(gpio_num);
}
return ret;
}

esp_err_t knob_gpio_wake_up_init(uint32_t gpio_num, uint8_t wake_up_level)
{
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
if (!esp_sleep_is_valid_wakeup_gpio(gpio_num)) {
ESP_LOGE(TAG, "GPIO %ld is not a valid wakeup source under CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP",
gpio_num);
return ESP_FAIL;
}
gpio_hold_en(gpio_num);
#endif
/* Enable wake up from GPIO */
esp_err_t ret = gpio_wakeup_enable(gpio_num, wake_up_level == 0 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL);
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "Enable gpio wakeup failed");

#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
#if SOC_PM_SUPPORT_EXT1_WAKEUP
ret = esp_sleep_enable_ext1_wakeup_io((1ULL << gpio_num), wake_up_level == 0 ? ESP_EXT1_WAKEUP_ANY_LOW : ESP_EXT1_WAKEUP_ANY_HIGH);
#else
/*!< Not support etc: esp32c2, esp32c3. Target must support ext1 wakeup */
ret = ESP_FAIL;
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "Target must support ext1 wakeup");
#endif
#else
ret = esp_sleep_enable_gpio_wakeup();
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "esp sleep enable gpio wakeup failed");

#endif
return ESP_OK;
}

0 comments on commit e9fb383

Please sign in to comment.