Add an equivalent example using the new Joystick API. Also add pin initializing code to Joystick::AddButton()

This commit is contained in:
2015-11-06 12:07:37 -05:00
parent c2771502e3
commit f2d7f48d43
4 changed files with 30 additions and 2 deletions

View File

@ -21,7 +21,10 @@ void Joystick::Init() {
if (_debug) Serial.println("DEBUG: Joystick library initialized.");
}
void Joystick::AddButton(uint8_t pin, ButtonType type) {
void Joystick::AddButton(uint8_t pin, ButtonType type, bool pullup) {
if (pullup) pinMode(pin, INPUT_PULLUP);
else pinMode(pin, INPUT);
_buttons[_num_buttons].pin = pin;
_buttons[_num_buttons].type = type;
_buttons[_num_buttons].last_state = digitalRead(pin);