animations: testanimation: rewrite into something that can help debug coord mappings
This commit is contained in:
parent
81bebad459
commit
5668266a23
@ -1,53 +1,32 @@
|
|||||||
#include "./TestAnimation.h"
|
#include "./TestAnimation.h"
|
||||||
|
#include "../Static.h"
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
|
|
||||||
const char*
|
|
||||||
TestAnimation::name() const
|
|
||||||
{
|
|
||||||
return "Test";
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TestAnimation::handleEvent(const InputEvent& evt)
|
|
||||||
{
|
|
||||||
if (evt.intent == InputEvent::Acceleration) {
|
|
||||||
if (evt.asInt() > 5) {
|
|
||||||
m_brightness += 15;
|
|
||||||
}
|
|
||||||
m_hue += scale8(evt.asInt(), 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evt.intent == InputEvent::UserInput) {
|
|
||||||
switch(evt.asInt()) {
|
|
||||||
case 1:
|
|
||||||
m_brightness.set(255, 0);break;
|
|
||||||
case 2:
|
|
||||||
m_saturation.set(255, 128);break;
|
|
||||||
default:
|
|
||||||
m_brightness.set(255, 0);
|
|
||||||
m_saturation.set(255, 128);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestAnimation::loop()
|
TestAnimation::loop()
|
||||||
{
|
{
|
||||||
m_x += 4;
|
m_x += 1;
|
||||||
if (m_x % 12 == 0) {
|
m_y += 1;
|
||||||
m_y += 28;
|
|
||||||
}
|
|
||||||
m_hue.update();
|
|
||||||
m_saturation.update();
|
|
||||||
m_brightness.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TestAnimation::render(Display* dpy) const
|
TestAnimation::render(Display* dpy) const
|
||||||
{
|
{
|
||||||
for(uint8_t col = 0; col < 3; col++) {
|
for(unsigned int i = 0; i < dpy->pixelCount(); i++) {
|
||||||
for (uint8_t i = 0; i < 254; i+=10) {
|
dpy->pixelAt(i) = CRGB{255, 255, 255};
|
||||||
dpy->pixelAt(VirtualCoordinates{(uint8_t)(m_x + (col * (254 / 3))), (uint8_t)(i + m_y)}) = CHSV(m_hue, m_saturation + 100, scale8(i, m_brightness));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
// Blank the canvas to white
|
||||||
|
Surface{dpy, {0, 0}, {255, 255}} = CRGB{255, 255, 255};
|
||||||
|
// Draw red line on top row
|
||||||
|
Surface{dpy, {0, 0}, {255, 0}} = CRGB{255, 0, 0};
|
||||||
|
// Green line on first column
|
||||||
|
Surface{dpy, {0, 0}, {0, 255}} = CRGB{0, 255, 0};
|
||||||
|
|
||||||
|
//Surface{dpy, {m_x, 0}, {m_x, 255}} = CRGB{255, 0, 0};
|
||||||
|
///Surface{dpy, {0, m_y}, {255, m_y}} = CRGB{255, 0, 0};
|
||||||
|
//dpy->pixelAt(VirtualCoordinates{m_x, m_y}) = CRGB{255, 0, 255};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC_ALLOC(TestAnimation);
|
||||||
|
STATIC_TASK(TestAnimation);
|
||||||
|
@ -2,15 +2,11 @@
|
|||||||
|
|
||||||
class TestAnimation: public Figment {
|
class TestAnimation: public Figment {
|
||||||
public:
|
public:
|
||||||
const char* name() const;
|
TestAnimation() : Figment("Test") {}
|
||||||
void handleEvent(const InputEvent& evt) override;
|
|
||||||
void loop() override;
|
void loop() override;
|
||||||
void render(Display* dpy) const override;
|
void render(Display* dpy) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AnimatedNumber m_hue;
|
|
||||||
AnimatedNumber m_saturation;
|
|
||||||
AnimatedNumber m_brightness;
|
|
||||||
uint8_t m_x;
|
uint8_t m_x;
|
||||||
uint8_t m_y;
|
uint8_t m_y;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user