diff --git a/src/animations/InputBlip.cpp b/src/animations/InputBlip.cpp new file mode 100644 index 0000000..753d4a7 --- /dev/null +++ b/src/animations/InputBlip.cpp @@ -0,0 +1,33 @@ +#include "InputBlip.h" + +InputBlip::InputBlip() + : Figment("InputBlip") +{ +} + +void +InputBlip::handleEvent(const InputEvent& evt) +{ + if (evt.intent != InputEvent::None) { + m_time = qadd8(m_time, 5); + } +} + +void +InputBlip::loop() +{ + if (m_time > 0) { + m_time--; + } +} + +void +InputBlip::render(Display* dpy) const +{ + if (m_time > 0) { + dpy->pixelAt(0) = CRGB(0, brighten8_video(ease8InOutApprox(m_time)), 0); + } +} + +STATIC_ALLOC(InputBlip); +STATIC_TASK(InputBlip); diff --git a/src/animations/InputBlip.h b/src/animations/InputBlip.h new file mode 100644 index 0000000..4ba8516 --- /dev/null +++ b/src/animations/InputBlip.h @@ -0,0 +1,13 @@ +#pragma once +#include "../Figments/Figments.h" +#include "../Static.h" + +class InputBlip: public Figment { + public: + InputBlip(); + void handleEvent(const InputEvent& evt) override; + void loop() override; + void render(Display* dpy) const override; + private: + uint8_t m_time = 0; +};