「さいころ」STM32G071とSSD1331でパラパラマンガ


x だんだんめんどくなったので過去ログを見よ

x イメージは、雀荘のサイコロ、ランダムを使ったスロットの類


目的
なんかプログラムを作って遊ぶ
MSXのいろいろな画面だけから発想を得て約2時間で作成
ちょつと長め


![o_cop286.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/7f46a53e-a436-81f5-fbb1-cfdff333bb3a.jpeg)



```c++



//OLED_SSD1331_saikoro1_071

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>
#include <SPI.h>


// You can use any (4 or) 5 pins
#define sclk 13
#define mosi 11
#define cs   10
#define rst  9
#define dc   8


// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF


Adafruit_SSD1331 display = Adafruit_SSD1331(&SPI, cs, dc, rst);


char *saikoro1[] = {

/*
 0000000000111111
 0123456789012345
*/

//1

"oooooooooooooooo", //0
"o              o", //1
"o              o", //2
"o              o", //3
"o              o", //4
"o              o", //5
"o              o", //6
"o      oo      o", //7
"o      oo      o", //8
"o              o", //9
"o              o", //10
"o              o", //11
"o              o", //12
"o              o", //13
"o              o", //14
"oooooooooooooooo", //15

//2

"oooooooooooooooo", //0
"o              o", //1
"o              o", //2
"o  oo          o", //3
"o  oo          o", //4
"o              o", //5
"o              o", //6
"o              o", //7
"o              o", //8
"o              o", //9
"o              o", //10
"o          oo  o", //11
"o          oo  o", //12
"o              o", //13
"o              o", //14
"oooooooooooooooo", //15

//3

"oooooooooooooooo", //0
"o              o", //1
"o              o", //2
"o  oo          o", //3
"o  oo          o", //4
"o              o", //5
"o              o", //6
"o      oo      o", //7
"o      oo      o", //8
"o              o", //9
"o              o", //10
"o          oo  o", //11
"o          oo  o", //12
"o              o", //13
"o              o", //14
"oooooooooooooooo", //15

//4

"oooooooooooooooo", //0
"o              o", //1
"o              o", //2
"o  oo      oo  o", //3
"o  oo      oo  o", //4
"o              o", //5
"o              o", //6
"o              o", //7
"o              o", //8
"o              o", //9
"o              o", //10
"o  oo      oo  o", //11
"o  oo      oo  o", //12
"o              o", //13
"o              o", //14
"oooooooooooooooo", //15

//5

"oooooooooooooooo", //0
"o              o", //1
"o              o", //2
"o  oo      oo  o", //3
"o  oo      oo  o", //4
"o              o", //5
"o              o", //6
"o      oo      o", //7
"o      oo      o", //8
"o              o", //9
"o              o", //10
"o  oo      oo  o", //11
"o  oo      oo  o", //12
"o              o", //13
"o              o", //14
"oooooooooooooooo", //15

//6

"oooooooooooooooo", //0
"o              o", //1
"o              o", //2
"o  oo      oo  o", //3
"o  oo      oo  o", //4
"o              o", //5
"o              o", //6
"o  oo      oo  o", //7
"o  oo      oo  o", //8
"o              o", //9
"o              o", //10
"o  oo      oo  o", //11
"o  oo      oo  o", //12
"o              o", //13
"o              o", //14
"oooooooooooooooo"  //15

};


//初期化
void setup() {

  //表示の開始
  display.begin();

  //display.fillScreen(BLACK);

}//setup


//メインループ
void loop() {

  int px,py; //座標
  int ii;    //ループカウンター
  int i_rand = 1; //ランダム
  char pc;   //ポイントのカラー


for(ii=0;ii<30;ii++){

  // 画面表示をクリア
  display.fillScreen(GREEN);

    //ランダムの設定
    i_rand = random(6);
    
    
    for(py=0;py<16;py++){
        for(px=0;px<16;px++){
            pc = saikoro1[py+(i_rand*16)][px];

            if( pc=='o'){

    // display.drawPixel(座標x, 座標y, 点の色);
    display.drawPixel(px, py, BLACK);

            } else {


    // display.drawPixel(座標x, 座標y, 点の色);
    display.drawPixel(px, py, WHITE);


            }//endif
            
            //printf("%c",pc);
        }//px
            //printf("\n");
    }//py

  delay(200); //200ms秒待つ

} //for ii

  delay(3000); //1秒待つ

}//loop




```