#define BOX_W 16
#define BOX_H 8
#include <GyverMAX7219.h>
MAX7219 <2, 1, 10, 11, 13> mx;
#include "sand.h"
Sand<BOX_W, BOX_H> box;
bool checkBound(int8_t x, int8_t y) {
// if (x < BOX_W / 2 && y > BOX_H / 2) return 0;
return (x >= 0 && y >= 0 && x < BOX_W && y < BOX_H);
}
void setXY(int8_t x, int8_t y, bool value) {
mx.dot(x, y, value);
}
void setup() {
Serial.begin(115200);
mx.begin(); // запускаем
mx.setBright(5); // яркость 0..15
mx.setFlip(1, 0);
box.attachBound(checkBound);
box.attachSet(setXY);
// mx.rect(0, 0, 5, 5);
// mx.update();
for (uint8_t x = 0; x < 7; x++) {
for (uint8_t y = 0; y < 7; y++) {
box.buf.set(x, y, 1);
}
}
}
void loop() {
mx.clear();
box.step(map(analogRead(A0), 0, 1023, 0, 360));
// box.step(-45);
// for (uint8_t x = 0; x < box.getW(); x++) {
// for (uint8_t y = 0; y < box.getH(); y++) {
// if (box.buf.get(x, y)) mx.dot(x, y);
// }
// }
mx.update();
delay(50);
static uint32_t tmr;
if (millis() - tmr >= 300) {
tmr = millis();
// mx.dot(0, 7, 0);
// box.buf.set(0, 7, 0);
// box.buf.set(0, 7, 1);
}
}