user_button.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "user_button.h"
  4. #include "iot_button.h"
  5. #include "esp_log.h"
  6. #include "freertos/FreeRTOS.h"
  7. #include "freertos/task.h"
  8. #include "freertos/queue.h"
  9. #include "freertos/semphr.h"
  10. #include "freertos/timers.h"
  11. #include "../EPD//include/EPD.h"
  12. #include <stdlib.h>
  13. #include <time.h>
  14. #include <unistd.h>
  15. #include <sys/time.h>
  16. static const char *LOG_TAG = "user button";
  17. static struct timeval btn_last_time; // 左屏超过30s,不发送按键lora信息
  18. extern QueueHandle_t button_Data_queue;
  19. // extern SemaphoreHandle_t button_semaphore;
  20. static button_handle_t user_button_handle[KEY_NUM] = {0};
  21. static button_handle_t user_powerbutton_handle[3] = {0};
  22. TimerHandle_t btn_timer_handle;
  23. RTC_FAST_ATTR static bool is_setting = false;
  24. RTC_FAST_ATTR static bool is_reset_net = false; // 配网
  25. RTC_FAST_ATTR static bool is_send_lora = false;
  26. RTC_FAST_ATTR static bool is_down = false;
  27. uint16_t adc_value[][2] =
  28. {
  29. {BAOYANG_MIN_ADC, BAOYANG_MAX_ADC},
  30. {FENGCUN_MIN_ADC, FENGCUN_MAX_ADC},
  31. {GUZHUANG_MIN_ADC, GUZHANG_MAX_ADC},
  32. {DAILIAO_MIN_ADC, DAILIAO_MAX_ADC},
  33. {TINGJI_MIN_ADC, TINGJI_MAX_ADC},
  34. {YUNXING_MIN_ADC, YUNXING_MAX_ADC},
  35. };
  36. static void press_up_cb(void *arg, void *usr_data);
  37. static void long_press_up_cb(void *arg, void *usr_data);
  38. uint16_t power_adc_value[][2] =
  39. {
  40. {0, 100},
  41. {1000, 1900},
  42. {2000, 3063},
  43. };
  44. int find_key_value(int value)
  45. {
  46. int key = 0xff;
  47. for (int i = 0; i < 6; i++)
  48. {
  49. if (
  50. (adc_value[i][1] >= value) &&
  51. (adc_value[i][0] <= value))
  52. {
  53. key = i;
  54. printf("key vaule %d\r\n", i);
  55. break;
  56. }
  57. }
  58. return key;
  59. }
  60. static void user_button_up_cb(void *arg, void *usr_data);
  61. static void power_long_press_start_cb(void *arg, void *usr_data);
  62. static void power_long_press_hold_cb(void *arg, void *usr_data);
  63. static void power_long_press_up_cb(void *arg, void *usr_data);
  64. static void power_press_up_cb(void *arg, void *usr_data);
  65. static void power_single_press_cb(void *arg, void *usr_data);
  66. static void button_down_cb(void *arg, void *usr_data);
  67. static void user_button_single_UP_cb(void *arg, void *usr_data);
  68. static void power_button_multi_press_cb(void *arg, void *usr_data);
  69. static void power_left_single_press_cb(void *arg, void *usr_data)
  70. {
  71. printf("%s\r\n", __FUNCTION__);
  72. }
  73. static void power_right_single_press_cb(void *arg, void *usr_data)
  74. {
  75. printf("%s\r\n", __FUNCTION__);
  76. }
  77. int button_idx = 0;
  78. int power_button_idx = 0;
  79. int power_button_mult_time = 0;
  80. void btn_timer_Callback(TimerHandle_t xTimer)
  81. {
  82. ESP_LOGW(LOG_TAG, "btn_timer_Callback");
  83. if (is_setting)
  84. {
  85. is_setting = false;
  86. }
  87. else if (is_reset_net)
  88. {
  89. is_reset_net = false;
  90. }
  91. is_setting = 0;
  92. // xTimerStop(btn_timer_handle,0);
  93. }
  94. static void get_rtc_time(struct tm *tmp)
  95. {
  96. struct timeval tv;
  97. gettimeofday(&tv, NULL);
  98. // 打印 RTC 时间戳
  99. printf("RTC Timestamp: %lld\n", tv.tv_sec);
  100. // 使用 localtime 函数将时间戳转换为本地时间
  101. tmp = localtime(&tv.tv_sec);
  102. // 打印本地时间
  103. printf(" get_rtc_time: %04d-%02d-%02d %02d:%02d:%02d\n",
  104. tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
  105. tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
  106. }
  107. bool is_btn_timeout(void)
  108. {
  109. struct timeval now_time;
  110. gettimeofday(&now_time, NULL);
  111. ESP_LOGD(LOG_TAG, "is_send_lora= %s now_time = %lld,last = %lld,\n", is_send_lora ? "ture" : "false", now_time.tv_sec, btn_last_time.tv_sec);
  112. struct tm *tmp = localtime(&now_time.tv_sec);
  113. // ESP_LOGI(LOG_TAG,"时间: %04d-%02d-%02d %02d:%02d:%02d\n",
  114. // tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
  115. // tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
  116. if (((now_time.tv_sec - btn_last_time.tv_sec) > 30) && (is_send_lora))
  117. {
  118. ESP_LOGW(LOG_TAG, "发送-----现在按键时间: %04d-%02d-%02d %02d:%02d:%02d\n",
  119. tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
  120. tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
  121. is_send_lora = false;
  122. return true;
  123. }
  124. return false;
  125. }
  126. void reset_btn_last_time(void)
  127. {
  128. if (!is_send_lora)
  129. {
  130. is_send_lora = true;
  131. }
  132. gettimeofday(&btn_last_time, NULL);
  133. struct tm *tmp = localtime(&btn_last_time.tv_sec);
  134. // printf("btn_last_time: %lld\n", btn_last_time.tv_sec);
  135. ESP_LOGW(LOG_TAG, "最后按键时间: %04d-%02d-%02d %02d:%02d:%02d\n",
  136. tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
  137. tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
  138. }
  139. void button_init(adc_oneshot_unit_handle_t adc_handle)
  140. {
  141. int i;
  142. printf("button_init\n");
  143. #if 1
  144. button_config_t adc_btn_cfg = {
  145. .type = BUTTON_TYPE_ADC,
  146. .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS,
  147. .short_press_time = CONFIG_BUTTON_SHORT_PRESS_TIME_MS,
  148. .adc_button_config = {
  149. .adc_channel = 7,
  150. .adc_handle = &adc_handle,
  151. },
  152. };
  153. // 左边6个按键初始化
  154. for (i = 0; i < KEY_NUM; i++)
  155. {
  156. adc_btn_cfg.adc_button_config.button_index = i;
  157. adc_btn_cfg.adc_button_config.min = adc_value[i][0];
  158. adc_btn_cfg.adc_button_config.max = adc_value[i][1];
  159. user_button_handle[i] = iot_button_create(&adc_btn_cfg);
  160. if (NULL == user_button_handle[i])
  161. {
  162. printf("Button create failed");
  163. }
  164. button_idx = i;
  165. iot_button_register_cb( user_button_handle[i], BUTTON_PRESS_DOWN, button_down_cb,button_idx);
  166. iot_button_register_cb(user_button_handle[i], BUTTON_PRESS_UP, user_button_up_cb, button_idx); // 松手才发按键消息
  167. // iot_button_register_cb( user_button_handle[i], BUTTON_LONG_PRESS_UP, long_press_up_cb,button_idx);
  168. // iot_button_register_cb( user_button_handle[i], BUTTON_PRESS_UP, user_button_single_click_cb,button_idx);
  169. }
  170. #endif
  171. // 电源按键
  172. btn_timer_handle = xTimerCreate(
  173. "btn_timer_handle",
  174. pdMS_TO_TICKS(10 * 1000),
  175. pdFALSE,
  176. 0,
  177. btn_timer_Callback);
  178. #if 0
  179. //右边3个按键 目前只是用一个按键 POWER
  180. button_config_t power_btn_cfg = {
  181. .type = BUTTON_TYPE_GPIO,
  182. .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS,
  183. .short_press_time = CONFIG_BUTTON_SHORT_PRESS_TIME_MS,
  184. .adc_button_config = {
  185. .adc_channel = 3,
  186. .adc_handle = &adc_handle,
  187. },
  188. };
  189. for(int i = 0;i < 1 ;i++)
  190. {
  191. power_btn_cfg.adc_button_config.button_index = i;
  192. power_btn_cfg.adc_button_config.min = power_adc_value[i][0] ;
  193. power_btn_cfg.adc_button_config.max = power_adc_value[i][1] ;
  194. user_powerbutton_handle[i] = iot_button_create(&power_btn_cfg);
  195. if(NULL == user_powerbutton_handle[i]) {
  196. printf( "Button create failed");
  197. }
  198. button_idx = i;
  199. iot_button_register_cb( user_powerbutton_handle[i], BUTTON_PRESS_DOWN, power_single_press_cb,button_idx);
  200. #if 0
  201. iot_button_register_cb( user_powerbutton_handle[i], BUTTON_LONG_PRESS_START, power_long_press_cb,button_idx);
  202. #else
  203. iot_button_register_cb( user_powerbutton_handle[i], BUTTON_LONG_PRESS_START, power_long_press_start_cb,button_idx);
  204. iot_button_register_cb( user_powerbutton_handle[i], BUTTON_LONG_PRESS_HOLD, power_long_press_hold_cb,button_idx);
  205. iot_button_register_cb( user_powerbutton_handle[i], BUTTON_LONG_PRESS_UP, power_long_press_up_cb,button_idx);
  206. #endif
  207. //注册按键多次按键回调
  208. button_event_config_t btn_cfg;
  209. btn_cfg.event = BUTTON_MULTIPLE_CLICK;
  210. // btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_COUNT_OTA;
  211. // power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
  212. // iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  213. btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_COUNT_RESET;
  214. power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
  215. iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  216. btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_BLE_OTA_MODE;
  217. power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
  218. iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  219. // //注册按键长按按键回调
  220. // button_event_config_t btn_long_press_cfg;
  221. // btn_cfg.event = BUTTON_LONG_PRESS_START;
  222. }
  223. #else
  224. button_config_t power_btn_cfg = {
  225. .type = BUTTON_TYPE_GPIO,
  226. .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS,
  227. .short_press_time = CONFIG_BUTTON_SHORT_PRESS_TIME_MS,
  228. .gpio_button_config = {
  229. .gpio_num = 4,
  230. .active_level = 0,
  231. },
  232. };
  233. for (i = 0; i < 1; i++)
  234. {
  235. // power_btn_cfg.adc_button_config.button_index = i;
  236. // power_btn_cfg.adc_button_config.min = power_adc_value[i][0] ;
  237. // power_btn_cfg.adc_button_config.max = power_adc_value[i][1] ;
  238. user_powerbutton_handle[i] = iot_button_create(&power_btn_cfg);
  239. if (NULL == user_powerbutton_handle[i])
  240. {
  241. printf("Button create failed");
  242. }
  243. button_idx = i;
  244. iot_button_register_cb(user_powerbutton_handle[i], BUTTON_PRESS_DOWN, power_single_press_cb, button_idx);
  245. #if 0
  246. iot_button_register_cb( user_powerbutton_handle[i], BUTTON_LONG_PRESS_START, power_long_press_cb,button_idx);
  247. #else
  248. iot_button_register_cb(user_powerbutton_handle[i], BUTTON_LONG_PRESS_START, power_long_press_start_cb, button_idx);
  249. iot_button_register_cb(user_powerbutton_handle[i], BUTTON_LONG_PRESS_HOLD, power_long_press_hold_cb, button_idx);
  250. // iot_button_register_cb(user_powerbutton_handle[i], BUTTON_LONG_PRESS_UP, power_long_press_up_cb, button_idx);
  251. iot_button_register_cb(user_powerbutton_handle[i], BUTTON_PRESS_UP, power_press_up_cb, button_idx);
  252. #endif
  253. // 注册按键多次按键回调
  254. button_event_config_t btn_cfg;
  255. btn_cfg.event = BUTTON_MULTIPLE_CLICK;
  256. // btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_COUNT_OTA;
  257. // power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
  258. // iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  259. btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_COUNT_RESET;
  260. power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks;
  261. iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  262. btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_DIS_RIGHT;
  263. power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks;
  264. iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  265. btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_BLE_OTA_MODE;
  266. power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks;
  267. iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
  268. // //注册按键长按按键回调
  269. // button_event_config_t btn_long_press_cfg;
  270. // btn_cfg.event = BUTTON_LONG_PRESS_START;
  271. }
  272. #endif
  273. }
  274. void button_deinit(void)
  275. {
  276. printf("button_deinit\n");
  277. for (int i = 0; i < KEY_NUM; i++)
  278. {
  279. iot_button_delete(user_button_handle[i]);
  280. }
  281. // iot_button_delete(user_powerbutton_handle[0]);
  282. }
  283. void power_button_init(adc_oneshot_unit_handle_t adc_handle)
  284. {
  285. }
  286. void power_button_deinit(void)
  287. {
  288. for (int i = 0; i < 3; i++)
  289. iot_button_delete(user_powerbutton_handle[i]);
  290. }
  291. uint8_t button_info = 0;
  292. #include "SPIFFS.h"
  293. #if 0
  294. static void power_long_press_cb(void *arg,void *usr_data)
  295. {
  296. switch ((int)usr_data)
  297. {
  298. case 0:
  299. printf("power key long press start\r\n");
  300. button_info = POWER_ON_INTO_STATUS_CHANGE_VALUE;
  301. if(xQueueSend(button_Data_queue,&button_info,0) != true)
  302. {
  303. ESP_LOGE(LOG_TAG,"queue send is fail");
  304. return;
  305. }
  306. break;
  307. case 1:
  308. printf("power left key long press\r\n");
  309. break;
  310. }
  311. }
  312. iot_button_get_long_press_hold_cnt((button_handle_t)arg)
  313. #else
  314. static void press_up_cb(void *arg, void *usr_data)
  315. {
  316. ESP_LOGE(LOG_TAG, "BUTTON_PRESS_UP %d", (int)usr_data);
  317. }
  318. static void long_press_up_cb(void *arg, void *usr_data)
  319. {
  320. ESP_LOGE(LOG_TAG, "BUTTON_LONG_PRESS_UP %d", (int)usr_data);
  321. }
  322. static void power_long_press_start_cb(void *arg, void *usr_data)
  323. {
  324. // ESP_LOGE(LOG_TAG, "power_long_press_start_cb\n");
  325. // is_power = true;
  326. }
  327. // static void power_long_press_up_cb(void *arg, void *usr_data)
  328. // {
  329. // }
  330. static void power_press_up_cb(void *arg, void *usr_data)
  331. {
  332. is_down = false;
  333. }
  334. bool is_key_press(void)
  335. {
  336. return is_down;
  337. }
  338. static void power_long_press_hold_cb(void *arg, void *usr_data)
  339. {
  340. // 设置的长按开始时间后开始计算hold_cnt 长按开始时间设置为1s,cnt计算时间间隔(SERIAL_TICKS)也设置为1s
  341. uint16_t hold_cnt = iot_button_get_long_press_hold_cnt((button_handle_t)arg);
  342. ESP_LOGE(LOG_TAG, " BUTTON_LONG_PRESS_HOLD[%d],count is [%d]\n", iot_button_get_ticks_time((button_handle_t)arg), hold_cnt);
  343. switch ((int)hold_cnt)
  344. {
  345. case 2: // 设置模式,长按3s进入
  346. if (is_setting && is_reset_net)
  347. {
  348. ESP_LOGE(LOG_TAG, "err:OTA 和 重新配网 同时");
  349. return;
  350. }
  351. if (is_setting)
  352. {
  353. button_info = POWER_ON_INTO_OTA_VALUE;
  354. if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  355. {
  356. ESP_LOGE(LOG_TAG, "queue send is fail");
  357. return;
  358. }
  359. }
  360. if (is_reset_net)
  361. {
  362. button_info = POWER_ON_INTO_RESET_VALUE;
  363. if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  364. {
  365. ESP_LOGE(LOG_TAG, "queue send is fail");
  366. return;
  367. }
  368. }
  369. break;
  370. case 4: // 5s开关机
  371. button_info = POWER_ON_INTO_STATUS_CHANGE_VALUE;
  372. if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  373. {
  374. ESP_LOGE(LOG_TAG, "queue send is fail");
  375. return;
  376. }
  377. break;
  378. default:
  379. // printf(" BUTTON_LONG_PRESS_HOLD[%d],count is [%d]\n", iot_button_get_ticks_time((button_handle_t)arg), hold_cnt);
  380. break;
  381. }
  382. }
  383. #endif
  384. #include "esp_sleep.h"
  385. static void power_single_press_cb(void *arg, void *usr_data)
  386. {
  387. if (Machine_info.power_status == 0)
  388. {
  389. return;
  390. }
  391. is_down = true;
  392. ESP_LOGE(LOG_TAG, "is_down true\n");
  393. switch ((int)usr_data)
  394. {
  395. case 0:
  396. ESP_LOGW(LOG_TAG,"power sigle press\r\n");
  397. // if (Machine_info.power_status == 1) // 开机
  398. // {
  399. button_info = POWER_ON_PRESS_VALUE;
  400. if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  401. {
  402. ESP_LOGE(LOG_TAG, "queue send is fail");
  403. return;
  404. }
  405. // }
  406. // else
  407. // {
  408. // button_info = POWER_OFF_PRESS_VALUE; // 关机状态下单击按键
  409. // if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  410. // {
  411. // ESP_LOGE(LOG_TAG, "queue send is fail");
  412. // return;
  413. // }
  414. // }
  415. break;
  416. case 1:
  417. printf("power left single press\r\n");
  418. break;
  419. case 2:
  420. printf("power right single press\r\n");
  421. break;
  422. }
  423. }
  424. static void button_down_cb(void *arg, void *usr_data)
  425. {
  426. ESP_LOGI(LOG_TAG, "%d true",(int)usr_data);
  427. is_down = true;
  428. }
  429. static void user_button_up_cb(void *arg, void *usr_data)
  430. {
  431. is_down = false;
  432. is_setting = false;
  433. is_reset_net = false;
  434. ESP_LOGW(LOG_TAG, " single_click_cb[%d]", iot_button_get_ticks_time((button_handle_t)arg));
  435. switch ((int)usr_data)
  436. {
  437. case BAOYANG_KEY:
  438. button_info = 6;
  439. ESP_LOGD(LOG_TAG, "bao yang");
  440. break;
  441. case FENGCUN_KEY:
  442. button_info = 5;
  443. ESP_LOGD(LOG_TAG, "feng cun");
  444. break;
  445. case GUZHUANG_KEY:
  446. button_info = 4;
  447. ESP_LOGD(LOG_TAG, "gu zhang");
  448. break;
  449. case DAILIAO_KEY:
  450. button_info = 3;
  451. ESP_LOGD(LOG_TAG, "dai liao");
  452. break;
  453. case TINGJI_KEY:
  454. button_info = 2;
  455. ESP_LOGD(LOG_TAG, "ting ji");
  456. break;
  457. case YUNXING_KEY:
  458. button_info = 1;
  459. ESP_LOGD(LOG_TAG, "yun xing");
  460. break;
  461. default:
  462. break;
  463. }
  464. #if 0
  465. if(xSemaphoreTake(button_semaphore, 0) != true)
  466. {
  467. ESP_LOGE(LOG_TAG,"button mutex is fail,not send lora queue");
  468. return;
  469. }
  470. xSemaphoreGive(button_semaphore);
  471. #endif
  472. if (Machine_info.power_status == 0) // 关机
  473. {
  474. printf("power off not refresh\r\n");
  475. return;
  476. }
  477. if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  478. {
  479. ESP_LOGE(LOG_TAG, "queue send is fail");
  480. return;
  481. }
  482. }
  483. static void power_button_multi_press_cb(void *arg, void *usr_data)
  484. {
  485. if (Machine_info.power_status == 0) // 关机
  486. {
  487. printf("关机状态\r\n");
  488. return;
  489. }
  490. switch ((int)usr_data)
  491. {
  492. case POWER_KEY_PRSSS_BLE_OTA_MODE:
  493. if (!is_setting && !is_reset_net) // 当前非配置模式
  494. {
  495. is_setting = true;
  496. xTimerStart(btn_timer_handle, 0);
  497. printf("短按2次\r\n");
  498. }
  499. break;
  500. case POWER_KEY_PRSSS_DIS_RIGHT:
  501. printf("短按3次\r\n");
  502. send_button_key_queue((uint8_t)POWER_ON_INTO_DIS_RIGHT);
  503. break;
  504. case POWER_KEY_PRSSS_COUNT_RESET:
  505. if (!is_setting && !is_reset_net)
  506. {
  507. is_reset_net = true;
  508. xTimerStart(btn_timer_handle, 0);
  509. printf("短按4次\r\n");
  510. }
  511. break;
  512. }
  513. }
  514. static void user_button_single_UP_cb(void *arg, void *usr_data)
  515. {
  516. }
  517. void send_button_key_queue(uint8_t value)
  518. {
  519. button_info = value;
  520. if (xQueueSend(button_Data_queue, &button_info, 0) != true)
  521. {
  522. ESP_LOGE(LOG_TAG, "queue send is fail");
  523. return;
  524. }
  525. }