QuickStart

ESP8266-SSD1306-BadApple!!.zip

MD5

3155923796a596f0c0a7c8fc09f75b16 ESP8266-SSD1306-BadApple!!.zip

SHA1

1ae70f75256b7ec626611f4a2b19047b1fec71d6 ESP8266-SSD1306-BadApple!!.zip

SHA256

0db0da8b332ae62712cb9f9138aa266160e74d6bf482fca7d96dc6b112f54ab8 ESP8266-SSD1306-BadApple!!.zip

CRC32

187d4be4 ESP8266-SSD1306-BadApple!!.zip
安装esptool.py并确保能连接设备
博主SSD1306地址为0x3C接线为D2接SDA,D1接SCL
如有更改需要可修改对应代码,点击Arduino-项目-导出已编译的二进制文件,重新编译固件。
运行upload脚本即可刷入固件

视频文件制作过程

下载来自fb39ca4/badapple-ti84vedio.bin
其编码方式为逐帧逐行逐列编码字节,0x00表示白像素,其他表示黑像素。
压缩程序代码

#include <bits/stdc++.h>
using namespace std;
int main(){
    ifstream is("frames.bin",ios::binary&ios::in);
    ofstream os("frames2.bin",ios::binary&ios::out);
    unsigned char cc=0;unsigned char w=0;
    vector<unsigned char> v;
    while (is.good()){
      unsigned char c=is.get();
      while (w==255||((c&1)!=(cc&1))){
       v.push_back(w);
       cc=cc?0:1;
       w=0;
      }
      w++;
    }
    for (auto i:v) os.put(i);
}

得到1.2MB压缩后视频文件

代码

#include <Wire.h>
#include "SSD1306Wire.h"
SSD1306Wire display(0x3C, D2, D1); // ADDRESS, SDA, SCL
uint32_t addr = 0x0045000;
uint32_t len = addr + 1209895;
void setup() {
  display.init();
}
struct buffers {
  unsigned char c[128];
  unsigned char *ci, *ce;
  uint32_t addri, addrr;
  buffers() {
    ci = ce = c + 128;
    addri = addr;
    addrr = addri + len;
  }
  char get() {
    if (addri >= addrr) exit(0);
    if (ci == ce) {
      ESP.flashRead(addri, (uint32_t*)c, 128);
      addri += 128;
      ci = c;
    }
    return *ci++;
  }
};
struct Read {
  unsigned char i, c;
  unsigned int p;
  buffers data;
  Read() {
    i = 1; c = 0; p = 0;
  }
  char get() {
    while (c == 0) {
      i = !i;
      c = data.get();
      p++;
    }
    c--;
    return i;
  }
} reader;
void test(){
  display.clear();
    for (int i = 0; i < 64; i++)
      for (int j = 0; j < 96; j++)
        display.setPixelColor(j, i, reader.get() ? WHITE : BLACK),display.display(),delay(16);
}
void doit(){
  display.clear();
  while (true) {
    for (int i = 0; i < 64; i++)
      for (int j = 0; j < 96; j++)
        display.setPixelColor(j, i, reader.get() ? WHITE : BLACK);
    display.display();
    delay(16); 
  }
}
void loop() {
  // put your main code here, to run repeatedly:
  doit();
}