//********************************************************************** /*   <カラーコード表示> */ //********************************************************************** #define SW1 PORTA.F2 #define SW2 PORTA.F3 #define SW3 PORTA.F4 //********************************************************************** char *color_code[10] = {"クロ","チャ","アカ","ダイダイ","キ","ミドリ","アオ","ムラサキ","ハイ","シロ"}; char buf[32]; void colorCodeDisp(short i, short j, short k) { static short val; // buf[0] = 0x00; strcat(buf, color_code[i]); strcat(buf, ","); strcat(buf, color_code[j]); strcat(buf, ","); strcat(buf, color_code[k]); // if (strlen(buf) <= 16) { Lcd_Custom_Out(1, 1, buf); } else { Lcd_Custom_Out(2, 1, &buf[16]); buf[16] = 0x00; Lcd_Custom_Out(1, 1, buf); } // val = (i * 10) + j; ByteToStr(val, buf); // switch (k) { case 0: //黒色 Lcd_Custom_Out(2, 9, buf); Lcd_Custom_Chr(2, 12, 0xF4); //Ω break; case 1: //茶色 buf[4] = 0x00; buf[3] = '0'; Lcd_Custom_Out(2, 8, buf); Lcd_Custom_Chr(2, 12, 0xF4); //Ω break; case 2: //赤色 buf[4] = 0x00; buf[3] = buf[2]; buf[2] = '.'; Lcd_Custom_Out(2, 8, buf); Lcd_Custom_Chr(2, 12, 'K'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 3: //橙色 Lcd_Custom_Out(2, 9, buf); Lcd_Custom_Chr(2, 12, 'K'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 4: //黄色 buf[4] = 0x00; buf[3] = '0'; Lcd_Custom_Out(2, 8, buf); Lcd_Custom_Chr(2, 12, 'K'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 5: //緑色 buf[4] = 0x00; buf[3] = buf[2]; buf[2] = '.'; Lcd_Custom_Out(2, 8, buf); Lcd_Custom_Chr(2, 12, 'M'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 6: //青色 Lcd_Custom_Out(2, 9, buf); Lcd_Custom_Chr(2, 12, 'M'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 7: //紫色 buf[4] = 0x00; buf[3] = '0'; Lcd_Custom_Out(2, 8, buf); Lcd_Custom_Chr(2, 12, 'M'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 8: //灰色 buf[4] = 0x00; buf[3] = buf[2]; buf[2] = '.'; Lcd_Custom_Out(2, 8, buf); Lcd_Custom_Chr(2, 12, 'G'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; case 9: //白色 Lcd_Custom_Out(2, 9, buf); Lcd_Custom_Chr(2, 12, 'G'); Lcd_Custom_Chr(2, 13, 0xF4); //Ω break; } } //********************************************************************** void main() { static short cnt, i, j, k; // OSCCON = 0b01110000; // クロックを8Mhzに設定する。 ANSEL = 0b00000000; // A/D変換は使用しない。 //ポートの設定 TRISA = 0b11111111; TRISB = 0b11111111; // Lcd_Custom_Config(&PORTA,1,0,7,6,&PORTB,5,6,7); Lcd_Custom_Cmd(LCD_CURSOR_OFF); Lcd_Custom_Cmd(LCD_CLEAR); // i = 0; j = 0; k = 0; // colorCodeDisp(i, j, k); // while (1) { if (SW1 == 0) { while (Button(&PORTA, 2, 1, 1) == 0) ; // if (i < 9) i++; else i = 0; // Lcd_Custom_Cmd(LCD_CLEAR); colorCodeDisp(i, j, k); } if (SW2 == 0) { while (Button(&PORTA, 3, 1, 1) == 0) ; // if (j < 9) j++; else j = 0; // Lcd_Custom_Cmd(LCD_CLEAR); colorCodeDisp(i, j, k); } if (SW3 == 0) { while (Button(&PORTA, 4, 1, 1) == 0) ; // if (k < 9) k++; else k = 0; // Lcd_Custom_Cmd(LCD_CLEAR); colorCodeDisp(i, j, k); } } } //**********************************************************************