Bugfix display highlight and new colors

pull/14/head
Dennis Bücker 1 year ago
parent f57c833d68
commit afecc92ea2
  1. 18
      src/DisplayModeLayouts.h
  2. 5
      src/EnterColorSequence.cpp
  3. 2
      src/ShowColorSequence.cpp
  4. 67
      src/SimonDisplay.cpp
  5. 4
      src/SimonDisplay.h
  6. 4
      src/SimonSays.cpp

@ -1,4 +1,4 @@
unsigned const int DisplayLayoutNoColor[25] =
static unsigned const int DisplayLayoutNoColor[25] =
{
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
@ -7,7 +7,7 @@ unsigned const int DisplayLayoutNoColor[25] =
0, 0, 0, 0, 0,
};
unsigned const int DisplayLayoutOneColor[25] =
static unsigned const int DisplayLayoutOneColor[25] =
{
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
@ -16,7 +16,7 @@ unsigned const int DisplayLayoutOneColor[25] =
1, 1, 1, 1, 1,
};
unsigned const int DisplayLayoutTwoColor[25] =
static unsigned const int DisplayLayoutTwoColor[25] =
{
1, 1, 0, 2, 2,
1, 1, 0, 2, 2,
@ -25,7 +25,7 @@ unsigned const int DisplayLayoutTwoColor[25] =
1, 1, 0, 2, 2,
};
unsigned const int DisplayLayoutThreeColor[25] =
static unsigned const int DisplayLayoutThreeColor[25] =
{
1, 1, 1, 0, 0,
1, 1, 1, 2, 2,
@ -34,7 +34,7 @@ unsigned const int DisplayLayoutThreeColor[25] =
3, 3, 3, 0, 0,
};
unsigned const int DisplayLayoutFourColor[25] =
static unsigned const int DisplayLayoutFourColor[25] =
{
1, 1, 0, 2, 2,
1, 1, 0, 2, 2,
@ -43,7 +43,7 @@ unsigned const int DisplayLayoutFourColor[25] =
4, 4, 0, 3, 3,
};
unsigned const int DisplayLayoutFiveColor[25] =
static unsigned const int DisplayLayoutFiveColor[25] =
{
1, 1, 5, 2, 2,
1, 1, 5, 2, 2,
@ -52,10 +52,10 @@ unsigned const int DisplayLayoutFiveColor[25] =
4, 4, 5, 3, 3,
};
unsigned const int DisplayLayoutSixColor[25] =
static unsigned const int DisplayLayoutSixColor[25] =
{
1, 5, 5, 6, 6,
1, 5, 5, 6, 6,
1, 6, 6, 5, 5,
1, 6, 6, 5, 5,
1, 1, 0, 4, 4,
2, 2, 3, 3, 4,
2, 2, 3, 3, 4,

@ -121,7 +121,10 @@ void EnterColorSequence::enter(SimonSays & simonSays){
Serial.println();
Serial.print("Number of unique elements: ");
Serial.println(numberOfUniqueColors);
// give information to display module
simonSays.simonDisplay.setNumberColors(numberOfUniqueColors);
simonSays.simonDisplay.setColorsToDisplay(arrayOfUniqueColors);
}
void EnterColorSequence::leave(SimonSays &simonSays)

@ -23,7 +23,7 @@ void ShowColorSequence::update(SimonSays & simonSays)
else
{
if (!lastDisplayWasColor) {
simonSays.simonDisplay.displayOneColorById(simonSays.currentSequence[positionDisplay]);
simonSays.simonDisplay.displayOneColorById(simonSays.currentSequence[positionDisplay],true);
Serial.print("Current color is: ");
Serial.println(simonSays.currentSequence[positionDisplay]);

@ -30,24 +30,24 @@ SimonDisplay::SimonDisplay(M5Atom &_m5) :
void SimonDisplay::begin()
{
baseColors[0] = CRGB(100,0,0);
baseColors[1] = CRGB::DarkBlue;
baseColors[2] = CRGB::DarkOrange;
baseColors[3] = CRGB::Gold;
baseColors[4] = CRGB::DarkViolet;
baseColors[5] = CRGB(100, 100, 100);
baseColors[6] = CRGB::Maroon;
baseColors[7] = CRGB::DarkTurquoise;
baseColors[8] = CRGB::DeepPink;
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[6] = CRGB::Black;
baseColors[7] = CRGB::Black;
baseColors[8] = CRGB::Black;
highlightColors[0] = CRGB(255,0,0);
highlightColors[1] = CRGB::Blue;
highlightColors[2] = CRGB::Orange;
highlightColors[3] = CRGB::Yellow;
highlightColors[4] = CRGB::Violet;
highlightColors[5] = CRGB::White;
highlightColors[6] = CRGB::Brown;
highlightColors[7] = CRGB::Turquoise;
highlightColors[8] = CRGB::Pink;
highlightColors[1] = CRGB(0,255,0);
highlightColors[2] = CRGB(0,80,255);
highlightColors[3] = CRGB(255,255,0);
highlightColors[4] = CRGB(255, 0, 255);
highlightColors[5] = CRGB(255, 127, 0);
highlightColors[6] = CRGB::Black;
highlightColors[7] = CRGB::Black;
highlightColors[8] = CRGB::Black;
}
void SimonDisplay::update()
@ -79,12 +79,18 @@ void SimonDisplay::setNumberColors(int _numberOfColors)
void SimonDisplay::setActiveColor(int _activeColor)
{
activeColor=_activeColor;
// Search for position of active color in array
for (int i = 0; i<numberOfColors; i++) {
if (colorsToDisplay[i]==_activeColor) {
activeColor = i;
return;
}
}
}
void SimonDisplay::displayOneColor(CRGB _color)
{
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
M5.dis.drawpix(i, _color);
}
@ -100,9 +106,14 @@ void SimonDisplay::clearDisplay()
M5.dis.clear();
}
void SimonDisplay::displayOneColorById(int colorId)
void SimonDisplay::displayOneColorById(int colorId, bool highlightBool)
{
displayOneColor(baseColors[colorId]);
if (highlightColors){
displayOneColor(highlightColors[colorId]);
}
else {
displayOneColor(baseColors[colorId]);
}
}
@ -116,7 +127,7 @@ void OneColorSelection::update(SimonDisplay &simonDisplay)
{
simonDisplay.clearDisplay(); // clear display first
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
if (DisplayLayoutOneColor[i] == 0)
{
@ -143,7 +154,7 @@ void TwoColorSelection::update(SimonDisplay &simonDisplay)
simonDisplay.clearDisplay(); // clear display first
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
if (DisplayLayoutTwoColor[i] == 0)
{
@ -162,6 +173,10 @@ void TwoColorSelection::update(SimonDisplay &simonDisplay)
}
}
}
for (int i = 0; i<simonDisplay.numberOfColors; i++){
Serial.print(simonDisplay.colorsToDisplay[i]);
}
Serial.println();
}
void ThreeColorSelection::update(SimonDisplay &simonDisplay)
@ -171,7 +186,7 @@ void ThreeColorSelection::update(SimonDisplay &simonDisplay)
simonDisplay.clearDisplay(); // clear display first
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
if (DisplayLayoutThreeColor[i]==0) {
// if there is a zero, this will display black
@ -194,7 +209,7 @@ void FourColorSelection::update(SimonDisplay &simonDisplay)
simonDisplay.clearDisplay(); // clear display first
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
if (DisplayLayoutFourColor[i] == 0)
{
@ -221,7 +236,7 @@ void FiveColorSelection::update(SimonDisplay &simonDisplay)
simonDisplay.clearDisplay(); // clear display first
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
if (DisplayLayoutFiveColor[i] == 0)
{
@ -247,7 +262,7 @@ void SixColorSelection::update(SimonDisplay &simonDisplay)
simonDisplay.clearDisplay(); // clear display first
for (int i = 0; i <= 25; i++)
for (int i = 0; i < 25; i++)
{
if (DisplayLayoutSixColor[i] == 0)
{

@ -71,7 +71,7 @@ class SimonDisplay {
void setNumberColors(int _numberOfColors);
void setColors();
void displayOneColor(CRGB color);
void displayOneColorById(int colorId);
void displayOneColorById(int colorId, bool highlightBool);
void drawPixel(int i, CRGB color);
void clearDisplay();
@ -84,7 +84,7 @@ class SimonDisplay {
CRGB highlightColors[9];
int numberOfColors;
int activeColor;
int activeColor; // idx of color id in array colorsToDisplay.
int currentMode;
friend class SingleColor;

@ -55,8 +55,8 @@ void SimonSays::goToNextPhase() {
void SimonSays::generateNewSequence() {
// Values will be generated by Level property
currentSequenceLength = 10;
int numberOfColors = 4;
currentSequenceLength = 8;
int numberOfColors = 6;
Serial.print("Generated sequence ");
for (int i = 0; i < currentSequenceLength; i++)

Loading…
Cancel
Save