/* 
 * ornament.c
 *
 * Display strings on a 5x7 dot matrix (Kingbright TA07-11HWA)
 * led display
 * (c) 2007/12/07 OE1GCA
 * oe1gca@aol.com
 * http://sprint.homelinux.net/ornament.html
 */

/* HW description:
 * µController: ATMEL AT89Cx051
 * Compiler: SDCC 2.5.0
 * Display: Kingbright TA07-11HWA, common anode
 * Xtal: 12MHz
 * 470R pullups on P3 required!
 */

/* port assignments */
/* P1.6..P1.0 cols
 * P3.4..P3.0 rows
 */

#include <at89x051.h>
#include <string.h>
#include "chargen.h"

unsigned char c=' ';	/* this is the display buffer */
volatile unsigned int t0=0;	/* this is the timer */
//const unsigned char txt[] = { "MERRY XMAS AND A HAPPY NEW YEAR  OE1GCA@AOL.COM "};
const unsigned char txt[] = { "FROHE WEIHNACHTEN UND PROSIT 2008  OE1GCA@AOL.COM  HTTP://SPRINT.HOMELINUX.NET/ORNAMENT.HTML "};

/************************************************************************/
/*                Timer 0 interrupt service function			*/
/*                executes each 128us @ 12 MHz Crystal Clock		*/
/************************************************************************/
void timer0() interrupt 1 using 0 {  /* Int Vector at 000BH, Reg Bank 0  */
static unsigned char col;
	
	col++;
	if (col>6)
		col = 0;
	P3 = 0;
	P1 = ~(1<<col);
	P3 = chargen[c-32][col];	/* sub 0x20 */
	if (t0)
		t0--;
}


void main (void) {
unsigned int x;
unsigned int l;
	
	/* setup Timer/Counter 0 */
        TMOD = 0x32;            /* setup ... */
	TH0 = 0x7F;		/* reload value */
	TR0 = 1;                /* enable counter 0             */
	ET0 = 1;                /* enable timer 0 interrupt     */
	EA  = 1;                /* global interrupt enable      */

	l = strlen ( &txt[0] );
	while (1) {
		for (x=0; x<=l; x++) {
			c = txt[x];
			t0 = 4500;
			while (t0);
			c = ' ';
			t0 = 450; 
			while (t0);
		}
	}
}
