mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
53 lines
No EOL
1,007 B
C++
53 lines
No EOL
1,007 B
C++
#include "SmartStrip.hpp"
|
|
|
|
#define LEDSTRIPE_PIN 15 // D8
|
|
|
|
void SmartStrip::init()
|
|
{
|
|
FastLED.addLeds<NEOPIXEL, LEDSTRIPE_PIN>(leds, 15);
|
|
reset();
|
|
}
|
|
|
|
void SmartStrip::reset()
|
|
{
|
|
FastLED.clear(true);
|
|
FastLED.show();
|
|
}
|
|
|
|
void SmartStrip::setGreen(int led)
|
|
{
|
|
leds[led].setRGB(0, 2, 0);
|
|
FastLED.show();
|
|
FastLED.show();
|
|
}
|
|
|
|
void SmartStrip::animateBottomToTop(int r, int g, int b)
|
|
{
|
|
for (int i = 0; i <= 14; i++)
|
|
{
|
|
leds[i].setRGB(r, g, b);
|
|
FastLED.show();
|
|
FastLED.show();
|
|
delay(100);
|
|
}
|
|
FastLED.clear(true);
|
|
FastLED.show();
|
|
}
|
|
|
|
void SmartStrip::progressBar(int min, int max, int val)
|
|
{
|
|
// starts at 14 and goes down to 0 as steeping continues
|
|
int level = map(val, min, max, 0, 14);
|
|
|
|
if (level != lastLevel)
|
|
{
|
|
lastLevel = level;
|
|
// update strip
|
|
for (int i = 14; i >= level; i--)
|
|
{
|
|
leds[i].setRGB(0, 0, 1);
|
|
FastLED.show();
|
|
FastLED.show();
|
|
}
|
|
}
|
|
} |