Added different modes. For now there are AM_CORNERS and AM_NODES.

This commit is contained in:
2021-01-06 11:51:11 +01:00
parent fdf357a3a1
commit 77eaea81d1
9 changed files with 198 additions and 65 deletions

View File

@ -13,7 +13,11 @@
// Examples, assuming EDGES_PER_PART == 3:
// Example: Nodes arranged in a circle: {1, 2, 2, 2, 2}
// Example: Nodes arranged in a line: {1, 2, 1, 2, 1, 2}
#define NODE_COUNT 3
#define LAYOUT {2, 1}
#define NODE_COUNT 5
#define LAYOUT {2, 1, 1, 2}
#define LED_COUNT NODE_COUNT * CORNERS_PER_PART * LEDS_PER_CORNER
#define LED_COUNT NODE_COUNT * CORNERS_PER_PART * LEDS_PER_CORNER
#define SPEEDUP 1
//#define TEST_MODE

View File

@ -1,5 +1,5 @@
#pragma once
#include <FastLED.h>
#include "my_fastled.h"
#include <vector>
#include <list>
#include "edge.h"
@ -18,12 +18,18 @@ class Corner {
bool effect_running = false;
uint8_t color_blend_state = 255;
uint16_t effect_id;
bool loop();
uint8_t effect_speed;
//bool loop();
void draw();
void blend_to(CRGB color, uint16_t effect_id=0);
void blend_to(CRGB color, uint16_t effect_id=0, uint8_t effect_speed=0);
void add_led(uint16_t led_id);
void merge_leds(Corner* c);
void step();
void infect(uint8_t short_level, uint8_t long_level);
bool is_finished();
void set_color(CRGB color);
bool reached_level(uint8_t level);
private:
void infect(std::vector<Corner*>* neighbours);
void _infect(std::vector<Corner*>* neighbours);
};

4
include/my_fastled.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
#define FASTLED_INTERNAL
#include <FastLED.h>

View File

@ -13,4 +13,10 @@ class Node {
Corner* _corners[CORNERS_PER_PART];
Node(uint16_t number);
Node* create_neighbour(uint8_t edge);
void blend_to(CRGB color, uint16_t effect_id=0, uint8_t effect_speed=0);
void set_color(CRGB color);
void infect(uint8_t level);
void step();
void draw();
};

View File

@ -1,5 +1,5 @@
#pragma once
#include <FastLED.h>
#include "my_fastled.h"
#include <list>
#include <vector>
#include "config.h"
@ -8,8 +8,13 @@
#include "corner.h"
extern std::list<Node*> nodes;
extern std::vector<Node*> nodes;
extern std::list<Edge*> edges;
extern std::vector<Corner*> corners;
extern CRGB leds[LED_COUNT];
extern CRGB leds[LED_COUNT];
enum AnimationMode {
AM_CORNERS,
AM_NODES
};

View File

@ -1,5 +1,5 @@
#pragma once
#include <FastLED.h>
#include "my_fastled.h"
#define LOG(...) Serial.printf(__VA_ARGS__)
#define LOGln(...) Serial.printf(__VA_ARGS__); Serial.println()