55 lines
1.1 KiB
Arduino
55 lines
1.1 KiB
Arduino
#include <Adafruit_NeoPixel.h>
|
|
#ifdef __AVR__
|
|
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
|
|
#endif
|
|
|
|
#include "ball_image.h"
|
|
|
|
#define PIN 12
|
|
|
|
#define PANEL_PIXEL_COUNT 16
|
|
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*3
|
|
|
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
|
|
|
void setPixel(unsigned short x, unsigned short y, uint32_t color)
|
|
{
|
|
if (y % 2 == 1)
|
|
{
|
|
x = PANEL_PIXEL_COUNT - 1 - x;
|
|
}
|
|
pixels.setPixelColor(x + (y * PANEL_PIXEL_COUNT), color);
|
|
}
|
|
|
|
|
|
void drawPanelImage(int offset_x, int offset_y) {
|
|
for (int row = 0; row < 16; row++) {
|
|
for (int col = 0; col < 16; col++) {
|
|
|
|
if (panel_image[row][col].color == 0) {
|
|
continue;
|
|
}
|
|
|
|
int pixel_x = panel_image[row][col].x + offset_x;
|
|
int pixel_y = panel_image[row][col].y + offset_y;
|
|
|
|
if (pixel_x >= 0 && pixel_x < PANEL_PIXEL_COUNT &&
|
|
pixel_y >= 0 && pixel_y < PANEL_PIXEL_COUNT) {
|
|
setPixel(pixel_x, pixel_y, panel_image[row][col].color);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void setup() {
|
|
pixels.begin();
|
|
|
|
pixels.clear();
|
|
drawPanelImage(0, 0);
|
|
pixels.show();
|
|
}
|
|
|
|
void loop() {
|
|
|
|
}
|