简略的打点。至于屏幕右下角呈现的那几条线,可能是proteus的BUG
程序如下
#include
#include “stdio.h”
#define uchar unsigned char
#define uint unsigned int
#define CLR_CS PORTD&=~(1<<0)
#define SET_CS PORTD|=(1<<0)
#define CLR_DC PORTD&=~(1<<1) //low for Control data high for Display data
#define SET_DC PORTD|=(1<<1)
#define CLR_RESET PORTD&=~(1<<2)
#define SET_RESET PORTD|=(1<<2)
uchar HZ[][32]={{0xFF,0xBF,0x4D,0x69,0x65,0x6D,0x09,0x65,0x6C,0x6E,0x66,0x68,0x6E,0x6F,0xCF,0xFF,0xBF,0xDF,0x5F,0x6F,0xB3,0xB8,0xD5,0xD5,0xED,0xE5,0xD9,0xDD,0xBF,0x3F,0xBF,0xFF},/*”爱”,0*/
{0xDF,0xDF,0xDD,0xDD,0x01,0xDE,0xDE,0xDF,0xDF,0x00,0xDF,0xDD,0x53,0xDF,0xDF,0xFF,0xFB,0xFB,0xBD,0x7D,0x80,0xFE,0xFE,0xEF,0xEF,0xF7,0xF8,0xE5,0xDE,0xBF,0x0F,0xFF},/*”我”,1*/
{0xFF,0xFF,0x03,0xF7,0xF7,0xF7,0xF7,0x00,0xF7,0xF7,0xF7,0xF7,0x03,0xF7,0xFF,0xFF,0xFF,0xFF,0xF8,0xFD,0xFD,0xFD,0xFD,0x00,0xFD,0xFD,0xFD,0xFD,0xF8,0xFF,0xFF,0xFF},/*”中”,2*/
{0xDF,0xEF,0xF7,0x03,0xFC,0xFD,0xEF,0xEF,0x80,0x77,0x77,0x7B,0x79,0x1B,0xFF,0xFF,0xFF,0xFB,0xFB,0xFA,0xFB,0xFB,0xFB,0x00,0xFB,0xFB,0xFB,0xFB,0xFB,0xFB,0xFB,0xFF},/*”华”,3*/
{0xDF,0xDF,0xDD,0xDD,0x01,0xDE,0xDE,0xDF,0xDF,0x00,0xDF,0xDD,0x53,0xDF,0xDF,0xFF,0xFB,0xFB,0xBD,0x7D,0x80,0xFE,0xFE,0xEF,0xEF,0xF7,0xF8,0xE5,0xDE,0xBF,0x0F,0xFF},/*”我”,4*/
{0xFF,0x07,0x73,0x74,0x77,0x07,0xBF,0xCF,0x70,0xF7,0xF7,0xF7,0xF7,0x07,0xFF,0xFF,0xFF,0x80,0xEF,0xEF,0xEF,0xC0,0xFF,0xFF,0xFF,0xFC,0xD9,0xBF,0xDF,0xE0,0xFF,0xFF},/*”的”,5*/
{0xFF,0xE7,0xFB,0xEB,0x6B,0x6B,0x2A,0x49,0xEB,0xEB,0x6B,0xFB,0xEB,0xF3,0xFB,0xFF,0xFF,0xD6,0xD6,0xEA,0xEB,0xB5,0x76,0xBB,0xC0,0xF9,0xF6,0xF6,0xEF,0xCF,0xEF,0xFF}};
/**********************************************************
Global Variable
**********************************************************/
uchar page;
uchar x,y;
uchar char_row;
uchar charpos;
uchar chardata;
void nokia_write_dorc(uchar bytefornokia);
void nokia_write_command(uchar bytefornokia_command);
void nokia_write_data(uchar bytefornokia_data);
void nokia_gotoxy(uchar xnokia, uchar ynokia);
void lcdpixel(uchar x, uchar y,uchar d);
void lcd_chr(uchar charsel);
void delay_ms(uint t)
{
uint i,j;
for(i=0;i
}
void SPI_init()
{
DDRB|=(1<<5)|(1<<7);//MOSI SCK OUTPUT
SPCR=(0<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(0<<1)|(1);
}
void SPI_sendB(uchar d)
{
/* 发动数据传输 */
SPDR = d;
/* 等候传输完毕 */
while(!(SPSR & (1<
/********************************************************
Nokia clear LCD function
********************************************************/
void nokia_cls() {
for (page=0; page<9; page++) // 9 page
{
nokia_write_command(0xB0 | page); // page address ie:0xB0,0xB1,…,0xB7
nokia_write_command(0x11); // most 4 bit column address command 0001 0011
nokia_write_command(0x02); // least 4 bit column address command 0000 0011
for (x=96; x>0; x–) // 96 column
nokia_write_data(0x00);
}
}
/**********************************************************
Reset LCD Function
**********************************************************/
void nokia_reset()
{
SET_RESET; //1
delay_ms(10);
CLR_RESET; //0
delay_ms(10);
SET_RESET; //1
delay_ms(100);
}
/**********************************************************
Initial LCD Function
**********************************************************/
void nokia_init() {
nokia_reset();
nokia_write_command(0xA6); // lcd in normal display mode (0xA7 negative mode)
nokia_write_command(0xA3); // lcd bias (1/9 0xA2 – 1/7 0xA3)
nokia_write_command(0xA1); // (0xA1 reverse lcd – 0xA0 select normal)
nokia_write_command(0xC0); // common output normal (0xC8 reverse)
nokia_write_command(0x22); // V5 resistor ratio
nokia_write_command(0x81); // electronic volume mode
nokia_write_command(0x2E); // power control set value (contrast level –> 0x00 lightest to 0x3F darkest)
nokia_write_command(0x2F); // power control set value
nokia_write_command(0xE3); // nop
nokia_write_command(0x40); // start line set
nokia_write_command(0xAF); // lcd on
nokia_write_command(0xA5); // lcd all points on
delay_ms(500);
nokia_write_command(0xAE); // lcd off
nokia_cls();
nokia_write_command(0xAF); // lcd on
nokia_write_command(0xA4); // lcd normal display mode
}
/**********************************************************
sent 8 bit data to LCD by series
**********************************************************/
void nokia_write_dorc(uchar bytefornokia)
{
SPI_sendB(bytefornokia);
}
/**********************************************************
Sent Command to LCD Function
**********************************************************/
void nokia_write_command(uchar bytefornokia_command)
{
CLR_DC; // lcd command mode
CLR_CS; // chip enabled
nokia_write_dorc(bytefornokia_command);
SET_CS; // chip disabled
}
/**********************************************************
Sent Data to LCD Function
**********************************************************/
void nokia_write_data(uchar bytefornokia_data) {
SET_DC; // display data mode
CLR_CS; // chip enabled
nokia_write_dorc(bytefornokia_data);
SET_CS; // chip disabled
}
/**********************************************************
goto xy position on LCD Function
**********************************************************/
void nokia_gotoxy(uchar lcd_row, uchar lcd_col)
{ //lcy_row: 0 – 8 (8th column has only 1 line / D0, lcd_col: 0 -15
char col_addr;
nokia_write_command(0xB0 + lcd_row); // page address set. pg 8-48 in the datasheet.
col_addr = 0x12+(lcd_col); // each font has five columns + 1 blank column. xaddr: 0 – 95 on noki
//a 7110. no offset.
//lcd_1st_col=0x12: the first column of display starts here. Weird! the datasheet didnt mention it.
nokia_write_command(0x10 | (col_addr>>4)); // column address 4 most bit set
nokia_write_command(0x0f & col_addr); // column address 4 least bit set
}
/**********************************************************
在xy方位xie一个字节
**********************************************************/
void lcdpixel(uchar x, uchar y,uchar d)// 左下角为(0,0) x 0-75 有个bug
// y 0-63
{
nokia_gotoxy(x,y);
nokia_write_data(d);
}
void lcd_HZ(uchar x,uchar y,uchar *s)
{
uchar i;
y=y*16;
for(i=0;i<16;i++)
{
lcdpixel(x,y+i,s[i]);
}
for(i=16;i<32;i++)
{
lcdpixel(x+1,y+i-16,s[i]);
}
}
void main()
{
uchar i;
DDRD=0XFF;
SPI_init();
nokia_init();
//lcdpixel(1,0,0xaa);
for(i=0;i<8;i++)
lcd_HZ(0,i,HZ[i]);
//nokia_write_command(0xa5); //diaplay all points on
//while(1);
}
字模的提取仍是用的PCtoLCD2000
######################################################################
上面的“家”,没显示出来
void main()
{
uchar i;
DDRD=0XFF;
SPI_init();
nokia_init();
//lcdpixel(1,0,0xaa);
for(i=0;i<6;i++)
lcd_HZ(0,i,HZ[i]);
lcd_HZ(2,0,HZ[6]);
//nokia_write_command(0xa5); //diaplay all points on
//while(1);
}