278 lines
No EOL
3.6 KiB
C
278 lines
No EOL
3.6 KiB
C
#include <reg52.h>
|
|
#include "display.h"
|
|
#include "delay.h"
|
|
#include "img.h"
|
|
|
|
// DB P1
|
|
// CTL P3
|
|
|
|
sbit RS = P3 ^ 0;
|
|
sbit RW = P3 ^ 1;
|
|
sbit E = P3 ^ 2;
|
|
sbit CSA = P3 ^ 4;
|
|
sbit CSB = P3 ^ 5;
|
|
|
|
|
|
|
|
|
|
void write()
|
|
{
|
|
RW = 0;
|
|
E = 0;
|
|
E = 1;
|
|
delay(2);
|
|
E = 0;
|
|
}
|
|
|
|
void drawNUMBER()
|
|
{
|
|
unsigned int j;
|
|
for(j =0 ; j < 64; j++)
|
|
{
|
|
|
|
|
|
CSA = 1;
|
|
CSB = 0;
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + 2;
|
|
write();
|
|
P1 = 0X40 + j;
|
|
write(); //Ò³2ÁÐjÆÁA
|
|
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = NUMBER_PAGE0[j - 1];
|
|
write();
|
|
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + 3;
|
|
write();
|
|
P1 = 0X40 + j;
|
|
write(); //Ò³3ÁÐjÆÁA
|
|
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = NUMBER_PAGE1[j - 1];
|
|
write();
|
|
|
|
|
|
}
|
|
for(j =0 ; j < 16; j++)
|
|
{
|
|
|
|
|
|
CSA = 0;
|
|
CSB = 1;
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + 2;
|
|
write();
|
|
P1 = 0X40 + j;
|
|
write(); //Ò³2ÁÐjÆÁA
|
|
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = NUMBER_RPAGE0[j - 1];
|
|
write();
|
|
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + 3;
|
|
write();
|
|
P1 = 0X40 + j;
|
|
write(); //Ò³3ÁÐjÆÁA
|
|
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = NUMBER_RPAGE1[j - 1];
|
|
write();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
void drawNAME()
|
|
{
|
|
unsigned int j;
|
|
|
|
for(j = 0; j < 48; j++)
|
|
{
|
|
|
|
|
|
CSA = 1;
|
|
CSB = 0;
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + 0;
|
|
write();
|
|
P1 = 0X40 + j;
|
|
write(); //Ò³0ÁÐjÆÁA
|
|
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = NAME_PAGE0[j - 1];
|
|
write();
|
|
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + 1;
|
|
write();
|
|
P1 = 0X40 + j;
|
|
write(); //Ò³1ÁÐjÆÁA
|
|
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = NAME_PAGE1[j - 1];
|
|
write();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
void clear()
|
|
{
|
|
unsigned int i, j;
|
|
CSA = 1;
|
|
CSB = 0;
|
|
for(i = 0; i < 8; i++)
|
|
{
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + i;
|
|
write();
|
|
P1 = 0X40;
|
|
write();
|
|
|
|
for(j = 0; j < 64; j++)
|
|
{
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = 0x00;;
|
|
write();
|
|
}
|
|
}
|
|
CSA = 0;
|
|
CSB = 1;
|
|
for(i = 0; i < 8; i++)
|
|
{
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + i;
|
|
write();
|
|
P1 = 0X40;
|
|
write();
|
|
|
|
for(j = 0; j < 64; j++)
|
|
{
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = 0x00;
|
|
write();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void miniclear()
|
|
{
|
|
unsigned int i, j;
|
|
CSA = 1;
|
|
CSB = 0;
|
|
for(i = 0; i < 2; i++)
|
|
{
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + i;
|
|
write();
|
|
P1 = 0X40;
|
|
write();
|
|
|
|
for(j = 0; j < 64; j++)
|
|
{
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = 0x00;;
|
|
write();
|
|
}
|
|
}
|
|
CSA = 0;
|
|
CSB = 1;
|
|
for(i = 0; i < 2; i++)
|
|
{
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + i;
|
|
write();
|
|
P1 = 0X40;
|
|
write();
|
|
|
|
for(j = 0; j < 64; j++)
|
|
{
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = 0x00;
|
|
write();
|
|
}
|
|
}
|
|
}
|
|
void displayInit()
|
|
{
|
|
E = 0;
|
|
RS = 1;
|
|
CSA = 1;
|
|
CSB = 0;
|
|
RS = 0;
|
|
P1 = 0X3F;
|
|
write();
|
|
|
|
CSA = 0;
|
|
CSB = 1;
|
|
RS = 0;
|
|
P1 = 0X3F;
|
|
write();
|
|
}
|
|
|
|
void test()
|
|
{
|
|
unsigned int i, j;
|
|
CSA = 1;
|
|
CSB = 0;
|
|
for(i = 0; i < 8; i++)
|
|
{
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + i;
|
|
write();
|
|
P1 = 0X40;
|
|
write();
|
|
|
|
for(j = 0; j < 64; j++)
|
|
{
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = 0x55;
|
|
write();
|
|
}
|
|
}
|
|
CSA = 0;
|
|
CSB = 1;
|
|
for(i = 0; i < 8; i++)
|
|
{
|
|
RS = 0;
|
|
RW = 0;
|
|
P1 = 0xb8 + i;
|
|
write();
|
|
P1 = 0X40;
|
|
write();
|
|
|
|
for(j = 0; j < 64; j++)
|
|
{
|
|
RS = 1;
|
|
RW = 0;
|
|
P1 = 0x55;;
|
|
write();
|
|
}
|
|
}
|
|
} |