NeoPixelの8x8RGBカラーLEDパネルでは数字フォントを表示できました。

Excelでカラーのドット絵を描く環境ができたので,今度は8x8の小さい絵を描いてみました。


MPUはSTMC011J4M7で,LEDパネルにはメッシュをつけています。





Excelでのデータ作成です。
 各ドットのカラーデータはセルから読み取った32bit(有効値はRGB各8bitの24bit)はRGBに分解せず,そのままの値でArduinoの配列変数として使えるように編集しています。





配列変数としてプログラムにコピペしたところです。
 下図では8x8の画面を4面作っていますが,1画面が小さいのであまりかさばらない?感じでしょうか,,。





出来が悪いですが実際に動かしてみた動画です。
かなり離れて見ると,少しはそれらしく見えますでしょうか(^^;;;;;。






プログラム的にはフォントの表示のプログラムに配列データを読み込むパートを追加しただけです(^^)。

 各ドットでは32bit(有効は下位24bit)の色データをそのまま使っているので,プログラム内でRGBに分解しています。

    for(int i=0; i< Y_max; i++){             // Show BitMap 2
for (int j=0; j< X_max; j++){
byte R=bMap_RGB24_2[i][j]%256/3;
byte G=(bMap_RGB24_2[i][j]/256)%256/3;
byte B=bMap_RGB24_2[i][j]/256/256/3;
p_set (j,i,R,G,B);
}
}






ドット絵を作るのにはセンスが必要ですねぇ,,。
私は全く絵心が無いので,小さなアイロンビーズや刺繍の構図を参考というよりもっと頂いて作ってみました(^^;;;;;。

本当に一から作れる人はすごいですねぇ,尊敬します,はい。


以下は自分のプログラム記録用メモです。
UARTも切っているので10Kb程度の大きさです。


/ STM32C011 NeoPixel 8x8 Test_2

// RGB_LED: 8x8
const unsigned int X_max = 8; // LED Matrix
const unsigned int Y_max = 8;

const unsigned int Led_max = X_max*Y_max; // number of LED
const byte c_order[]={1,0,2}; // send GRB, R:1, G:0, B:2

byte bData[X_max][Y_max][3]; // Data Buffer
byte aData[Led_max][3]; // Serial data for output

// bitMap_RGB24[data number][y][x], 0x00BBGGRR
const long bMap_RGB24_0[8][8]={{0,0,0,0,0,0,0,0},{255,255,255,0,65280,65280,65280,0},{255,0,255,0,65280,0,65280,0},
{255,255,255,16711680,65280,65280,65280,0},{255,0,255,0,65280,0,65280,0},
{255,255,255,0,65280,65280,65280,0},{0,0,0,0,0,0,0,0},
{16777215,16777215,16777215,16777215,16777215,16777215,16777215,16777215}};

const long bMap_RGB24_1[8][8]={{0,0,0,0,0,0,0,0},{65535,65535,0,0,0,16711935,16711935,16711935},{65535,0,65535,0,0,0,16711935,0},
{65535,0,65535,16776960,16776960,16776960,16711935,0},{65535,0,65535,16776960,0,16776960,16711935,0},
{65535,65535,0,16776960,16776960,16776960,16711935,0},{0,0,0,0,0,0,0,0},
{16777215,16777215,16777215,16777215,16777215,16777215,16777215,16777215}};


const long bMap_RGB24_2[8][8]={{0,0,255,255,255,255,255,0},{0,255,255,255,16777215,255,255,255},
{0,255,255,255,255,255,255,255},{0,0,16777215,0,16777215,0,16777215,0},
{0,16777215,16777215,16777215,16777215,16777215,16777215,16777215},
{0,0,16777215,16777215,0,16777215,16777215,0},{0,255,16711680,255,255,255,16711680,255},
{0,255,65535,16711680,16711680,16711680,65535,255}};

const long bMap_RGB24_3[8][8]={{0,0,65280,65280,65280,65280,65280,0},{0,65280,65280,65280,16777215,65280,65280,65280},
{0,65280,65280,65280,65280,65280,65280,65280},{0,0,16777215,0,16777215,0,16777215,0},
{0,16777215,16777215,16777215,16777215,16777215,16777215,16777215},{0,0,16777215,16777215,0,16777215,16777215,0},
{0,65280,16711680,65280,65280,65280,16711680,65280},{0,65280,65535,16711680,16711680,16711680,65535,65280}};

void setup() {

pinMode(PA8, OUTPUT);

// LED All Clear
allset(0,0,0);
show_Data();
delay(500);
}

// ************************************************************************************

void loop(){
byte bbr=0x4F; // Brightness // Basic Colors setting
// R, G, B, R+G, R+B, G+B, R+G+B
byte base_Color[7][3]={{bbr,0,0},{0,bbr,0},{0,0,bbr},
{bbr,bbr,0},{bbr,0,bbr},{0,bbr,bbr},{bbr,bbr,bbr}};

int waitms=3000;

allset (0,0,0); // Clear Display
show_Data();

for(int xp=8; xp > -17; xp--){ /* Title Roll Start */

for(int i=0; i< Y_max; i++){ // Show BitMap 0
for (int j=0; j< X_max; j++){
byte R=bMap_RGB24_0[i][j]%256/3;
byte G=(bMap_RGB24_0[i][j]/256)%256/3;
byte B=bMap_RGB24_0[i][j]/256/256/3;
p_set (j+xp,i,R,G,B);
}
}

for(int i=0; i< Y_max; i++){ // Show BitMap 1(x:+8)
for (int j=0; j< X_max; j++){
byte R=bMap_RGB24_1[i][j]%256/3;
byte G=(bMap_RGB24_1[i][j]/256)%256/3;
byte B=bMap_RGB24_1[i][j]/256/256/3;
p_set (j+xp+8,i,R,G,B);
}
}

for(int i=0; i< Y_max; i++){ // Show BitMap black(x:+16)
for (int j=0; j< X_max; j++){
p_set (j+xp+16,i,0,0,0);
}
}

show_Data();
delay(400);

} // Title Roll End


for (int k=0; k<2; k++){ /* Start Charactors */
for(int i=0; i< Y_max; i++){ // Show BitMap 2
for (int j=0; j< X_max; j++){
byte R=bMap_RGB24_2[i][j]%256/3;
byte G=(bMap_RGB24_2[i][j]/256)%256/3;
byte B=bMap_RGB24_2[i][j]/256/256/3;
p_set (j,i,R,G,B);
}
}
for (int bl=0; bl < 30; bl++){
p_set (4,5,0x4F,0,0x4F);
show_Data();
delay(50);
p_set (4,5,0,0,0);
show_Data();
delay(200);
}


for(int i=0; i< Y_max; i++){ // Show BitMap 3
for (int j=0; j< X_max; j++){
byte R=bMap_RGB24_3[i][j]%256/3;
byte G=(bMap_RGB24_3[i][j]/256)%256/3;
byte B=bMap_RGB24_3[i][j]/256/256/3;
p_set (j,i,R,G,B);
}
}
for (int bl=0; bl < 30; bl++){
p_set (4,5,0x4F,0x4F,0);
show_Data();
delay(50);
p_set (4,5,0,0,0);
show_Data();
delay(200);
}
}


for(int i=0; i< Y_max; i++){ /* Show Basic Colors */
for (int j=0; j< X_max; j++){
byte pc=(X_max*i+j)%7; // point color
p_set (j, i,base_Color[pc][0],base_Color[pc][1],base_Color[pc][2]);
show_Data();
delay(50);
}
}
delay(waitms);

} // loop End

// *************************************************************************************************


// bData, Make all LEDs the same color

void allset (byte r,byte g,byte b){
for(int i=0; i< X_max; i++){
for (int j=0; j< Y_max; j++){
bData[i][j][0]=r;
bData[i][j][1]=g;
bData[i][j][2]=b;
}
}
}


// bData, Make a LED the color

void p_set (int x, int y, byte r, byte g, byte b){
if (x>=0 && x< X_max && y>=0 && y< Y_max){
bData[x][y][0]=r;
bData[x][y][1]=g;
bData[x][y][2]=b;
}
}


// Show the data

void show_Data(){
bData_to_aData(); // Send data to Serial buffer
sendData(); // Serial output to LEDs
}

void bData_to_aData(){
for (int i=0; i< Led_max; i++){
int x,y;
y=i/X_max;
if (y % 2 > 0){
x=i % X_max;
}else{
x=X_max-(i % X_max)-1;
}
aData[i][0]=bData[x][y][0];
aData[i][1]=bData[x][y][1];
aData[i][2]=bData[x][y][2];
}
}


void sendData(){
noInterrupts();
for (byte numLed=0; numLed<Led_max; numLed++){ //led
for (byte rgbLed=0; rgbLed <3; rgbLed++){ // G-R-B
byte a=aData[numLed][c_order[rgbLed]]; // set 1byte
for (byte i=0; i<8; i++){ // loop bit:7---0
if ((a & 0x80) >0){ // *** if bit=1 ***
for (int i=0; i<3; i++){ // High_long
for (int j=0; j<8; j++){
digitalWriteFast(PA_8, HIGH);
}
}
for (int i=0; i<2; i++){ // Low_short
for (int j=0; j<8; j++){
digitalWriteFast(PA_8, LOW);
}
}
}else{ // *** if bit=0 ***
for (int i=0; i<2; i++){ // High_short
for (int j=0; j<8; j++){
digitalWriteFast(PA_8, HIGH);
}
}
for (int i=0; i<3; i++){
for (int j=0; j<8; j++){
digitalWriteFast(PA_8, LOW); // Low_long
}
}
}
a=a*2; // set bit7
} // next bit
} // next byte(G-R-B)
} // next LED
interrupts();
}