void pulse(char line, int speed) { int x; for (x = 0; x < 10000; x+=speed) { line_on(line); delay_us(x + 100); line_off(line); delay_us(10000 - x); } for (x = 0; x < 10000; x+=speed) { line_on(line); delay_us(10100 - x); line_off(line); delay_us(x + 100); } }
void cycle(int speed) { int x; if (speed > 32000) speed = 32000; for (x = 65; x < 72; x++) { line_on(x); delay_us(32100 - speed); } for (x = 72; x >= 65; x--) { line_on(x); delay_us(32100 - speed); } line_off('B'); delay_us(32100 - speed); line_off('A'); }
void line_on(char line)//send 'A' through 'H' { char temp; if (line_on_2 != 0) line_off(line_on_2);//can't have more than one line on at a time //keep track of what's on and in what sequence line_on_2 = line_on_1; line_on_1 = line; temp = line - 65; if (temp < 6) DDRC |= (1<<temp); else DDRB |= (1<<(temp-6)); }
/* Efface un triangle dont les sommets sont les points (x1, y1), (x2, y2) et (x3, y3) */ void SuppTriangle(int x1, int y1, int x2, int y2, int x3, int y3) { line_off(fenetreCourante, x1, y1, x2, y2); line_off(fenetreCourante, x2, y2, x3, y3); line_off(fenetreCourante, x3, y3, x1, y1); }
/* Efface une ligne entre les points (x1, y1) et (x2, y2) */ void SuppLigne(int x1, int y1, int x2, int y2) { line_off(fenetreCourante, x1, y1, x2, y2); }
int main (void) { int x; ioinit(); //Setup IO pins and defaults delay_ms(5000); while(1) { for (x = 0; x < 4; x++) { pulse('A',125); delay_ms(100); } for (x = 10000; x < 25000; x+=1000) { cycle(x); } for (x = 25000; x < 32000; x+=200) { cycle(x); } for (x = 0; x < 1600; x++) { cycle(32000); } for (x = 0; x < 15; x++) { line_on('F'); delay_ms(20); line_on('B'); delay_ms(20); line_on('H'); delay_ms(20); line_on('E'); delay_ms(20); line_on('C'); delay_ms(20); line_on('A'); delay_ms(20); line_on('D'); delay_ms(20); line_on('G'); delay_ms(20); } line_off('D'); line_off('G'); for (x = 0; x < 4; x++) { pulse('A',250); delay_ms(100); } delay_ms(1000); } }