int main(void) { uint8_t state = 0; init(); while(1) { state++; clear_frame_buffer(); set_pixel( state % 64, 2, 1 ); shift_pixel_data(); _delay_ms(500); } }
int main (void) { // Sync with the monitor. mk_mon_sync(); TIME t1,t2,diff; // Enable stack checking. start_stack_check(); clear_frame_buffer(); t1 = hw_tifu_systimer_get(); /*Initalize the C-Heap communication*/ /* FBlock is used as token for communication between Core1 & Core2 */ unsigned int token_size = sizeof(FBlock); /* FIFO can store 6 tokens. */ unsigned int fifo_size = 1; /*Init FiFo*/ cheap_init_fifo(producer, consumer, token_size, fifo_size, (unsigned int)producer_data, (unsigned int) consumer_data, mb1_dma1_BASEADDR, mb1_cmemout1_BASEADDR, mb2_dma1_BASEADDR, mb2_cmemout1_BASEADDR); /* signal to core 2 that the FIFO is initialized and can be read from. */ *fifo_sync_data = 1; hw_dma_send_addr((void *)fifo_sync, (int*)fifo_sync_data, sizeof(int),(void *)mb1_dma1_BASEADDR); jpeg_dec_main(); t2 = hw_tifu_systimer_get(); diff = t2 - t1; mk_mon_debug_info(LO_64(diff)); mk_mon_debug_info(0XFDDE); // Signal the monitor we are done. mk_mon_debug_tile_finished(); return 0; }
void *key_controll_pthread_fun() { int keyboard_fd; char *keyboard_str = "/dev/input/by-path/platform-i8042-serio-0-event-kbd"; //int open(const char *pathname, int flags); //int open(const char *pathname, int flags, mode_t mode); //int creat(const char *pathname, mode_t mode); if((keyboard_fd = open(keyboard_str , O_RDONLY )) < 0) { fprintf( stderr , "open %s failed:%s\n" , keyboard_str , strerror(errno)); exit(1); } // fprintf( stdout , "open %s success\n" , keyboard_str ); #if 0 struct input_event { struct timeval time; __u16 type; __u16 code; __s32 value; }; #endif struct input_event i_event; int read_bytes; int auto_display = 0; int keep_reading = 1; clear_frame_buffer( fb ); first_show(); show_weather(fb , weather_info); while(keep_reading) { // fprintf(stdout , "1\n"); if((read_bytes = read(keyboard_fd , &i_event , sizeof(struct input_event))) < 0) { fprintf(stdout , "read from keyboard error:%s\n" , strerror(errno)); exit(1); } else { // press key if(EV_KEY == i_event.type) { // value == 1 means key DOWN however 2 means key UP if(i_event.value == 1) { //fprintf(stdout , "key DOWN value=%d\n" , i_event.value); switch(i_event.code) { case KEY_LEFT : change_global_keycode(&global_keycode , i_event.code); // clear_frame_buffer( fb ); // pthread_cancel(auto_display_pthread); show_privious(); // show_weather(fb , weather_info); break; case KEY_RIGHT: change_global_keycode(&global_keycode , i_event.code); // clear_frame_buffer( fb ); // pthread_cancel(auto_display_pthread); show_next(); // show_weather(fb , weather_info); break; case KEY_N: change_global_keycode(&global_keycode , i_event.code); pthread_cancel(music_pthread); system("killall -9 madplay"); // pthread_mutex_lock(&music_mutex); next_music(); if(auto_display == 0) { // pthread_mutex_lock(&music_mutex); clear_frame_buffer( fb ); first_show(); show_weather(fb , weather_info); // pthread_mutex_lock(&music_mutex); } break; case KEY_P: change_global_keycode(&global_keycode , i_event.code); pthread_cancel(music_pthread); system("killall -9 madplay"); //int pthread_mutex_lock(pthread_mutex_t *mutex); // pthread_mutex_lock(&music_mutex); privious_music(); if(auto_display == 0) { // pthread_mutex_lock(&music_mutex); clear_frame_buffer( fb ); first_show(); show_weather(fb , weather_info); // pthread_mutex_lock(&music_mutex); } break; case KEY_SPACE: if(auto_display == 0) { auto_display = 1; auto_display_pthread = start_auto_display_pthread(); } else { auto_display = 0; pthread_cancel(auto_display_pthread); clear_frame_buffer( fb ); first_show(); show_weather(fb , weather_info); } break; case KEY_Q: change_global_keycode(&global_keycode , i_event.code); pthread_cancel(auto_display_pthread); pthread_cancel(music_pthread); system("killall -9 madplay"); goto END; } } #if 0 else if(i_event.value == 0) { fprintf(stdout , "key UP value=%d\n" , i_event.value); } else { fprintf(stdout , "do not know value=%d\n" , i_event.value); } #endif } } } END: fprintf(stdout ,"key_controll_pthread exit : %s\n" , __func__); //int close(int fd); close(keyboard_fd); //void pthread_exit(void *value_ptr); pthread_exit(NULL); }
/*----------------------------------------------------------------------- tiga_set_rast Clears the display to a given color. -----------------------------------------------------------------------*/ void tiga_set_rast(tigaRast *r, Pixel color) { clear_frame_buffer(color); /* Clear the whole frame buffer */ return; }