Skip to content

Commit

Permalink
Merge pull request #98 from AEFeinstein/fix-pushy
Browse files Browse the repository at this point in the history
Fix pushy checkWeed/checkRainbow
  • Loading branch information
AEFeinstein authored Oct 19, 2023
2 parents d139b2e + 1359f95 commit 2838d9a
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions main/modes/pushy/pushy.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,32 @@ static void displayCounter(char const* counterStr)

static void checkSubStr(char const* counterStr, char const* const subStr, bool digitBitmap[NUM_DIGITS], int64_t* timer)
{
bool found = false;
char const* curCounterStr = counterStr;
memset(digitBitmap, false, NUM_DIGITS);

char const* subStrInCounterStr = strstr(counterStr, subStr);
if (subStrInCounterStr == NULL)
char const* subStrInCounterStr = strstr(curCounterStr, subStr);
while (NULL != subStrInCounterStr)
{
*timer = EFFECT_MAX;
return;
uint8_t startDigit = subStrInCounterStr - counterStr;
for (uint8_t i = 0; i < strlen(subStr); i++)
{
digitBitmap[startDigit + i] = true;
}

*timer = 0;
found = true;

// Move curCounterStr to be one after the found str
curCounterStr = &subStrInCounterStr[1];
// Continue searching
subStrInCounterStr = strstr(curCounterStr, subStr);
}

uint8_t startDigit = subStrInCounterStr - counterStr;
for (uint8_t i = 0; i < strlen(subStr); i++)
if (!found)
{
digitBitmap[startDigit + i] = true;
*timer = EFFECT_MAX;
}

*timer = 0;
}

static void checkRainbow(char const* counterStr)
Expand Down

0 comments on commit 2838d9a

Please sign in to comment.