Thông báo

Collapse
No announcement yet.

Giúp đỡ về khai báo Font trong keilC

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • Giúp đỡ về khai báo Font trong keilC

    mình có đoạn code như sau
    #include <REGX52.H>
    #include <string.h>

    //******************BANG MA ASCII on LED matrix font 5x7 ****************

    unsigned char code code_Tab[97][6]={
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//SPACE 0
    0xFF,0xFF,0xA0,0xFF,0xFF,0xFF,//! 1
    0xFF,0xFF,0xF8,0xF4,0xFF,0xFF,//' 2
    0xEB,0x80,0xEB,0x80,0xEB,0xFF,//# 3
    0xDB,0xD5,0x80,0xD5,0xED,0xFF,//$ 4
    0xD8,0xEA,0x94,0xAB,0x8D,0xFF,//% 5
    0xC9,0xB6,0xA9,0xDF,0xAF,0xFF,//& 6
    0xFF,0xFF,0xF8,0xF4,0xFF,0xFF,//' 7
    0xFF,0xE3,0xDD,0xBE,0xFF,0xFF,//( 8
    0xFF,0xBE,0xDD,0xE3,0xFF,0xFF,//) 9
    0xD5,0xE3,0x80,0xE3,0xD5,0xFF,//* 10
    0xF7,0xF7,0xC1,0xF7,0xF7,0xFF,//+ 11
    0xFF,0xA7,0xC7,0xFF,0xFF,0xFF,//, 12
    0xF7,0xF7,0xF7,0xF7,0xF7,0xFF,//- 13
    0xFF,0x9F,0x9F,0xFF,0xFF,0xFF,//x 14
    0xFF,0xC9,0xC9,0xFF,0xFF,0xFF,// / 15
    0xC1,0xAE,0xB6,0xBA,0xC1,0xFF,//0 16
    0xFF,0xBD,0x80,0xBF,0xFF,0xFF,//1 17
    0x8D,0xB6,0xB6,0xB6,0xB9,0xFF,//2 18
    0xDD,0xBE,0xB6,0xB6,0xC9,0xFF,//3 19
    0xE7,0xEB,0xED,0x80,0xEF,0xFF,//4 20
    0xD8,0xBA,0xBA,0xBA,0xC6,0xFF,//5 21
    0xC3,0xB5,0xB6,0xB6,0xCF,0xFF,//6 22
    0xFE,0x8E,0xF6,0xFA,0xFC,0xFF,//7 23
    0xC9,0xB6,0xB6,0xB6,0xC9,0xFF,//8 24
    0xF9,0xB6,0xB6,0xD6,0xE1,0xFF,//9 25
    0xFF,0xC9,0xC9,0xFF,0xFF,0xFF,//: 26
    0xFF,0xA4,0xC4,0xFF,0xFF,0xFF,//// 27
    0xF7,0xEB,0xDD,0xBE,0xFF,0xFF,//< 28
    0xEB,0xEB,0xEB,0xEB,0xEB,0xFF,//= 29
    0xFF,0xBE,0xDD,0xEB,0xF7,0xFF,//> 30
    0xFD,0xFE,0xAE,0xF6,0xF9,0xFF,//? 31
    0xCD,0xB6,0x8E,0xBE,0xC1,0xFF,//@ 32
    0x83,0xF5,0xF6,0xF5,0x83,0xFF,//A 33
    0xBE,0x80,0xB6,0xB6,0xC9,0xFF,//B 34
    0xC1,0xBE,0xBE,0xBE,0xDD,0xFF,//C 35
    0xBE,0x80,0xBE,0xBE,0xC1,0xFF,//D 36
    0x80,0xB6,0xB6,0xB6,0xBE,0xFF,//E 37
    0x80,0xF6,0xF6,0xFE,0xFE,0xFF,//F 38
    0xC1,0xBE,0xB6,0xB6,0xC5,0xFF,//G 39
    0x80,0xF7,0xF7,0xF7,0x80,0xFF,//H 40
    0xFF,0xBE,0x80,0xBE,0xFF,0xFF,//I 41
    0xDF,0xBF,0xBE,0xC0,0xFE,0xFF,//J 42
    0x80,0xF7,0xEB,0xDD,0xBE,0xFF,//K 43
    0x80,0xBF,0xBF,0xBF,0xFF,0xFF,//L 44
    0x80,0xFD,0xF3,0xFD,0x80,0xFF,//M 45
    0x80,0xFD,0xFB,0xF7,0x80,0xFF,//N 46
    0xC1,0xBE,0xBE,0xBE,0xC1,0xFF,//O 47
    0x80,0xF6,0xF6,0xF6,0xF9,0xFF,//P 48
    0xC1,0xBE,0xAE,0xDE,0xA1,0xFF,//Q 49
    0x80,0xF6,0xE6,0xD6,0xB9,0xFF,//R 50
    0xD9,0xB6,0xB6,0xB6,0xCD,0xFF,//S 51
    0xFE,0xFE,0x80,0xFE,0xFE,0xFF,//T 52
    0xC0,0xBF,0xBF,0xBF,0xC0,0xFF,//U 53
    0xE0,0xDF,0xBF,0xDF,0xE0,0xFF,//V 54
    0xC0,0xBF,0xCF,0xBF,0xC0,0xFF,//W 55
    0x9C,0xEB,0xF7,0xEB,0x9C,0xFF,//X 56
    0xFC,0xFB,0x87,0xFB,0xFC,0xFF,//Y 57
    0x9E,0xAE,0xB6,0xBA,0xBC,0xFF,//Z 58
    0xFF,0x80,0xBE,0xBE,0xFF,0xFF,//[ 59
    0xFD,0xFB,0xF7,0xEF,0xDF,0xFF,//\ 60
    0xFF,0xBE,0xBE,0x80,0xFF,0xFF,//] 61
    0xFB,0xFD,0xFE,0xFD,0xFB,0xFF,//^ 92
    0x7F,0x7F,0x7F,0x7F,0x7F,0xFF,//_ 63
    0xFF,0xFF,0xF8,0xF4,0xFF,0xFF,//' 64
    0xDF,0xAB,0xAB,0xAB,0xC7,0xFF,//a 65
    0x80,0xC7,0xBB,0xBB,0xC7,0xFF,//b 66
    0xFF,0xC7,0xBB,0xBB,0xBB,0xFF,//c 67
    0xC7,0xBB,0xBB,0xC7,0x80,0xFF,//d 68
    0xC7,0xAB,0xAB,0xAB,0xF7,0xFF,//e 69
    0xF7,0x81,0xF6,0xF6,0xFD,0xFF,//f 70
    0xF7,0xAB,0xAB,0xAB,0xC3,0xFF,//g 71
    0x80,0xF7,0xFB,0xFB,0x87,0xFF,//h 72
    0xFF,0xBB,0x82,0xBF,0xFF,0xFF,//i 73
    0xDF,0xBF,0xBB,0xC2,0xFF,0xFF,//j 74
    0xFF,0x80,0xEF,0xD7,0xBB,0xFF,//k 75
    0xFF,0xBE,0x80,0xBF,0xFF,0xFF,//l 76
    0x83,0xFB,0x87,0xFB,0x87,0xFF,//m 77
    0x83,0xF7,0xFB,0xFB,0x87,0xFF,//n 78
    0xC7,0xBB,0xBB,0xBB,0xC7,0xFF,//o 79
    0x83,0xEB,0xEB,0xEB,0xF7,0xFF,//p 80
    0xF7,0xEB,0xEB,0xEB,0x83,0xFF,//q 81
    0x83,0xF7,0xFB,0xFB,0xF7,0xFF,//r 82
    0xB7,0xAB,0xAB,0xAB,0xDB,0xFF,//s 83
    0xFF,0xFB,0xC0,0xBB,0xBB,0xFF,//t 84
    0xC3,0xBF,0xBF,0xDF,0x83,0xFF,//u 85
    0xE3,0xDF,0xBF,0xDF,0xE3,0xFF,//v 86
    0xC3,0xBF,0xCF,0xBF,0xC3,0xFF,//w 87
    0xBB,0xD7,0xEF,0xD7,0xBB,0xFF,//x 88
    0xF3,0xAF,0xAF,0xAF,0xC3,0xFF,//y 89
    0xBB,0x9B,0xAB,0xB3,0xBB,0xFF,//z 90
    0xFB,0xE1,0xE0,0xE1,0xFB,0xFF,//^ 62
    0xE3,0xE3,0xC1,0xE3,0xF7,0xFF,//-> 93
    0xF7,0xE3,0xC1,0xE3,0xE3,0xFF,//<- 94
    0xEF,0xC3,0x83,0xC3,0xEF,0xFF,// 95
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//BLANK CHAR 96
    };
    sbit SDA = P2^0;
    sbit SCL = P2^1;
    sbit STR = P2^2;

    sfr DataPort = 0x90;
    //-------------------------------------------
    //-------------------------------------------

    unsigned char *String_input ="ngay moi tot lanh van su nhu y ";
    // thay doi chu chay bat ky o day !!
    unsigned int Pos=0,lengh_STR;
    unsigned char Tic=0;
    #define With_of_font 6
    void main (){
    unsigned char Temp_code;
    unsigned int j;
    TMOD=0x01;
    TH0=TL0=-65543;
    TR0=1;
    ET0=1;
    lengh_STR = strlen(String_input)*6;
    EA=1;
    while(1){

    SDA=1;
    for(j=Pos;j<45+Pos;j++){
    Temp_code=code_Tab[ String_input [(j%lengh_STR)/With_of_font] -32] [j%With_of_font];
    DataPort=0xFF;
    SCL=1;
    SCL=0;
    STR=1;
    STR=0;
    DataPort = Temp_code;
    SDA=0;


    }
    }
    }

    void inter() interrupt 1
    { Tic++;
    if(Tic==2){
    Tic=0;
    Pos++;
    if(Pos>=lengh_STR)
    Pos=0;
    } }



    các bác cho hỏi là unsigned char code code_Tab[97][6]
    là khai báo ra sao vậy vì thường mình thấy khai báo mảng phía sau tên mảng là [xx] còn ở đây là [xx] [yy].?????
    và 1 cái nũa là khai báo
    unsigned char *String_input ="ngay moi tot lanh van su nhu y ";
    *string_input là cấu trúc khai báo tên đại diện của 1 chuỗi ký tự ha?(có *phía trước nữa -lạ quá???)

    vậy muốn tạo font tiếng việt thì mình phải khai báo như thế nào để trình keilC hiều???/ mong các bác giải đáp giúp e

  • #2
    vậy làm sao khi mình gõ 1 đoạn text mà nó có thể tham chiếu tới giá trị của ký tự mà mình khai báo vậy,phải chăng căn cứ theo bảng mã ascii với "space"là vị trí thứ 0 thì nó sẽ tham chiếu tới vị trí số 0 mà mình đã khai báo ở trên ,đúng k các bác?

    Comment


    • #3
      chính xác , dó là cách của Code tren.

      Comment


      • #4
        Temp_code=code_Tab[ String_input [(j%lengh_STR)/With_of_font] -32] [j%With_of_font];
        àh giờ thì e đã hiểu giá trị 32 đoạn code này lấy đâu ra rồi thanks bác @canhcongphal

        Comment


        • #5
          một cái mảng dài quá vđk sẽ ko dịch đc hết mảng , và mình ko biết 1 mảng trong keil chứa đc bao nhiêu kí tự nữa

          Comment


          • #6
            Đang tập tành làm robot dò line.Làm xong cả r nhưng đang đau đầu vs đoạn code.Các bác có code thì post lên cho ae tham khảo vs nha.

            Comment


            • #7
              cho em hỏi chút.chương trtinhf của em thế này.
              #include <REGX52.H>
              unsigned char code mang[96][5]=
              {
              {0x00, 0x00, 0x00, 0x00, 0x00},// (space)
              {0x00, 0x00, 0x5F, 0x00, 0x00},// !
              {0x00, 0x07, 0x00, 0x07, 0x00},// "
              {0x14, 0x7F, 0x14, 0x7F, 0x14},// #
              {0x24, 0x2A, 0x7F, 0x2A, 0x12},// $
              {0x23, 0x13, 0x08, 0x64, 0x62},// %
              {0x36, 0x49, 0x55, 0x22, 0x50},// &
              {0x00, 0x05, 0x03, 0x00, 0x00},// '
              {0x00, 0x1C, 0x22, 0x41, 0x00},// (
              {0x00, 0x41, 0x22, 0x1C, 0x00},// )
              {0x08, 0x2A, 0x1C, 0x2A, 0x08},// *
              {0x08, 0x08, 0x3E, 0x08, 0x08},// +
              {0x00, 0x50, 0x30, 0x00, 0x00},// ,
              {0x08, 0x08, 0x08, 0x08, 0x08},// -
              {0x00, 0x30, 0x30, 0x00, 0x00},// .
              {0x20, 0x10, 0x08, 0x04, 0x02},// /
              {0x3E, 0x51, 0x49, 0x45, 0x3E},// 0
              {0x00, 0x42, 0x7F, 0x40, 0x00},// 1
              {0x42, 0x61, 0x51, 0x49, 0x46},// 2
              {0x21, 0x41, 0x45, 0x4B, 0x31},// 3
              {0x18, 0x14, 0x12, 0x7F, 0x10},// 4
              {0x27, 0x45, 0x45, 0x45, 0x39},// 5
              {0x3C, 0x4A, 0x49, 0x49, 0x30},// 6
              {0x01, 0x71, 0x09, 0x05, 0x03},// 7
              {0x36, 0x49, 0x49, 0x49, 0x36},// 8
              {0x06, 0x49, 0x49, 0x29, 0x1E},// 9
              {0x00, 0x36, 0x36, 0x00, 0x00},// :
              {0x00, 0x56, 0x36, 0x00, 0x00},// ;
              {0x00, 0x08, 0x14, 0x22, 0x41},// <
              {0x14, 0x14, 0x14, 0x14, 0x14},// =
              {0x41, 0x22, 0x14, 0x08, 0x00},// >
              {0x02, 0x01, 0x51, 0x09, 0x06},// ?
              {0x32, 0x49, 0x79, 0x41, 0x3E},// @
              {0x7E, 0x11, 0x11, 0x11, 0x7E},// A
              {0x7F, 0x49, 0x49, 0x49, 0x36},// B
              {0x3E, 0x41, 0x41, 0x41, 0x22},// C
              {0x7F, 0x41, 0x41, 0x22, 0x1C},// D
              {0x7F, 0x49, 0x49, 0x49, 0x41},// E
              {0x7F, 0x09, 0x09, 0x01, 0x01},// F
              {0x3E, 0x41, 0x41, 0x51, 0x32},// G
              {0x7F, 0x08, 0x08, 0x08, 0x7F},// H
              {0x00, 0x41, 0x7F, 0x41, 0x00},// I
              {0x20, 0x40, 0x41, 0x3F, 0x01},// J
              {0x7F, 0x08, 0x14, 0x22, 0x41},// K
              {0x7F, 0x40, 0x40, 0x40, 0x40},// L
              {0x7F, 0x02, 0x04, 0x02, 0x7F},// M
              {0x7F, 0x04, 0x08, 0x10, 0x7F},// N
              {0x3E, 0x41, 0x41, 0x41, 0x3E},// O
              {0x7F, 0x09, 0x09, 0x09, 0x06},// P
              {0x3E, 0x41, 0x51, 0x21, 0x5E},// Q
              {0x7F, 0x09, 0x19, 0x29, 0x46},// R
              {0x46, 0x49, 0x49, 0x49, 0x31},// S
              {0x01, 0x01, 0x7F, 0x01, 0x01},// T
              {0x3F, 0x40, 0x40, 0x40, 0x3F},// U
              {0x1F, 0x20, 0x40, 0x20, 0x1F},// V
              {0x7F, 0x20, 0x18, 0x20, 0x7F},// W
              {0x63, 0x14, 0x08, 0x14, 0x63},// X
              {0x03, 0x04, 0x78, 0x04, 0x03},// Y
              {0x61, 0x51, 0x49, 0x45, 0x43},// Z
              {0x00, 0x00, 0x7F, 0x41, 0x41},// [
              {0x02, 0x04, 0x08, 0x10, 0x20},// "\"
              {0x41, 0x41, 0x7F, 0x00, 0x00},// ]
              {0x04, 0x02, 0x01, 0x02, 0x04},// ^
              {0x40, 0x40, 0x40, 0x40, 0x40},// _
              {0x00, 0x01, 0x02, 0x04, 0x00},// `
              {0x20, 0x54, 0x54, 0x54, 0x78},// a
              {0x7F, 0x48, 0x44, 0x44, 0x38},// b
              {0x38, 0x44, 0x44, 0x44, 0x20},// c
              {0x38, 0x44, 0x44, 0x48, 0x7F},// d
              {0x38, 0x54, 0x54, 0x54, 0x18},// e
              {0x08, 0x7E, 0x09, 0x01, 0x02},// f
              {0x08, 0x14, 0x54, 0x54, 0x3C},// g
              {0x7F, 0x08, 0x04, 0x04, 0x78},// h
              {0x00, 0x44, 0x7D, 0x40, 0x00},// i
              {0x20, 0x40, 0x44, 0x3D, 0x00},// j
              {0x00, 0x7F, 0x10, 0x28, 0x44},// k
              {0x00, 0x41, 0x7F, 0x40, 0x00},// l
              {0x7C, 0x04, 0x18, 0x04, 0x78},// m
              {0x7C, 0x08, 0x04, 0x04, 0x78},// n
              {0x38, 0x44, 0x44, 0x44, 0x38},// o
              {0x7C, 0x14, 0x14, 0x14, 0x08},// p
              {0x08, 0x14, 0x14, 0x18, 0x7C},// q
              {0x7C, 0x08, 0x04, 0x04, 0x08},// r
              {0x48, 0x54, 0x54, 0x54, 0x20},// s
              {0x04, 0x3F, 0x44, 0x40, 0x20},// t
              {0x3C, 0x40, 0x40, 0x20, 0x7C},// u
              {0x1C, 0x20, 0x40, 0x20, 0x1C},// v
              {0x3C, 0x40, 0x30, 0x40, 0x3C},// w
              {0x44, 0x28, 0x10, 0x28, 0x44},// x
              {0x0C, 0x50, 0x50, 0x50, 0x3C},// y
              {0x44, 0x64, 0x54, 0x4C, 0x44},// z
              {0x00, 0x08, 0x36, 0x41, 0x00},// {
              {0x00, 0x00, 0x7F, 0x00, 0x00},// |
              {0x00, 0x41, 0x36, 0x08, 0x00},// }
              {0x08, 0x08, 0x2A, 0x1C, 0x08},// ->
              {0x08, 0x1C, 0x2A, 0x08, 0x08}, // <-
              };
              unsigned char code ma1[]={5, 0, 0, 0, 0, 2, 12, 24, 96, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 112, 24, 6, 10, 48, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 0, 0, 0, 5,5, 0, 0, 0, 0, 0, 0, 0, 0, 1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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 119, 251, 7, 127, 135, 123, 123, 123, 135, 255, 135, 123, 123, 179, 255, 151, 107, 107, 7, 123, 243, 203, 63, 207, 243, 251, 127, 3, 119, 251, 251, 127, 255, 135, 123, 123, 179, 255, 135, 123, 123, 123, 135, 255, 123, 3, 119, 251, 7, 119, 251, 7, 127, 255, 255, 255, 255, 255};
              sbit EN =P3^0;
              sbit RW =P3^1;
              sbit DS =P3^2;
              sbit CS1= P3^3;
              sbit CS2 =P3^4;
              sbit BY =P2^7;
              void delay(long d)
              {
              long f;
              for(f=0;f<d;f++);
              }
              void tre(void)
              {
              unsigned char n;
              for(n=0;n<5;n++);
              }
              void chonchip(char a)
              {
              if(a==0) {CS1=1;CS2=0;}
              else {CS1=0;CS2=1;}
              tre();
              }
              void cho(void)
              {
              P2=0;
              DS=0;
              RW=1;
              EN=1;
              tre();
              EN=0;
              while(BY==1){EN=1;tre();EN=0;}
              }
              void set(char on)
              {
              cho();
              RW=0;
              DS=0;
              P2=(0x3E+on);
              EN=1;
              tre();
              EN=0;
              }
              void cot(unsigned char socot)
              {
              cho();
              RW=DS=0;
              P2=(0x40+socot);
              EN=1;
              tre();
              EN=0;
              }
              void hang(unsigned char sohang)
              {
              cho();
              RW=DS=0;
              P2=(0xB8+sohang);
              EN=1;
              tre();
              EN=0;
              }
              void cuon(unsigned char hangcuon)
              {
              cho();
              RW=DS=0;
              P2=(0xC0+hangcuon);
              EN=1;
              tre();
              EN=0;
              }
              void init(void)
              {
              chonchip(0);
              set(1);
              cot(0);
              hang(0);
              cuon(0);
              chonchip(1);
              set(1);
              cot(0);
              hang(0);
              cuon(0);
              }
              void gotoxy(unsigned char x,unsigned char y)
              {
              if(y<64) {chonchip(0);
              cot(y);
              hang(x);
              }
              if(y>63){chonchip(1);
              cot(y-64);
              hang(x);
              }
              }
              void viet(unsigned char chu)
              {
              cho();
              DS=1;
              RW=0;
              P2=chu;
              EN=1;
              tre();
              EN=0;
              tre();
              }
              void xoa(void)
              {
              unsigned char cot,hang;
              for(hang=0;hang<8;hang++)
              {
              gotoxy(hang,0);
              for(cot=0;cot<64;cot++)
              {viet(0);}
              }
              for(hang=0;hang<8;hang++)
              {
              gotoxy(hang,64);
              for(cot=64;cot<128;cot++)
              {viet(0);}
              }
              }
              void vietchuoi(unsigned char r)
              {
              unsigned char g;
              for(g=0;g<5;g++)
              {
              viet(mang[r-32][g]);
              }
              }
              void ve(unsigned char *j)
              {
              unsigned long n,v,b,m;
              for(v=0;v<8;v++)
              {
              gotoxy(v,0);
              for(b=0;b<64;b++)
              {
              m=v*128+b;
              viet(j[m]);
              }
              gotoxy(v,64);
              for(n=64;n<128;n++)
              {
              m=v*128+n;
              viet(j[m]);
              }
              }
              }
              void main()
              {
              init();
              xoa();
              while(1)
              {
              gotoxy(2,66);
              viet(0x55);delay(40000);
              xoa();
              ve(ma1);delay(50000);
              xoa();delay(3000);
              ve(ma2);delay(50000);
              xoa();delay(3000);
              gotoxy(4,6);
              vietchuoi("d");delay(50000);
              xoa();delay(30000);
              }
              }

              em không viết được chữ d còn vẫn đưa được ma1 .chương trình của em sai ở đâu ạ và phải sửa thế nào.
              em viết cho GLCD 128x64(LMG12641BS1R)

              Comment

              Về tác giả

              Collapse

              truongloi Tìm hiểu thêm về truongloi

              Bài viết mới nhất

              Collapse

              Đang tải...
              X