2022-04-28 02:00:04 +00:00
|
|
|
|
#include <reg52.h>
|
|
|
|
|
#include "display.h"
|
|
|
|
|
#include "delay.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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const unsigned char Z[] =
|
|
|
|
|
{
|
|
|
|
|
0x10, 0x60, 0x02, 0x0C, 0xC0, 0x04, 0x04, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
|
|
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
|
|
|
|
|
0x20, 0x24, 0x24, 0xA4, 0xFE, 0x23, 0x22, 0x20, 0x00, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
const unsigned char Z2[] =
|
|
|
|
|
{
|
|
|
|
|
0x04, 0x04, 0x7C, 0x03, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x10, 0x08, 0x06, 0x01, 0xFF, 0x01, 0x06, 0x00, 0x00, 0x3F, 0x10, 0x10, 0x10, 0x3F, 0x00, 0x00
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
void write()
|
2022-04-28 02:00:04 +00:00
|
|
|
|
{
|
2022-05-05 13:32:33 +00:00
|
|
|
|
RW = 0;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
E = 0;
|
|
|
|
|
E = 1;
|
|
|
|
|
delay(2);
|
|
|
|
|
E = 0;
|
2022-04-28 02:00:04 +00:00
|
|
|
|
}
|
2022-05-05 12:25:59 +00:00
|
|
|
|
|
2022-04-28 02:00:04 +00:00
|
|
|
|
void writeData(unsigned char d)
|
|
|
|
|
{
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = d;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
void setCommand(unsigned char d)
|
2022-04-28 02:00:04 +00:00
|
|
|
|
{
|
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setPage(unsigned char p)
|
|
|
|
|
{
|
2022-05-05 12:25:59 +00:00
|
|
|
|
setCommand(0xb8 + p);
|
2022-04-28 02:00:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setLine(unsigned char p)
|
|
|
|
|
{
|
2022-05-05 12:25:59 +00:00
|
|
|
|
setCommand(0xc0 + p);
|
2022-04-28 02:00:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setY(unsigned char p)
|
|
|
|
|
{
|
2022-05-05 12:25:59 +00:00
|
|
|
|
setCommand(0x40 + p);
|
2022-04-28 02:00:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
void name(unsigned int line)
|
2022-04-28 02:00:04 +00:00
|
|
|
|
{
|
2022-05-05 13:32:33 +00:00
|
|
|
|
unsigned char l = line % 128;
|
|
|
|
|
unsigned int j;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
for(j = l; j < l + 48; j++)
|
|
|
|
|
{
|
|
|
|
|
if(j < 64)
|
|
|
|
|
{
|
|
|
|
|
CSA = 1;
|
|
|
|
|
CSB = 0;
|
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + 0;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40 + j;
|
|
|
|
|
write(); //ҳ0<D2B3><30>j<EFBFBD><6A>A
|
|
|
|
|
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = Z[j - l];
|
|
|
|
|
write();
|
2022-04-28 02:00:04 +00:00
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + 1;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40 + j;
|
|
|
|
|
write(); //ҳ1<D2B3><31>j<EFBFBD><6A>A
|
|
|
|
|
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = Z2[j - l];
|
|
|
|
|
write();
|
|
|
|
|
}
|
|
|
|
|
else if(j < 128)
|
2022-05-05 12:25:59 +00:00
|
|
|
|
{
|
2022-05-05 13:32:33 +00:00
|
|
|
|
CSA = 0;
|
|
|
|
|
CSB = 1;
|
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + 0;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40 + j - 63;
|
|
|
|
|
write(); //ҳ0<D2B3><30>j-63<36><33>B
|
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = Z[j - l];
|
2022-05-05 12:25:59 +00:00
|
|
|
|
write();
|
2022-05-05 13:32:33 +00:00
|
|
|
|
|
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + 1;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40 + j - 63;
|
|
|
|
|
write(); //ҳ1<D2B3><31>j-63<36><33>B
|
|
|
|
|
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = Z2[j - l];
|
|
|
|
|
write();
|
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
}
|
2022-05-05 13:32:33 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CSA = 1;
|
|
|
|
|
CSB = 0;
|
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + 0;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40 + j - 127;
|
|
|
|
|
write(); //ҳ0<D2B3><30>j-127<32><37>A
|
2022-04-28 02:00:04 +00:00
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = Z[j - l];
|
2022-05-05 12:25:59 +00:00
|
|
|
|
write();
|
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + 1;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40 + j - 127;
|
|
|
|
|
write(); //ҳ1<D2B3><31>j-127<32><37>A
|
2022-05-05 12:25:59 +00:00
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = Z2[j - l];
|
|
|
|
|
write();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clear()
|
|
|
|
|
{
|
|
|
|
|
unsigned int i, j;
|
|
|
|
|
CSA = 1;
|
|
|
|
|
CSB = 0;
|
|
|
|
|
for(i = 0; i < 8; i++)
|
|
|
|
|
{
|
2022-05-05 12:25:59 +00:00
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = 0xb8 + i;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40;
|
|
|
|
|
write();
|
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
for(j = 0; j < 64; j++)
|
2022-05-05 12:25:59 +00:00
|
|
|
|
{
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = 0x00;;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
write();
|
|
|
|
|
}
|
2022-05-05 13:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
CSA = 0;
|
|
|
|
|
CSB = 1;
|
|
|
|
|
for(i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
RS = 0;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
RW = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = 0xb8 + i;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40;
|
|
|
|
|
write();
|
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
for(j = 0; j < 64; j++)
|
2022-05-05 12:25:59 +00:00
|
|
|
|
{
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = 0x00;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
write();
|
2022-05-05 13:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-28 02:00:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-05 12:25:59 +00:00
|
|
|
|
|
2022-05-05 13:32:33 +00:00
|
|
|
|
void miniclear()
|
2022-04-28 02:00:04 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int i, j;
|
|
|
|
|
CSA = 1;
|
|
|
|
|
CSB = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
for(i = 0; i < 2; i++)
|
2022-04-28 02:00:04 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
for(i = 0; i < 2; i++)
|
2022-04-28 02:00:04 +00:00
|
|
|
|
{
|
|
|
|
|
RS = 0;
|
|
|
|
|
RW = 0;
|
|
|
|
|
P1 = 0xb8 + i;
|
|
|
|
|
write();
|
|
|
|
|
P1 = 0X40;
|
|
|
|
|
write();
|
|
|
|
|
|
|
|
|
|
for(j = 0; j < 64; j++)
|
|
|
|
|
{
|
|
|
|
|
RS = 1;
|
|
|
|
|
RW = 0;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
P1 = 0x00;
|
2022-04-28 02:00:04 +00:00
|
|
|
|
write();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void init()
|
|
|
|
|
{
|
|
|
|
|
E = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
RS = 1;
|
2022-04-28 02:00:04 +00:00
|
|
|
|
CSA = 1;
|
|
|
|
|
CSB = 0;
|
|
|
|
|
RS = 0;
|
|
|
|
|
P1 = 0X3F;
|
|
|
|
|
write();
|
|
|
|
|
|
|
|
|
|
CSA = 0;
|
|
|
|
|
CSB = 1;
|
|
|
|
|
RS = 0;
|
2022-05-05 13:32:33 +00:00
|
|
|
|
P1 = 0X3F;
|
2022-04-28 02:00:04 +00:00
|
|
|
|
write();
|
2022-05-05 12:25:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test()
|
|
|
|
|
{
|
2022-05-05 13:32:33 +00:00
|
|
|
|
unsigned int i, j;
|
2022-05-05 12:25:59 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-28 02:00:04 +00:00
|
|
|
|
}
|