Skip to content

Commit

Permalink
report time now start running from first touch, audio of wrong touche…
Browse files Browse the repository at this point in the history
…s isnt played, and slight delay after start phase to prevent double touches (#23)
  • Loading branch information
JelmerT authored and trottier committed Oct 3, 2019
1 parent f185047 commit 75d458a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions games/017_Simon/src/simon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,18 @@ bool playSimon(){
yield_wait_for(hub.AnyButtonPressed(), false);
if(hub.AnyButtonPressed()){
touchLog[touchLogIndex] = hub.AnyButtonPressed();
touchLogTimes[touchLogIndex] = millis() - timestampBefore;
touchLogIndex++;}
touchLogTimes[touchLogIndex] = 0;
touchLogIndex++;
// Record start timestamp for performance logging
timestampBefore = millis();
}

// turn off all touchpad lights
hub.SetLights(hub.LIGHT_BTNS, 0, 0, 0);

// slight delay to prevent double presses to show up as a miss
yield_sleep_ms(100, false);

// wait until: no button is currently pressed
yield_wait_for((!hub.AnyButtonPressed()), false);

Expand Down Expand Up @@ -500,8 +506,6 @@ bool playSimon(){
TARGET_RESPONSE_INTENSITY_GREEN,
TARGET_RESPONSE_INTENSITY_BLUE,
SLEW);
hub.PlayAudio(buttonToAudio(pressed[sequence_pos]), AUDIO_VOLUME);
yield_sleep_ms(SOUND_TOUCHPAD_DELAY-50, false);
hub.SetLights(hub.LIGHT_BTNS, 0, 0, 0); // turn off all touchpad lights

// Do lots of logging
Expand All @@ -512,6 +516,9 @@ bool playSimon(){
timeout = false;
if (pressed[sequence_pos] == touchpad_sequence[sequence_pos]){
// correct touchpad touched in sequence
// play touchpad sound
hub.PlayAudio(buttonToAudio(pressed[sequence_pos]), AUDIO_VOLUME);
yield_sleep_ms(SOUND_TOUCHPAD_DELAY-50, false);
accurate = true;
Log.info("Correct");
} else {
Expand Down

0 comments on commit 75d458a

Please sign in to comment.