esp8266-std/include/ne_keypad.h

70 lines
1.4 KiB
C

#ifndef NE_KEYPAD_H
#define NE_KEYPAD_H
#include "user_main.h"
#if NE_DEBUG_VERSION
/* define network led pin */
#define NE_NETWORK_LED_PIN 12
/* define io interrupt enable/disable */
#define ETS_GPIO_INTR_ENABLE() _xt_isr_unmask(1 << ETS_GPIO_INUM) //ENABLE INTERRUPTS
#define ETS_GPIO_INTR_DISABLE() _xt_isr_mask(1 << ETS_GPIO_INUM) //DISABLE INTERRUPTS
/* define keypad config */
#define BUTTON_IO_MUC PERIPHS_IO_MUX_MTCK_U
#define BUTTON_IO_NUM 13
#define BUTTON_IO_FUNC FUNC_GPIO13
#define BUTTON_IO_PIN GPIO_Pin_13
/* keypad event type */
#define UP 1
#define DOWN 0
#define INTERVAL_TIME 10
/* pushdown enum */
enum {
DNA_KEYPAD_PUSHDOWN_SHORT = 0, /**< define keypad pushdown short time */
DNA_KEYPAD_PUSHDOWN_LONG, /**< define keypad pushdown long time */
};
/* network led on/off enum */
typedef enum {
NE_NETWORK_LED_ON,
NE_NETWORK_LED_OFF
}ne_network_led_e;
/* keypad callback function */
typedef void (* keypad_press_cb_t)(int type);
/* Keypad application config */
typedef struct keypad_dev_t {
unsigned char pin;
unsigned char pushdown;
unsigned short event_type;
unsigned int down_count;
unsigned int short_time;
unsigned int long_time;
keypad_press_cb_t callback;
}keypad_dev_t;
int ne_timer_init(void);
int ne_keypad_init(void);
#endif
#endif