#include "Glcd.h"
Glcd::Glcd()
{
//ctor
GLCD = new Serial(p9, p10); // tx, rx
// GLCD->baud(19200);
GLCD->baud(38400);
do {
GLCD->putc(0xa5);
}while(GLCD->getc()!=0xa5);
clearAll();
}
Glcd::Glcd(PinName tx, PinName rx)
{
GLCD = new Serial(tx, rx); // tx, rx
GLCD->baud(38400);
do {
GLCD->putc(0xa5);
}while(GLCD->getc()!=0xa5);
clearAll();
}
void Glcd::draw(int x, int y, unsigned char dt[], int n)
{
GLCD->putc(0x08); // start
GLCD->putc(y); // page
GLCD->putc(x); // col
GLCD->putc(n); // # of byte
for(int i=0; i<n; i++)
GLCD->putc(dt[i]);
GLCD->getc();
}
void Glcd::clear(int x, int y, int n)
{
GLCD->putc(0x08); // start
GLCD->putc(y); // page
GLCD->putc(x); // col
GLCD->putc(n); // # of byte
for(int i=0; i<n; i++)
GLCD->putc(0);
GLCD->getc();
}
void Glcd::drawChar(int x, int y, unsigned char ch)
{
GLCD->putc(0x02); // char
GLCD->putc(y); // page
GLCD->putc(x); // col
GLCD->putc(ch);
GLCD->getc();
}
void Glcd::print(int x, int y, char *str)
{
int n = strlen(str);
for(int i=0; i<n; i++){
drawChar(x+i*5, y, (unsigned char)str[i]);
}
}
void Glcd::clearAll()
{
GLCD->putc(1);
GLCD->getc();
}
|
1
2
3
4
5
6 デフォールトは9600bps
7 19200bpsに変更する場合
8 38400bpsに変更する場合
9 これを超えるスピードはうまくいかない
10 PICと同期させるためのマジックナンバー
11 同期すると同様のマジックナンバーが送り返される
12 画面クリアする
13
14
15
16
17
18
19
20
21
22
23
24 n×8ドットのグラフィックデータを送る
25
26 転送開始コマンド
27 ページ番号
28 カラム番号
29 データ転送バイト数
30
31
32 終了を返す
33
34
35
36
37
38
39
40
41
42 データはゼロを送る
43
44
45
46 文字を表示させる
47
48 文字表示コマンド
49 ページ
50 カラム
51 文字データ
52 終了を返す
53
54
55 文字列の表示
56
57
58
59
60
61
62
63 全画面クリア
64
65 クリアコマンドを送る
66
|