ShigezoneフルカラーLEDパネルを使う(令和)
はじめに
Qiitaの記事「マトリクスLEDパネルの動作確認」( https://qiita.com/Yukiya_Ishioka/items/c455f7bfbcb240bb2ba7 )でESP32を使い、秋葉原の Shigezone で購入した64×64のマトリクスLEDパネルを使って「令和」画像を表示するプログラムを紹介しました。
Shigezoneから「フルカラーLEDパネル用ESP32制御ボードキット」という商品が発売されたのを見つけたのですが、先のQiitaの記事で使った回路とは違うため、記事内のプログラムそのものでは動作しないことが分かりました。
このため、「フルカラーLEDパネル用ESP32制御ボードキット」でそのまま使えるプログラムを公開しようと考えました。
なお、この記事の執筆時点では「フルカラーLEDパネル用ESP32制御ボードキット」を入手していないため、商品に添付されている説明書に記されているページにある回路図からピン設定を変更しています。
・フルカラーLEDパネル用ESP32制御ボードキット(基板+部品)
https://www.shigezone.com/product/hub75eboard/
・秋葉原ラジオデパートShigezone(シゲゾーン)
https://www.shigezone.com/
・Qiitaの記事「マトリクスLEDパネルの動作確認」
https://qiita.com/Yukiya_Ishioka/items/c455f7bfbcb240bb2ba7
・Qiitaの記事「ShigezoneフルカラーLEDパネルを使う(令和2)」
https://qiita.com/Yukiya_Ishioka/items/b26cd1eae5f5c37470d5
・ShigezoneフルカラーLEDパネルでRSS表示
https://qiita.com/Yukiya_Ishioka/items/33d27c350a3b4c677261
マイコンとマトリクスLEDパネルの接続
回路図からESP32DevKitとマトリクスLEDパネルとの接続は以下の設定になります。
#define R1PIN 25
#define G1PIN 26
#define B1PIN 27
#define R2PIN 21
#define G2PIN 22
#define B2PIN 23
#define APIN 12
#define BPIN 16
#define CPIN 17
#define DPIN 18
#define EPIN 4
#define CLKPIN 15
#define LATPIN 32
#define OEPIN 33
Arduino IDEの設定
ボード種別やOTAの有無により挙動が変わる可能性があるので、実行確認時のArduino IDEの設定内容を公開しておきます。
ESP32制御ボードキット対応プログラム
「令和」を題材に、あの画像 を元にビットマップデータを作り、プログラム内に組込み、表示するプログラムを紹介します。
/*
* Copyright(C) by Yukiya Ishioka
*/
#include <stdio.h>
#include <string.h>
/* ESP32 */
#define R1PIN 25
#define G1PIN 26
#define B1PIN 27
#define R2PIN 21
#define G2PIN 22
#define B2PIN 23
#define APIN 12
#define BPIN 16
#define CPIN 17
#define DPIN 18
#define EPIN 4
#define CLKPIN 15
#define LATPIN 32
#define OEPIN 33
#define DEF_DISP_WIDTH 128
#define DEF_SEL_LINE 32
int led_color;
const unsigned char mask_pattern[8] = {
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
};
const unsigned char char_dat_yoko[ 1024 ] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,
0xff,0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xfc,0xff,0xff,0xff,0xff,
0xff,0x81,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xf9,0xff,0xff,0xff,0xff,0xff,0x80,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf1,0xff,0xff,
0xff,0xff,0xff,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xe3,0xff,0xff,0xff,0xff,0xff,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc3,
0xff,0xff,0xff,0xff,0xff,0x00,0xfe,0x7f,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0x87,0xff,0xff,0xff,0xfd,
0xfe,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x0f,0xff,0xff,0xff,0xfb,0xfe,0x03,0xf8,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x1f,0xff,0xff,
0xff,0xf3,0xfe,0x07,0xf0,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xf8,0x3f,0xff,0xff,0xff,0xe3,0xfc,0x07,
0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x3f,
0xff,0xff,0xff,0xc3,0xfc,0x0f,0xc1,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xc0,0x7f,0xff,0xff,0xff,0xc7,
0xf8,0x0f,0x81,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x80,0xff,0xff,0xff,0xff,0x87,0xf8,0x1e,0x03,0xff,
0xff,0xff,0xff,0xff,0xff,0xfe,0x01,0xdf,0xff,0xff,
0xff,0x07,0xf8,0x18,0x07,0xff,0xff,0xff,0xff,0xff,
0xff,0xfc,0x03,0xc3,0xff,0xff,0xff,0x03,0xf0,0x00,
0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x0f,0xc1,
0xff,0xff,0xfe,0x03,0xf0,0x00,0x1f,0xff,0xff,0xff,
0xff,0xff,0xff,0xe0,0x1f,0xe0,0xff,0xff,0xf8,0x03,
0xf0,0x00,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0x80,
0x3f,0xe0,0x7f,0xff,0xf8,0x00,0x60,0x00,0xff,0xc3,
0x7f,0xff,0xff,0xff,0xfe,0x00,0xff,0xe0,0x7f,0xff,
0xf8,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xff,0xff,
0xf8,0x01,0xff,0xe0,0x7f,0xff,0xf8,0x06,0x00,0x00,
0x00,0x00,0x3f,0xff,0xff,0xf3,0xe0,0x00,0xff,0xc0,
0xff,0xff,0xf8,0x06,0x00,0x00,0x00,0x00,0x7f,0xff,
0xff,0xf0,0x00,0x18,0x3f,0xc0,0xff,0xcf,0xfc,0x0f,
0x00,0x40,0x04,0xff,0xff,0xff,0xff,0xf8,0x00,0x3c,
0x1f,0x81,0xff,0xc7,0xfc,0x0f,0x81,0xe0,0x7f,0xff,
0xff,0xff,0xff,0xf0,0x00,0xfc,0x0f,0x80,0x3f,0x81,
0xfe,0x1f,0x81,0xe0,0x7f,0xff,0xff,0xff,0xff,0xf0,
0x01,0xfc,0x0f,0x80,0x00,0x00,0xff,0x1f,0x81,0xf0,
0x7f,0xff,0xff,0xff,0xff,0xf8,0x03,0xfc,0x0f,0x04,
0x00,0x00,0xff,0xff,0x80,0xf8,0xff,0xff,0xff,0xff,
0xff,0xfc,0x03,0xfc,0x0f,0x06,0x00,0x03,0xff,0xff,
0xc0,0x1f,0xff,0xff,0xff,0xff,0xff,0xfe,0x01,0xfc,
0x0f,0x0f,0x39,0xff,0xff,0xff,0xf0,0x0f,0xff,0xff,
0xff,0xff,0xff,0xff,0xf0,0x7e,0x0e,0x0f,0xf8,0x3f,
0xff,0xff,0xfc,0x03,0xff,0xff,0xff,0xff,0xff,0xff,
0xf8,0x3f,0x1c,0x1f,0xe0,0x1f,0xff,0xff,0xfe,0x00,
0x3f,0xff,0xff,0xff,0xff,0xff,0xfc,0x0f,0xfc,0x1e,
0x00,0x1f,0xff,0xff,0xfe,0x00,0x03,0xff,0xff,0xff,
0xff,0xff,0xfe,0x07,0xf8,0x00,0x00,0x1f,0xff,0xff,
0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
0xf8,0x00,0x00,0x3f,0xff,0xff,0xf9,0x00,0x00,0xff,
0xff,0xff,0xff,0xff,0xff,0x80,0xf8,0x00,0x00,0xff,
0xff,0xff,0xf9,0x80,0x01,0xff,0xff,0xff,0xff,0xff,
0xff,0xc0,0x38,0x00,0x03,0xff,0xff,0xff,0xf8,0xf0,
0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x0c,0x00,
0x1f,0xff,0xff,0xff,0xf8,0x7f,0x87,0xff,0xff,0xff,
0xff,0xff,0xff,0xf0,0x06,0x01,0xff,0xff,0xff,0xff,
0xf8,0xff,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,
0x00,0x0f,0xff,0xff,0xff,0xff,0xf1,0xff,0x03,0xff,
0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x1f,0xff,0xff,
0xff,0xff,0xf1,0xff,0x03,0xff,0xff,0xff,0xff,0xff,
0xff,0xfe,0x00,0x3f,0xff,0xff,0xff,0xff,0xf1,0xff,
0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x1f,
0xff,0xff,0xff,0xff,0xf1,0xff,0x03,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xc0,0x0f,0xff,0xff,0xff,0xff,
0xf3,0xff,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xe0,0x07,0xff,0xff,0xff,0xff,0xe3,0xfe,0x07,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x03,0xff,0xff,
0xff,0xff,0xe0,0x00,0x07,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xf0,0x01,0xff,0xff,0xff,0xff,0xc0,0x00,
0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x01,
0xff,0xff,0xff,0xff,0x80,0x00,0x07,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xfc,0x00,0xff,0xff,0xff,0xff,
0x80,0x00,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xfc,0x00,0xff,0xff,0xff,0xff,0x80,0x00,0x07,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0xff,0xff,
0xff,0xff,0xc0,0x00,0x07,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xfe,0x00,0xff,0xff,0xff,0xff,0xe0,0x00,
0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x00,
0xff,0xff,0xff,0xff,0xe0,0x1f,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0x00,0x7f,0xff,0xff,0xff,
0xf0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x00,0x7f,0xff,0xff,0xff,0xf8,0x7f,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf1,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
} ;
void led_addr_wr( int a, int b, int c, int d, int e )
{
digitalWrite( OEPIN, HIGH );
usleep(3);
digitalWrite( APIN, a );
digitalWrite( BPIN, b );
digitalWrite( CPIN, c );
digitalWrite( DPIN, d );
digitalWrite( EPIN, e );
usleep(3);
digitalWrite( LATPIN, HIGH );
digitalWrite( LATPIN, LOW );
digitalWrite( OEPIN, LOW );
}
void matled_line_clear( void )
{
int col;
for( col=0 ; col<DEF_DISP_WIDTH ; col++ ) {
digitalWrite( R1PIN, LOW );
digitalWrite( G1PIN, LOW );
digitalWrite( B1PIN, LOW );
digitalWrite( R2PIN, LOW );
digitalWrite( G2PIN, LOW );
digitalWrite( B2PIN, LOW );
digitalWrite( CLKPIN, HIGH );
digitalWrite( CLKPIN, LOW );
}
led_addr_wr( 0, 0, 0, 0, 0 );
}
void setup( void )
{
/* init serial */
Serial.begin(115200);
Serial.println( "call setup()" );
pinMode( R1PIN, OUTPUT );
pinMode( G1PIN, OUTPUT );
pinMode( B1PIN, OUTPUT );
pinMode( R2PIN, OUTPUT );
pinMode( G2PIN, OUTPUT );
pinMode( B2PIN, OUTPUT );
pinMode( APIN, OUTPUT );
pinMode( BPIN, OUTPUT );
pinMode( CPIN, OUTPUT );
pinMode( DPIN, OUTPUT );
pinMode( EPIN, OUTPUT );
pinMode( CLKPIN, OUTPUT );
pinMode( LATPIN, OUTPUT );
pinMode( OEPIN, OUTPUT );
digitalWrite( CLKPIN, LOW );
digitalWrite( LATPIN, LOW );
digitalWrite( OEPIN, LOW );
/* dummy address set */
led_addr_wr( LOW, LOW, LOW, LOW, LOW );
/* clear MATLED */
matled_line_clear();
led_color = 1;
}
void loop( void )
{
int a, b, c, d, e;
int dr, dg, db;
int row, col;
int i, j;
unsigned char *buff1;
dr = 0;
dg = 0;
db = 0;
if( led_color & 0x1 ) dr = 1;
if( led_color & 0x2 ) db = 1;
if( led_color & 0x4 ) dg = 1;
Serial.printf( "color DR=%d DG=%d DB=%d\n", dr, dg, db );
buff1 = (unsigned char *)char_dat_yoko ;
j = 0;
while( 1 ) {
for( i=0 ; i<DEF_SEL_LINE ; i++ ) {
row = (DEF_DISP_WIDTH / 8) * (DEF_SEL_LINE -1 - i);
for( col=0 ; col<DEF_DISP_WIDTH ; col++ ) {
/* R1 G1 B1 */
//if( (j % 3) == 0 && (buff1[ (DEF_DISP_WIDTH / 8) * DEF_SEL_LINE + row + (col >> 3) ] & mask_pattern[ col & 0x07 ]) != 0 ) {
if( (buff1[ (DEF_DISP_WIDTH / 8) * DEF_SEL_LINE + row + (col >> 3) ] & mask_pattern[ col & 0x07 ]) != 0 ) { digitalWrite( R1PIN, dr );
digitalWrite( G1PIN, dg );
digitalWrite( B1PIN, db );
} else {
digitalWrite( R1PIN, LOW );
digitalWrite( G1PIN, LOW );
digitalWrite( B1PIN, LOW );
}
/* R2 G2 B2 */
//if( (j % 3) == 0 && (buff1[ row + (col >> 3) ] & mask_pattern[ col & 0x07 ]) != 00 ) {
if( (buff1[ row + (col >> 3) ] & mask_pattern[ col & 0x07 ]) != 0 ) {
digitalWrite( R2PIN, dr );
digitalWrite( G2PIN, dg );
digitalWrite( B2PIN, db );
} else {
digitalWrite( R2PIN, LOW );
digitalWrite( G2PIN, LOW );
digitalWrite( B2PIN, LOW );
}
digitalWrite( CLKPIN, HIGH );
digitalWrite( CLKPIN, LOW );
}
/* set access row position */
a = b = c = d = e = 0;
if( i & 0x01 ) a = 1;
if( i & 0x02 ) b = 1;
if( i & 0x04 ) c = 1;
if( i & 0x08 ) d = 1;
if( i & 0x10 ) e = 1;
led_addr_wr( a, b, c, d, e );
}
j++;
}
/* clear MATLED */
matled_line_clear();
led_color++;
}
さいごに
表示につかったデータは64x64パネルを2枚使って「令和」を表示するプログラムになっているため、パネル1枚を使った場合には2文字目の「和」が表示されます。
「令」を表示する場合にはソースファイルの231行目付近の以下の行の「col<DEF_DISP_WIDTH」を「col<DEF_DISP_WIDTH/2」へ変更することで表示を変えられます。
for( col=0 ; col<DEF_DISP_WIDTH ; col++ ) {
↓
for( col=0 ; col<DEF_DISP_WIDTH/2 ; col++ ) {
データやプログラムを変更して色々な画像など表示にトライしてみてください。
-以上-
Author And Source
この問題について(ShigezoneフルカラーLEDパネルを使う(令和)), 我々は、より多くの情報をここで見つけました https://qiita.com/Yukiya_Ishioka/items/9984a42072edc950b4a4著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .