OLED常用尺寸

  • 72x40,0.42in
  • 96x32,0.54in
  • 96x16,0.69in
  • 64x48,0.71in
  • 128x80,0.78in,面板尺寸12.13x23.6mm
  • 128x32,0.91in
  • 128x64,0.96in/1.09in

图像转字符串

常见驱动芯片

其它小工具

行byte转列byte

  • 1x8的位图字节数据(每个字节为水平方向上的8个bit)转换为SSD1306写入的用的格式(每个字节为竖直方向上的8个bit)
  • 若以Horizontal - 1 bit per pixel生成bitmap,为
    const unsigned char bitmap_test [] PROGMEM = {
    0xf0, ..., 0x00, 
    0xf0, ..., 0x00, 
    0xe0, ..., 0x00, 
    0xe0, ..., 0x00, 
    0xc0, ..., 0x00, 
    0xc0, ..., 0x00, 
    0x80, ..., 0x00, 
    0x80, ..., 0x00, 
    0x00, ..., 0x00, 
    0x00, ..., 0x00, ...
    
  • 若以Vertical - 1 bit per pixel生成bitmap,为
    const unsigned char bitmap_test [] PROGMEM = {
    0xff, 0x3f, 0x0f, 0x03, 0x00, ..., 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, ..., 0x00, ..
    
  • 转换代码为(wh分别为width和height)
  int idx = 0;
  while (idx < w*h){
    // load a 8x8 bit matrix each time
    setCursorXY(idx%w, idx/w);
    byte buffer[8] = {};
    for (uint8_t i = 0; i < 8; i++){
      byte temp = pgm_read_byte(&bitmap[(idx/w*8)*w+i*w+idx%w]);
      for (uint8_t j = 0; j < 8; j++){
        buffer[j] |= ( ((temp>>(7-j)) & 1) << i);
      }
    }
    TinyWireM.beginTransmission(OLED_ADDRESS); // begin transmitting
    TinyWireM.send(OzOLED_DATA_MODE);//data mode
    for (uint8_t i = 0; i < 8; i++){
      TinyWireM.send(buffer[i]);
    }
    TinyWireM.endTransmission();    // stop transmitting
    idx += 1;
  }

好像没有什么用的8x8 bit矩阵转置代码

  • 输入为const byte *bitmap
byte transpose[8] = {};
for (uint8_t i = 0; i < 8; i++){
    byte temp = pgm_read_byte(&bitmap[i]);
    for (uint8_t j = 0; j < 8; j++){
        transpose[j] |= ((temp>>j) & 1) << (7-i);
    }
}
for (uint8_t i = 0; i < 8; i++){
    sendData(transpose[i]);
}