|
0.png (37.85 KB, 下載次數(shù): 35)
下載附件
2016-4-21 00:18 上傳
51單片機(jī)控制Nokia5110uv4工程
部分源碼預(yù)覽:
- #include "lcd.h"
- #include "font.h"
-
- /*--------------------------------------------------------------*/
- //寫(xiě)入一個(gè)字節(jié)(數(shù)據(jù)或指令)
- //wByte: 待寫(xiě)入的數(shù)據(jù)
- //datOrCmd: 1-數(shù)據(jù), 0-指令
- void writeByte(unsigned char wByte, unsigned char datOrCmd)
- {
- unsigned char i;
- CS = 0; //使能
- DC = datOrCmd; //1-數(shù)據(jù) //0-指令
- for(i = 8; i; i--) //8位數(shù)據(jù), 先高后低
- {
- if(wByte & 0x80) {
- DIN = 1;
- }
- else {
- DIN = 0;
- }
- CLK = 0;
- wByte <<= 1; //移位(延時(shí))
- CLK = 1; //上升沿寫(xiě)入
- }
- CS = 1; //禁止
- }
-
- void clear()//清屏
- {
- unsigned int i;
- writeCmd(0x80);
- writeCmd(0x40);
- for(i = 504; i; i--){
- writeDat(0x00);//將所有RAM寫(xiě)0
- }
- }
-
- //x: 0 - 83
- //y: 0 - 5
- void moveTo(unsigned char x, unsigned char y)//設(shè)置寫(xiě)數(shù)據(jù)位置
- {
- writeCmd(x|0x80);
- writeCmd(y|0x40);
- }
-
- //x:0~9
- //y:0~2
- void writeChar(unsigned char x, unsigned char y, unsigned char c) //寫(xiě)一個(gè)字符
- {
- unsigned char i, j;
- c -= 32;
- x <<= 3;
- y <<= 1;
- for(j = 0; j < 2; j++)
- {
- moveTo(x, (y + j));
- for(i = 0; i < 8; i++)
- writeDat(font[c][8 * j + i]);
- }
- }
-
- //x:0~9
- //y:0~2
- void writeString(unsigned char x, unsigned char y, unsigned char *str)//寫(xiě)一個(gè)字符串
- {
- while(*str && x < 10)
- {
- writeChar(x++, y, *str);
- str++;
- }
- }
-
- void LCDInit(void)
- {
- RST = 0;
- RST = 1;//硬件復(fù)位
-
- writeCmd(0x21); //工作模式, 水平尋址, 擴(kuò)展指令
- writeCmd(0x07); //VLCD溫度系數(shù),設(shè)置0x04~0x07,越小越黑
-
- writeCmd(0x13); //設(shè)置偏置系統(tǒng)(BSx) 1:48,設(shè)置為0x10~0x17
- writeCmd(128+25); //設(shè)置電壓VLCD = 3.06 + 0.06*Vop, 對(duì)比度調(diào)整,設(shè)置為0x80~0xff;128+(0~127)
-
- writeCmd(0x20); //工作模式, 水平尋址, 常規(guī)指令
- writeCmd(0x0c); //普通模式
- writeCmd(0x80); //起始頁(yè)地址0
- writeCmd(0x40); //起始列地址0
- clear(); //清全屏
- }
復(fù)制代碼
|
-
-
nokia 5110.zip
2016-4-20 20:57 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
30.54 KB, 下載次數(shù): 42, 下載積分: 黑幣 -5
工程
評(píng)分
-
查看全部評(píng)分
|