C4EV3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
ev3_button.h
Go to the documentation of this file.
1 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #ifndef ev3_button_h
41 #define ev3_button_h
42 
43 #include <stdio.h>
44 #include <fcntl.h>
45 #include <stdlib.h>
46 #include <unistd.h>
47 #include <string.h>
48 #include <signal.h>
49 #include <sys/mman.h>
50 #include <stdbool.h>
51 #include <limits.h>
52 
53 #include "ev3_constants.h"
54 
55 float HardwareVersion();
56 
57 const char* HardwareVersionString();
58 
59 #define LED_BLACK 0
60 #define LED_GREEN 1
61 #define LED_RED 2
62 #define LED_ORANGE 3
63 #define LED_GREEN_FLASH 4
64 #define LED_RED_FLASH 5
65 #define LED_ORANGE_FLASH 6
66 #define LED_GREEN_PULSE 7
67 #define LED_RED_PULSE 8
68 #define LED_ORANGE_PULSE 9
69 #define NUM_LED_PATTERNS 10
70 
71 void SetLedWarning(bool Value);
72 
73 bool IsLedWarning();
74 
75 void SetLedPattern(uint8_t Pattern);
76 
77 uint8_t GetLedPattern();
78 
79 uint16_t ButtonWaitForAnyEvent(unsigned int timeout);
80 
81 uint16_t ButtonWaitForAnyPress(unsigned int timeout);
82 
83 bool ButtonIsUp(uint8_t Button);
84 
85 bool ButtonIsDown(uint8_t Button);
86 
87 void ButtonWaitForPress(uint8_t Button);
88 
89 void ButtonWaitForPressAndRelease(uint8_t Button);
90 
91 // NXC-style API functions (no support for short press, long press,
92 // short release, long release, or press counts
93 bool ButtonPressedEx(uint8_t btn, bool resetCount);
94 
95 static inline bool ButtonPressed(uint8_t btn) {
96  return ButtonPressedEx(btn, false);
97 }
98 
99 char ReadButtonEx(uint8_t btn, bool reset, bool* pressed, uint16_t* count);
100 
101 uint8_t ButtonState(uint8_t btn);
102 
103 #endif // ev3_button_h
104 
105 #ifdef __cplusplus
106 }
107 #endif
float HardwareVersion()
uint16_t ButtonWaitForAnyPress(unsigned int timeout)
void SetLedPattern(uint8_t Pattern)
const char * HardwareVersionString()
Constants for various EV3 modules.
char ReadButtonEx(uint8_t btn, bool reset, bool *pressed, uint16_t *count)
bool ButtonPressedEx(uint8_t btn, bool resetCount)
bool ButtonIsUp(uint8_t Button)
void ButtonWaitForPress(uint8_t Button)
void ButtonWaitForPressAndRelease(uint8_t Button)
uint16_t ButtonWaitForAnyEvent(unsigned int timeout)
bool IsLedWarning()
bool ButtonIsDown(uint8_t Button)
uint8_t GetLedPattern()
void SetLedWarning(bool Value)
uint8_t ButtonState(uint8_t btn)