Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
2
Indexable
Never
#include <Adafruit_SSD1306.h>
#include <splash.h>

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <TimerOne.h>
#include "SdFat.h"


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI   11
#define OLED_CLK   13
#define OLED_DC    9
#define OLED_CS    10
#define OLED_RESET 8
Adafruit_SSD1306 OLED(SCREEN_WIDTH, SCREEN_HEIGHT,
  OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


SdFat SD;

File file;


void setup() {
  OLED.clearDisplay();
  OLED.display();
  Serial.begin(9600);
  
  Serial.println("test");
  if (!SD.begin(4)) {
    Serial.println("COULD NOT INITIALIZE SD CARD");
    return;
  }

  Serial.println("123");
  file = SD.open("output1.avi", FILE_READ);
  if (!file){
    Serial.print("COULD NOT LOAD FILE");
    return;
  }
  
  Serial.println("Done.");
//  while (1){
//    displayFrame();
//  }
}

void loop() {
 byte b = 0x00;
  for (int y = 0; y < 64; y++){
    for (int x = 0; x < 128; x += 8){
      b = file.read();
      OLED.drawPixel(x, y, b & 0x01);
      OLED.drawPixel(x + 1, y, (b >> 1) & 0x01);
      OLED.drawPixel(x + 2, y, (b >> 2) & 0x01);
      OLED.drawPixel(x + 3, y, (b >> 3) & 0x01);
      OLED.drawPixel(x + 4, y, (b >> 4) & 0x01);
      OLED.drawPixel(x + 5, y, (b >> 5) & 0x01);
      OLED.drawPixel(x + 6, y, (b >> 6) & 0x01);
      OLED.drawPixel(x + 7, y, (b >> 7) & 0x01);
    }
  }
  OLED.display();
}

void displayFrame(void)
{
  
}