/*
MATRIX FORMAT
ROW & COL ACTIVE HI
COL SCAN BY 74LS164
-----------5
-----------4
-----------3
-----------2
-----------1
-------2 1 0
row 3-7 decoder
a=2.0
b=2.1
c=2.2
column ck,dt
ck=1.6
dt=1.7
*/
#include <reg51.h>
#include <intrins.h>
#define TRUE 1 /* define logical true / false */
#define FALSE 0 /* values for bit variables */
#define SCROLL_DELAY 1 /* scroll delay */
#define TIMER0_COUNT 0xFADA // 1.1ms
void modu1();
void modu2();
void modu3();
void modu4();
void modu5();
void sendCommand(char* command);
void sendChar(unsigned char c);
void delay_us(unsigned int d);
void sort(unsigned char a,unsigned char *d,unsigned char *m);
extern signed char write2464(unsigned int Address, unsigned char Data);
extern unsigned char read2464(unsigned int Address);
typedef unsigned char byte; /* type define objects with */
typedef unsigned int word; /* more classical microprocessor */
code unsigned char matrix[91][7]=
{ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // Space
0xFB,0xFB,0xFB,0xFB,0xFB,0xFF,0xFB, // ;!
0xF5,0xF5,0xF5,0xFF,0xFF,0xFF,0xFF, // "
0xF5,0xF5,0xE0,0xF5,0xE0,0xF5,0xF5, // #
0xFB,0xF0,0xEB,0xF1,0xFA,0xE1,0xFB, // $
0xE3,0xEA,0xE5,0xFB,0xF4,0xEA,0xF8, // %
0xF7,0xEB,0xEB,0xF7,0xEA,0xED,0xF2, // &
0xF9,0xF9,0xFD,0xFB,0xFF,0xFF,0xFF, // '
0xFD,0xFB,0xF7,0xF7,0xF7,0xFB,0xFD, // (
0xF7,0xFB,0xFD,0xFD,0xFD,0xFB,0xF7, // )
0xFB,0xEA,0xF1,0xFB,0xF1,0xEA,0xFB, // *
0xFF,0xFB,0xFB,0xE0,0xFB,0xFB,0xFF, // +
0xFF,0xFF,0xFF,0xF3,0xF3,0xFB,0xF7, // ,
0xFF,0xFF,0xFF,0xF1,0xFF,0xFF,0xFF, // -
0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xF3, // .
0xFF,0xFE,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0xEE,0xEC,0xF2, // d
0xFF,0xFF,0xF1,0xEE,0xE0,0xEF,0xF1, // e
0xF9,0xF6,0xF7,0xE1,0xF7,0xF7,0xF7, // f
0xFF,0xFF,0xF0,0xEE,0xF0,0xFE,0xF1, // g
0xEF,0xEF,0xE9,0xE6,0xEE,0xEE,0xEE, // h
0xFB,0xFF,0xF3,0xFB,0xFB,0xFB,0xF1, // i
0xFD,0xFF,0xF9,0xFD,0xFD,0xFD,0xF3, // j
0xF7,0xF7,0xF6,0xF5,0xF3,0xF5,0xF6, // k
0xF3,0xFB,0xFB,0xFB,0xFB,0xFB,0xF1, // l
0xFF,0xFF,0xE5,0xEA,0xEA,0xEA,0xEA, // m
0xFF,0xFF,0xE9,0xE6,0xEE,0xEE,0xEE, // n
0xFF,0xFF,0xF1,0xEE,0xEE,0xEE,0xF1, // o
0xFF,0xFF,0xE1,0xEE,0xE1,0xEF,0xEF, // p
0xFF,0xFF,0xF0,0xEE,0xF0,0xFE,0xFE, // q
0xFF,0xFF,0xE9,0xE6,0xEF,0xEF,0xEF, // r
0xFF,0xFF,0xF0,0xEF,0xF1,0xFE,0xE1, // s
0xFB,0xFB,0xF0,0xFB,0xFB,0xFB,0xFC, // t
0xFF,0xFF,0xEE,0xEE,0xEE,0xEC,0xF2, // u
0xFF,0xFF,0xEE,0xEE,0xEE,0xF5,0xFB, // v
0xFF,0xFF,0xEE,0xEE,0xEA,0xEA,0xF4, // w
0xFF,0xFF,0xEE,0xF5,0xFB,0xF5,0xEE, // x
0xFF,0xFF,0xEE,0xF5,0xFB,0xFB,0xF3, // y
0xFF,0xFF,0xE0,0xFD,0xFB,0xF7,0xE0}; // z
code char MSG1[]="your message here ";
sbit LED_CLOCK = P1^7;
sbit LED_DATA = P1^6;
char msg[41];
unsigned char dig[20];
bit CH_LIM,OFF_CH;
byte tmp,t;
void main(void)
{
byte modu,divi,blank1_limit,blank2_limit,ch_limit;
byte i,j,k,offset_ch,old_divi,diff;
int offset_col,t1;
int row;
P1=0xFF;
P3=0xFF;
P2=0xFF;
EA =0;
TL1=0XFD; //9600 @ 11.0592
TH1=0XFD;
TMOD =0x21;
SCON =0X50;
ET0=1;
TR1=1;
//EA = 1;
RI=0;
/*
main execution loop, executes forever.
*/
LED_CLOCK = 1;
P2=7;
offset_col=0;
blank1_limit=17;
ch_limit=0;
blank2_limit=0;
offset_ch=40;
CH_LIM=0;
OFF_CH=0;
k=0;
for(i=0;i<=40;i++) msg=read2464(i);
for(t1=40;t1>=0;t1--)msg[t1]=MSG1[40-t1]; //store msg
while(1){
if(RI){
P2=7;
sendCommand("TYPE MSG:\r");
i=41;
while(1){
while(!RI);
RI=0;
if(i!=0 || SBUF==13){
if(SBUF==13){
sendCommand("\rOK\r");
sendCommand("Storing....wait\r");
for(k=i;k>0;k--)msg[k]=0x20; //space char
msg[0]=0x20;
for(i=0;i<=40;i++) tmp=write2464(i,msg);
sendCommand("OK\r");
break;
}
if(SBUF==0x08){
if(i!=40){sendChar(SBUF);++i;}
}
else{
msg=SBUF;
sendChar(msg);
--i;
}
}
if(SBUF==0x08 && i==0){
if(i!=40){sendChar(SBUF);++i;}
}
}
}
for(k=0;k<SCROLL_DELAY;k++){
//delay_us(60000);
for(row=6;row>-1;row--){
i=16;
for(j=0;j<blank1_limit;j++){
dig=0xff;--i;
}
t=0;
for(j=0;j<ch_limit;j++){
dig=matrix[msg[(t+offset_ch)]-0x20][row];
--t;
--i;
}
for(j=0;j<blank2_limit;j++){
dig=0xff;--i;
}
if(modu==1)modu1();
else if(modu==2) modu2();
else if(modu==3) modu3();
else if(modu==4) modu4();
else if(modu==5) modu5();
for(i=1;i<17;i++){
t=dig;
if(t & 0x01) LED_DATA =0;
else LED_DATA=1;
LED_CLOCK = 1;LED_CLOCK = 0; LED_CLOCK = 1;
t=t >>1;
if(t & 0x01) LED_DATA =0;
else LED_DATA=1;
LED_CLOCK = 1;LED_CLOCK = 0; LED_CLOCK = 1;
t=t >>1;
if(t & 0x01) LED_DATA =0;
else LED_DATA=1;
LED_CLOCK = 1;LED_CLOCK = 0; LED_CLOCK = 1;
t=t >>1;
if(t & 0x01) LED_DATA =0;
else LED_DATA=1;
LED_CLOCK = 1;LED_CLOCK = 0; LED_CLOCK = 1;
t=t >>1;
if(t & 0x01) LED_DATA =0;
else LED_DATA=1;
LED_CLOCK = 1;LED_CLOCK = 0; LED_CLOCK = 1;
t=t >>1;
if(t & 0x01) LED_DATA =0;
else LED_DATA=1;
LED_CLOCK = 1;LED_CLOCK = 0; LED_CLOCK = 1;
}
P2=row;
delay_us(2000);
P2=7;
}
}//delay
if(++offset_col>348){ // 96 + 150 + 96
offset_col=0;
blank1_limit=17;
ch_limit=0;
blank2_limit=0;
offset_ch=40;
CH_LIM=0;
OFF_CH=0;
}
modu=offset_col%6;
divi=offset_col/6;
if(divi!=old_divi)diff=1;
else diff=0;
if(blank1_limit!=0)blank1_limit=blank1_limit-diff;
if(CH_LIM){
if(OFF_CH){
blank2_limit=blank2_limit+diff;
ch_limit=ch_limit-diff;
if(ch_limit==255)ch_limit=0;
}
offset_ch=offset_ch-diff;
if(offset_ch>41)offset_ch=0;
}else{
ch_limit=ch_limit+diff;
}
if(offset_ch==16)OFF_CH=1;
if(ch_limit==17)CH_LIM=1;
old_divi=divi;
}//while
}//----------------end main
void sendCommand(char* command){
char index, temp;
index=0;
while(1){ //for(index = 0; temp != 0; index++){
temp = command[index];
if(temp==0)break;
sendChar(temp);
++index;
}
}
void sendChar(unsigned char c){
SBUF = c;
while(!TI);TI = 0;
}
void delay_us(unsigned int d){
unsigned int i,m;
m=d/14;
for(i=0;i<m;i++);
}
void modu1(){
tmp=dig[0];
dig[0]<<=1;
t=dig[1];
dig[1]<<=1;
dig[1]=(dig[1])|((tmp>>5) & 0x01);
tmp=dig[2];
dig[2]<<=1;
dig[2]=(dig[2])|((t>>5)& 0x01);
t=dig[3];
dig[3]<<=1;
dig[3]=(dig[3])|((tmp>>5)& 0x01);
tmp=dig[4];
dig[4]<<=1;
dig[4]=(dig[4])|((t>>5)& 0x01);
t=dig[5];
dig[5]<<=1;
dig[5]=(dig[5])|((tmp>>5)& 0x01);
tmp=dig[6];
dig[6]<<=1;
dig[6]=(dig[6])|((t>>5) & 0x01);
t=dig[7];
dig[7]<<=1;
dig[7]=(dig[7])|((tmp>>5)& 0x01);
tmp=dig[8];
dig[8]<<=1;
dig[8]=(dig[8])|((t>>5)& 0x01);
t=dig[9];
dig[9]<<=1;
dig[9]=(dig[9])|((tmp>>5)& 0x01);
tmp=dig[10];
dig[10]<<=1;
dig[10]=(dig[10])|((t>>5) & 0x01);
t=dig[11];
dig[11]<<=1;
dig[11]=(dig[11])|((tmp>>5)& 0x01);
tmp=dig[12];
dig[12]<<=1;
dig[12]=(dig[12])|((t>>5)& 0x01);
t=dig[13];
dig[13]<<=1;
dig[13]=(dig[13])|((tmp>>5)& 0x01);
tmp=dig[14];
dig[14]<<=1;
dig[14]=(dig[14])|((t>>5) & 0x01);
t=dig[15];
dig[15]<<=1;
dig[15]=(dig[15])|((tmp>>5) & 0x01);
tmp=dig[16];
dig[16]<<=1;
dig[16]=(dig[16])|((t>>5) & 0x01);
// t=dig[17];
// dig[17]<<=1;
// dig[17]=(dig[17])|((tmp>>5) & 0x01);
// tmp=dig[18];
// dig[18]<<=1;
// dig[18]=(dig[18])|((t>>5) & 0x01);
}
void modu2(){
tmp=dig[0];
dig[0]<<=2;
t=dig[1];
dig[1]<<=2;
dig[1]=(dig[1])|((tmp>>4) & 0x03);
tmp=dig[2];
dig[2]<<=2;
dig[2]=(dig[2])|((t>>4)& 0x03);
t=dig[3];
dig[3]<<=2;
dig[3]=(dig[3])|((tmp>>4)& 0x03);
tmp=dig[4];
dig[4]<<=2;
dig[4]=(dig[4])|((t>>4)& 0x03);
t=dig[5];
dig[5]<<=2;
dig[5]=(dig[5])|((tmp>>4)& 0x03);
tmp=dig[6];
dig[6]<<=2;
dig[6]=(dig[6])|((t>>4) & 0x03);
t=dig[7];
dig[7]<<=2;
dig[7]=(dig[7])|((tmp>>4)& 0x03);
tmp=dig[8];
dig[8]<<=2;
dig[8]=(dig[8])|((t>>4)& 0x03);
t=dig[9];
dig[9]<<=2;
dig[9]=(dig[9])|((tmp>>4)& 0x03);
tmp=dig[10];
dig[10]<<=2;
dig[10]=(dig[10])|((t>>4) & 0x03);
t=dig[11];
dig[11]<<=2;
dig[11]=(dig[11])|((tmp>>4)& 0x03);
tmp=dig[12];
dig[12]<<=2;
dig[12]=(dig[12])|((t>>4)& 0x03);
t=dig[13];
dig[13]<<=2;
dig[13]=(dig[13])|((tmp>>4)& 0x03);
tmp=dig[14];
dig[14]<<=2;
dig[14]=(dig[14])|((t>>4) & 0x03);
t=dig[15];
dig[15]<<=2;
dig[15]=(dig[15])|((tmp>>4) & 0x03);
tmp=dig[16];
dig[16]<<=2;
dig[16]=(dig[16])|((t>>4) & 0x03);
// t=dig[17];
// dig[17]<<=2;
// dig[17]=(dig[17])|((tmp>>4) & 0x03);
// tmp=dig[18];
// dig[18]<<=2;
// dig[18]=(dig[18])|((t>>4) & 0x03);
}
void modu3(){
tmp=dig[0];
dig[0]<<=3;
t=dig[1];
dig[1]<<=3;
dig[1]=(dig[1])|((tmp>>3) & 0x07);
tmp=dig[2];
dig[2]<<=3;
dig[2]=(dig[2])|((t>>3)& 0x07);
t=dig[3];
dig[3]<<=3;
dig[3]=(dig[3])|((tmp>>3)& 0x07);
tmp=dig[4];
dig[4]<<=3;
dig[4]=(dig[4])|((t>>3)& 0x07);
t=dig[5];
dig[5]<<=3;
dig[5]=(dig[5])|((tmp>>3)& 0x07);
tmp=dig[6];
dig[6]<<=3;
dig[6]=(dig[6])|((t>>3) & 0x07);
t=dig[7];
dig[7]<<=3;
dig[7]=(dig[7])|((tmp>>3)& 0x07);
tmp=dig[8];
dig[8]<<=3;
dig[8]=(dig[8])|((t>>3)& 0x07);
t=dig[9];
dig[9]<<=3;
dig[9]=(dig[9])|((tmp>>3)& 0x07);
tmp=dig[10];
dig[10]<<=3;
dig[10]=(dig[10])|((t>>3) & 0x07);
t=dig[11];
dig[11]<<=3;
dig[11]=(dig[11])|((tmp>>3)& 0x07);
tmp=dig[12];
dig[12]<<=3;
dig[12]=(dig[12])|((t>>3)& 0x07);
t=dig[13];
dig[13]<<=3;
dig[13]=(dig[13])|((tmp>>3)& 0x07);
tmp=dig[14];
dig[14]<<=3;
dig[14]=(dig[14])|((t>>3) & 0x07);
t=dig[15];
dig[15]<<=3;
dig[15]=(dig[15])|((tmp>>3) & 0x07);
tmp=dig[16];
dig[16]<<=3;
dig[16]=(dig[16])|((t>>3) & 0x07);
// t=dig[17];
// dig[17]<<=3;
// dig[17]=(dig[17])|((tmp>>3) & 0x07);
// tmp=dig[18];
// dig[18]<<=3;
// dig[18]=(dig[18])|((t>>3) & 0x07);
}
void modu4(){
tmp=dig[0];
dig[0]<<=4;
t=dig[1];
dig[1]<<=4;
dig[1]=(dig[1])|((tmp>>2) & 0x0f);
tmp=dig[2];
dig[2]<<=4;
dig[2]=(dig[2])|((t>>2)& 0x0f);
t=dig[3];
dig[3]<<=4;
dig[3]=(dig[3])|((tmp>>2)& 0x0f);
tmp=dig[4];
dig[4]<<=4;
dig[4]=(dig[4])|((t>>2)& 0x0f);
t=dig[5];
dig[5]<<=4;
dig[5]=(dig[5])|((tmp>>2)& 0x0f);
tmp=dig[6];
dig[6]<<=4;
dig[6]=(dig[6])|((t>>2) & 0x0f);
t=dig[7];
dig[7]<<=4;
dig[7]=(dig[7])|((tmp>>2)& 0x0f);
tmp=dig[8];
dig[8]<<=4;
dig[8]=(dig[8])|((t>>2)& 0x0f);
t=dig[9];
dig[9]<<=4;
dig[9]=(dig[9])|((tmp>>2)& 0x0f);
tmp=dig[10];
dig[10]<<=4;
dig[10]=(dig[10])|((t>>2) & 0x0f);
t=dig[11];
dig[11]<<=4;
dig[11]=(dig[11])|((tmp>>2)& 0x0f);
tmp=dig[12];
dig[12]<<=4;
dig[12]=(dig[12])|((t>>2)& 0x0f);
t=dig[13];
dig[13]<<=4;
dig[13]=(dig[13])|((tmp>>2)& 0x0f);
tmp=dig[14];
dig[14]<<=4;
dig[14]=(dig[14])|((t>>2) & 0x0f);
t=dig[15];
dig[15]<<=4;
dig[15]=(dig[15])|((tmp>>2) & 0x0f);
tmp=dig[16];
dig[16]<<=4;
dig[16]=(dig[16])|((t>>2) & 0x0f);
// t=dig[17];
// dig[17]<<=4;
// dig[17]=(dig[17])|((tmp>>2) & 0x0f);
// tmp=dig[18];
// dig[18]<<=4;
// dig[18]=(dig[18])|((t>>2) & 0x0f);
}
void modu5(){
tmp=dig[0];
dig[0]<<=5;
t=dig[1];
dig[1]<<=5;
dig[1]=(dig[1])|((tmp>>1) & 0x1f);
tmp=dig[2];
dig[2]<<=5;
dig[2]=(dig[2])|((t>>1)& 0x1f);
t=dig[3];
dig[3]<<=5;
dig[3]=(dig[3])|((tmp>>1)& 0x1f);
tmp=dig[4];
dig[4]<<=5;
dig[4]=(dig[4])|((t>>1)& 0x1f);
t=dig[5];
dig[5]<<=5;
dig[5]=(dig[5])|((tmp>>1)& 0x1f);
tmp=dig[6];
dig[6]<<=5;
dig[6]=(dig[6])|((t>>1) & 0x1f);
t=dig[7];
dig[7]<<=5;
dig[7]=(dig[7])|((tmp>>1)& 0x1f);
tmp=dig[8];
dig[8]<<=5;
dig[8]=(dig[8])|((t>>1)& 0x1f);
t=dig[9];
dig[9]<<=5;
dig[9]=(dig[9])|((tmp>>1)& 0x1f);
tmp=dig[10];
dig[10]<<=5;
dig[10]=(dig[10])|((t>>1) & 0x1f);
t=dig[11];
dig[11]<<=5;
dig[11]=(dig[11])|((tmp>>1)& 0x1f);
tmp=dig[12];
dig[12]<<=5;
dig[12]=(dig[12])|((t>>1)& 0x1f);
t=dig[13];
dig[13]<<=5;
dig[13]=(dig[13])|((tmp>>1)& 0x1f);
tmp=dig[14];
dig[14]<<=5;
dig[14]=(dig[14])|((t>>1) & 0x1f);
t=dig[15];
dig[15]<<=5;
dig[15]=(dig[15])|((tmp>>1) & 0x1f);
tmp=dig[16];
dig[16]<<=5;
dig[16]=(dig[16])|((t>>1) & 0x1f);
// t=dig[17];
// dig[17]<<=5;
// dig[17]=(dig[17])|((tmp>>1) & 0x1f);
// tmp=dig[18];
// dig[18]<<=5;
// dig[18]=(dig[18])|((t>>1) & 0x1f);
}