From e1fbd998c5cc25bf184006650900d790431b03bc Mon Sep 17 00:00:00 2001 From: hodginsa Date: Tue, 13 Feb 2018 20:32:00 -0500 Subject: [PATCH] New Firmware and Python Script --- FIRMWARE/PIXO_Acc_Pong/PIXO_Acc_Pong.ino | 201 ++++++++++++ .../PIXO_Upvote_ParticlePhysics.ino | 290 ++++++++++++++++++ FIRMWARE/PIXO_WIP/PIXO_WIP.ino | 165 ++++------ FIRMWARE/PIXO_WIP/image.h | 4 +- PYTHON/CreateMatrix.py | 19 ++ 5 files changed, 570 insertions(+), 109 deletions(-) create mode 100644 FIRMWARE/PIXO_Acc_Pong/PIXO_Acc_Pong.ino create mode 100644 FIRMWARE/PIXO_Upvote_ParticlePhysics/PIXO_Upvote_ParticlePhysics.ino create mode 100644 PYTHON/CreateMatrix.py diff --git a/FIRMWARE/PIXO_Acc_Pong/PIXO_Acc_Pong.ino b/FIRMWARE/PIXO_Acc_Pong/PIXO_Acc_Pong.ino new file mode 100644 index 0000000..9afbb39 --- /dev/null +++ b/FIRMWARE/PIXO_Acc_Pong/PIXO_Acc_Pong.ino @@ -0,0 +1,201 @@ +/* + Accerlerometer Pong for the PIXO Pixel. + Utilizes the Adafruit GFX Libraries as well as the DotStar Libraries. + + This version is created to use with the MPU6050 + + Developed by Sean Hodgins and is licensed under GPL 3.0 +*/ + +#include // For I2C communication +#include +#include +#include +#include +#include +#include "I2Cdev.h" +#include "MPU6050.h" + +MPU6050 mpu; + +#define WIDTH 16 // Display width in pixels +#define HEIGHT 16 // Display height in pixels +#define MAX_FPS 45 // Maximum redraw rate, frames/second +#define SCALE 128 + + +int ballx = 5 * SCALE; +int bally = 5 * SCALE; +int ballvx = 20; +int ballvy = 10; +int p1 = 6; +int p2 = 6; +int PW = 5; +int lasty = 0; +int curry = 0; +int p2a = 1; +int p2v = 0; +int p2loc = 256; +int p1score = 0; +int p2score = 0; +int difficulty = 0; + +uint32_t prevTime = 0; + +int16_t rax, ray, raz; +int16_t rgx, rgy, rgz; + +#define DATAPIN 19 +#define CLOCKPIN 18 + +#define BRIGHTNESS 30 + +Adafruit_DotStarMatrix pixo = Adafruit_DotStarMatrix( + 16, 16, DATAPIN, CLOCKPIN, + DS_MATRIX_TOP + DS_MATRIX_LEFT + + DS_MATRIX_ROWS + DS_MATRIX_PROGRESSIVE, + DOTSTAR_BGR); + + +void setup(void) { + uint8_t i, j, bytes; + Serial.begin(115200); + +#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE + Wire.begin(); +#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE + Fastwire::setup(400, true); +#endif + Serial.println("Initializing I2C devices..."); + mpu.initialize(); + + Serial.println("Testing device connections..."); + Serial.println(mpu.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed"); + + pixo.begin(); + + pixo.setBrightness(BRIGHTNESS); +} + + +void loop() { + + + + uint32_t t; + while (((t = micros()) - prevTime) < (1000000L / MAX_FPS)); + prevTime = t; + + + + // Read accelerometer... + mpu.getMotion6(&rax, &ray, &raz, &rgx, &rgy, &rgz); + randomSeed(A7); + + ballx = ballx + ballvx; //Move Ball + bally = bally + ballvy; + + curry = (0.90 * lasty) + (0.1 * ray); //Filter Accelerometer data for user paddle + lasty = curry; + + + p1 = map(curry, -4000, 4000, 0, (16 - PW) * SCALE); + int p1s = p1 / SCALE; + p1s = constrain(p1s, 1, 16 - PW); + + p2v = constrain(p2v, -25, 25); + p2loc = p2loc + p2v; + p2 = p2loc / SCALE; + p2 = constrain(p2, 1, 16 - PW); + + int bys = bally / SCALE; + + if (ballx > (14 * SCALE)) { + if (bys >= p2 && bys <= (p2 + PW)) { + ballvx = (ballvx) * -1.1; + ballvx = constrain(ballvx, -40, 40); + difficulty++; + paddleDeflect(p2loc, bally, PW); + } + if (ballx > (15 * SCALE) + 50) { + if (bys < p2 || bys > (p2 + PW)) { + delay(2000); + p1score++; + + resetGame(); + } + } + } + if (ballx < SCALE) { + if (bys >= p1s && bys <= (p1s + PW)) { + ballvx = (ballvx ) * -1.1; + ballvx = constrain(ballvx, -40, 40); + difficulty++; + paddleDeflect(p1, bally, PW); + + } + if (ballx < 10) { + if (bys < p1s || bys > (p1s + PW)) { + delay(2000); + p2score++; + + resetGame(); + + } + } + } + if (bally > (15 * SCALE) || bally < SCALE + 10) { + ballvy = ballvy * -1; + } + + if ((p2loc + ((PW / 2) * SCALE)) < bally) { + p2v = p2v + p2a; + } + if ((p2loc + ((PW / 2) * SCALE)) > bally) { + p2v = p2v - p2a; + + } + //SEND TO DISPLAY + pixo.fillScreen(0); + pixo.drawFastHLine(0, 0, 16, pixo.Color(100, 0, 0)); + pixo.drawFastHLine(5, 0, 6, pixo.Color(100, 100, 0)); + if (p2score > 0) { + pixo.drawFastHLine(17, 0, -p2score, pixo.Color(0, 200, 0)); + } + if (p1score > 0) { + pixo.drawFastHLine(0, 0, p1score, pixo.Color(0, 200, 0)); + } + pixo.drawFastVLine(0, p1s, PW, pixo.Color(200, 255, 255)); + pixo.drawFastVLine(15, p2, PW, pixo.Color(200, 255, 255)); + pixo.drawPixel((ballx / SCALE), (bally / SCALE), pixo.Color(200, 255, 255)); + pixo.show(); + + //GAME HAS ENDED + if (p1score == 5 || p2score == 5) { + while (1); + } +} + + + +void paddleDeflect(int ploc, int bloc, int pwidth) { + int err = bloc - (ploc + (pwidth * SCALE) / 2); + int diff = difficulty / 2; + //Serial.println(diff); + err = map(err, -300, 300, -10 - diff, 10 + diff); + err = constrain(err, -25, 25); + ballvy = err; +} + +void resetGame() { + ballx = 5 * SCALE; + bally = 5 * SCALE; + ballvx = 20; + ballvy = 10; + p1 = 6; + p2 = 6; + p2a = 1; + p2v = 0; + p2loc = 256; +} + diff --git a/FIRMWARE/PIXO_Upvote_ParticlePhysics/PIXO_Upvote_ParticlePhysics.ino b/FIRMWARE/PIXO_Upvote_ParticlePhysics/PIXO_Upvote_ParticlePhysics.ino new file mode 100644 index 0000000..62e8d80 --- /dev/null +++ b/FIRMWARE/PIXO_Upvote_ParticlePhysics/PIXO_Upvote_ParticlePhysics.ino @@ -0,0 +1,290 @@ +//-------------------------------------------------------------------------- +// This code is modified from the following Adafruit tutorial: https://learn.adafruit.com/animated-led-sand/overview +/* + + This code is modified from the following Adafruit tutorial: https://learn.adafruit.com/animated-led-sand/overview + This program shows an upvote arrow 3 times then on the 4th it breaks into particles that will move based on accelerometer readings. +*/ + + +#include // For I2C communication +#include +#include +#include +#include +#include +#include "I2Cdev.h" +#include "MPU6050.h" + + + +MPU6050 mpu; + +uint8_t upvote[256][3] = {{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, 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, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 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, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + +//int N_GRAINS = 0; +#define N_GRAINS 114 // Number of grains of sand +#define WIDTH 16 // Display width in pixels +#define HEIGHT 16 // Display height in pixels +#define MAX_FPS 45 +#define SCALE 128 +#define WBOUNCE -2 +#define BBOUNCE -2 + +#define MAX_X (WIDTH * SCALE - 1) +#define MAX_Y (HEIGHT * SCALE - 1) +struct Grain { + int16_t x, y; + int16_t vx, vy; +} grain[N_GRAINS]; + +int16_t rax, ray, raz; +int16_t rgx, rgy, rgz; +uint32_t prevTime = 0; +uint8_t backbuffer = 0, + img[WIDTH * HEIGHT]; + + + +#define DATAPIN 19 +#define CLOCKPIN 18 + + +#define SHIFTDELAY 30 +#define BRIGHTNESS 20 + + + +Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix( + 16, 16, DATAPIN, CLOCKPIN, + DS_MATRIX_TOP + DS_MATRIX_LEFT + + DS_MATRIX_ROWS + DS_MATRIX_PROGRESSIVE, + DOTSTAR_BGR); + + +void setup(void) { + uint8_t i, j, bytes; + Serial.begin(115200); + +#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE + Wire.begin(); +#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE + Fastwire::setup(400, true); +#endif + Serial.println("Initializing I2C devices..."); + mpu.initialize(); + Serial.println("Testing device connections..."); + Serial.println(mpu.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed"); + + matrix.begin(); + matrix.setBrightness(BRIGHTNESS); + + notification(); + notification(); + notification(); + notificationhalf(); + + memset(img, 0, sizeof(img)); // Clear the img[] array + int grain_num = 0; + for (int x = 0; x < 256; x++) { + if (upvote[x][0] > 0) { + + int NX = x % 16; + int NY = x / 16; + grain[grain_num].x = (NX * SCALE); // Assign random position within + grain[grain_num].y = (NY * SCALE); + grain_num++; + } + } + + for (i = 0; i < N_GRAINS; i++) { // For each sand grain... + img[(grain[i].y / SCALE) * WIDTH + (grain[i].x / SCALE)] = 255; // Mark it + grain[i].vx = grain[i].vy = 0; // Initial velocity is zero + } +} + + +void loop() { + + uint32_t t; + while (((t = micros()) - prevTime) < (1000000L / MAX_FPS)); + prevTime = t; + + + backbuffer = 1 - backbuffer; // Swap front/back buffer index + + // Read accelerometer... + mpu.getMotion6(&rax, &ray, &raz, &rgx, &rgy, &rgz); + randomSeed(A7); + + int16_t ax = -rax / SCALE, // Transform accelerometer axes + ay = ray / SCALE, // to grain coordinate space + az = abs(raz) / 128; // Random motion factor + + az = (az >= 3) ? 1 : 4 - az; // Clip & invert + ax -= az; // Subtract motion factor from X, Y + ay -= az; + long az2 = az * 2 + 1; // Range of random motion to add back in + + + int32_t v2; // Velocity squared + float v; // Absolute velocity + for (int i = 0; i < N_GRAINS; i++) { + grain[i].vx += ax + random(az2); // A little randomness makes + grain[i].vy += ay + random(az2); // tall stacks topple better! + + v2 = (int32_t)grain[i].vx * grain[i].vx + (int32_t)grain[i].vy * grain[i].vy; + if (v2 > 65536) { // If v^2 > 65536, then v > SCALE + v = sqrt((float)v2); // Velocity vector magnitude + grain[i].vx = (int)(SCALE * (float)grain[i].vx / v); // Maintain heading + grain[i].vy = (int)(SCALE * (float)grain[i].vy / v); // Limit magnitude + } + } + + uint8_t i, bytes, oldidx, newidx, delta; + int16_t newx, newy; + // const uint8_t *ptr = remap; + + randomSeed(A7); + int list[N_GRAINS]; + for (int num = 0; num < N_GRAINS; num++) { + list[num] = num; + } + for (int a = 0; a < N_GRAINS; a++) + { + int r = random(a, (N_GRAINS)); + int temp = list[a]; + list[a] = list[r]; + list[r] = temp; + } + + for (int num = 0; num < N_GRAINS; num++) { + Serial.print(list[num]); + Serial.print(", "); + } + Serial.println(",,Done."); + for (i = 0; i < N_GRAINS; i++) { + newx = grain[list[i]].x + grain[list[i]].vx; + newy = grain[list[i]].y + grain[list[i]].vy; + if (newx > MAX_X) { + newx = MAX_X; + grain[list[i]].vx /= WBOUNCE; + } else if (newx < 0) { + newx = 0; + grain[list[i]].vx /= WBOUNCE; + } + if (newy > MAX_Y) { + newy = MAX_Y; + grain[list[i]].vy /= WBOUNCE; + } else if (newy < 0) { + newy = 0; + grain[list[i]].vy /= WBOUNCE; + } + + oldidx = (grain[list[i]].y / SCALE) * WIDTH + (grain[list[i]].x / SCALE); + newidx = (newy / SCALE) * WIDTH + (newx / SCALE); + if ((oldidx != newidx) && + img[newidx]) { + delta = abs(newidx - oldidx); + if (delta == 1) { + newx = grain[list[i]].x; + grain[list[i]].vx /= BBOUNCE; + newidx = oldidx; + } else if (delta == WIDTH) { + newy = grain[list[i]].y; + grain[list[i]].vy /= BBOUNCE; + newidx = oldidx; + } else { + + if ((abs(grain[list[i]].vx) - abs(grain[list[i]].vy)) >= 0) { + newidx = (grain[list[i]].y / SCALE) * WIDTH + (newx / SCALE); + if (!img[newidx]) { + newy = grain[list[i]].y; + grain[list[i]].vy /= BBOUNCE; + } else { + newidx = (newy / SCALE) * WIDTH + (grain[list[i]].x / SCALE); + if (!img[newidx]) { + newx = grain[list[i]].x; + grain[list[i]].vx /= BBOUNCE; + } else { + newx = grain[list[i]].x; + newy = grain[list[i]].y; + grain[list[i]].vx /= BBOUNCE; + grain[list[i]].vy /= BBOUNCE; + newidx = oldidx; + } + } + } else { + newidx = (newy / SCALE) * WIDTH + (grain[list[i]].x / SCALE); + if (!img[newidx]) { + newx = grain[list[i]].x; + grain[list[i]].vy /= BBOUNCE; + } else { + newidx = (grain[list[i]].y / SCALE) * WIDTH + (newx / SCALE); + if (!img[newidx]) { + newy = grain[list[i]].y; + grain[list[i]].vy /= BBOUNCE; + } else { + newx = grain[list[i]].x; + newy = grain[list[i]].y; + grain[list[i]].vx /= BBOUNCE; + grain[list[i]].vy /= BBOUNCE; + newidx = oldidx; + } + } + } + } + } + grain[list[i]].x = newx; + grain[list[i]].y = newy; + img[oldidx] = 0; + img[newidx] = 255; + + } + matrix.fillScreen(0); + for (int i = 0; i < N_GRAINS; i++) { + int x = grain[i].x / SCALE; + int y = grain[i].y / SCALE; + matrix.drawPixel(x, y, matrix.Color(205, 110, 0)); + } + matrix.show(); + + + +} + +void notificationhalf() { + for (int j = 15; j >= 0; j--) { + matrix.fillScreen(0); + for (int i = 0; i < 256; i++) { + matrix.setPixelColor(i + (j * 16), upvote[i][0], upvote[i][1], upvote[i][2]); + } + matrix.show(); + delay(15); + } + delay(100); +} + +void notification() { + for (int j = 15; j >= 0; j--) { + matrix.fillScreen(0); + for (int i = 0; i < 256; i++) { + matrix.setPixelColor(i + (j * 16), upvote[i][0], upvote[i][1], upvote[i][2]); + } + matrix.show(); + delay(15); + } + delay(700); + for (int j = 0; j >= -16; j--) { + matrix.fillScreen(0); + for (int i = 0; i < 256; i++) { + matrix.setPixelColor(i + (j * 16), upvote[i][0], upvote[i][1], upvote[i][2]); + } + matrix.show(); + delay(15); + } + delay(500); + matrix.fillScreen(0); + matrix.show(); +} + diff --git a/FIRMWARE/PIXO_WIP/PIXO_WIP.ino b/FIRMWARE/PIXO_WIP/PIXO_WIP.ino index 4fd8d74..8feea33 100644 --- a/FIRMWARE/PIXO_WIP/PIXO_WIP.ino +++ b/FIRMWARE/PIXO_WIP/PIXO_WIP.ino @@ -1,5 +1,11 @@ -// Adafruit_DotStarMatrix example for single DotStar LED matrix. -// Scrolls 'Adafruit' across the matrix. +/* + 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. + +*/ #include #include @@ -11,155 +17,100 @@ #define DATAPIN 19 #define CLOCKPIN 18 +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}}; -#define SHIFTDELAY 100 -#define BRIGHTNESS 50 + +#define BRIGHTNESS 30 // MATRIX DECLARATION: -// Parameter 1 = width of DotStar matrix -// Parameter 2 = height of matrix -// Parameter 3 = pin number (most are valid) -// Parameter 4 = matrix layout flags, add together as needed: -// DS_MATRIX_TOP, DS_MATRIX_BOTTOM, DS_MATRIX_LEFT, DS_MATRIX_RIGHT: -// Position of the FIRST LED in the matrix; pick two, e.g. -// DS_MATRIX_TOP + DS_MATRIX_LEFT for the top-left corner. -// DS_MATRIX_ROWS, DS_MATRIX_COLUMNS: LEDs are arranged in horizontal -// rows or in vertical columns, respectively; pick one or the other. -// DS_MATRIX_PROGRESSIVE, DS_MATRIX_ZIGZAG: all rows/columns proceed -// in the same order, or alternate lines reverse direction; pick one. -// See example below for these values in action. -// Parameter 5 = pixel type: -// DOTSTAR_BRG Pixels are wired for BRG bitstream (most DotStar items) -// DOTSTAR_GBR Pixels are wired for GBR bitstream (some older DotStars) -// DOTSTAR_BGR Pixels are wired for BGR bitstream (APA102-2020 DotStars) - -Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix( +Adafruit_DotStarMatrix pixo = Adafruit_DotStarMatrix( 16, 16, DATAPIN, CLOCKPIN, DS_MATRIX_BOTTOM + DS_MATRIX_LEFT + DS_MATRIX_ROWS + DS_MATRIX_PROGRESSIVE, DOTSTAR_BGR); const uint16_t primaryColors[] = { - matrix.Color(100, 0, 0), matrix.Color(0, 100, 0), matrix.Color(0, 0, 100) + pixo.Color(100, 0, 0), pixo.Color(0, 100, 0), pixo.Color(0, 0, 100) }; -const uint16_t adaColors[] = { - matrix.Color(255, 0, 0), //A red - matrix.Color(255, 125, 0), //D orange - matrix.Color(200, 255, 0), //A yellowish - matrix.Color(0, 255, 0), //F green - matrix.Color(0, 255, 225), //R blue - matrix.Color(150, 0, 255), //U purple - matrix.Color(255, 0, 220), //I pink - matrix.Color(255, 65, 0), //T reddish - matrix.Color(255, 220, 0) //! orange/yellow -}; - -char adafruit[] = "ADAFRUIT!"; void setup() { Serial.begin(115200); // uncomment to have wait //while (!Serial) delay(500); - - matrix.begin(); - + + pixo.begin(); + pixo.setBrightness(BRIGHTNESS); for (byte i = 0; i < 3; i++) { - matrix.fillScreen(primaryColors[i]); - matrix.show(); + pixo.fillScreen(primaryColors[i]); + pixo.show(); delay(500); - matrix.fillScreen(0); - matrix.show(); + pixo.fillScreen(0); + pixo.show(); } } -int x = matrix.width(); +int x = pixo.width(); int pass = 0; void loop() { - matrix.setBrightness(BRIGHTNESS); - while(1){ - // pongDemo(); - SinglePix(); + pixo.setBrightness(BRIGHTNESS); + //while(1){ + //SinglePix(); // RandomPix(); //} - //notification(); - - } + notification(); -void SinglePix(){ - for (int x = 0; x<256;x++){ - - matrix.setPixelColor(x, 255, 255, 255); +} + +void SinglePix() { + for (int x = 0; x < 256; x++) { + pixo.setPixelColor(x, 255, 255, 255); delay(10); - matrix.show(); + pixo.show(); delay(200); -} + } } -void RandomPix(){ +void RandomPix() { randomSeed(A1); - int x = random(0,256); - matrix.fillScreen(0); - matrix.setPixelColor(x, 255, 255, 255); - matrix.show(); - delay(50); - + int x = random(0, 256); + pixo.fillScreen(0); + pixo.setPixelColor(x, 255, 255, 255); + pixo.show(); + delay(50); } -void notification(){ - for (int j = 15; j>=0;j--){ - matrix.fillScreen(0); - for (int i = 0; i<256; i++) { - matrix.setPixelColor(i+(j*16), upvote[i][0], upvote[i][1], upvote[i][2]); - //Serial.println(i); - //delay(1); - } - matrix.show(); - delay(15); +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); } delay(1000); - for (int j = 0; j>=-16;j--){ - matrix.fillScreen(0); - for (int i = 0; i<256; i++) { - matrix.setPixelColor(i+(j*16), upvote[i][0], upvote[i][1], upvote[i][2]); - //Serial.println(i); - //delay(1); - } - matrix.show(); - delay(15); + 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); } delay(1000); - matrix.fillScreen(0); - matrix.show(); + pixo.fillScreen(0); + pixo.show(); } -float ballx = 5; +float ballx = 5; float bally = 5; float paddle1, paddle2 = 3; float ballvx = -0.3; float ballvy = 0.1; -void pongDemo(){ - matrix.fillScreen(0); - matrix.drawFastVLine(0, (int)paddle1, 6, (200,200,200)); - matrix.drawFastVLine(15, (int)paddle2, 6, (200,200,200)); - matrix.drawPixel((int)ballx,(int)bally,(200,200,200)); - if (ballx > 14 || ballx<1){ - ballvx = ballvx *-1; - } - if (bally > 14 || bally<0){ - ballvy = ballvy * -1; - } - paddle1 = bally-3; - paddle2 = bally-3; - ballx = ballx + ballvx; - bally = bally + ballvy; - Serial.print(ballx); - Serial.print(","); - Serial.println(bally); - matrix.show(); - delay(30); -} diff --git a/FIRMWARE/PIXO_WIP/image.h b/FIRMWARE/PIXO_WIP/image.h index 9777150..41da695 100644 --- a/FIRMWARE/PIXO_WIP/image.h +++ b/FIRMWARE/PIXO_WIP/image.h @@ -3,5 +3,5 @@ int twitter[256][3] = {{40, 170, 225}, {40, 170, 225}, {40, 170, 225}, {40, 170, int ig[256][3] = {{0, 0, 0}, {182, 45, 118}, {190, 52, 133}, {177, 58, 155}, {176, 70, 183}, {166, 79, 206}, {159, 82, 215}, {155, 79, 212}, {151, 76, 208}, {148, 73, 203}, {144, 70, 199}, {140, 67, 194}, {128, 59, 178}, {125, 57, 176}, {118, 54, 163}, {0, 0, 0}, {209, 27, 81}, {204, 35, 93}, {217, 48, 127}, {184, 51, 134}, {169, 59, 155}, {158, 68, 177}, {148, 77, 200}, {143, 76, 200}, {141, 72, 193}, {138, 69, 189}, {133, 66, 184}, {129, 62, 180}, {129, 61, 179}, {142, 66, 199}, {121, 56, 171}, {118, 54, 163}, {221, 21, 56}, {241, 31, 82}, {206, 36, 94}, {184, 49, 120}, {197, 50, 125}, {184, 55, 144}, {169, 61, 161}, {155, 72, 185}, {147, 77, 201}, {144, 75, 195}, {143, 71, 196}, {142, 71, 198}, {131, 65, 172}, {129, 61, 178}, {142, 66, 198}, {121, 56, 170}, {236, 13, 35}, {232, 21, 56}, {213, 24, 65}, {202, 35, 92}, {215, 48, 127}, {197, 56, 146}, {184, 64, 167}, {176, 72, 190}, {165, 81, 211}, {155, 81, 214}, {153, 78, 210}, {145, 73, 199}, {137, 68, 189}, {127, 63, 178}, {129, 62, 181}, {128, 60, 179}, {255, 6, 18}, {235, 10, 28}, {213, 26, 67}, {239, 31, 81}, {203, 35, 93}, {194, 42, 112}, {196, 53, 138}, {175, 57, 151}, {163, 66, 171}, {162, 78, 202}, {148, 77, 202}, {133, 69, 185}, {138, 69, 190}, {137, 68, 188}, {128, 63, 179}, {141, 67, 195}, {255, 8, 3}, {246, 3, 8}, {226, 18, 46}, {245, 21, 56}, {216, 28, 75}, {210, 36, 95}, {192, 46, 118}, {171, 53, 137}, {171, 62, 161}, {157, 71, 180}, {155, 76, 198}, {148, 77, 204}, {150, 76, 205}, {139, 71, 192}, {136, 65, 184}, {143, 70, 198}, {255, 33, 1}, {246, 15, 1}, {241, 8, 24}, {253, 13, 34}, {234, 22, 59}, {216, 28, 71}, {199, 34, 89}, {205, 43, 113}, {190, 53, 138}, {176, 54, 142}, {151, 72, 176}, {155, 75, 196}, {159, 83, 219}, {143, 72, 196}, {137, 68, 186}, {147, 73, 202}, {255, 64, 1}, {246, 47, 3}, {246, 0, 2}, {255, 6, 15}, {235, 13, 35}, {216, 23, 54}, {216, 29, 75}, {217, 38, 100}, {197, 44, 116}, {206, 60, 155}, {179, 55, 137}, {158, 68, 175}, {177, 85, 222}, {145, 77, 202}, {141, 72, 191}, {151, 76, 207}, {255, 94, 1}, {246, 75, 3}, {244, 19, 2}, {255, 12, 2}, {245, 1, 9}, {227, 20, 48}, {242, 21, 56}, {212, 27, 74}, {205, 35, 91}, {211, 48, 126}, {186, 48, 126}, {170, 62, 162}, {191, 77, 202}, {153, 73, 189}, {144, 74, 199}, {155, 79, 211}, {255, 125, 1}, {248, 103, 3}, {244, 51, 2}, {255, 40, 0}, {246, 7, 1}, {231, 7, 23}, {237, 13, 33}, {242, 21, 56}, {222, 28, 74}, {231, 40, 105}, {196, 40, 105}, {178, 53, 137}, {201, 67, 177}, {165, 63, 165}, {146, 77, 202}, {158, 82, 215}, {255, 156, 1}, {246, 131, 3}, {244, 78, 2}, {255, 71, 0}, {255, 32, 1}, {245, 14, 0}, {231, 9, 32}, {244, 14, 37}, {232, 22, 60}, {208, 29, 77}, {195, 37, 97}, {199, 43, 114}, {197, 56, 147}, {176, 56, 146}, {155, 72, 182}, {165, 79, 205}, {255, 187, 1}, {246, 155, 1}, {245, 102, 6}, {255, 105, 0}, {246, 59, 0}, {250, 32, 1}, {247, 11, 0}, {235, 0, 4}, {233, 15, 31}, {227, 18, 48}, {219, 29, 76}, {207, 35, 94}, {211, 48, 127}, {187, 48, 124}, {166, 62, 163}, {179, 71, 185}, {249, 201, 1}, {249, 182, 1}, {234, 142, 20}, {247, 117, 1}, {255, 107, 0}, {255, 70, 0}, {255, 40, 0}, {255, 11, 2}, {255, 6, 15}, {255, 15, 40}, {247, 21, 57}, {236, 30, 78}, {212, 37, 97}, {187, 42, 110}, {181, 52, 136}, {180, 59, 154}, {245, 212, 4}, {255, 225, 0}, {247, 183, 3}, {236, 132, 18}, {252, 115, 4}, {249, 84, 1}, {244, 54, 1}, {246, 24, 0}, {246, 0, 1}, {242, 5, 19}, {234, 15, 41}, {229, 25, 68}, {202, 32, 78}, {203, 35, 94}, {219, 49, 129}, {183, 50, 129}, {245, 218, 18}, {247, 214, 2}, {255, 224, 0}, {247, 181, 1}, {244, 159, 2}, {247, 135, 5}, {244, 107, 2}, {246, 79, 2}, {244, 49, 2}, {246, 16, 0}, {246, 2, 5}, {235, 9, 24}, {227, 19, 52}, {243, 32, 83}, {206, 36, 95}, {196, 39, 107}, {0, 0, 0}, {245, 217, 18}, {250, 217, 4}, {249, 201, 1}, {255, 188, 2}, {255, 155, 1}, {255, 124, 1}, {255, 94, 1}, {255, 64, 1}, {255, 33, 1}, {255, 8, 3}, {255, 7, 19}, {238, 14, 38}, {228, 21, 57}, {205, 29, 58}, {0, 0, 0}}; int upvote[256][3] = {{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, 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, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 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, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 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}, {31, 8, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; int sh[256][3] = {{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, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {3, 3, 3}, {2, 2, 2}, {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}, {3, 3, 3}, {3, 3, 3}, {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, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {22, 22, 22}, {58, 58, 58}, {78, 78, 78}, {86, 86, 86}, {69, 69, 69}, {5, 5, 5}, {1, 1, 1}, {3, 3, 3}, {0, 0, 0}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {86, 86, 86}, {154, 154, 154}, {114, 114, 114}, {73, 73, 73}, {49, 49, 49}, {40, 40, 40}, {39, 39, 39}, {6, 6, 6}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {93, 93, 93}, {163, 163, 163}, {118, 118, 118}, {65, 65, 65}, {17, 17, 17}, {0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {14, 14, 14}, {52, 52, 52}, {0, 0, 0}, {35, 35, 35}, {0, 0, 0}, {2, 2, 2}, {3, 3, 3}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, {30, 30, 30}, {74, 74, 74}, {114, 114, 114}, {122, 122, 122}, {54, 54, 54}, {0, 0, 0}, {21, 21, 21}, {211, 211, 211}, {4, 4, 4}, {174, 174, 174}, {48, 48, 48}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {3, 3, 3}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {32, 32, 32}, {131, 131, 131}, {108, 108, 108}, {0, 0, 0}, {183, 183, 183}, {38, 38, 38}, {136, 136, 136}, {130, 130, 130}, {41, 41, 41}, {75, 75, 75}, {78, 78, 78}, {0, 0, 0}, {0, 0, 0}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, {20, 20, 20}, {51, 51, 51}, {199, 199, 199}, {152, 152, 152}, {199, 199, 199}, {116, 116, 116}, {110, 110, 110}, {193, 193, 193}, {51, 51, 51}, {46, 46, 46}, {25, 25, 25}, {0, 0, 0}, {1, 1, 1}, {0, 0, 0}, {61, 61, 61}, {154, 154, 154}, {123, 123, 123}, {76, 76, 76}, {53, 53, 53}, {173, 173, 173}, {155, 155, 155}, {123, 123, 123}, {0, 0, 0}, {181, 181, 181}, {4, 4, 4}, {0, 0, 0}, {0, 0, 0}, {2, 2, 2}, {0, 0, 0}, {49, 49, 49}, {209, 209, 209}, {32, 32, 32}, {0, 0, 0}, {0, 0, 0}, {117, 117, 117}, {126, 126, 126}, {53, 53, 53}, {135, 135, 135}, {1, 1, 1}, {134, 134, 134}, {63, 63, 63}, {2, 2, 2}, {3, 3, 3}, {1, 1, 1}, {1, 1, 1}, {24, 24, 24}, {124, 124, 124}, {87, 87, 87}, {75, 75, 75}, {126, 126, 126}, {143, 143, 143}, {11, 11, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {53, 53, 53}, {126, 126, 126}, {0, 0, 0}, {3, 3, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {25, 25, 25}, {35, 35, 35}, {24, 24, 24}, {0, 0, 0}, {0, 0, 0}, {2, 2, 2}, {3, 3, 3}, {0, 0, 0}, {0, 0, 0}, {35, 35, 35}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {3, 3, 3}, {1, 1, 1}, {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, 0}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {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, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; - -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}}; +int glogo[256][3] = {{255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {11, 11, 11}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {125, 125, 125}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {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, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {116, 116, 116}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {170, 170, 170}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {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, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}, {255, 255, 255}}; +//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}}; diff --git a/PYTHON/CreateMatrix.py b/PYTHON/CreateMatrix.py new file mode 100644 index 0000000..4497760 --- /dev/null +++ b/PYTHON/CreateMatrix.py @@ -0,0 +1,19 @@ +import sys +from PIL import Image + + +img = sys.argv[1] +size = 16, 16 + +im = Image.open(img) +smallim = im.resize(size, Image.ANTIALIAS); +smallim = smallim.convert('RGB') +pixels = list(smallim.getdata()) + +imgstr = str(pixels).strip('[]') +imgstr = imgstr.replace('(','{') +imgstr = imgstr.replace(')','}') + +f = open(img + '.h', 'w') +f.write('int imageArray[256][3] = {' + imgstr + '};') +f.close()