70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
#include <Arduino.h>
|
|
#include <FastLED.h>
|
|
#include "config.h"
|
|
#include "tools.h"
|
|
#include "node.h"
|
|
#include "edge.h"
|
|
#include "corner.h"
|
|
#include "prototypes.h"
|
|
|
|
std::list<Node*> nodes;
|
|
std::list<Edge*> edges;
|
|
std::list<Corner*> corners;
|
|
|
|
CRGB leds[LED_COUNT];
|
|
|
|
void setup_layout() {
|
|
LOGln("Setting up layout...");
|
|
uint8_t layout[] = LAYOUT;
|
|
Node* current_node = new Node();
|
|
nodes.push_back(current_node);
|
|
|
|
for(uint16_t i=0; i<NODE_COUNT-1; i++) {
|
|
current_node = current_node->create_neighbour(layout[i]);
|
|
nodes.push_back(current_node);
|
|
}
|
|
|
|
for(Node* node: nodes) {
|
|
for(Edge* edge: node->edges) {
|
|
//LOGln("Edge #%d: %p", i, edge);
|
|
auto e = std::find(edges.begin(), edges.end(), edge);
|
|
if (e == edges.end()) {
|
|
edges.push_back(edge);
|
|
}
|
|
}
|
|
for(Corner* corner: node->corners) {
|
|
//LOGln("Corner #%d: %p", i, corner);
|
|
auto c = std::find(corners.begin(), corners.end(), corner);
|
|
if (c == corners.end()) {
|
|
corners.push_back(corner);
|
|
}
|
|
}
|
|
}
|
|
|
|
LOGln("Counts:");
|
|
LOGln("Nodes: %3d", nodes.size());
|
|
LOGln("Edges: %3d", edges.size());
|
|
LOGln("Corners: %3d", corners.size());
|
|
}
|
|
|
|
void setup_fastled() {
|
|
LOGln("Setting up FastLED...");
|
|
// GPIO5 = D1
|
|
// GPIO2 = D4
|
|
FastLED.addLeds<WS2812B, 5, GRB>(leds, LEDS_PER_CORNER * CORNERS_PER_PART * NODE_COUNT).setCorrection(TypicalLEDStrip);
|
|
LOGln("LEDs: %3d", LED_COUNT);
|
|
FastLED.setBrightness(255);
|
|
set_all_leds(CRGB(0xFF));
|
|
}
|
|
|
|
void setup() {
|
|
Serial.begin(74880);
|
|
LOGln("ESPleaf starting.");
|
|
|
|
setup_layout();
|
|
setup_fastled();
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
} |