Added effect 'gol': Conway's Game of Life.

This commit is contained in:
2019-06-14 05:32:17 +02:00
parent 291a3be623
commit 1e23936374
5 changed files with 130 additions and 2 deletions

View File

@ -7,11 +7,12 @@ class Window {
public:
const uint8_t x, y;
const uint8_t width, height;
uint16_t count;
static Window* getFullWindow();
Window(): Window(0, 0, LED_WIDTH, LED_HEIGHT) {};
Window(uint8_t x, uint8_t y) : Window(x, y, LED_WIDTH-x, LED_HEIGHT-y) {};
Window(uint8_t x, uint8_t y, uint8_t width, uint8_t height) : x(x), y(y), width(width), height(height) {};
Window(uint8_t x, uint8_t y, uint8_t width, uint8_t height) : x(x), y(y), width(width), height(height) { count = width*height; };
void clear();
void clear(CRGB* color);

View File

@ -69,7 +69,9 @@
#define EFFECT_FIREWORK_BLUR 200
#define EFFECT_FIREWORK_FADEOUT_SPEED 5
#define EFFECT_GOL_START_PERCENTAGE 128
#define EFFECT_GOL_BLEND_SPEED 5
// Stop editing here
#ifdef DEBUG

23
include/effect_gol.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include "Effect.h"
class GolEffect : public Effect {
private:
uint8_t *_data;
uint8_t *_old;
uint8_t _blend;
uint8_t _hue = 0;
uint8_t _old_hue = 0;
uint16_t _step;
void _advance();
void _draw();
void _initialize();
public:
GolEffect();
void start();
void stop();
void loop();
bool can_be_shown_with_clock();
};