-
Notifications
You must be signed in to change notification settings - Fork 6
/
keypad.h
72 lines (57 loc) · 1.75 KB
/
keypad.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
keypad.h - I2C keypad plugin
Part of grblHAL
Copyright (c) 2017-2020 Terje Io
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _KEYPAD_H_
#define _KEYPAD_H_
#ifdef ARDUINO
#include "../grbl/gcode.h"
#include "../grbl/settings.h"
#else
#include "grbl/gcode.h"
#include "grbl/settings.h"
#endif
#define KEYBUF_SIZE 8 // must be a power of 2
#define KEYPAD_I2CADDR 0x49
#define JOG_XR 'R'
#define JOG_XL 'L'
#define JOG_YF 'F'
#define JOG_YB 'B'
#define JOG_ZU 'U'
#define JOG_ZD 'D'
#define JOG_XRYF 'r'
#define JOG_XRYB 'q'
#define JOG_XLYF 's'
#define JOG_XLYB 't'
#define JOG_XRZU 'w'
#define JOG_XRZD 'v'
#define JOG_XLZU 'u'
#define JOG_XLZD 'x'
typedef enum {
JogMode_Fast = 0,
JogMode_Slow,
JogMode_Step
} jogmode_t;
typedef void (*keycode_callback_ptr)(const char c);
typedef bool (*on_keypress_preview_ptr)(const char c, uint_fast16_t state);
typedef void (*on_jogmode_changed_ptr)(jogmode_t jogmode);
typedef struct {
on_keypress_preview_ptr on_keypress_preview;
on_jogmode_changed_ptr on_jogmode_changed;
} keypad_t;
extern keypad_t keypad;
bool keypad_init (void);
void keypad_keyclick_handler (bool keydown);
void keypad_enqueue_keycode (char c);
#endif