sbit Serial_Data at RA0_bit;
sbit SH_Clk at RA1_bit;
sbit ST_Clk at RA2_bit;
sbit CD4017_Clk at RA2_bit;
sbit CD4017_RST at RA1_bit;
const unsigned short CharData[][7] =
{
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0x20, Space
{0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04} , // 0x21, !
{0x09, 0x09, 0x12, 0x00, 0x00, 0x00, 0x00}, // 0x22, "
{0x0a, 0x0a, 0x1f, 0x0a, 0x1f, 0x0a, 0x0a} , // 0x23, #
{0x04, 0x0f, 0x14, 0x0e, 0x05, 0x1e, 0x04} , // 0x24, $
{0x19, 0x19, 0x02, 0x04, 0x08, 0x13, 0x13} , // 0x25, %
.............................................................................
{0x00, 0x00, 0x11, 0x0a, 0x04, 0x0a, 0x11}, // 0x78, x
{0x00, 0x11, 0x11, 0x0f, 0x01, 0x11, 0x0e}, // 0x79, y
{0x00, 0x00, 0x1f, 0x02, 0x04, 0x08, 0x1f}, // 0x7a, z
{0x06, 0x08, 0x08, 0x10, 0x08, 0x08, 0x06}, // 0x7b, {
{0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04}, // 0x7c, |
{0x0c, 0x02, 0x02, 0x01, 0x02, 0x02, 0x0c}, // 0x7d, }
{0x08, 0x15, 0x02, 0x00, 0x00, 0x00, 0x00} // 0x7e, ~
};
unsigned short Buffer[7][5] = {
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};
unsigned int speed, StringLength;
unsigned short i, l, k, row, scroll, temp, shift_step=1;
unsigned short m, SerialConnect=0, UserIP = 0;
const unsigned char default_message[]="hello world";
void Send_Data(unsigned short rw){
unsigned short Mask, t, num, Flag;
for (num = 0; num < 5; num++) {
Mask = 0x01;
for (t=0; t<6; t++){
Flag = Buffer[rw][num] & Mask;
if(Flag=0) Serial_Data = 0;
else Serial_Data = 1;
SH_Clk = 1;
SH_Clk = 0;
Mask = Mask << 1;
}
}
// Apply clock on ST_Clk
ST_Clk = 1;
ST_Clk = 0;
}
void scrollleft()
{
StringLength = 11;//hello world
for (k=0; k<StringLength+4; k++){
for (scroll=0; scroll<(7/shift_step); scroll++) {
for (row=0; row<7; row++){
index = default_message[k];
temp = CharData[index-32][row];
Buffer[row][4] = (Buffer[row][4] << Shift_Step) | (Buffer[row][3] >> (7-Shift_Step));
Buffer[row][3] = (Buffer[row][3] << Shift_Step) | (Buffer[row][2] >> (7-Shift_Step));
Buffer[row][2] = (Buffer[row][2] << Shift_Step) | (Buffer[row][1] >> (7-Shift_Step));
Buffer[row][1] = (Buffer[row][1] << Shift_Step) | (Buffer[row][0] >> (7-Shift_Step));
Buffer[row][0] = (Buffer[row][0] << Shift_Step)| (temp >> ((7-shift_step)-scroll*shift_step));
}
speed = 15;
for(l=0; l<speed;l++){
CD4017_Rst = 1;
CD4017_Rst = 0;
for (i=0; i<7; i++) {
Send_Data(i);
CD4017_Clk = 1;
CD4017_Clk = 0;
Delay_ms(1);
} // i
} // l
} // scroll
} // k
}
void main() {
CMCON = 0x07; // Disable comparators
ADCON0 = 0x00; // Select ADC channel AN0
ADCON1 = 0b00001110; // RA0 as analog input
TRISC = 0x00;
TRISB = 0xFF;
TRISA = 0x01;
while(1){
scrollleft();
}
}