123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #ifndef _USER_BUTTON_H_
- #define _USER_BUTTON_H_
- #include "esp_adc/adc_oneshot.h"
- #include "esp_adc/adc_cali.h"
- #include "esp_adc/adc_cali_scheme.h"
- #define KEY_NUM 6
- #if 0 //以前没改过硬件的adc采集值
- #define BAOYANG_MIN_ADC 0
- #define BAOYANG_MAX_ADC 200
- #define FENGCUN_MIN_ADC 300
- #define FENGCUN_MAX_ADC 700
- #define GUZHUANG_MIN_ADC 800
- #define GUZHANG_MAX_ADC 1200
- #define DAILIAO_MIN_ADC 1300
- #define DAILIAO_MAX_ADC 1700
- #define TINGJI_MIN_ADC 1800
- #define TINGJI_MAX_ADC 2200
- #define YUNXING_MIN_ADC 2300
- #define YUNXING_MAX_ADC 3000
- #else
- // #define BAOYANG_MIN_ADC 230
- // #define BAOYANG_MAX_ADC 300
- // #define FENGCUN_MIN_ADC 700//500
- // #define FENGCUN_MAX_ADC 1000//600
- // #define GUZHUANG_MIN_ADC 500
- // #define GUZHANG_MAX_ADC 600
- // #define DAILIAO_MIN_ADC 350
- // #define DAILIAO_MAX_ADC 450
- // #define TINGJI_MIN_ADC 0//500
- // #define TINGJI_MAX_ADC 20//600
- // #define YUNXING_MIN_ADC 100
- // #define YUNXING_MAX_ADC 220
- #define BAOYANG_MIN_ADC 0
- #define BAOYANG_MAX_ADC 20
- #define FENGCUN_MIN_ADC 501
- #define FENGCUN_MAX_ADC 700
- #define GUZHUANG_MIN_ADC 701
- #define GUZHANG_MAX_ADC 1000
- #define DAILIAO_MIN_ADC 351
- #define DAILIAO_MAX_ADC 500
- #define TINGJI_MIN_ADC 20
- #define TINGJI_MAX_ADC 220
- #define YUNXING_MIN_ADC 221
- #define YUNXING_MAX_ADC 350
- #endif
- typedef enum
- {
-
- BAOYANG_KEY = 0,
- FENGCUN_KEY,
- GUZHUANG_KEY,
- DAILIAO_KEY ,
- TINGJI_KEY ,
- YUNXING_KEY,
- POWER_KEY,
- }KEY_t;
- //按键值
- typedef enum
- {
- POWER_LONG_START_VALUE = 0xF0, //长按开始
- POWER_ON_PRESS_VALUE = 0xF1, //短按
- POWER_OFF_PRESS_VALUE = 0xF2, //
- POWER_ON_INTO_SETTING_VALUE = 0xF3, //进入设置模式
- POWER_ON_INTO_OTA_VALUE = 0xF4, //进入OTA模式
- POWER_ON_INTO_RESET_VALUE = 0xF5, //进入复位模式
-
- POWER_ON_INTO_STATUS_CHANGE_VALUE = 0xF6,//切换开关机
- POWER_ON_INTO_DIS_RIGHT = 0xF7,
-
- }KEY_VALUE_t;
- #define POWER_KEY_LONG_PRSSS_TIME 3000//电源键长按开关机时常
- #define POWER_KEY_PRSSS_BLE_OTA_MODE 2 //进入设置模式
- #define POWER_KEY_PRSSS_DIS_RIGHT 3
- #define POWER_KEY_PRSSS_COUNT_RESET 4 //电源键多次按键恢复出厂
- //extern uint16_t adc_value[][2];
- void button_init(adc_oneshot_unit_handle_t adc_handle);
- void button_deinit(void);
- void power_button_init(adc_oneshot_unit_handle_t adc_handle);
- void power_button_deinit(void);
- int find_key_value(int value);
- bool is_btn_timeout(void);
- void send_button_key_queue(uint8_t value);
- void reset_btn_last_time(void);
- bool is_key_press(void);
- #endif/*_USER_BUTTON_H_*/
|