Skip to content

Commit c6ea906

Browse files
committed
Merge branch 'feat/fan_rainmaker_supports_reset_factory' into 'master'
feat(bldc_fan): support resetting RainMaker by long-pressing the start button See merge request ae_group/esp-iot-solution!1411
2 parents 7706ced + d321d3c commit c6ea906

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

examples/motor/bldc_fan_rainmaker/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ The `bldc_fan_rainmaker` example connects a brushless motor-driven fan to the ES
2121
* Overcurrent, over/under-voltage protection [feature]
2222
* Phase loss protection [feature]
2323

24-
* [esp_rainmaker](https://components.espressif.com/components/espressif/esp_rainmaker) is a complete and lightweight AIoT solution that enables private cloud deployment for your business in a simple, cost-effective, and efficient manner.
24+
* [esp_rainmaker](https://components.espressif.com/components/espressif/esp_rainmaker) is a complete and lightweight AIoT solution that enables private cloud deployment for your business in a simple, cost-effective, and efficient manner.
25+
26+
## Hardware Overview
27+
28+
You can click [here](https://dl.espressif.com/AE/esp-iot-solution/bldc_fan_rainmaker_sch.pdf) to download the hardware schematic. By using the corresponding buttons, you can control the fan's start and stop, rotate the stepper motor, enable natural wind mode, and reset Rainmaker.

examples/motor/bldc_fan_rainmaker/main/Kconfig.projbuild

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,28 @@ menu "ESP RainMaker App Wi-Fi Provisioning"
6464
Provisioning Name Prefix.
6565

6666
endmenu
67+
68+
menu "Example Configuration"
69+
70+
config FAN_RAINMAKER_LONG_PRESS_RESET_SECONDS
71+
int "Long press reset timeout (seconds)"
72+
default 5
73+
range 3 15
74+
help
75+
Set the duration in seconds for long press to reset RainMaker configuration.
76+
77+
config FAN_RAINMAKER_RESET_SECONDS
78+
int "RainMaker reset timeout (seconds)"
79+
default 3
80+
range 2 10
81+
help
82+
Set the timeout in seconds for RainMaker reset operation.
83+
84+
config FAN_RAINMAKER_REBOOT_SECONDS
85+
int "RainMaker reboot timeout (seconds)"
86+
default 3
87+
range 2 10
88+
help
89+
Set the timeout in seconds for RainMaker reboot operation.
90+
91+
endmenu

examples/motor/bldc_fan_rainmaker/main/app/include/app_rainmaker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "esp_err.h"
1010
#include "esp_rmaker_core.h"
11+
#include "esp_rmaker_utils.h"
1112

1213
#ifdef __cplusplus
1314
extern "C" {

examples/motor/bldc_fan_rainmaker/main/hal/hal_fan_button.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -106,6 +106,11 @@ static void hal_fan_button_signle_click_cb(void *arg, void *data)
106106
}
107107
}
108108

109+
static void hal_fan_button_long_press_hold_cb(void *arg, void *data)
110+
{
111+
ESP_ERROR_CHECK(esp_rmaker_factory_reset(CONFIG_FAN_RAINMAKER_RESET_SECONDS, CONFIG_FAN_RAINMAKER_REBOOT_SECONDS));
112+
}
113+
109114
static void hal_fan_oneshot_timer_cb(void *arg)
110115
{
111116
ESP_LOGI(TAG, "Count is over");
@@ -134,7 +139,7 @@ esp_err_t hal_fan_button_init(gpio_num_t start_pin, gpio_num_t mode_pin, gpio_nu
134139

135140
button_config_t cfg = {
136141
.type = BUTTON_TYPE_GPIO,
137-
.long_press_time = 5000,
142+
.long_press_time = CONFIG_FAN_RAINMAKER_LONG_PRESS_RESET_SECONDS * 1000,
138143
.short_press_time = 200,
139144
.gpio_button_config = {
140145
.gpio_num = pin[0],
@@ -148,6 +153,8 @@ esp_err_t hal_fan_button_init(gpio_num_t start_pin, gpio_num_t mode_pin, gpio_nu
148153
iot_button_register_cb(hal_fan_button_handle[i], BUTTON_SINGLE_CLICK, hal_fan_button_signle_click_cb, NULL);
149154
}
150155

156+
iot_button_register_cb(hal_fan_button_handle[SETTING_START], BUTTON_LONG_PRESS_HOLD, hal_fan_button_long_press_hold_cb, NULL); /*!< Support reset rainmaker */
157+
151158
hal_fan_button.fan_timing_count = 0;
152159
const esp_timer_create_args_t oneshot_timer_args = {
153160
.callback = &hal_fan_oneshot_timer_cb,

0 commit comments

Comments
 (0)