Skip to content

Commit d8e5997

Browse files
committed
Added Esplora readJoystickButton function to be consistent with Esplora readButton
1 parent d7d78ff commit d8e5997

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

libraries/Esplora/Esplora.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ boolean _Esplora::readButton(byte ch) {
111111
return (val > 512) ? HIGH : LOW;
112112
}
113113

114+
boolean _Esplora::readJoystickButton() {
115+
if (readChannel(CH_JOYSTICK_SW) == 1023) {
116+
return HIGH;
117+
} else if (readChannel(CH_JOYSTICK_SW) == 0) {
118+
return LOW;
119+
}
120+
}
121+
122+
114123
void _Esplora::writeRGB(byte r, byte g, byte b) {
115124
writeRed(r);
116125
writeGreen(g);

libraries/Esplora/Esplora.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef ESPLORA_H_
2222
#define ESPLORA_H_
2323

24-
#include "Arduino.h"
24+
#include <Arduino.h>
2525

2626
/*
2727
* The following constants are used internally by the Esplora
@@ -141,6 +141,8 @@ class _Esplora {
141141
* LOW if the button is pressed, and HIGH otherwise.
142142
*/
143143
boolean readButton(byte channel);
144+
145+
boolean readJoystickButton();
144146

145147
void writeRGB(byte red, byte green, byte blue);
146148
void writeRed(byte red);

libraries/Esplora/keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ readLightSensor KEYWORD2
1616
readTemperature KEYWORD2
1717
readMicrophone KEYWORD2
1818
readJoystickSwitch KEYWORD2
19+
readJoystickButton KEYWORD2
1920
readJoystickX KEYWORD2
2021
readJoystickY KEYWORD2
2122
readAccelerometer KEYWORD2

0 commit comments

Comments
 (0)