#include "SdFat.h"
#include<FastLED.h>
SdFat SD;
File file;
int frame=0;
unsigned char i;
unsigned char j;
#define DATA_PIN 22
#define X_SEGMENTS 32
#define Y_SEGMENTS 32
#define NUM_SEGMENTS (X_SEGMENTS * Y_SEGMENTS)
CRGB leds[NUM_SEGMENTS];
unsigned char disp1[19][8]={0x0c,0x1e,0x3e,0x7c,0x7c,0x3e,0x1e,0x0c};
void Init_MAX7219(void)
{
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_SEGMENTS);
}
void setPoint(int x, int y, int state)
{
leds[x + y * X_SEGMENTS] = state;
}
void show()
{
FastLED.show();
}
void displayFrame(void)
{
byte b0 = 0x00;
frame++;
byte b1 = 0x00;
byte b2 = 0x00;
for (int y = 0; y < 32; y++){
for (int x = 0; x < 32; x++){
b0 = file.read();
switch(b0) {
case 0x2E:
setPoint(x, y, CRGB::White);
break;
case 0x20:
setPoint(x, y, CRGB::Black);
break;
}
}
}
show();
}
void setup() {
delay(50);
Init_MAX7219();
Serial.begin(115200);
//delay(4000);
if (!SD.begin(15)) {
Serial.println(F("COULD NOT INITIALIZE SD CARD"));
return;
}
file = SD.open("video.rawr", FILE_READ);
if (!file){
Serial.print("COULD NOT LOAD FILE");
return;
}
while (1){
displayFrame();
}
}
void loop()
{
//no
}