Compare commits
No commits in common. "pinganimator" and "master" have entirely different histories.
pinganimat
...
master
@ -5,9 +5,7 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
|
|
||||||
Clock::Clock() : strip(NUMPIXELS, STRIPPIN, NEO_GRB + NEO_KHZ800), refreshTicker() {
|
Clock::Clock() : strip(NUMPIXELS, STRIPPIN, NEO_GRB + NEO_KHZ800), animator(), refreshTicker() {
|
||||||
LoadAnimator an = LoadAnimator();
|
|
||||||
animator = &an;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clock::init() {
|
void Clock::init() {
|
||||||
@ -56,12 +54,12 @@ void Clock::refreshTime() {
|
|||||||
|
|
||||||
// if not time is set (only seconds since start) start animation
|
// if not time is set (only seconds since start) start animation
|
||||||
if (now <= 604800) {
|
if (now <= 604800) {
|
||||||
animator->startLoadAnimation(&strip);
|
animator.startLoadAnimation(&strip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animator->animationActive()) {
|
if (animator.animationActive()) {
|
||||||
animator->stopLoadAnimation();
|
animator.stopLoadAnimation();
|
||||||
strip.clear();
|
strip.clear();
|
||||||
|
|
||||||
// only add on first time iteration
|
// only add on first time iteration
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
class Clock {
|
class Clock {
|
||||||
private:
|
private:
|
||||||
Adafruit_NeoPixel strip{};
|
Adafruit_NeoPixel strip{};
|
||||||
LoadAnimationBase *animator;
|
LoadAnimator animator;
|
||||||
Ticker refreshTicker;
|
Ticker refreshTicker;
|
||||||
Ticker transitionTicker;
|
Ticker transitionTicker;
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by lukas on 01.02.22.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LEDSTRIPINTERFACE_LOADANIMATIONBASE_H
|
|
||||||
#define LEDSTRIPINTERFACE_LOADANIMATIONBASE_H
|
|
||||||
|
|
||||||
#include "Adafruit_NeoPixel.h"
|
|
||||||
|
|
||||||
class LoadAnimationBase {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* start the animation if not already runnint
|
|
||||||
* @param strip pointer to strip object
|
|
||||||
*/
|
|
||||||
virtual void startLoadAnimation(Adafruit_NeoPixel *strip) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stop the animation
|
|
||||||
*/
|
|
||||||
virtual void stopLoadAnimation() = 0;
|
|
||||||
|
|
||||||
virtual bool animationActive() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LEDSTRIPINTERFACE_LOADANIMATIONBASE_H
|
|
@ -9,7 +9,7 @@ void LoadAnimator::startLoadAnimation(Adafruit_NeoPixel* strip) {
|
|||||||
this->strip = strip;
|
this->strip = strip;
|
||||||
|
|
||||||
if (!timer.active())
|
if (!timer.active())
|
||||||
timer.attach_ms(100, [this] { animationStep(); });
|
timer.attach_ms(100, std::bind(&LoadAnimator::animationStep, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadAnimator::stopLoadAnimation() {
|
void LoadAnimator::stopLoadAnimation() {
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#define LEDSTRIPINTERFACE_LOADANIMATOR_H
|
#define LEDSTRIPINTERFACE_LOADANIMATOR_H
|
||||||
|
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
#include "LoadAnimationBase.h"
|
#include "Adafruit_NeoPixel.h"
|
||||||
|
|
||||||
class LoadAnimator : public LoadAnimationBase {
|
class LoadAnimator {
|
||||||
private:
|
private:
|
||||||
Ticker timer;
|
Ticker timer;
|
||||||
uint8_t x, y, nro, nroo, nrooo;
|
uint8_t x, y, nro, nroo, nrooo;
|
||||||
@ -26,14 +26,14 @@ class LoadAnimator : public LoadAnimationBase {
|
|||||||
* start the animation if not already runnint
|
* start the animation if not already runnint
|
||||||
* @param strip pointer to strip object
|
* @param strip pointer to strip object
|
||||||
*/
|
*/
|
||||||
void startLoadAnimation(Adafruit_NeoPixel *strip) override;
|
void startLoadAnimation(Adafruit_NeoPixel *strip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stop the animation
|
* stop the animation
|
||||||
*/
|
*/
|
||||||
void stopLoadAnimation() override;
|
void stopLoadAnimation();
|
||||||
|
|
||||||
bool animationActive() override;
|
bool animationActive();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LEDSTRIPINTERFACE_LOADANIMATOR_H
|
#endif // LEDSTRIPINTERFACE_LOADANIMATOR_H
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by lukas on 01.02.22.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "PingLoadAnimator.h"
|
|
||||||
void PingLoadAnimator::startLoadAnimation(Adafruit_NeoPixel* strip) {
|
|
||||||
this->strip = strip;
|
|
||||||
|
|
||||||
if (!timer.active())
|
|
||||||
timer.attach_ms(100, [this] { animationStep(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void PingLoadAnimator::stopLoadAnimation() {
|
|
||||||
timer.detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PingLoadAnimator::animationActive() {
|
|
||||||
return timer.active();
|
|
||||||
}
|
|
||||||
void PingLoadAnimator::animationStep() {
|
|
||||||
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by lukas on 01.02.22.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef LEDSTRIPINTERFACE_PINGLOADANIMATOR_H
|
|
||||||
#define LEDSTRIPINTERFACE_PINGLOADANIMATOR_H
|
|
||||||
|
|
||||||
#include <Ticker.h>
|
|
||||||
#include "LoadAnimationBase.h"
|
|
||||||
class PingLoadAnimator : LoadAnimationBase {
|
|
||||||
private:
|
|
||||||
Ticker timer;
|
|
||||||
Adafruit_NeoPixel *strip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* one animation step to process the animation
|
|
||||||
*/
|
|
||||||
void animationStep();
|
|
||||||
public:
|
|
||||||
void startLoadAnimation(Adafruit_NeoPixel* strip) override;
|
|
||||||
void stopLoadAnimation() override;
|
|
||||||
bool animationActive() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LEDSTRIPINTERFACE_PINGLOADANIMATOR_H
|
|
Loading…
Reference in New Issue
Block a user