int main(void) { printf("init rotenc\n"); rotenc_init(ROTENC_PIN_0, ROTENC_PIN_1, ROTENC_PIN_BTN, &rotenc); printf("init ht1632c\n"); ht1632c_init(NUM_PANELS, PANEL_ROTATION); ht1632c_pwm(7); int color = GREEN; for(int i=0;i<480;i++) { int j = (i + 1) % 160; if(j == 0) color ++; ht1632c_clear(); ht1632c_putstr(32-j, 0, "Hello there", &font_12x16, color, TRANSPARENT); ht1632c_sendframe(); usleep(50000); } printf("all led's in black and end\n"); ht1632c_box(0, 0, WIDTH - 1, HEIGHT - 1, BLACK); ht1632c_sendframe(); ht1632c_close(); printf("done.\n"); }
int main(void) { printf("init rotenc\n"); rotenc_init(ROTENC_PIN_0, ROTENC_PIN_1, ROTENC_PIN_BTN, &rotenc); printf("init ht1632c\n"); ht1632c_init(NUM_PANELS, PANEL_ROTATION); ht1632c_pwm(7); ht1632c_clear(); ht1632c_line(8, 0, 8, HEIGHT-1, GREEN); ht1632c_line(8, 0, 23, 0, GREEN); ht1632c_line(23, 0, 23, HEIGHT-1, GREEN); ht1632c_line(8, HEIGHT-1, 23, HEIGHT-1, GREEN); ht1632c_box(9, 1, 15, 7, RED); ht1632c_box(16, 8, 22, 14, RED); ht1632c_sendframe(); sleep(5); printf("all led's in black and end\n"); ht1632c_box(0, 0, WIDTH - 1, HEIGHT - 1, BLACK); ht1632c_sendframe(); ht1632c_close(); printf("done.\n"); }
//main code int main(void) { //init stuff //init the ht1632c LED matrix driver chip ht1632c_init(); //init the ADC init_ADC(); //init srand() with a somewhat random number from ADC9's low bits init_srand(); //init button stuff for input and pullup //and setup INT0 for button if you set DO_YOU_WANT_BUTTON_INT0 init_button(); //init timer1 for use in triggering an interrupt //on overflow, which updates the display and calculates new generation. init_timer1(); //init the I/O for the 7 segment display control init_digit_pins(); init_segment_pins(); //reset the display with a "random" array using rand() reset_grid(); //test glider //fb[29] = 0b00100000; //fb[30] = 0b00101000; //fb[31] = 0b00110000; //variable to store generation_count for display on 7 segment displays uint16_t g_count=0; //enable global interrupts sei(); //infinite loop while(1){ //check if the update generation count flag has been set //by within the timer1 overflow interrupt. //if set put the updated value into g_count and reset the flag. if(update_gen_flag){ g_count = generation_count; update_gen_flag=0; } write_number(g_count); //write the g_count to 7 segment displays //write_number(generation_count); //if the seven_seg_error flag is set (output is over 999 for 3 digits) //then reset the grid if(seven_seg_error_flag){ reset_grid(); } } }
/* // - LEDArrayInit() // - Sets up the timer, and configures // - the ports to drive the display. // - Returns - nothing */ void LEDArrayInit() { // Setup the timer // Timer0 CK/1024 TCCR0 = (1<<CS02) | (1<<CS00); TIMSK = (1<<TOIE0); // Initialize the HT1632C Driver chip ht1632c_init(); }
int main(void) { printf("init rotenc\n"); rotenc_init(ROTENC_PIN_0, ROTENC_PIN_1, ROTENC_PIN_BTN, &rotenc); printf("init ht1632c\n"); ht1632c_init(NUM_PANELS, PANEL_ROTATION); ht1632c_pwm(7); printf("all led's in red\n"); ht1632c_box(0, 0, WIDTH - 1, HEIGHT - 1, RED); ht1632c_sendframe(); printf("sleeping a while\n"); sleep(3); printf("all led's in green\n"); ht1632c_box(0, 0, WIDTH - 1, HEIGHT - 1, GREEN); ht1632c_sendframe(); printf("sleeping a while\n"); sleep(3); printf("all led's in orange\n"); ht1632c_box(0, 0, WIDTH - 1, HEIGHT - 1, ORANGE); ht1632c_sendframe(); printf("sleeping a while\n"); sleep(3); printf("all led's in black and end\n"); ht1632c_box(0, 0, WIDTH - 1, HEIGHT - 1, BLACK); ht1632c_sendframe(); ht1632c_close(); printf("done.\n"); }