AStar32U4 library
AStar32U4Buttons.h
Go to the documentation of this file.
1 // Copyright Pololu Corporation. For more information, see http://www.pololu.com/
2 
5 #pragma once
6 
7 #include <Pushbutton.h>
8 #include <FastGPIO.h>
9 #include <USBPause.h>
10 #include <SPIPause.h>
11 #include <util/delay.h>
12 
14 #define A_STAR_32U4_BUTTON_A 14
15 
20 #define A_STAR_32U4_BUTTON_B IO_D5
21 
23 #define A_STAR_32U4_BUTTON_C 17
24 
35 {
36 public:
38  {
39  }
40 };
41 
53 {
54 public:
55  virtual bool isPressed()
56  {
57  // These objects take care of disabling USB interrupts temporarily
58  // and restoring the pin to its previous state at the end.
59  USBPause usbPause;
61 
63  _delay_us(3);
65  }
66 };
67 
85 {
86 public:
87  virtual bool isPressed()
88  {
89  SPIPause spiPause;
90  USBPause usbPause;
92 
94  _delay_us(3);
96  }
97 };
static bool isInputHigh() __attribute__((always_inline))
Reads the input value of the pin.
Definition: FastGPIO.h:352
Interfaces with button A.
Interfaces with button C.
Main class for interfacing with pushbuttons.
Definition: Pushbutton.h:137
static void setInput() __attribute__((always_inline))
Sets a pin to be a digital input with the internal pull-up resistor disabled.
Definition: FastGPIO.h:333
#define A_STAR_32U4_BUTTON_A
Pushbutton(uint8_t pin, uint8_t pullUp=PULL_UP_ENABLED, uint8_t defaultState=DEFAULT_STATE_HIGH)
Definition: Pushbutton.cpp:120
virtual bool isPressed()
indicates whether button is currently pressed without any debouncing.
General pushbutton class that handles debouncing.
Definition: Pushbutton.h:70
virtual bool isPressed()
indicates whether button is currently pressed without any debouncing.
Interfaces with button B.