pixopixel/FIRMWARE/PIXO_WIP/PIXO_WIP.ino

117 lines
5.6 KiB
Arduino
Raw Normal View History

2018-02-14 01:32:00 +00:00
/*
PIXO Pixel WIP Test Program
This program is a work in progress but will let you test your LED matrix if it is working or not.
Try out the various Demos and images in the image.h file.
Many libraries from Adafruit are needed and can be seen below.
*/
2018-02-01 00:29:16 +00:00
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_DotStarMatrix.h>
#include <Adafruit_DotStar.h>
#include <Fonts/TomThumb.h>
#include "image.h"
#define DATAPIN 19
#define CLOCKPIN 18
2018-02-14 01:32:00 +00:00
int mario[256][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {112, 104, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {248, 171, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {248, 171, 0}, {112, 104, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {216, 0, 0}, {112, 104, 0}, {112, 104, 0}, {216, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {216, 0, 0}, {112, 104, 0}, {112, 104, 0}, {216, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {248, 171, 0}, {248, 171, 0}, {112, 104, 0}, {216, 0, 0}, {248, 171, 0}, {216, 0, 0}, {216, 0, 0}, {248, 171, 0}, {216, 0, 0}, {112, 104, 0}, {248, 171, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {248, 171, 0}, {248, 171, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {248, 171, 0}, {248, 171, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {248, 171, 0}, {248, 171, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {0, 0, 0}, {0, 0, 0}, {216, 0, 0}, {216, 0, 0}, {216, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {112, 104, 0}, {0, 0, 0}, {0, 0, 0}};
2018-02-01 00:29:16 +00:00
2018-02-14 01:32:00 +00:00
#define BRIGHTNESS 30
2018-02-01 00:29:16 +00:00
// MATRIX DECLARATION:
2018-02-14 01:32:00 +00:00
Adafruit_DotStarMatrix pixo = Adafruit_DotStarMatrix(
2018-02-01 00:29:16 +00:00
16, 16, DATAPIN, CLOCKPIN,
DS_MATRIX_BOTTOM + DS_MATRIX_LEFT +
DS_MATRIX_ROWS + DS_MATRIX_PROGRESSIVE,
DOTSTAR_BGR);
const uint16_t primaryColors[] = {
2018-02-14 01:32:00 +00:00
pixo.Color(100, 0, 0), pixo.Color(0, 100, 0), pixo.Color(0, 0, 100)
2018-02-01 00:29:16 +00:00
};
void setup() {
Serial.begin(115200);
// uncomment to have wait
//while (!Serial) delay(500);
2018-02-14 01:32:00 +00:00
pixo.begin();
pixo.setBrightness(BRIGHTNESS);
2018-02-01 00:29:16 +00:00
for (byte i = 0; i < 3; i++) {
2018-02-14 01:32:00 +00:00
pixo.fillScreen(primaryColors[i]);
pixo.show();
2018-02-01 00:29:16 +00:00
delay(500);
2018-02-14 01:32:00 +00:00
pixo.fillScreen(0);
pixo.show();
2018-02-01 00:29:16 +00:00
}
}
2018-02-14 01:32:00 +00:00
int x = pixo.width();
2018-02-01 00:29:16 +00:00
int pass = 0;
void loop() {
2018-02-14 01:32:00 +00:00
pixo.setBrightness(BRIGHTNESS);
//while(1){
//SinglePix();
2018-02-01 00:29:16 +00:00
// RandomPix();
//}
2018-02-14 01:32:00 +00:00
notification();
}
2018-02-01 00:29:16 +00:00
2018-02-14 01:32:00 +00:00
void SinglePix() {
for (int x = 0; x < 256; x++) {
pixo.setPixelColor(x, 255, 255, 255);
2018-02-01 00:29:16 +00:00
delay(10);
2018-02-14 01:32:00 +00:00
pixo.show();
2018-02-01 00:29:16 +00:00
delay(200);
2018-02-14 01:32:00 +00:00
}
2018-02-01 00:29:16 +00:00
}
2018-02-14 01:32:00 +00:00
void RandomPix() {
2018-02-01 00:29:16 +00:00
randomSeed(A1);
2018-02-14 01:32:00 +00:00
int x = random(0, 256);
pixo.fillScreen(0);
pixo.setPixelColor(x, 255, 255, 255);
pixo.show();
delay(50);
2018-02-01 00:29:16 +00:00
}
2018-02-14 01:32:00 +00:00
void notification() {
for (int j = 15; j >= 0; j--) {
pixo.fillScreen(0);
for (int i = 0; i < 256; i++) {
pixo.setPixelColor(i + (j * 16), mario[i][0], mario[i][1], mario[i][2]);
//Serial.println(i);
//delay(1);
}
pixo.show();
delay(15);
2018-02-01 00:29:16 +00:00
}
delay(1000);
2018-02-14 01:32:00 +00:00
for (int j = 0; j >= -16; j--) {
pixo.fillScreen(0);
for (int i = 0; i < 256; i++) {
pixo.setPixelColor(i + (j * 16), mario[i][0], mario[i][1], mario[i][2]);
}
pixo.show();
delay(15);
2018-02-01 00:29:16 +00:00
}
delay(1000);
2018-02-14 01:32:00 +00:00
pixo.fillScreen(0);
pixo.show();
2018-02-01 00:29:16 +00:00
}
2018-02-14 01:32:00 +00:00
float ballx = 5;
2018-02-01 00:29:16 +00:00
float bally = 5;
float paddle1, paddle2 = 3;
float ballvx = -0.3;
float ballvy = 0.1;