2021-01-03 16:12:47 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "config.h"
|
|
|
|
#include "edge.h"
|
|
|
|
#include "corner.h"
|
2021-01-08 19:33:58 +00:00
|
|
|
#include "prototypes.h"
|
|
|
|
|
|
|
|
// Delta-X data. Per direction of a triangle is a triple with Delta-X values for each direction.
|
|
|
|
static const int8_t dx[][3] = {{0, 1, -1}, {1, 0, -1}, {1, -1, 0}, {0, -1, 1}, {-1, 0, 1}, {-1, 1, 0}};
|
2021-01-08 21:21:44 +00:00
|
|
|
static const int8_t dy[][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}, {1, 0, 0}, {0, -1, 0}, {0, 0, 1}};
|
2021-01-08 19:33:58 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int8_t x;
|
|
|
|
int8_t y;
|
|
|
|
} Coords;
|
2021-01-03 16:12:47 +00:00
|
|
|
|
|
|
|
class Node {
|
|
|
|
public:
|
2021-01-08 21:21:44 +00:00
|
|
|
uint16_t _number;
|
2021-01-08 19:33:58 +00:00
|
|
|
Coords coords;
|
|
|
|
uint8_t direction;
|
2021-01-03 16:12:47 +00:00
|
|
|
Node* neighbours[CORNERS_PER_PART];
|
|
|
|
Edge* edges[CORNERS_PER_PART];
|
2021-01-04 11:44:41 +00:00
|
|
|
Corner* _corners[CORNERS_PER_PART];
|
2021-01-08 19:33:58 +00:00
|
|
|
Node(uint16_t number, Coords c, uint8_t direction);
|
2021-01-03 16:12:47 +00:00
|
|
|
Node* create_neighbour(uint8_t edge);
|
2021-01-08 21:21:44 +00:00
|
|
|
Coords coords_at_direction(uint8_t edge);
|
2021-01-06 10:51:11 +00:00
|
|
|
|
|
|
|
void blend_to(CRGB color, uint16_t effect_id=0, uint8_t effect_speed=0);
|
|
|
|
void set_color(CRGB color);
|
2021-01-08 10:30:10 +00:00
|
|
|
void infect(uint16_t level);
|
2021-01-06 10:51:11 +00:00
|
|
|
void step();
|
|
|
|
void draw();
|
2021-01-03 16:12:47 +00:00
|
|
|
};
|