-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttonbuffer.h
56 lines (47 loc) · 1008 Bytes
/
buttonbuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Written by Icewire Technologies
*/
#ifndef _BUTTONBUFFER_H
#define _BUTTONBUFFER_H
#include <stdint.h>
#include <stdbool.h>
/* Types of a button press */
enum ButtonPress {
BUTTON_NONE,
BUTTON_TAP,
BUTTON_HOLD,
BUTTON_TRIPLE_TAP
};
/* Circular buffer that holds button press data */
struct ButtonPressBuffer {
volatile enum ButtonPress *button_presses;
uint16_t size;
uint16_t start;
uint16_t end;
volatile uint16_t count;
};
/*
* DESC
*
* PARAMS
*/
void construct_button_press_buffer(struct ButtonPressBuffer *button_press_buffer, volatile enum ButtonPress *button_presses, uint16_t size);
/*
* DESC
*
* PARAMS
*/
void clear_button_press_buffer(struct ButtonPressBuffer *button_press_buffer);
/*
* DESC
*
* PARAMS
*/
bool add_button_press(struct ButtonPressBuffer *button_press_buffer, enum ButtonPress button_press);
/*
* DESC
*
* PARAMS
*/
bool remove_button_press(struct ButtonPressBuffer *button_press_buffer, enum ButtonPress *button_press_ret);
#endif