Add feature to give feedback for long button press, resolves #8

pull/14/head
Dennis Bücker 1 year ago
parent 754bbb7c87
commit 9c818b730f
  1. 9
      src/DisplayModeLayouts.h
  2. 27
      src/EnterColorSequence.cpp

@ -18,6 +18,15 @@ static unsigned const int DisplayLayoutX[25] =
1, 0, 0, 0, 1,
};
static unsigned const int DisplayLayoutODot[25] =
{
1, 1, 1, 1, 1,
1, 0, 0, 0, 1,
1, 0, 1, 0, 1,
1, 0, 0, 0, 1,
1, 1, 1, 1, 1,
};
static unsigned const int DisplayLayoutCheckmark[25] =
{
0, 0, 0, 0, 0,

@ -192,7 +192,20 @@ void EnterColorSequence::update(SimonSays &simonSays)
// Update the color to display every tick for failsave
simonSays.simonDisplay.setActiveColor(arrayOfUniqueColors[inputActiveColor]);
// check for long press
// check for long press for indication, if long enough
if (M5.Btn.wasPressedFor(MCUInfo::longButtonPress))
{
// this will run immediatly when button press is long enough
// Go to custom display mode (will be resetted with button release)
simonSays.simonDisplay.setDisplayMode(0);
// show white O with dot
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutODot, true, 2, 10, 9); // 2 colors: highlight colors, 9: white, 10:black, // needs custom mode
//Serial.println("Button press was long enough.");
}
// check for long press and release
if (M5.Btn.wasReleaseFor(MCUInfo::longButtonPress))
{
// Check if selected color was correct !-> loose condition + restart
@ -200,19 +213,25 @@ void EnterColorSequence::update(SimonSays &simonSays)
// check if sequence ready
// --> advance level
if (arrayOfUniqueColors[inputActiveColor] == simonSays.currentSequence[inputSequencePosition]) {
// Reset display mode.
simonSays.simonDisplay.setDisplayMode(numberOfUniqueColors);
if (arrayOfUniqueColors[inputActiveColor] == simonSays.currentSequence[inputSequencePosition])
{
// show green flash as correct input, maybe enter this earlier after pressdown already
// Advance sequence counter
inputSequencePosition++;
// Check for game End condition
if (inputSequencePosition == simonSays.currentSequenceLength) {
if (inputSequencePosition == simonSays.currentSequenceLength)
{
levelCompleted = true;
levelSuccess = true;
}
}
else {
else
{
// An error was made, this will go to error mode
levelCompleted = true;
levelSuccess = false;

Loading…
Cancel
Save