forked from PetteriAimonen/dso-quad-logic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttons.h
48 lines (35 loc) · 1.32 KB
/
buttons.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
#pragma once
#include <stdint.h>
#include "irq.h"
/* Functions for accessing the button status and timer ticks, which are
* updated in a 1ms interval interrupt routine.
*/
// This can be replaced elsewhere to execute custom code every ms
// The call will come from an interrupt context.
static void TimerTick() {}
// Check if some keys have been pressed, but don't clear the key status.
uint32_t peek_keys(uint32_t mask);
// Check if some keys have been pressed, and clear the status for them.
uint32_t get_keys(uint32_t mask);
// Check if some keys are being held down
// Returns the keys that are still down and the number of milliseconds they've
// been down.
uint32_t held_keys(uint32_t mask, uint32_t *ticks);
// Get number of milliseconds passed since boot
uint32_t get_time();
// Delay a specified number of milliseconds in a while loop
void delay_ms(uint32_t milliseconds);
// Get scroller increment based on held_keys time. This achieves incremental
// acceleration.
int scroller_speed();
#define BUTTON1 0x4000
#define BUTTON2 0x2000
#define BUTTON3 0x0100
#define BUTTON4 0x0200
#define SCROLL1_LEFT 0x0400
#define SCROLL1_RIGHT 0x0800
#define SCROLL1_PRESS 0x1000
#define SCROLL2_LEFT 0x0008
#define SCROLL2_RIGHT 0x8000
#define SCROLL2_PRESS 0x0040
#define ANY_KEY 0xFFFF