Bugfix #12 by redrawing every tick. Introduces ugly blink when starting new sequence.

pull/14/head
Dennis Bücker 1 year ago
parent d0f76fc5d1
commit 754bbb7c87
  1. 52
      src/EnterColorSequence.cpp

@ -125,6 +125,11 @@ void EnterColorSequence::enter(SimonSays & simonSays){
Serial.print("Number of unique elements: ");
Serial.println(numberOfUniqueColors);
// give information to display module
simonSays.simonDisplay.setNumberColors(numberOfUniqueColors);
simonSays.simonDisplay.setActiveColor(inputActiveColor);
simonSays.simonDisplay.setColorsToDisplay(arrayOfUniqueColors);
// Switch to correct color selection state
switch (numberOfUniqueColors)
{
@ -151,11 +156,6 @@ void EnterColorSequence::enter(SimonSays & simonSays){
break;
}
// give information to display module
simonSays.simonDisplay.setNumberColors(numberOfUniqueColors);
simonSays.simonDisplay.setActiveColor(inputActiveColor);
simonSays.simonDisplay.setColorsToDisplay(arrayOfUniqueColors);
Serial.println("Please enter color sequence.");
}
@ -167,34 +167,31 @@ void EnterColorSequence::update(SimonSays &simonSays)
{
if (!levelCompleted)
{
// if (!inputStarted) {
// // Only start,
// simonSays.simonDisplay.displayOneColor(CRGB::Green);
// //Serial.println("Game not started condition.");
// if (M5.Btn.wasPressed())
// {
// inputStarted = true;
// }
// else
// {
// return;
// }
// }
// check for short press
if (M5.Btn.wasReleased())
{
// Advance the input color
inputActiveColor = (inputActiveColor + 1) % numberOfUniqueColors;
simonSays.simonDisplay.setActiveColor(arrayOfUniqueColors[inputActiveColor]);
// Debug for selection
Serial.print("Input position: ");
Serial.println(inputSequencePosition);
Serial.print("Current color: ");
Serial.println(arrayOfUniqueColors[inputActiveColor]);
// Debug help to see where input is in sequence and if next input is correct.
Serial.print("Next requested color is ");
Serial.print(simonSays.currentSequence[inputSequencePosition]);
Serial.print(" and current selected color is ");
Serial.print(arrayOfUniqueColors[inputActiveColor]);
Serial.print(" an input click would be: ");
if (arrayOfUniqueColors[inputActiveColor] == simonSays.currentSequence[inputSequencePosition])
{
Serial.println("CORRECT.");
}
else
{
Serial.println("FALSE!");
}
}
// Update the color to display every tick for failsave
simonSays.simonDisplay.setActiveColor(arrayOfUniqueColors[inputActiveColor]);
// check for long press
if (M5.Btn.wasReleaseFor(MCUInfo::longButtonPress))
{
@ -225,7 +222,8 @@ void EnterColorSequence::update(SimonSays &simonSays)
else
{
// This code will run, if level is completed
simonSays.simonDisplay.setDisplayMode(0); // set display mode to custom
simonSays.simonDisplay.setDisplayMode(0); // set display mode to custom for displayLayout.
ticksTillNextLevel--; // decrese tick counter
if (levelSuccess)
{

Loading…
Cancel
Save