File tree 3 files changed +15
-9
lines changed 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,17 @@ void Buttons::init() {
30
30
// if (DEBUG) {Serial.print(F("DEBUG,buttons: initialized Gamepad1\r\n"));}
31
31
}
32
32
33
- void Buttons::readInputs () {
33
+ bool Buttons::readInputs () {
34
34
unsigned char buttonPushed = 2 ; // this is set to notify light show that a button press has happened
35
+ bool buttonChangedState = false ;
35
36
// read shift register values
36
37
if (buttonReader.update () || numberButtonsPressed > 0 ) {
37
38
// if (DEBUG) {Serial.print(F("DEBUG"));}
38
39
for (unsigned char i = 0 ; i < 24 ; i++) {
39
40
bool currentButtonState = !buttonReader.state (i);
40
41
// if (DEBUG) {Serial.print(currentButtonState);}
41
42
if (currentButtonState != config.lastButtonState [i]) {
42
-
43
+ buttonChangedState = true ;
43
44
44
45
if (currentButtonState == 1 ) {
45
46
buttonPushed = 1 ;
@@ -63,6 +64,7 @@ void Buttons::readInputs() {
63
64
config.lightShowState = INPUT_RECEIVED_SET_LIGHTS_LOW;
64
65
}
65
66
}
67
+ return buttonChangedState;
66
68
}
67
69
68
70
bool Buttons::sendButtonPush (unsigned char i, bool currentButtonState) {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Buttons {
9
9
10
10
public:
11
11
Buttons ();
12
- void readInputs ();
12
+ bool readInputs ();
13
13
void init ();
14
14
void sendButtonState ();
15
15
bool sendButtonPush (unsigned char i, bool currentButtonState);
Original file line number Diff line number Diff line change @@ -37,9 +37,8 @@ void setup() {
37
37
38
38
39
39
void loop () {
40
- // long int t1 = millis();
41
- buttons.readInputs ();
42
- if (!USBDevice.isSuspended ()) {
40
+ // unsigned long t1 = micros();
41
+ if (!buttons.readInputs () && !USBDevice.isSuspended ()) {
43
42
plunger.plungerRead ();
44
43
if (config.accelerometerEprom > 0 ) {
45
44
accel.accelerometerRead ();
@@ -50,10 +49,15 @@ void loop() {
50
49
config.updateUSB = false ;
51
50
}
52
51
comm.communicate ();
52
+ } else {
53
+ Gamepad1.write ();
54
+ // unsigned long t2 = micros();
55
+ // Serial.print(F("DEBUG,Time taken by the task: "));
56
+ // Serial.print(t2 - t1);
57
+ // Serial.println(F(" microseconds"));
58
+ // delay(100);
53
59
}
54
- // long int t2 = millis();
55
- // Serial.print(F("DEBUG,Time taken by the task: ")); Serial.print((t2-t1)); Serial.print(F(" milliseconds\r\n"));
56
- // delay(100);
60
+
57
61
// Serial.println("arduino is running");
58
62
59
63
}
You can’t perform that action at this time.
0 commit comments