images can be send but are not drawn correctly
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "index.h"
|
||||
|
||||
// For ESP8266, you would use:
|
||||
@@ -14,7 +15,7 @@
|
||||
#define PIN 12
|
||||
|
||||
#define PANEL_PIXEL_COUNT 16
|
||||
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*3
|
||||
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT
|
||||
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
@@ -25,6 +26,8 @@ struct Pixel
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
Pixel new_image[PANEL_PIXEL_COUNT][PANEL_PIXEL_COUNT];
|
||||
|
||||
// dont change this
|
||||
Pixel saved_imaged[12][16][16] = {
|
||||
{
|
||||
@@ -93,14 +96,37 @@ Pixel getPixelFromSaved(unsigned char i, int row, int col)
|
||||
return saved_imaged[i][row][col];
|
||||
}
|
||||
|
||||
void drawImageFromArr(int offset_x, int offset_y, unsigned char i) {
|
||||
Pixel getPixel(int row, int col)
|
||||
{
|
||||
return new_image[row][col];
|
||||
}
|
||||
|
||||
void drawImageFromArr(int offset_x, int offset_y) {
|
||||
for (int row = 0; row < 16; row++) {
|
||||
for (int col = 0; col < 16; col++) {
|
||||
Pixel px = getPixel(row, col);
|
||||
if (px.color == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int pixel_x = px.x + offset_x;
|
||||
int pixel_y = px.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, px.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawImageFromSaved(int offset_x, int offset_y, unsigned char i) {
|
||||
for (int row = 0; row < 16; row++) {
|
||||
for (int col = 0; col < 16; col++) {
|
||||
Pixel px = getPixelFromSaved(i, row, col);
|
||||
if (px.color == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int pixel_x = px.x + offset_x;
|
||||
int pixel_y = px.y + offset_y;
|
||||
|
||||
@@ -117,7 +143,7 @@ void setup() {
|
||||
pixels.begin();
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
drawImageFromArr(0, 0, 0);
|
||||
drawImageFromSaved(0, 0, 0);
|
||||
start_server();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user