STarted reorganizing files into proper .h and .cpp files.

This commit is contained in:
Fabian Schlenz 2019-05-28 05:46:25 +02:00
parent ce0c834326
commit 2cbb981eea
4 changed files with 29 additions and 16 deletions

View File

@ -30,19 +30,10 @@
.w and .h contain the dimensions of the image. .w and .h contain the dimensions of the image.
**/ **/
#ifndef Animations_H
typedef struct { #define Animations_H
uint8_t *colors; #include <Arduino.h>
uint8_t *data; #include "prototypes.h"
uint16_t *offsets;
uint16_t *delays;
boolean individual_delays;
int color_count;
int frame_count;
int w;
int h;
} AnimationData;
uint8_t animation_koopa_colors[] PROGMEM = {182, 154, 17, 0, 0, 0, 48, 48, 48, 142, 4, 6, 254, 252, 255, 3, 1, 138, 17, 239, 18}; uint8_t animation_koopa_colors[] PROGMEM = {182, 154, 17, 0, 0, 0, 48, 48, 48, 142, 4, 6, 254, 252, 255, 3, 1, 138, 17, 239, 18};
uint8_t animation_koopa_data[] PROGMEM = { uint8_t animation_koopa_data[] PROGMEM = {
@ -159,3 +150,5 @@ uint8_t animation_heart_data[] PROGMEM = {
uint16_t animation_heart_delays[] = {100, 100, 100, 100, 100, 100, 100, 400, 100, 100, 100, 100, 100, 100, 200}; uint16_t animation_heart_delays[] = {100, 100, 100, 100, 100, 100, 100, 400, 100, 100, 100, 100, 100, 100, 200};
uint16_t animation_heart_offsets[] = {0, 190, 344, 608, 875, 1025, 1291, 1588, 1790, 1944, 2208, 2473, 2627, 2893, 3190, 3392}; uint16_t animation_heart_offsets[] = {0, 190, 344, 608, 875, 1025, 1291, 1588, 1790, 1944, 2208, 2473, 2627, 2893, 3190, 3392};
AnimationData animation_heart = {&animation_heart_colors[0], &animation_heart_data[0], &animation_heart_offsets[0], &animation_heart_delays[0], false, 4, 15, 32, 32}; AnimationData animation_heart = {&animation_heart_colors[0], &animation_heart_data[0], &animation_heart_offsets[0], &animation_heart_delays[0], false, 4, 15, 32, 32};
#endif

16
include/prototypes.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef prototypes_H
#define prototypes_H
typedef struct {
uint8_t *colors;
uint8_t *data;
uint16_t *offsets;
uint16_t *delays;
boolean individual_delays;
int color_count;
int frame_count;
int w;
int h;
} AnimationData;
#endif

View File

@ -1,3 +1,7 @@
#include <Arduino.h>
#include <FastLED.h>
#include "prototypes.h"
struct EffectEntry { struct EffectEntry {
char* name; char* name;
Effect* effect; Effect* effect;
@ -285,12 +289,12 @@ class SingleDynamic : public Effect {
} }
boolean can_be_shown_with_clock() { return true; } boolean can_be_shown_with_clock() { return true; }
virtual void loop() { virtual void loop() {
EVERY_N_MILLISECONDS(getLoopTime()) { EVERY_N_MILLISECONDS(getLoopTime()) {
memcpy(old_tiles, tiles, tile_count*sizeof(CRGB)); memcpy(old_tiles, tiles, tile_count*sizeof(CRGB));
blend = 0; blend = 0;
update(); update();
} }
for (int x=0; x<window.w; x++) for (int y=0; y<window.h; y++) { for (int x=0; x<window.w; x++) for (int y=0; y<window.h; y++) {
int index = y/2 * window.w/2 + x/2; int index = y/2 * window.w/2 + x/2;
setPixel(window, x, y, nblend(old_tiles[index], tiles[index], blend)); setPixel(window, x, y, nblend(old_tiles[index], tiles[index], blend));

View File

@ -11,6 +11,7 @@
#include "ntp.h" #include "ntp.h"
#include "config.h" #include "config.h"
#include "animations.h"
CRGB leds[LED_COUNT]; CRGB leds[LED_COUNT];
WiFiClient wifi; WiFiClient wifi;
WiFiUDP ntpUDP; WiFiUDP ntpUDP;
@ -47,7 +48,6 @@ class Effect {
#include "functions.h" #include "functions.h"
#include "text.h" #include "text.h"
#include "sprites.h" #include "sprites.h"
#include "animations.h"
#include "tools.h" #include "tools.h"
SimpleList<Effect*>* cycle_effects; SimpleList<Effect*>* cycle_effects;