Initial Commit

This commit is contained in:
2026-03-31 10:19:59 -04:00
commit a1af89eef1
15 changed files with 444 additions and 0 deletions

75
include/Animation.h Normal file
View File

@@ -0,0 +1,75 @@
#ifndef ANIMATION_H
#define ANIMATION_H
#include <FastLED.h>
#include <elapsedMillis.h>
class Animation {
public:
Animation(long _updateTime, uint16_t _finishedAfterCycles) : updateTime(_updateTime),
finishedAfterCycles(_finishedAfterCycles), cycles(0), enabled(false),
initialized(false), timer(0) {}
virtual void initialize(CRGB* leds) {}
virtual void execute(CRGB* leds) {}
virtual bool isFinished() {
return cycles > finishedAfterCycles;
}
void update(CRGB* leds) {
if(enabled) {
if(timer >= updateTime) {
if(!initialized) {
initialize(leds);
cycles = 0;
initialized = true;
}
if(!isFinished()) {
execute(leds);
}
resetTimer();
}
}
}
void enable() {
enabled = true;
}
void disable() {
enabled = false;
}
void reinitialize() {
initialized = false;
}
bool isEnabled() {
return enabled;
}
protected:
void resetTimer() {
timer = 0;
}
void cycleCompleted() {
cycles = cycles += 1;
}
private:
long
updateTime;
uint16_t
cycles,
finishedAfterCycles;
bool
enabled,
initialized;
elapsedMillis
timer;
};
#endif

17
include/Bitmaps.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef BITMAPS_H
#define BITMAPS_H
#include <Arduino.h>
const uint8_t teamLogoBitmap[] = {
0b11100111,
0b11000011,
0b10100101,
0b00011000,
0b00011000,
0b10100101,
0b11000011,
0b11100111
};
#endif

9
include/GlobalSettings.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef GLOBALSETTINGS_H
#define GLOBALSETTINGS_H
#define WIDTH 32
#define HEIGHT 8
#define OUTPUT_PIN 6
#define MODE XYModes::HORIZONTALSCAN
#endif

37
include/README Normal file
View File

@@ -0,0 +1,37 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the convention is to give header files names that end with `.h'.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@@ -0,0 +1,38 @@
#ifndef SLIDINGSQUAREPACKEDBITMAP_H
#define SLIDINGSQUAREPACKEDBITMAP_H
#include <Arduino.h>
#include <FastLED.h>
#include "GlobalSettings.h"
#include "Animation.h"
#include "Utilities.h"
class SlidingSquarePackedBitmap : public Animation {
public:
SlidingSquarePackedBitmap(long _updateTime, const uint8_t* _bitmap, CRGB _color) :
Animation(_updateTime, (WIDTH - 8) * 2 * 5), bitmap(_bitmap), color(_color),
currentX(0), currentDirection(1) {}
void initialize(CRGB* leds) {
currentX = 0;
currentDirection = 1;
resetTimer();
Utilities::setAll(leds, MODE, CRGB::Black);
}
void execute(CRGB* leds);
private:
const uint8_t*
bitmap;
uint16_t
currentX;
int8_t
currentDirection;
CRGB
color;
};
#endif

86
include/Utilities.h Normal file
View File

@@ -0,0 +1,86 @@
#ifndef UTILITIES_H
#define UTILITIES_H
#include <Arduino.h>
#include <FastLED.h>
#include "GlobalSettings.h"
enum class XYModes {
HORIZONTALSCAN,
HORIZONTALSERPENTINE,
COLUMNSCAN,
COLUMNSERPENTINE
};
class Utilities {
public:
static uint16_t XY(XYModes mode, uint16_t x, uint16_t y) {
if(mode == XYModes::HORIZONTALSCAN) {
return WIDTH * y + x;
} else if(mode == XYModes::COLUMNSCAN) {
return HEIGHT * x + y;
} else if(mode == XYModes::HORIZONTALSERPENTINE) {
if(y & 0x1) {
return y * WIDTH + (WIDTH - 1 - x);
} else {
return y * WIDTH + x;
}
} else if(mode == XYModes::COLUMNSERPENTINE) {
if(x & 0x1) {
return x * HEIGHT + (HEIGHT - 1 - y);
} else {
return x * HEIGHT + y;
}
} else {
return 0; //How did you get here?
}
}
static void setArea(CRGB* leds, XYModes mode, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, CRGB color) {
for(uint16_t x = startX; x < endX; x++) {
for(uint16_t y = startY; y < endY; y++) {
leds[XY(mode, x, y)] = color;
}
}
}
static void setAll(CRGB* leds, XYModes mode, CRGB color) {
setArea(leds, mode, 0, 0, WIDTH, HEIGHT, color);
}
static void drawPackedSquareBitmap(CRGB* leds, XYModes mode, const uint8_t* bitmap, uint16_t xOrigin, CRGB color) {
for(uint16_t y = 0; y < 8; y++) {
uint8_t mask = 0x80;
for(uint16_t x = xOrigin; x < xOrigin + 8; x++) {
if((bitmap[y] & mask) != 0) {
leds[XY(mode, x, y)] = color;
}
mask >>= 1;
}
}
}
static void drawPackedFullFrameBitmap(CRGB* leds, XYModes mode, const uint32_t* bitmap, CRGB color) {
for(uint16_t y = 0; y < 8; y++) {
uint32_t mask = 0x80000000;
for(uint16_t x = 0; x < 32; x++) {
if((bitmap[y] & mask) != 0) {
leds[XY(mode, x, y)] = color;
}
mask >>= 1;
}
}
}
static void drawFullFrameIndexedMap(CRGB* leds, XYModes mode, uint8_t** indexMap, CRGB* colors) {
for(uint16_t x = 0; x < WIDTH; x++) {
for(uint16_t y = 0; y < HEIGHT; y++) {
leds[XY(mode, x, y)] = colors[indexMap[x][y]];
}
}
}
};
#endif