Merge pull request 'Add level indication to fix #13' (#15) from feature/level-indication into main
Reviewed-on: #15main
commit
a60ad6617f
|
@ -63,6 +63,15 @@ static unsigned const int DisplayLayoutPlayButtonLifeIndication[25] =
|
|||
0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
static unsigned const int DisplayLayoutPlayButtonLifeIndicationUp[25] =
|
||||
{
|
||||
0, 2, 0, 1, 0,
|
||||
0, 3, 0, 1, 1,
|
||||
0, 4, 0, 1, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static unsigned const int DisplayLayoutOneColor[25] =
|
||||
{
|
||||
1, 1, 1, 1, 1,
|
||||
|
|
|
@ -6,7 +6,7 @@ ShowColorSequence::ShowColorSequence():
|
|||
positionDisplay{0},
|
||||
speed{10},
|
||||
ticksTillNextColor{0},
|
||||
lastDisplayWasColor{false},
|
||||
lastDisplayWasColor{true},
|
||||
sequenceDisplayHasStartedBool{false}
|
||||
{}
|
||||
|
||||
|
@ -16,6 +16,8 @@ void ShowColorSequence::enter(SimonSays & simonSays)
|
|||
simonSays.simonDisplay.setActiveColor(simonSays.currentSequence[positionDisplay]);
|
||||
simonSays.simonDisplay.setDisplayMode(0);
|
||||
sequenceDisplayHasStartedBool = false; // reset to not start showing anything
|
||||
lastDisplayWasColor = true; // to start with a short black
|
||||
ticksTillNextColor = 20; // time of black for beginning
|
||||
}
|
||||
|
||||
void ShowColorSequence::update(SimonSays & simonSays)
|
||||
|
@ -31,22 +33,24 @@ void ShowColorSequence::update(SimonSays & simonSays)
|
|||
// Case switches inital display, depending on number of lifes
|
||||
case 3:
|
||||
// all (3) lifes remaining
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndication, true, 5, 10, 9, 1, 1, 1); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndicationUp, true, 5, 10, 9, 1, 1, 1); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
break;
|
||||
case 2:
|
||||
// two (2) lifes remaining
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndication, true, 5, 10, 9, 0, 1, 1); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndicationUp, true, 5, 10, 9, 0, 1, 1); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
break;
|
||||
case 1:
|
||||
// one (1) lifes remaining
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndication, true, 5, 10, 9, 0, 0, 1); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndicationUp, true, 5, 10, 9, 0, 0, 1); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
break;
|
||||
case 0:
|
||||
// no (0) lifes remaining
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndication, true, 5, 10, 9, 0, 0, 0); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
simonSays.simonDisplay.displayDisplayLayout(DisplayLayoutPlayButtonLifeIndicationUp, true, 5, 10, 9, 0, 0, 0); // highlight colors, 9: white, 10:black, 1: green, 0: red this button needs 5 colors
|
||||
break;
|
||||
}
|
||||
|
||||
simonSays.simonDisplay.displayAddLevelIndication(simonSays.currentLevel);
|
||||
|
||||
if (M5.Btn.wasPressed())
|
||||
{
|
||||
// Leave this mode when button was pressed.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "SimonDisplay.h"
|
||||
#include "DisplayModeLayouts.h"
|
||||
#include "MCUInfo.h"
|
||||
|
||||
namespace{
|
||||
CustomDisplay customDisplay;
|
||||
|
@ -29,12 +30,12 @@ SimonDisplay::SimonDisplay(M5Atom &_m5) :
|
|||
|
||||
void SimonDisplay::begin()
|
||||
{
|
||||
baseColors[0] = CRGB(100,0,0);
|
||||
baseColors[1] = CRGB(0,100,0);
|
||||
baseColors[2] = CRGB(0,30,100);
|
||||
baseColors[3] = CRGB(100,100,0);
|
||||
baseColors[4] = CRGB(100, 0, 100);
|
||||
baseColors[5] = CRGB(127, 63, 0);
|
||||
baseColors[0] = CRGB(80,0,0);
|
||||
baseColors[1] = CRGB(0,80,0);
|
||||
baseColors[2] = CRGB(0,20,80);
|
||||
baseColors[3] = CRGB(80,80,0);
|
||||
baseColors[4] = CRGB(80, 0, 80);
|
||||
baseColors[5] = CRGB(63, 32, 0);
|
||||
baseColors[6] = CRGB::Black;
|
||||
baseColors[7] = CRGB::Black;
|
||||
baseColors[8] = CRGB::Black;
|
||||
|
@ -46,7 +47,7 @@ void SimonDisplay::begin()
|
|||
highlightColors[2] = CRGB(0,80,255); // blue
|
||||
highlightColors[3] = CRGB(255,255,0); // yellow?
|
||||
highlightColors[4] = CRGB(255, 0, 255); // violett?
|
||||
highlightColors[5] = CRGB(255, 127, 0); // orange
|
||||
highlightColors[5] = CRGB(255, 100, 0); // orange
|
||||
highlightColors[6] = CRGB::Black;
|
||||
highlightColors[7] = CRGB::Black;
|
||||
highlightColors[8] = CRGB::Black;
|
||||
|
@ -171,7 +172,34 @@ void SimonDisplay::displayDisplayLayout(unsigned const int DisplayLayout[25], bo
|
|||
|
||||
}
|
||||
|
||||
void CustomDisplay::update(SimonDisplay &simonDisplay)
|
||||
void SimonDisplay::displayAddLevelIndication(int currentLevel)
|
||||
{
|
||||
int maxLevel = MCUInfo::maxLevel;
|
||||
CRGB color;
|
||||
|
||||
int levelLedId;
|
||||
for (levelLedId = 0; levelLedId < maxLevel; levelLedId++)
|
||||
{
|
||||
if(currentLevel>levelLedId)
|
||||
{
|
||||
// indicate level Led green for solved
|
||||
color=CRGB(0,50,0);
|
||||
}
|
||||
else if (currentLevel == levelLedId)
|
||||
{
|
||||
//indicate red for current level
|
||||
color=CRGB(50,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// indicate white for future
|
||||
color=CRGB(50,50,50);
|
||||
}
|
||||
drawPixel(levelLedId+15,color); // starts in lower row, max level 10
|
||||
}
|
||||
}
|
||||
|
||||
void CustomDisplay::update(SimonDisplay &simonDisplay)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ class SimonDisplay {
|
|||
void displayOneColor(CRGB color);
|
||||
void displayOneColorById(int colorId, bool highlightBool);
|
||||
void displayDisplayLayout(unsigned const int DisplayLayout[25], bool useHighlightColors, int numColors, ...);
|
||||
void displayAddLevelIndication(int currentLevel);
|
||||
void drawPixel(int i, CRGB color);
|
||||
void clearDisplay();
|
||||
|
||||
|
|
Loading…
Reference in New Issue