#include #include "scan_led.h" #include "screens.h" #include "scroll_text.h" #include unsigned char r, c, color,c_on,intensity; const unsigned char test_scroll[8][36] = { {c_r,c_r,c_r,c_r,c_r,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_r,c_r,c_r,c_r,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_r,c_r,c_r,c_r,c_b,c_r,c_b,c_b,c_b,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_r,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_b,c_r,c_r,c_b,c_r,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_r,c_b,c_r,c_b,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_r,c_b,c_b,c_b,c_b,c_r,c_r,c_r,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_r,c_b,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_r,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_b,c_r,c_r,c_r,c_r,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_r,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b}, {c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_b,c_b,c_r,c_b,c_r,c_r,c_r,c_r,c_r,c_b,c_b,c_b,c_b,c_b,c_b,c_b,c_r,c_r,c_r,c_r,c_r,c_b,c_r,c_b,c_b,c_b,c_r,c_b}}; unsigned char simple_colors[8][3] = { {0,0,0}, {TOTAL,0,0}, {TOTAL,10,0}, {TOTAL,50,0}, {0,TOTAL,0}, {0,0,TOTAL}, {TOTAL,0,TOTAL-30}, {TOTAL,TOTAL,TOTAL-30}}; void initio() { DDRA = 0xFF; DDRB = 0xFF; DDRC = 0xFF; DDRD = 0xFF; turn_off(); } void turn_off(){ PORTA = 0x00; //row select (all off) PORTB = 0x00; //red PORTC = 0x00; //green PORTD = 0x00; //blue } //this will START the timer void init_timer0() { r=0; c=0; color=0; c_on=0; TCCR0 = 0x0A; TIMSK |= 0x01; TCNT0 = 0x00; set_next_color(); } /* void set_cur_screen(unsigned char** screen){ cur_screen=screen; } */ void set_next_color(){ unsigned char col,actual_column; color++; if(color == 3){ color=0; c++; if(c == 8){ c=0; r++; if(r == 8){ r=0; } } } actual_column = get_start_col() + c; if(actual_column >= COLS){ actual_column -= COLS; } col=test_scroll[r][actual_column]; intensity=simple_colors[col][color]; PORTA=(0x80 >> r); if(intensity > 0){ switch(color){ case 0: PORTB=(0x80 >> c); break; case 1: PORTC=(0x80 >> c); break; case 2: PORTD=(0x80 >> c); break; } c_on = 1; TCNT0=0x00; OCR0 = intensity; } else { c_on = 0; TCNT0=0x00; OCR0 = TOTAL; } } ISR(TIMER0_COMP_vect){ if(c_on == 1){ turn_off(); c_on=0; if(TOTAL > intensity){ TCNT0=0x00; OCR0=TOTAL-intensity; } else { set_next_color(); } } else { set_next_color(); } }