espleaf/include/node.h

35 lines
929 B
C
Raw Normal View History

2021-01-03 16:12:47 +00:00
#pragma once
class Node;
2021-01-03 16:12:47 +00:00
#include <Arduino.h>
#include "config.h"
#include "corner.h"
#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}};
static const int8_t dy[][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}, {1, 0, 0}, {0, -1, 0}, {0, 0, 1}};
typedef struct {
int8_t x;
int8_t y;
} Coords;
2021-01-03 16:12:47 +00:00
class Node {
public:
uint16_t _number;
Coords coords;
uint8_t direction;
2021-01-03 16:12:47 +00:00
Node* neighbours[CORNERS_PER_PART];
Corner* _corners[CORNERS_PER_PART];
Node(uint16_t number, Coords c, uint8_t direction);
2021-01-03 16:12:47 +00:00
Node* create_neighbour(uint8_t edge);
Coords coords_at_direction(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(uint16_t level);
void step();
void draw();
2021-01-03 16:12:47 +00:00
};