Skip to content

Commit 39b3308

Browse files
committed
kconfig: update configuration definitions
1 parent f5dbcc3 commit 39b3308

File tree

9 files changed

+135
-133
lines changed

9 files changed

+135
-133
lines changed

main/Kconfig.projbuild

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config BT_NAME
77
help
88
Bluetooth name exposed by the device.
99

10-
config ENABLE_BLE_IF
10+
config ENABLE_BLE_CONTROL_IF
1111
bool "Enable BLE Control Interface"
1212
default y
1313
help
@@ -46,10 +46,10 @@ menu "Fan Configuration"
4646
config FAN_IN_PIN
4747
int "Fan In Pin"
4848
default 27
49-
endmenu
49+
endmenu
5050

5151
menu "Key Configuration"
52-
config ENABLE_EC
52+
config ENABLE_ENCODER
5353
bool "Enable Encoder"
5454
default y
5555
help
@@ -58,7 +58,7 @@ config ENABLE_EC
5858
choice EC_TYPE
5959
prompt "Encoder Type"
6060
default EC_TYPE_1P2D
61-
depends on ENABLE_EC
61+
depends on ENABLE_ENCODER
6262
help
6363
Select the encoder type.
6464

@@ -71,76 +71,76 @@ endchoice
7171
config EC_PHASE_A_PIN
7272
int "Encoder Phase A Pin"
7373
default 21
74-
depends on ENABLE_EC
74+
depends on ENABLE_ENCODER
7575

7676
config EC_PHASE_B_PIN
7777
int "Encoder Phase B Pin"
7878
default 22
79-
depends on ENABLE_EC
79+
depends on ENABLE_ENCODER
8080

8181
config EC_BUTTON_PIN
8282
int "Encoder Button Pin"
8383
default 32
84-
depends on ENABLE_EC
84+
depends on ENABLE_ENCODER
8585

86-
config ENABLE_PWR_KEY
87-
bool "Enable Power Key"
86+
config ENABLE_POWER_MODE_KEY
87+
bool "Enable Power Mode Key"
8888
default y
8989
depends on ENABLE_QC
9090
help
91-
Select this to enable Power Key.
91+
Select this to enable Power Mode Key.
9292

93-
config PWR_KEY_HOLD_TIME
94-
int "Power Key Hold Time (ms)"
93+
config POWER_MODE_KEY_HOLD_TIME
94+
int "Power Mode Key Hold Time (ms)"
9595
default 50
96-
depends on ENABLE_PWR_KEY
96+
depends on ENABLE_POWER_MODE_KEY
9797

98-
choice PWR_KEY_ACTIVE_LEVEL
99-
prompt "Power Key Active Level"
100-
default PWR_KEY_ACTIVE_LOW
101-
depends on ENABLE_PWR_KEY
98+
choice POWER_MODE_KEY_ACTIVE_LEVEL
99+
prompt "Power Mode Key Active Level"
100+
default POWER_MODE_KEY_ACTIVE_LOW
101+
depends on ENABLE_POWER_MODE_KEY
102102
help
103-
Select Power Key Active Level.
103+
Select Power Mode Key Active Level.
104104

105-
config PWR_KEY_ACTIVE_HIGH
105+
config POWER_MODE_KEY_ACTIVE_HIGH
106106
bool "Active High"
107-
config PWR_KEY_ACTIVE_LOW
107+
config POWER_MODE_KEY_ACTIVE_LOW
108108
bool "Active Low"
109109
endchoice
110110

111-
config PWR_KEY_PIN
112-
int "Power Key Pin"
111+
config POWER_MODE_KEY_PIN
112+
int "Power Mode Key Pin"
113113
default 0
114-
depends on ENABLE_PWR_KEY
114+
depends on ENABLE_POWER_MODE_KEY
115115

116-
config ENABLE_SLP_KEY
116+
config ENABLE_SLEEP_KEY
117117
bool "Enable Sleep Key"
118118
default y
119119
help
120120
Select this to enable Sleep Key.
121121

122-
config SLP_KEY_HOLD_TIME
122+
config SLEEP_KEY_HOLD_TIME
123123
int "Sleep Key Hold Time (ms)"
124124
default 50
125-
depends on ENABLE_SLP_KEY
125+
depends on ENABLE_SLEEP_KEY
126126

127-
choice SLP_KEY_ACTIVE_LEVEL
127+
choice SLEEP_KEY_ACTIVE_LEVEL
128128
prompt "Sleep Key Active Level"
129-
default SLP_KEY_ACTIVE_LOW
130-
depends on ENABLE_SLP_KEY
129+
default SLEEP_KEY_ACTIVE_LOW
130+
depends on ENABLE_SLEEP_KEY
131131
help
132132
Select Sleep Key Active Level.
133133

134-
config SLP_KEY_ACTIVE_HIGH
134+
config SLEEP_KEY_ACTIVE_HIGH
135135
bool "Active High"
136-
config SLP_KEY_ACTIVE_LOW
136+
config SLEEP_KEY_ACTIVE_LOW
137137
bool "Active Low"
138138
endchoice
139139

140-
config SLP_KEY_PIN
140+
config SLEEP_KEY_PIN
141141
int "Sleep Key Pin"
142142
default 35
143-
depends on ENABLE_SLP_KEY
143+
depends on ENABLE_SLEEP_KEY
144144
endmenu
145145

146146
menu "GUI Configuration"

main/inc/user/key_handle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef INC_USER_KEY_HANDLE_H_
99
#define INC_USER_KEY_HANDLE_H_
1010

11-
extern void pwr_key_handle(void);
12-
extern void slp_key_handle(void);
11+
extern void power_mode_key_handle(void);
12+
extern void sleep_key_handle(void);
1313

1414
#endif /* INC_USER_KEY_HANDLE_H_ */

main/src/app_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ static void board_init(void)
5454

5555
static void user_init(void)
5656
{
57-
#ifdef CONFIG_ENABLE_EC
57+
#ifdef CONFIG_ENABLE_ENCODER
5858
ec_init();
5959
#endif
6060

61-
#if defined(CONFIG_ENABLE_PWR_KEY) || defined(CONFIG_ENABLE_SLP_KEY)
61+
#if defined(CONFIG_ENABLE_POWER_MODE_KEY) || defined(CONFIG_ENABLE_SLEEP_KEY)
6262
key_init();
6363
#endif
6464

@@ -76,7 +76,7 @@ static void user_init(void)
7676
led_init();
7777
#endif
7878

79-
#ifdef CONFIG_ENABLE_BLE_IF
79+
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
8080
ble_app_init();
8181
#endif
8282
}

main/src/chip/bt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const char *bt_dev_address = NULL;
1818

1919
void bt_init(void)
2020
{
21+
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
2122
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
2223

2324
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
@@ -28,11 +29,10 @@ void bt_init(void)
2829

2930
bt_dev_address = (const char *)esp_bt_dev_get_address();
3031

31-
ESP_LOGI(TAG, "initialized, bt: 0, ble: %d",
32-
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
33-
1
32+
ESP_LOGI(TAG, "initialized, bt: 0, ble: 1");
3433
#else
35-
0
34+
ESP_ERROR_CHECK(esp_bt_mem_release(ESP_BT_MODE_BTDM));
35+
36+
ESP_LOGI(TAG, "initialized, bt: 0, ble: 0");
3637
#endif
37-
);
3838
}

main/src/core/os.c

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
EventGroupHandle_t user_event_group;
2222

23-
#if defined(CONFIG_ENABLE_SLP_KEY) || defined(CONFIG_ENABLE_BLE_IF)
23+
#if defined(CONFIG_ENABLE_SLEEP_KEY) || defined(CONFIG_ENABLE_BLE_CONTROL_IF)
2424
static EventBits_t sleep_wait_bits = 0;
2525
static EventBits_t reset_wait_bits = 0;
2626

@@ -37,43 +37,52 @@ static void os_pwr_task_handle(void *pvParameters)
3737
portMAX_DELAY
3838
);
3939

40-
ESP_LOGW(OS_PWR_TAG, "waiting for unfinished jobs....");
41-
vTaskDelay(500 / portTICK_RATE_MS);
42-
4340
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
4441
if (uxBits & OS_PWR_SLEEP_BIT) {
45-
xEventGroupWaitBits(
46-
user_event_group,
47-
sleep_wait_bits,
48-
pdFALSE,
49-
pdTRUE,
50-
portMAX_DELAY
51-
);
52-
53-
#ifdef CONFIG_ENABLE_SLP_KEY
42+
if (sleep_wait_bits) {
43+
ESP_LOGW(OS_PWR_TAG, "waiting for unfinished jobs....");
44+
45+
vTaskDelay(500 / portTICK_RATE_MS);
46+
47+
xEventGroupWaitBits(
48+
user_event_group,
49+
sleep_wait_bits,
50+
pdFALSE,
51+
pdTRUE,
52+
portMAX_DELAY
53+
);
54+
}
55+
56+
#ifdef CONFIG_ENABLE_SLEEP_KEY
5457
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
55-
rtc_gpio_set_direction(CONFIG_SLP_KEY_PIN, RTC_GPIO_MODE_INPUT_ONLY);
56-
#ifdef CONFIG_SLP_KEY_ACTIVE_LOW
57-
rtc_gpio_pulldown_dis(CONFIG_SLP_KEY_PIN);
58-
rtc_gpio_pullup_en(CONFIG_SLP_KEY_PIN);
59-
esp_sleep_enable_ext1_wakeup(1ULL << CONFIG_SLP_KEY_PIN, ESP_EXT1_WAKEUP_ALL_LOW);
58+
rtc_gpio_set_direction(CONFIG_SLEEP_KEY_PIN, RTC_GPIO_MODE_INPUT_ONLY);
59+
#ifdef CONFIG_SLEEP_KEY_ACTIVE_LOW
60+
rtc_gpio_pulldown_dis(CONFIG_SLEEP_KEY_PIN);
61+
rtc_gpio_pullup_en(CONFIG_SLEEP_KEY_PIN);
62+
esp_sleep_enable_ext1_wakeup(1ULL << CONFIG_SLEEP_KEY_PIN, ESP_EXT1_WAKEUP_ALL_LOW);
6063
#else
61-
rtc_gpio_pullup_dis(CONFIG_SLP_KEY_PIN);
62-
rtc_gpio_pulldown_en(CONFIG_SLP_KEY_PIN);
63-
esp_sleep_enable_ext1_wakeup(1ULL << CONFIG_SLP_KEY_PIN, ESP_EXT1_WAKEUP_ANY_HIGH);
64+
rtc_gpio_pullup_dis(CONFIG_SLEEP_KEY_PIN);
65+
rtc_gpio_pulldown_en(CONFIG_SLEEP_KEY_PIN);
66+
esp_sleep_enable_ext1_wakeup(1ULL << CONFIG_SLEEP_KEY_PIN, ESP_EXT1_WAKEUP_ANY_HIGH);
6467
#endif
6568
#endif
6669

6770
ESP_LOGW(OS_PWR_TAG, "sleep now");
6871
esp_deep_sleep_start();
6972
} else if (uxBits & OS_PWR_RESET_BIT) {
70-
xEventGroupWaitBits(
71-
user_event_group,
72-
reset_wait_bits,
73-
pdFALSE,
74-
pdTRUE,
75-
portMAX_DELAY
76-
);
73+
if (reset_wait_bits) {
74+
ESP_LOGW(OS_PWR_TAG, "waiting for unfinished jobs....");
75+
76+
vTaskDelay(500 / portTICK_RATE_MS);
77+
78+
xEventGroupWaitBits(
79+
user_event_group,
80+
reset_wait_bits,
81+
pdFALSE,
82+
pdTRUE,
83+
portMAX_DELAY
84+
);
85+
}
7786

7887
ESP_LOGW(OS_PWR_TAG, "reset now");
7988
esp_restart();
@@ -83,53 +92,46 @@ static void os_pwr_task_handle(void *pvParameters)
8392

8493
void os_pwr_sleep_wait(EventBits_t bits)
8594
{
86-
if (bits) {
87-
sleep_wait_bits = bits;
88-
xEventGroupSetBits(user_event_group, OS_PWR_SLEEP_BIT);
89-
} else {
90-
#ifdef CONFIG_ENABLE_SLP_KEY
91-
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
92-
rtc_gpio_set_direction(CONFIG_SLP_KEY_PIN, RTC_GPIO_MODE_INPUT_ONLY);
93-
#ifdef CONFIG_SLP_KEY_ACTIVE_LOW
94-
rtc_gpio_pulldown_dis(CONFIG_SLP_KEY_PIN);
95-
rtc_gpio_pullup_en(CONFIG_SLP_KEY_PIN);
96-
esp_sleep_enable_ext1_wakeup(1ULL << CONFIG_SLP_KEY_PIN, ESP_EXT1_WAKEUP_ALL_LOW);
97-
#else
98-
rtc_gpio_pullup_dis(CONFIG_SLP_KEY_PIN);
99-
rtc_gpio_pulldown_en(CONFIG_SLP_KEY_PIN);
100-
esp_sleep_enable_ext1_wakeup(1ULL << CONFIG_SLP_KEY_PIN, ESP_EXT1_WAKEUP_ANY_HIGH);
101-
#endif
102-
#endif
103-
ESP_LOGW(OS_PWR_TAG, "sleep now");
104-
esp_deep_sleep_start();
105-
}
95+
sleep_wait_bits = bits;
96+
xEventGroupSetBits(user_event_group, OS_PWR_SLEEP_BIT);
10697
}
10798

10899
void os_pwr_reset_wait(EventBits_t bits)
109100
{
110-
if (bits) {
111-
reset_wait_bits = bits;
112-
xEventGroupSetBits(user_event_group, OS_PWR_RESET_BIT);
113-
} else {
114-
ESP_LOGW(OS_PWR_TAG, "reset now");
115-
esp_restart();
116-
}
101+
reset_wait_bits = bits;
102+
xEventGroupSetBits(user_event_group, OS_PWR_RESET_BIT);
117103
}
118104
#endif
119105

120106
void os_init(void)
121107
{
122108
user_event_group = xEventGroupCreate();
123109

124-
#ifdef CONFIG_ENABLE_SLP_KEY
110+
#if defined(CONFIG_ENABLE_SLEEP_KEY) || defined(CONFIG_ENABLE_BLE_CONTROL_IF)
111+
xTaskCreatePinnedToCore(os_pwr_task_handle, "osPwrT", 2048, NULL, 5, NULL, 0);
112+
#endif
113+
114+
#ifdef CONFIG_ENABLE_SLEEP_KEY
125115
if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_UNDEFINED) {
126-
ESP_LOGW(OS_PWR_TAG, "resuming from sleep mode");
116+
#if CONFIG_SLEEP_KEY_HOLD_TIME > 500
117+
vTaskDelay((CONFIG_SLEEP_KEY_HOLD_TIME - 500) / portTICK_RATE_MS);
118+
119+
#ifdef CONFIG_SLEEP_KEY_ACTIVE_LOW
120+
if (rtc_gpio_get_level(CONFIG_SLEEP_KEY_PIN) == 0) {
121+
#else
122+
if (rtc_gpio_get_level(CONFIG_SLEEP_KEY_PIN) == 1) {
123+
#endif
124+
ESP_LOGW(OS_PWR_TAG, "resuming from sleep mode....");
125+
} else {
126+
ESP_LOGW(OS_PWR_TAG, "resuming aborted.");
127+
128+
os_pwr_sleep_wait(0);
129+
}
130+
#else
131+
ESP_LOGW(OS_PWR_TAG, "resuming from sleep mode....");
132+
#endif
127133
} else {
128134
os_pwr_sleep_wait(0);
129135
}
130136
#endif
131-
132-
#if defined(CONFIG_ENABLE_SLP_KEY) || defined(CONFIG_ENABLE_BLE_IF)
133-
xTaskCreatePinnedToCore(os_pwr_task_handle, "osPwrT", 2048, NULL, 5, NULL, 0);
134-
#endif
135137
}

main/src/user/ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#define TAG "ec"
2121

22-
#ifdef CONFIG_ENABLE_EC
22+
#ifdef CONFIG_ENABLE_ENCODER
2323
static void pin_init(void)
2424
{
2525
gpio_config_t io_conf = {

main/src/user/fan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void fan_task(void *pvParameter)
159159

160160
if (xQueueReceive(fan_evt_queue, &fan_evt, 500 / portTICK_RATE_MS)) {
161161
switch (fan_evt) {
162-
#ifdef CONFIG_ENABLE_EC
162+
#ifdef CONFIG_ENABLE_ENCODER
163163
case EC_EVT_I: {
164164
int16_t duty_tmp = fan_duty + 1;
165165
fan_set_duty((duty_tmp < 255) ? duty_tmp : 255);

0 commit comments

Comments
 (0)