LEDMatrixDisplay Program 文字ごとに色を変更できるように修正
Fork of LEDMatrix_Master by
Revision 10:e261964e4989, committed 2014-03-28
- Comitter:
- nameless129
- Date:
- Fri Mar 28 15:33:29 2014 +0000
- Parent:
- 8:b24bd32cd2ed
- Commit message:
- ?????????????????
Changed in this revision
--- a/15x16fontsLib.cpp Sat Nov 16 06:27:26 2013 +0000
+++ b/15x16fontsLib.cpp Fri Mar 28 15:33:29 2014 +0000
@@ -126,3 +126,47 @@
c = *str;
}
}
+
+void drawStr15x16_AutoColer(char *str ,int pos_x)
+{
+ unsigned char f_SJISChar = 0;
+ unsigned char c = 0;
+ unsigned char c_color = 0;
+ unsigned int SJISChar = 0;
+ unsigned int CountChar = 0;
+ const unsigned char color_pattern[6] = {COLOR_R,COLOR_Y,COLOR_G,COLOR_C,COLOR_B,COLOR_M};
+
+ c = *str;
+ while(c != '\0')
+ {
+ //2バイト文字の判定
+ if( ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xfc)) && f_SJISChar != 1 )
+ {
+ SJISChar = c;
+ f_SJISChar = 1;
+ }
+ else if(f_SJISChar == 1)
+ {
+ SJISChar = (SJISChar<<8) | c;
+ f_SJISChar = 0;
+ read_font(SJISChar);
+ draw_kanji_15x16(pos_x-CountChar*8, color_pattern[c_color], 16);
+ CountChar+=2;
+ }
+ else //ASCII文字
+ {
+ SJISChar = c;
+ f_SJISChar = 0;
+ read_font(SJISChar);
+ draw_kanji_15x16(pos_x-CountChar*8, color_pattern[c_color], 8);
+ CountChar++;
+ }
+ str++;
+ c = *str;
+ c_color++;
+ if(c_color>=6)
+ {
+ c_color = 0;
+ }
+ }
+}
\ No newline at end of file
--- a/15x16fontsLib.h Sat Nov 16 06:27:26 2013 +0000 +++ b/15x16fontsLib.h Fri Mar 28 15:33:29 2014 +0000 @@ -2,5 +2,5 @@ #define __15X16FONTSLIB_H_ extern void drawStr15x16(char *str ,int pos_x,unsigned char color); - +extern void drawStr15x16_AutoColer(char *str ,int pos_x); #endif \ No newline at end of file
--- a/main.cpp Sat Nov 16 06:27:26 2013 +0000
+++ b/main.cpp Fri Mar 28 15:33:29 2014 +0000
@@ -15,7 +15,37 @@
unsigned int ImageBuf[3][DISPLAY_XSIZE];//16*6
unsigned int ColerMap[3][DISPLAY_XSIZE];
-unsigned int CountChar(char *str)
+unsigned int CountChar_full_W(char *str )
+{
+ unsigned char f_SJISChar = 0;
+ unsigned char c = 0;
+ unsigned int CountChar = 0;
+
+ c = *str;
+ while(c != '\0')
+ {
+ //2バイト文字の判定
+ if( ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xfc)) && f_SJISChar != 1 )
+ {
+ f_SJISChar = 1;
+ }
+ else if(f_SJISChar == 1)
+ {
+ CountChar++;
+ f_SJISChar = 0;
+ }
+ else
+ {
+ f_SJISChar = 0;
+ }
+
+ str++;
+ c = *str;
+ }
+ return CountChar;
+}
+
+unsigned int CountChar_half_W(char *str)
{
unsigned char f_SJISChar = 0;
unsigned char c = 0;
@@ -31,15 +61,20 @@
}
else
{
- f_SJISChar = 0;
- CountChar++;
+ if( f_SJISChar == 1)
+ {
+ f_SJISChar = 0;
+ }
+ else
+ {
+ CountChar++;
+ }
}
str++;
c = *str;
}
return CountChar;
}
-
void SPILineOut(unsigned char setLine)
{
unsigned int data[3]={0};
@@ -193,18 +228,10 @@
int main()
{
unsigned int i = 0;
- char tmpstr[100];
+ unsigned int s_Strs = 0;
- /*=====================*/
- /*ここを書き換えてください*/
- /*=====================*/
- //ET2013 ARMブース mbedコーナーにようこそ!
-
- char strs[100]={0x82,0x64,0x82,0x73,0x82,0x51,0x82,0x4f,0x82,0x50,0x82,0x52,0x81,0x40,0x82,0x60,
- 0x82,0x71,0x82,0x6c,0x83,0x75,0x81,0x5b,0x83,0x58,0x81,0x40,0x82,0x8d,0x82,0x82,
- 0x82,0x85,0x82,0x84,0x83,0x52,0x81,0x5b,0x83,0x69,0x81,0x5b,0x82,0xc9,0x82,0xe6,
- 0x82,0xa4,0x82,0xb1,0x82,0xbb,0x81,0x49,0x00};
-
+ char strs[100]={};
+ memset(strs,' ',sizeof(strs));
// Read text file for display message, if exist.
FILE *fp;
fp = fopen("/local/message.txt", "r");
@@ -215,11 +242,9 @@
free(fp);
#endif
}
-
spi.format(16,1);
spi.frequency(1000000);
- memset(tmpstr,0,sizeof(tmpstr));
memset(ImageBuf,0,sizeof(ImageBuf));
i=0;
@@ -230,11 +255,16 @@
while(1)
{
memset(ImageBuf,0,sizeof(ImageBuf));
-
- for(i=0; i<DISPLAY_XSIZE+(16*CountChar(strs)-1); i++)
+ s_Strs = CountChar_half_W(strs)*8;
+ s_Strs += CountChar_full_W(strs)*16;
+ for(i=0; i<DISPLAY_XSIZE+(s_Strs)-16; i++)
{
+#if 1
drawStr15x16(strs ,i, COLOR_W);
ApplyColerMap();
+#else
+ drawStr15x16_AutoColer(strs ,i);
+#endif
outBordData();
wait(0.05);
}
