Added defines for code quality

This commit is contained in:
CommanderRedYT
2021-09-30 14:09:05 +02:00
parent 0529c85151
commit fb120aa7f8
2 changed files with 15 additions and 4 deletions

View File

@ -8,12 +8,13 @@
#include "globals.h"
#include "cpputils.h"
#include "espchrono.h"
#include "ledstripdefines.h"
namespace {
std::vector<CRGB> leds;
uint8_t gHue = 0;
int16_t blinkAnimation = 0;
int16_t blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT;
void showDefaultLedstrip();
@ -28,7 +29,7 @@ void updateLedStrip()
{
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
if (cpputils::is_in(blinkAnimation, 1, 2, 3))
if (cpputils::is_in(blinkAnimation, LEDSTRIP_ANIMATION_BLINKLEFT, LEDSTRIP_ANIMATION_BLINKRIGHT, LEDSTRIP_ANIMATION_BLINKBOTH))
{
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
@ -37,9 +38,9 @@ void updateLedStrip()
auto color = CRGB{255, 255, 0};
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
if (blinkAnimation != 2)
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT)
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
if (blinkAnimation != 1)
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT)
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
}
}

View File

@ -0,0 +1,10 @@
#pragma once
/*
* This file contains a few defines, so you don't have to remember which ledstrip animation is which number
*/
#define LEDSTRIP_ANIMATION_DEFAULTRAINBOW 0
#define LEDSTRIP_ANIMATION_BLINKLEFT 1
#define LEDSTRIP_ANIMATION_BLINKRIGHT 2
#define LEDSTRIP_ANIMATION_BLINKBOTH 3
#define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW