Caddy
A 2005 Roborodentia entry with vision and path planning capability
 All Data Structures Files Functions Variables Typedefs Macros Pages
buttons.h
Go to the documentation of this file.
1 /*
2  * This file is part of Caddy.
3  *
4  * Caddy is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Caddy is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Caddy. If not, see <http://www.gnu.org/licenses/>.
16  */
21 #ifndef BUTTONS_H_
22 #define BUTTONS_H_
23 
24 #include <avr/io.h>
25 #include <stdint.h>
26 #include <stdbool.h>
27 
28 #define RED_BUTTON 0
29 #define L_UP_BUTTON 1
30 #define L_DOWN_BUTTON 2
31 #define R_UP_BUTTON 3
32 #define R_DOWN_BUTTON 4
33 #define NEST_BUTTON 5
34 #define NUM_BUTTONS 6 // change isPressed(uint8_t button) when adding a button
35 
36 #define RED_BUTTON_DOWN bit_is_clear(PIND,6)
37 #define L_UP_BUTTON_DOWN bit_is_clear(PINA,0)
38 #define L_DOWN_BUTTON_DOWN bit_is_clear(PINA,1)
39 #define R_UP_BUTTON_DOWN bit_is_clear(PINA,2)
40 #define R_DOWN_BUTTON_DOWN bit_is_clear(PINA,3)
41 #define NEST_BUTTON_DOWN bit_is_clear(PINB,0)
42 
43 #define BREAK_BEAM_TRIGGERED bit_is_set(PINB,1)
44 
45 void initButtons(void);
46 void waitFor(uint8_t button);
47 inline bool justPressed(uint8_t button);
48 inline bool justReleased(uint8_t button);
49 void debounceButtons(void);
50 inline bool isPressed(uint8_t button);
51 inline bool bothRightButtonsPressed(void);
52 inline bool bothLeftButtonsPressed(void);
53 
54 #endif // #ifndef BUTTONS_H_