A number of changes to try to get to the point where I could use Wokwi for some basic testing of animations
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
#ifndef ACTION_H
|
||||
#define ACTION_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "functional"
|
||||
#include "StreamEvent.h"
|
||||
|
||||
template <typename T>
|
||||
class Action {
|
||||
public:
|
||||
Action(function<bool(StreamEvent*)> _funcEventMatchesAction, function<T*(StreamEvent*)> _funcInvokeAction,
|
||||
function<void(Print*)> _funcDescribeAction) : funcEventMatchesAction(_funcEventMatchesAction),
|
||||
funcInvokeAction(_funcInvokeAction), funcDescribeAction(_funcDescribeAction) {}
|
||||
|
||||
bool eventMatchesAction(StreamEvent* event) {
|
||||
return funcEventMatchesAction(event);
|
||||
}
|
||||
|
||||
void describeAction(Print* printStream) {
|
||||
funcDescribeAction(printStream);
|
||||
}
|
||||
|
||||
T* invokeAction(StreamEvent* event) {
|
||||
return funcInvokeAction(event);
|
||||
}
|
||||
|
||||
private:
|
||||
function<bool(StreamEvent*)> funcEventMatchesAction;
|
||||
function<T*(StreamEvent*)> funcInvokeAction;
|
||||
function<void(Print*)> funcDescribeAction;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -60,7 +60,7 @@ class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
||||
|
||||
protected:
|
||||
void updateLEDs() {
|
||||
controller->showLeds();
|
||||
controller->showLeds(255);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,7 @@ class CLEDControllerPhysicalStrip : public LEDHAL {
|
||||
void setColor(int16_t pixel, CRGB color) { controller->leds()[pixel] = color; }
|
||||
|
||||
protected:
|
||||
void updateLEDs() { controller->showLeds(); }
|
||||
void updateLEDs() { controller->showLeds(255); }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#ifndef GULLSMANAGER_H
|
||||
#define GULLSMANAGER_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Action.h"
|
||||
#include "LEDHAL.h"
|
||||
#include "AnimationBase.h"
|
||||
|
||||
class GULLSManager {
|
||||
public:
|
||||
GULLSManager(Stream* _stream, uint16_t _maxHALs, uint16_t _maxAnimations,
|
||||
uint16_t _maxResponseActions, uint16_t _maxAnimationBuilderActions);
|
||||
|
||||
bool addLEDHAL(LEDHAL* hal);
|
||||
|
||||
bool addAnimation(AnimationBase* animation);
|
||||
|
||||
bool addResponseAction(Action<char>* action);
|
||||
|
||||
bool addAnimationBuilderAction(Action<AnimationBase>* action);
|
||||
|
||||
void update();
|
||||
private:
|
||||
uint16_t
|
||||
maxHALs,
|
||||
maxAnimations,
|
||||
maxResponseActions,
|
||||
maxAnimationBuilderActions;
|
||||
Stream*
|
||||
stream;
|
||||
LEDHAL**
|
||||
hals;
|
||||
AnimationBase**
|
||||
animations;
|
||||
Action<char>**
|
||||
responseActions;
|
||||
Action<AnimationBase>**
|
||||
animationBuilderActions;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef SMARTMATRIXPHYSICALMATRIX_H
|
||||
#define SMARTMATRIXPHYSICALMATRIX_H
|
||||
|
||||
#ifdef CORE_TEENSY
|
||||
|
||||
#include "SmartMatrix.h"
|
||||
#include "LEDHAL2D.h"
|
||||
|
||||
@@ -43,4 +45,5 @@ class SmartMatrixPhysicalMatrix : public LEDHAL2D {
|
||||
SMLayerBackground<rgb24, 0>* layer;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@ class StreamEvent
|
||||
handled = false;
|
||||
|
||||
code = _readFrom->read();
|
||||
subCode = _readFrom->read();
|
||||
flags = _readFrom->read();
|
||||
|
||||
if (flags & 0x01 == 1) {
|
||||
@@ -32,6 +33,8 @@ class StreamEvent
|
||||
|
||||
uint8_t getCode() { return code; }
|
||||
|
||||
uint8_t getSubCode() { return subCode; }
|
||||
|
||||
uint16_t getPayloadSize() { return payloadSize; }
|
||||
|
||||
byte* getPayload() { return payload; }
|
||||
@@ -40,7 +43,7 @@ class StreamEvent
|
||||
bool isResponse() { return flags & 0x02 == 2; }
|
||||
bool isDescribeRequest() { return flags & 0x04 == 4; }
|
||||
|
||||
virtual ~StreamEvent() { delete[] payload; }
|
||||
~StreamEvent() { delete[] payload; }
|
||||
|
||||
private:
|
||||
byte*
|
||||
@@ -49,6 +52,7 @@ class StreamEvent
|
||||
payloadSize;
|
||||
uint8_t
|
||||
code,
|
||||
subCode,
|
||||
flags;
|
||||
bool
|
||||
handled;
|
||||
|
||||
Reference in New Issue
Block a user