#include
#include
#include "ascii5x7.h"
#define LCD_RW P2_3 // 40-DIP pin 24
#define LCD_CS2 P2_4 // 40-DIP pin 25
#define LCD_CS1 P2_5 // 40-DIP pin 26
#define LCD_DI P2_6 // 40-DIP pin 27
#define LCD_EN P2_7 // 40-DIP pin 28
#define LCD_D07 P0 // 40-DIP pins 39 down to 32
void LCD_delay (void) _naked
{
_asm
nop
nop
ret
_endasm;
}
// Sends a command to the display.
void LCD_Command (bit lr, unsigned char val)
{
if(lr) LCD_CS1=1; // Left half
else LCD_CS2=1; // Right half
LCD_DI=0; //Command
LCD_D07=val;
LCD_EN=1;
LCD_delay();
LCD_EN=0; //Strobe command in
LCD_CS1=0;
LCD_CS2=0;
}
// Sends a byte of data to the display.
void LCD_Write (unsigned char x, unsigned char y, unsigned char val)
{
bit lr;
lr=(x<64)?1:0;
//Set the x position
LCD_Command(lr, (x&0x3f)|0x40);
//Set the y position (page address)
LCD_Command(lr, (y&0x7)|0xb8);
if(lr) LCD_CS1=1; // Left half
else LCD_CS2=1;
2007-03-23
17:24:05
·
2 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design