「46」よろーをデカ文字(32x32) LPC812とSSD1306



「46」よろーをデカ文字(32x32) LPC812とSSD1306


x 過去ログを見よ!!


![o_cop344.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/55c00fc3-bfc6-8f8b-6ff2-4d1afb00515c.jpeg)



```c++



//oled_test2_16x24_812_1

#include "mbed.h"
#include "SSD1308.h"

//i2c initialization
//       SDA    SCL
I2C i2c(P0_10, P0_11); //812

// ビットマップデータ
char databytes1[] =
    {

  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x8f, 0xf8, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xf0, 0x3f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xce, 0x7f, 0xff, 0xff, 0x9e, 0x7f, 0xff, 
  0xff, 0xbe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xc0, 0x03, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xff, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xf8, 0x07, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 
  0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x1f, 0xe0, 0x7f, 0xff, 0x80, 0x00, 0x7f, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xf0, 0x07, 0xff, 
  0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xfc, 0xff, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0x8f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0xff, 0xff, 
  0xff, 0xf0, 0xff, 0xff, 0xff, 0xe1, 0x9f, 0xff, 0xff, 0xc3, 0x9f, 0xff, 0xff, 0x87, 0x9f, 0xff, 
  0xff, 0x1f, 0x9f, 0xff, 0xff, 0x3f, 0x9f, 0xff, 0xfe, 0x3f, 0x9f, 0xff, 0xfe, 0x7f, 0x9f, 0xff, 
  0xfe, 0x7f, 0x1f, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 
  0xfe, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 
  0xfe, 0x3f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 
  0xff, 0xf2, 0x07, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xfc, 0xff, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x00, 0x07, 0xff, 
  0xfe, 0x00, 0x03, 0xff, 0xfe, 0x1f, 0xf3, 0xff, 0xfe, 0x3f, 0xf9, 0xff, 0xfe, 0x7f, 0xfc, 0xff, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 
  0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xe3, 0xff, 
  0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x3f, 0xff, 
  0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 
  0xff, 0xe1, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 
  0xff, 0x0f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 
  0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 
  0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7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, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xfe, 0x1f, 0xff

    };

int gop[8][8] = {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},

                 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}};

unsigned char bbh[]
    // 1122
    = {0, 0, 0, 0, 0, 0, 0, 0};


void p_m270(char ttt[]) {
  char cc;
  for (int ii = 0; ii < 8; ii++) {
    cc = ttt[ii];
    gop[ii][7] = cc & 0x1;    cc = cc >> 1;
    gop[ii][6] = cc & 0x1;    cc = cc >> 1;
    gop[ii][5] = cc & 0x1;    cc = cc >> 1;
    gop[ii][4] = cc & 0x1;    cc = cc >> 1;

    gop[ii][3] = cc & 0x1;    cc = cc >> 1;
    gop[ii][2] = cc & 0x1;    cc = cc >> 1;
    gop[ii][1] = cc & 0x1;    cc = cc >> 1;
    gop[ii][0] = cc & 0x1;
  } // for
} // p_m270


void p_out(unsigned char ttt[]) {
  char cc;
  for (int ii = 0; ii < 8; ii++) {
    cc = 0;
    cc = cc + (gop[0][ii] * 1);
    cc = cc + (gop[1][ii] * 2);
    cc = cc + (gop[2][ii] * 4);
    cc = cc + (gop[3][ii] * 8);
    cc = cc + (gop[4][ii] * 16);
    cc = cc + (gop[5][ii] * 32);
    cc = cc + (gop[6][ii] * 64);
    cc = cc + (gop[7][ii] * 128);
    ttt[ii] = cc;
  } // for
} // p_out


//32x32
void bitmap32x32( SSD1308 *oled, uint8_t * databytes9,   int p_row ,  int p_col ) {

  int o_row = 0;
  int o_col = 0;
  int kk = 0;

  o_row = p_row;

  for (int ii = 0; ii < 4; ii++) {

    o_col = p_col;

    for (int jj = 0; jj < 4; jj++) {

      char koi[8];

      koi[0] = *(databytes9 + kk + 0);
      koi[1] = *(databytes9 + kk + 4);
      koi[2] = *(databytes9 + kk + 8);
      koi[3] = *(databytes9 + kk + 12);

      koi[4] = *(databytes9 + kk + 16);
      koi[5] = *(databytes9 + kk + 20);
      koi[6] = *(databytes9 + kk + 24);
      koi[7] = *(databytes9 + kk + 28);

      kk = kk + 1;

      p_m270(koi);
      p_out(bbh);

      oled->writeBitmap((uint8_t *)bbh, 
                        o_row,
                       (o_row + 1 - 1),
                        o_col,
                       (o_col + 8 - 1));

      o_col = o_col + 8;

    } // for jj

    o_row = o_row + 1;

    kk = kk + 7 * 4;

  } // for ii


} // bitmap32x32





//メイン関数
int main() {

  wait_ms(500); // 0.5秒の待ち

  // Instantiate OLED
  SSD1308 oled = SSD1308(&i2c, SSD1308_SA0);

  int p_row = 0;
  int p_col = 0;


  int c1000 = 1; //千の桁
  int c100  = 2; //百の桁
  int c10   = 3; //十の桁
  int c1    = 4; //一の桁

  int x = 46; //数値


//10の割り算 0から9999までは、正しい。 stm32
#define DIV10(n) (((n*409)+((n*154)>>8))>>12)

  c1    =  (  x - (DIV10(x) * 10)  );  // '0'+(d%10)
  x = DIV10(x);
  c10   =  (  x - (DIV10(x) * 10)  );  // '0'+(d%10)
  x = DIV10(x);
  c100  =  (  x - (DIV10(x) * 10)  );  // '0'+(d%10)
  c1000 =   DIV10(x);                  // '0'+(d/10)




  bitmap32x32( &oled,(uint8_t *) ( databytes1+(c1000 *(32/8)*32)  ), p_row ,  p_col );

  p_col = p_col + 32; 

  bitmap32x32( &oled,(uint8_t *) ( databytes1+(c100 *(32/8)*32)  ) , p_row ,  p_col );

  p_col = p_col + 32;

  bitmap32x32( &oled,(uint8_t *) ( databytes1+(c10 *(32/8)*32)  ) , p_row ,  p_col );

  p_col = p_col + 32;

  bitmap32x32( &oled,(uint8_t *) ( databytes1+(c1 *(32/8)*32)  ) , p_row ,  p_col );




  while (1) {}

} // main




```