user_button.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _USER_BUTTON_H_
  2. #define _USER_BUTTON_H_
  3. #include "esp_adc/adc_oneshot.h"
  4. #include "esp_adc/adc_cali.h"
  5. #include "esp_adc/adc_cali_scheme.h"
  6. #define KEY_NUM 6
  7. #if 0 //以前没改过硬件的adc采集值
  8. #define BAOYANG_MIN_ADC 0
  9. #define BAOYANG_MAX_ADC 200
  10. #define FENGCUN_MIN_ADC 300
  11. #define FENGCUN_MAX_ADC 700
  12. #define GUZHUANG_MIN_ADC 800
  13. #define GUZHANG_MAX_ADC 1200
  14. #define DAILIAO_MIN_ADC 1300
  15. #define DAILIAO_MAX_ADC 1700
  16. #define TINGJI_MIN_ADC 1800
  17. #define TINGJI_MAX_ADC 2200
  18. #define YUNXING_MIN_ADC 2300
  19. #define YUNXING_MAX_ADC 3000
  20. #else
  21. // #define BAOYANG_MIN_ADC 230
  22. // #define BAOYANG_MAX_ADC 300
  23. // #define FENGCUN_MIN_ADC 700//500
  24. // #define FENGCUN_MAX_ADC 1000//600
  25. // #define GUZHUANG_MIN_ADC 500
  26. // #define GUZHANG_MAX_ADC 600
  27. // #define DAILIAO_MIN_ADC 350
  28. // #define DAILIAO_MAX_ADC 450
  29. // #define TINGJI_MIN_ADC 0//500
  30. // #define TINGJI_MAX_ADC 20//600
  31. // #define YUNXING_MIN_ADC 100
  32. // #define YUNXING_MAX_ADC 220
  33. #define BAOYANG_MIN_ADC 0
  34. #define BAOYANG_MAX_ADC 20
  35. #define FENGCUN_MIN_ADC 501
  36. #define FENGCUN_MAX_ADC 700
  37. #define GUZHUANG_MIN_ADC 701
  38. #define GUZHANG_MAX_ADC 1000
  39. #define DAILIAO_MIN_ADC 351
  40. #define DAILIAO_MAX_ADC 500
  41. #define TINGJI_MIN_ADC 20
  42. #define TINGJI_MAX_ADC 220
  43. #define YUNXING_MIN_ADC 221
  44. #define YUNXING_MAX_ADC 350
  45. #endif
  46. typedef enum
  47. {
  48. BAOYANG_KEY = 0,
  49. FENGCUN_KEY,
  50. GUZHUANG_KEY,
  51. DAILIAO_KEY ,
  52. TINGJI_KEY ,
  53. YUNXING_KEY,
  54. POWER_KEY,
  55. }KEY_t;
  56. //按键值
  57. typedef enum
  58. {
  59. POWER_LONG_START_VALUE = 0xF0, //长按开始
  60. POWER_ON_PRESS_VALUE = 0xF1, //短按
  61. POWER_OFF_PRESS_VALUE = 0xF2, //
  62. POWER_ON_INTO_SETTING_VALUE = 0xF3, //进入设置模式
  63. POWER_ON_INTO_OTA_VALUE = 0xF4, //进入OTA模式
  64. POWER_ON_INTO_RESET_VALUE = 0xF5, //进入复位模式
  65. POWER_ON_INTO_STATUS_CHANGE_VALUE = 0xF6,//切换开关机
  66. POWER_ON_INTO_DIS_RIGHT = 0xF7,
  67. }KEY_VALUE_t;
  68. #define POWER_KEY_LONG_PRSSS_TIME 3000//电源键长按开关机时常
  69. #define POWER_KEY_PRSSS_SETTING_MODE 2 //进入设置模式
  70. #define POWER_KEY_PRSSS_COUNT_RESET 4 //电源键多次按键恢复出厂
  71. //extern uint16_t adc_value[][2];
  72. void button_init(adc_oneshot_unit_handle_t adc_handle);
  73. void button_deinit(void);
  74. void power_button_init(adc_oneshot_unit_handle_t adc_handle);
  75. void power_button_deinit(void);
  76. int find_key_value(int value);
  77. void send_button_key_queue(uint8_t value);
  78. #endif/*_USER_BUTTON_H_*/