Makeblock-library-for-Arduino  V3.2.4
It's a library for arduino application developers
Me4Button.h
Go to the documentation of this file.
1 
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef Me4Button_H
41 #define Me4Button_H
42 
43 /* Includes ------------------------------------------------------------------*/
44 #include <stdint.h>
45 #include <stdbool.h>
46 #include <Arduino.h>
47 #include "MeConfig.h"
48 
49 #ifdef ME_PORT_DEFINED
50 #include "MePort.h"
51 #endif // ME_PORT_DEFINED
52 
53 /* Exported macro ------------------------------------------------------------*/
54 #define KEY_NULL (0)
55 #define KEY_1 (1)
56 #define KEY_2 (2)
57 #define KEY_3 (3)
58 #define KEY_4 (4)
59 
60 #define KEY_NULL_VALUE (962) // 1023*((5-0.3)/5)
61 #define KEY_1_VALUE (0)
62 #define KEY_2_VALUE (481) // 962/2
63 #define KEY_3_VALUE (641) // 962*2/3
64 #define KEY_4_VALUE (721) // 962*3/4
65 
66 #define DEBOUNCED_INTERVAL (8)
67 // If you want key response faster, you can set DEBOUNCED_INTERVAL to a
68 // smaller number.
69 
70 #define FALSE (0)
71 #define TRUE (1)
72 
78 #ifndef ME_PORT_DEFINED
79 class Me4Button
80 #else // !ME_PORT_DEFINED
81 class Me4Button : public MePort
82 #endif // !ME_PORT_DEFINED
83 {
84 public:
85 #ifdef ME_PORT_DEFINED
86 
92  Me4Button(void);
93 
100  Me4Button(uint8_t port);
101 #else // ME_PORT_DEFINED
102 
107  Me4Button(uint8_t port);
108 #endif // ME_PORT_DEFINED
109 
123  void setpin(uint8_t port);
124 
139  uint8_t pressed(void);
140 private:
141  volatile unsigned long previous_time;
142  volatile unsigned long key_debounced_count;
143  volatile unsigned long key_match_count;
144  volatile unsigned long key_debounced_value;
145  volatile int16_t Pre_Button_Value;
146  volatile uint8_t _KeyPin;
147 };
148 #endif // Me4Button_H
Configuration file of library.
Port Mapping for RJ25.
Definition: MePort.h:118
void setpin(uint8_t port)
Definition: Me4Button.cpp:98
Me4Button(void)
Definition: Me4Button.cpp:54
Driver for Me 4 Button module.
Definition: Me4Button.h:81
uint8_t pressed(void)
Definition: Me4Button.cpp:121
Header for MePort.cpp module.