按键控制清空本地阀门信息操作
This commit is contained in:
parent
db936c1bb6
commit
23174359f8
|
@ -94,7 +94,7 @@ static void _CommonBtnEvtCb (void *arg)
|
|||
// }
|
||||
// button_cnt++;
|
||||
}
|
||||
else if ((flex_button_event_read(&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_LONG_HOLD)&&(flex_button_event_read(&user_button[USER_BUTTON_0]) == FLEX_BTN_PRESS_REPEAT_CLICK))
|
||||
else if ((flex_button_event_read(&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_LONG_HOLD)&&(flex_button_event_read(&user_button[USER_BUTTON_0]) == FLEX_BTN_PRESS_DOUBLE_CLICK))
|
||||
{
|
||||
LOG_I("本地清除阀门信息");
|
||||
rt_uint8_t mac_addr[6] = {0};
|
||||
|
|
|
@ -36,34 +36,34 @@
|
|||
* 2019-08-02 MurphyZhao Migrate code to github.com/murphyzhao account
|
||||
* 2019-12-26 MurphyZhao Refactor code and implement multiple clicks
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef __FLEXIBLE_BUTTON_H__
|
||||
#define __FLEXIBLE_BUTTON_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define FLEX_BTN_SCAN_FREQ_HZ 40 // How often flex_button_scan () is called
|
||||
#define FLEX_BTN_SCAN_FREQ_HZ 40 // How often flex_button_scan () is called
|
||||
#define FLEX_MS_TO_SCAN_CNT(ms) (ms / (1000 / FLEX_BTN_SCAN_FREQ_HZ)) //
|
||||
/* Multiple clicks interval, default 300ms */
|
||||
#define MAX_MULTIPLE_CLICKS_INTERVAL (FLEX_MS_TO_SCAN_CNT(300))
|
||||
#define MAX_MULTIPLE_CLICKS_INTERVAL (FLEX_MS_TO_SCAN_CNT(500))
|
||||
|
||||
typedef void (*flex_button_response_callback)(void*);
|
||||
typedef void (*flex_button_response_callback)(void *);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FLEX_BTN_PRESS_DOWN = 0,
|
||||
FLEX_BTN_PRESS_CLICK,
|
||||
FLEX_BTN_PRESS_DOUBLE_CLICK,//
|
||||
FLEX_BTN_PRESS_REPEAT_CLICK,
|
||||
FLEX_BTN_PRESS_SHORT_START,
|
||||
FLEX_BTN_PRESS_SHORT_UP,
|
||||
FLEX_BTN_PRESS_LONG_START,
|
||||
FLEX_BTN_PRESS_LONG_UP,
|
||||
FLEX_BTN_PRESS_LONG_HOLD,// 长按
|
||||
FLEX_BTN_PRESS_LONG_HOLD_UP,
|
||||
FLEX_BTN_PRESS_MAX,
|
||||
FLEX_BTN_PRESS_NONE,
|
||||
FLEX_BTN_PRESS_DOWN = 0, // 按钮按下开始
|
||||
FLEX_BTN_PRESS_CLICK, // 单击事件(按下后释放)
|
||||
FLEX_BTN_PRESS_DOUBLE_CLICK, // 双击事件(两次快速单击)
|
||||
FLEX_BTN_PRESS_REPEAT_CLICK, // 连续点击事件(多次点击)
|
||||
FLEX_BTN_PRESS_SHORT_START, // 短按开始
|
||||
FLEX_BTN_PRESS_SHORT_UP, // 短按结束(释放)
|
||||
FLEX_BTN_PRESS_LONG_START, // 长按开始
|
||||
FLEX_BTN_PRESS_LONG_UP, // 长按结束(释放)
|
||||
FLEX_BTN_PRESS_LONG_HOLD, // 持续长按事件
|
||||
FLEX_BTN_PRESS_LONG_HOLD_UP, // 持续长按结束(释放)
|
||||
FLEX_BTN_PRESS_MAX, // 事件总数,用于边界检查
|
||||
FLEX_BTN_PRESS_NONE // 无事件
|
||||
} flex_button_event_t;
|
||||
|
||||
/**
|
||||
|
@ -127,13 +127,13 @@ typedef enum
|
|||
* Internal use, user unavailable.
|
||||
* Used to record the current state of buttons.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
typedef struct flex_button
|
||||
{
|
||||
struct flex_button* next;
|
||||
struct flex_button *next;
|
||||
|
||||
uint8_t (*usr_button_read)(void *);
|
||||
flex_button_response_callback cb;
|
||||
uint8_t (*usr_button_read)(void *);
|
||||
flex_button_response_callback cb;
|
||||
|
||||
uint16_t scan_cnt;
|
||||
uint16_t click_cnt;
|
||||
|
@ -146,17 +146,18 @@ typedef struct flex_button
|
|||
|
||||
uint8_t id;
|
||||
uint8_t pressed_logic_level : 1;
|
||||
uint8_t event : 4;
|
||||
uint8_t status : 3;
|
||||
uint8_t event : 4;
|
||||
uint8_t status : 3;
|
||||
} flex_button_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
int8_t flex_button_register(flex_button_t *button);
|
||||
flex_button_event_t flex_button_event_read(flex_button_t* button);
|
||||
void flex_button_scan(void);
|
||||
int8_t flex_button_register(flex_button_t *button);
|
||||
flex_button_event_t flex_button_event_read(flex_button_t *button);
|
||||
void flex_button_scan(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue