#include <Adafruit_NeoPixel.h>
const uint8_t LED_MATRIX_WIDTH = 8;
const uint8_t LED_MATRIX_HEIGHT = 8;
const uint8_t LED_MATRIX_PIN = 13;
const uint8_t FIELD_COLOR_R = 0x18;
const uint8_t FIELD_COLOR_G = 0x46;
const uint8_t FIELD_COLOR_B = 0x5a;
Adafruit_NeoPixel ledStrip(LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT, LED_MATRIX_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
void setup() {
ledStrip.begin();
fillFieldBackground();
}
void loop() {
}
void drawPixel(uint8_t x, uint8_t y, uint8_t red, uint8_t green, uint8_t blue) {
uint16_t ledNumber = (y << 3) + x; // тоже самое, что 8 * y + x;
ledStrip.setPixelColor(ledNumber, ledStrip.Color(red, green, blue));
ledStrip.show();
}
// Заливаее задний фон поля
void fillFieldBackground() {
ledStrip.clear();
for (uint8_t y = 1; y < LED_MATRIX_HEIGHT - 1; y++) {
for (uint8_t x = 1; x < LED_MATRIX_WIDTH - 1; x++) {
drawPixel(x, y, FIELD_COLOR_R, FIELD_COLOR_G, FIELD_COLOR_B);
}
}
}