mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
Add progress bar for strip
This commit is contained in:
parent
1279b8bfe0
commit
d2e845e2dd
3 changed files with 34 additions and 1 deletions
|
@ -18,6 +18,20 @@ 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)
|
||||
|
@ -25,5 +39,15 @@ 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);
|
||||
|
||||
// TODO: only update strip when necessarry
|
||||
if (level != lastLevel)
|
||||
{
|
||||
lastLevel = level;
|
||||
// update strip
|
||||
for (int i = 14; i >= level; i--)
|
||||
{
|
||||
leds[i].setRGB(0, 0, 1);
|
||||
FastLED.show();
|
||||
FastLED.show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,11 @@ public:
|
|||
|
||||
void setGreen(int led);
|
||||
|
||||
void animateBottomToTop(int r, int g, int b);
|
||||
|
||||
void progressBar(int min, int max, int val);
|
||||
|
||||
private:
|
||||
CRGB leds[PIXELCOUNT]; // Define the array of leds
|
||||
int lastLevel = -1;
|
||||
};
|
|
@ -130,6 +130,10 @@ void loop()
|
|||
{
|
||||
smartDisplay.printWaitForRFIDScreen();
|
||||
|
||||
smartStrip.setGreen(0);
|
||||
smartStrip.setGreen(7);
|
||||
smartStrip.setGreen(14);
|
||||
|
||||
// this blocks execution until a tag has been detected (5s timeout)
|
||||
String uid = smartRFID.readTag(5000);
|
||||
if (uid != "no_tag_detected" && uid != "")
|
||||
|
@ -244,6 +248,7 @@ void loop()
|
|||
{
|
||||
teaTimer.endSteeping();
|
||||
smartDisplay.printMsg("DONE");
|
||||
smartStrip.animateBottomToTop(0, 1, 0);
|
||||
delay(1000);
|
||||
state = State::REQUEST_FEEDBACK;
|
||||
break;
|
||||
|
@ -258,6 +263,7 @@ void loop()
|
|||
else
|
||||
{
|
||||
smartDisplay.printMsg("DONE");
|
||||
smartStrip.animateBottomToTop(0, 1, 0);
|
||||
delay(1000);
|
||||
state = State::REQUEST_FEEDBACK;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue