New Display modes

pull/14/head
Dennis Bücker 1 year ago
parent 228bddd074
commit 3f2b546867
  1. 2
      src/EnterColorSequence.cpp
  2. 5
      src/ShowColorSequence.cpp
  3. 68
      src/SimonDisplay.cpp
  4. 56
      src/SimonDisplay.h

@ -20,7 +20,7 @@ EnterColorSequence::EnterColorSequence() :
void EnterColorSequence::enter(SimonSays & simonSays){
// Reset game to no input yet
inputStarted = false;
simonSays.simonDisplay.setDisplayMode(1);
simonSays.simonDisplay.setDisplayMode(0);
}
void EnterColorSequence::leave(SimonSays &simonSays)

@ -10,6 +10,7 @@ void ShowColorSequence::enter(SimonSays & simonSays)
{
positionDisplay = 0;
simonSays.simonDisplay.setActiveColor(simonSays.currentSequence[positionDisplay]);
simonSays.simonDisplay.setDisplayMode(0);
}
void ShowColorSequence::update(SimonSays & simonSays)
@ -21,7 +22,7 @@ void ShowColorSequence::update(SimonSays & simonSays)
else
{
simonSays.simonDisplay.setActiveColor(simonSays.currentSequence[positionDisplay]);
simonSays.simonDisplay.displayOneColorById(simonSays.currentSequence[positionDisplay]);
Serial.print("Current color is: ");
Serial.println(simonSays.currentSequence[positionDisplay]);
@ -34,6 +35,6 @@ void ShowColorSequence::update(SimonSays & simonSays)
simonSays.goToNextPhase();
return;
}
ticksTillNextColor=100; //TODO: Set this by selected level
ticksTillNextColor=10; //TODO: Set this by selected level
}
}

@ -1,18 +1,28 @@
#include "SimonDisplay.h"
namespace{
SingleColor singleColor;
CustomDisplay customDisplay;
CustomDisplay customDisplay;
OneColorSelection oneColorSelection;
TwoColorSelection twoColorSelection;
ThreeColorSelection threeColorSelection;
FourColorSelection fourColorSelection;
FiveColorSelection fiveColorSelection;
SixColorSelection sixColorSelection;
}
SimonDisplay::SimonDisplay(M5Atom &_m5) :
m5(_m5),
numberOfColors{2},
currentColor{0},
activeColor{0},
currentMode{0},
modeList{
&singleColor,
&customDisplay
&customDisplay,
&oneColorSelection,
&twoColorSelection,
&threeColorSelection,
&fourColorSelection,
&fiveColorSelection,
&sixColorSelection
}
{}
@ -52,25 +62,10 @@ void SimonDisplay::setDisplayMode(unsigned int _mode)
void SimonDisplay::setActiveColor(int _highlightColor)
{
currentColor=_highlightColor;
activeColor=_highlightColor;
//this->displayOneColor(baseColors[currentColor]); // One could include the highlight bool here
}
void SimonDisplay::drawSingleColor(int colorId, bool hightlightBool)
{
// Legacy, delete lateron
for (int i = 0; i <= 25; i++)
{
if (hightlightBool){
M5.dis.drawpix(i, highlightColors[colorId]);
}
else{
M5.dis.drawpix(i, baseColors[colorId]);
}
}
}
void SimonDisplay::displayOneColor(CRGB _color)
{
for (int i = 0; i <= 25; i++)
@ -79,14 +74,37 @@ void SimonDisplay::displayOneColor(CRGB _color)
}
}
void SingleColor::update(SimonDisplay & simonDisplay)
void SimonDisplay::displayOneColorById(int colorId)
{
// Display single current color
//simonDisplay.drawSingleColor(simonDisplay.currentColor, false);
simonDisplay.displayOneColor(simonDisplay.baseColors[simonDisplay.currentColor]);
displayOneColor(baseColors[colorId]);
}
void CustomDisplay::update(SimonDisplay & simonDisplay)
{
}
void OneColorSelection::update(SimonDisplay &simonDisplay)
{
}
void TwoColorSelection::update(SimonDisplay &simonDisplay)
{
}
void ThreeColorSelection::update(SimonDisplay &simonDisplay)
{
}
void FourColorSelection::update(SimonDisplay &simonDisplay)
{
}
void FiveColorSelection::update(SimonDisplay &simonDisplay)
{
}
void SixColorSelection::update(SimonDisplay &simonDisplay)
{
}

@ -12,17 +12,49 @@ class DisplayMode {
virtual void update(SimonDisplay & simonDisplay) {}
};
class SingleColor final : public DisplayMode {
class CustomDisplay final : public DisplayMode
{
public:
void update(SimonDisplay & simonDisplay) override;
void update(SimonDisplay &simonDisplay) override;
};
class CustomDisplay final : public DisplayMode
class OneColorSelection final : public DisplayMode {
public:
void update(SimonDisplay &simonDisplay) override;
};
class TwoColorSelection final : public DisplayMode
{
public:
void update(SimonDisplay &simonDisplay) override;
};
class ThreeColorSelection final : public DisplayMode
{
public:
void update(SimonDisplay &simonDisplay) override;
};
class FourColorSelection final : public DisplayMode
{
public:
void update(SimonDisplay &simonDisplay) override;
};
class FiveColorSelection final : public DisplayMode
{
public:
void update(SimonDisplay &simonDisplay) override;
};
class SixColorSelection final : public DisplayMode
{
public:
void update(SimonDisplay &simonDisplay) override;
};
class SimonDisplay {
public:
SimonDisplay(M5Atom & _m5);
@ -30,14 +62,16 @@ class SimonDisplay {
void begin();
void update();
void setActiveColor(int _highlightColor);
void setColorSequence(int _colorSequence[10]);
void setActiveColor(int _highlightColor); // The color ID is highlighed. Applicable only for screens with more than 1 color.
//void setColorSequence(int _colorSequence[10]);
void setDisplayMode(unsigned int _mode);
void setNumberColors(int _numberOfColors);
void setColors();
void displayOneColor(CRGB color);
void displayOneColorById(int colorId);
private:
private :
M5Atom m5;
CRGB currentColors[9];
@ -45,17 +79,13 @@ class SimonDisplay {
CRGB highlightColors[9];
int numberOfColors;
int currentColor;
int activeColor;
int currentMode;
friend class SingleColor;
friend class CustomDisplay;
DisplayMode * modeList[2];
DisplayMode * modeList[7];
int currentSequence[10];
private:
// this is used with friends
void drawSingleColor(int colorId, bool hightlightBool);
};
Loading…
Cancel
Save