| ??? 02/25/08 13:53 Read: times |
#151404 - A bit easier to read? Responding to: ???'s previous message |
A little whitespace goes a long way:
#include <reg52.h>
#define MAX_LINES 3
#define MAXCHARS_ON_LINE 10
#define CHAR_MASK 0xBF
#define high 1
#define low 0
sbit clear = P3^0;
sbit write = P3^1;
#define uint unsigned int
#define uchar unsigned char
void msec(uint x)
{ uchar j;
while (x-->0)
{ for(j=0;j<125;j++);
}
}
void code clear_display()
{ clear=high;
clear=low;
clear=high;}
void code write_enable()
{write=high;
write=low;
write=high;}
void code word_delay()
{msec(3500);}
unsigned char code *phrases2[] = {
"Short", "Medium", "Very long" };
void put_phrase( unsigned char line_no )
{
while (*phrases2[line_no] != 0x00)
{
P0 = *phrases2[line_no];
++phrases2[line_no];
write_enable();
}
}
void main( void )
{
clear_display();
for(;;)
{
unsigned char line_no;
for ( line_no = 0; line_no < MAX_LINES; line_no++ )
{
put_phrase( line_no );
word_delay();
clear_display();
}
}
}
Still requires MAX_LINES to be manually updated - see: http://www.8052.com/forum/read.phtml?id=151340 http://www.8052.com/forum/read.phtml?id=151341 And there's the issue of phrase lengths - see: http://www.8052.com/forum/read.phtml?id=151327 Still needs some consistency in the placing of the braces... |



