Skip to content

Commit

Permalink
Added parameter aRepetitions to pattern RainbowCycle
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Sep 21, 2022
1 parent 0f3e796 commit 38cf9ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/MatrixSnake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ void MatrixAndSnakePatternsDemoHandler(NeoPatterns *aLedsPtr) {
switch (tState) {
case 0:
// myLoadTest(tLedsPtr);
// Random ticker
setMatrixAndSnakePatternsDemoHandlerRandomTickerText();
tLedsPtr->TickerInit(sTickerTextPtr, NeoPatterns::Wheel(0), COLOR32_BLACK, 80, sTickerDirection, FLAG_TICKER_DATA_IN_FLASH);
sTickerDirection--;
Expand All @@ -1103,7 +1104,7 @@ void MatrixAndSnakePatternsDemoHandler(NeoPatterns *aLedsPtr) {
if (sHeartDirection == DIRECTION_UP) {
tYOffset = tLedsPtr->Rows + HEART_HEIGHT;
}
// move in
// move heart in
tLedsPtr->MovingPicturePGM(heart8x8, COLOR32_RED_HALF, COLOR32_BLACK, tXOffset, tYOffset, tSteps, 100, sHeartDirection);
break;
case 2:
Expand All @@ -1124,7 +1125,7 @@ void MatrixAndSnakePatternsDemoHandler(NeoPatterns *aLedsPtr) {
break;

case 6:
// move out - for move out, we can use Move instead of MovingPicturePGM
// move heart out - for move out, we can use Move instead of MovingPicturePGM
tLedsPtr->Move(sHeartDirection, tLedsPtr->Rows, 100);
// change direction for next time
if (sHeartDirection == DIRECTION_DOWN) {
Expand All @@ -1137,6 +1138,7 @@ void MatrixAndSnakePatternsDemoHandler(NeoPatterns *aLedsPtr) {
aLedsPtr->Delay(1500);
break;
case 8:
// Snake or Fire or Snow pattern
if (sSnakeFireSnowSelector == 0) {
initSnakeAutorun(tLedsPtr, 200, COLOR32_BLUE, 1);
} else if (sSnakeFireSnowSelector == 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/NeoPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ class NeoPatterns: public virtual NeoPixel {
* If aDoUpdate is true, update pattern, otherwise only redraw the pattern
*/
#if defined(ENABLE_PATTERN_RAINBOW_CYCLE)
void RainbowCycle(uint8_t aIntervalMillis, uint8_t aDirection = DIRECTION_UP);
void RainbowCycleD(uint8_t aDurationMillis, uint8_t aDirection = DIRECTION_UP);
void RainbowCycle(uint8_t aIntervalMillis, uint8_t aDirection = DIRECTION_UP, uint8_t aRepetitions = 1);
void RainbowCycleD(uint8_t aDurationMillis, uint8_t aDirection = DIRECTION_UP, uint8_t aRepetitions = 1);
bool RainbowCycleUpdate(bool aDoUpdate = true);
#endif
#if defined(ENABLE_PATTERN_COLOR_WIPE)
Expand Down
16 changes: 9 additions & 7 deletions src/NeoPatterns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,14 @@ bool NeoPatterns::decrementTotalStepCounterAndSetNextIndex() {
* Initialize for a RainbowCycle
* First of 256 steps is last pixel = Wheel(0) = RED going up over yellow and green to BLUE or backwards if DIRECTION_DOWN
*/
void NeoPatterns::RainbowCycleD(uint8_t aDurationMillis, uint8_t aDirection) {
RainbowCycle(aDurationMillis, aDirection | PARAMETER_IS_DURATION);
void NeoPatterns::RainbowCycleD(uint8_t aDurationMillis, uint8_t aDirection, uint8_t aRepetitions) {
RainbowCycle(aDurationMillis, aDirection | PARAMETER_IS_DURATION, aRepetitions);
}

void NeoPatterns::RainbowCycle(uint8_t aIntervalMillis, uint8_t aDirection) {
void NeoPatterns::RainbowCycle(uint8_t aIntervalMillis, uint8_t aDirection, uint8_t aRepetitions) {
// Must move index in opposite direction
Direction = OppositeDirection(aDirection & DIRECTION_MASK);
TotalStepCounter = 256;
TotalStepCounter = 256 * aRepetitions;
if (Direction == DIRECTION_UP) {
Index = 0;
} else {
Expand Down Expand Up @@ -679,12 +679,13 @@ bool NeoPatterns::RainbowCycleUpdate(bool aDoUpdate) {

#if defined(ENABLE_PATTERN_COLOR_WIPE)
/**
* ColorWipeD 2. Parameter is complete duration and not step interval
* @brief Initialize for a ColorWipe. First step is one pixel set, last step is all pixel set.
* @param aMode can be 0 / FLAG_DO_CLEAR (default) or FLAG_DO_NOT_CLEAR(_BlackPixel)
* @param aDirection can be DIRECTION_UP (default) or DIRECTION_DOWN
*/
void NeoPatterns::ColorWipeD(color32_t aColor, uint16_t aIntervalMillis, uint8_t aMode, uint8_t aDirection) {
ColorWipe(aColor, aIntervalMillis, aMode, aDirection | PARAMETER_IS_DURATION);
void NeoPatterns::ColorWipeD(color32_t aColor, uint16_t aDurationMillis, uint8_t aMode, uint8_t aDirection) {
ColorWipe(aColor, aDurationMillis, aMode, aDirection | PARAMETER_IS_DURATION);
}
void NeoPatterns::ColorWipe(color32_t aColor, uint16_t aIntervalMillis, uint8_t aMode, uint8_t aDirection) {
Color1 = aColor;
Expand Down Expand Up @@ -1114,7 +1115,8 @@ bool NeoPatterns::ScannerExtendedUpdate(bool aDoUpdate) {
#endif

#if defined(ENABLE_PATTERN_STRIPES)
/*
/**
* StripesD Parameter is complete duration and not step interval
* Start with aLength1 pixel of aLength1 followed by aLength2 pixel of aColor2 and then starting with aColor1 again until Strip ends.
* If DIRECTION_DOWN the same pattern starts from the other end.
* If aNumberOfSteps == (aLength1 + aLength2) the last pattern is equal first pattern
Expand Down
4 changes: 2 additions & 2 deletions src/utility/font_6x8.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const uint8_t font_PGM[] PROGMEM =
0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00, // 0x60
0x00,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00, // 0x61 a
0x10,0x10,0x1E,0x11,0x11,0x11,0x1E,0x00, // 0x62
0x00,0x00,0x0E,0x11,0x10,0x11,0x0E,0x00, // 0x63
0x00,0x00,0x0E,0x10,0x10,0x10,0x0E,0x00, // 0x63 c
0x01,0x01,0x0F,0x11,0x11,0x11,0x0F,0x00, // 0x64
0x00,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00, // 0x65
0x06,0x08,0x08,0x1E,0x08,0x08,0x08,0x00, // 0x66
Expand All @@ -86,7 +86,7 @@ const uint8_t font_PGM[] PROGMEM =
0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x00, // 0x6C l
0x00,0x00,0x1A,0x15,0x15,0x11,0x11,0x00, // 0x6D
0x00,0x00,0x1C,0x12,0x12,0x12,0x12,0x00, // 0x6E
0x00,0x00,0x0E,0x11,0x11,0x11,0x0E,0x00, // 0x6F
0x00,0x00,0x0E,0x11,0x11,0x11,0x0E,0x00, // 0x6F o
0x00,0x00,0x1E,0x11,0x11,0x11,0x1E,0x10, // 0x70
0x00,0x00,0x0F,0x11,0x11,0x11,0x0F,0x01, // 0x71
0x00,0x00,0x16,0x09,0x08,0x08,0x1C,0x00, // 0x72
Expand Down

0 comments on commit 38cf9ec

Please sign in to comment.