void winner_blink(__u8 player, int time) { printf("winner time: %d\n",time); // turn on if (blink) { printf(" blink on"); blink = 0; draw_time(time, GREEN); redraw(); if (player == P1) draw_score_p1(5); else draw_score_p2(5); } //turn off else { printf("blink off"); blink = 1; clear_time(); redraw(); if (player == P1) clear_score_p1(); else clear_score_p2(); } redraw(); }
void draw_time_board() { glPushMatrix(); glTranslatef(1000, 770 - 36 - 20, 0); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(0, 0); glVertex2f(150, 0); glVertex2f(150, 36); glVertex2f(0, 36); glEnd(); glLineWidth(5); glColor3f(0,0,1); glBegin(GL_LINE_STRIP); glVertex2f(0, 0); glVertex2f(150, 0); glVertex2f(150,36); glVertex2f(0, 36); glVertex2f(0,0); glEnd(); glLineWidth(1); glColor3f(1,0.98,0); glPushMatrix(); glTranslatef(8,8,0); glScalef(0.2,0.2,1); draw_time(count*50); glPopMatrix(); glPopMatrix(); }
void fdhand_draw_now (cairo_t *cr, double width, double height, int seconds) { struct timeval tv; gettimeofday (&tv, NULL); draw_time (cr, width, height, &tv, seconds); }
void TimeBar::update(int flush) { draw_time(); // Need to redo these when range is drawn to get the background updated. update_labels(); update_points(); EDL *edl = get_edl(); int64_t pixel = -1; // Draw highlight position if(edl && (highlighted || current_operation == TIMEBAR_DRAG) && get_cursor_x() >= 0 && get_cursor_y() < get_w()) { //printf("TimeBar::update %d %d\n", __LINE__, get_cursor_x()); double position = pixel_to_position(get_cursor_x()); position = get_edl()->align_to_frame(position, 0); pixel = position_to_pixel(position); update_clock(position); } if(pixel < 0) { double position = test_highlight(); if(position >= 0) pixel = position_to_pixel(position); } if(pixel >= 0 && pixel < get_w()) { set_color(mwindow->theme->timebar_cursor_color); set_line_dashes(1); //printf("TimeBar::update %d pane=%d pixel=%jd\n", __LINE__, pane->number, pixel); draw_line(pixel, 0, pixel, get_h()); set_line_dashes(0); } if(edl) { int64_t pixel = position_to_pixel( edl->local_session->get_selectionstart(1)); // Draw insertion point position. set_color(mwindow->theme->timebar_cursor_color); draw_line(pixel, 0, pixel, get_h()); } update_highlights(); // Get the labels to show show_window(0); flash(flush); //printf("TimeBar::update %d this=%p %d\n", __LINE__, this, current_operation); }
void handle_minute_tick(struct tm* tick_time, TimeUnits units_changed) { // If the month or year changes, the day will change, too. if (units_changed & DAY_UNIT) { draw_dayofweek(tick_time); draw_date(tick_time); } draw_time(tick_time); }
static void main_layer_update_proc(Layer *layer, GContext *ctx) { draw_time(layer, ctx); if (show_battery) { draw_battery(layer, ctx); } if (show_timeline) { draw_timeline(layer, ctx); } }
// ------------------------------------------------------- void DrawHud (const CControl *ctrl) { if (!param.show_hud) return; ETR_DOUBLE speed = ctrl->cvel.Length(); SetupGuiDisplay (); //draw_gauge (speed * 3.6, ctrl->jump_amt); ScopedRenderMode rm(TEXFONT); draw_time(); draw_herring_count (g_game.herring); DrawSpeed (speed * 3.6); DrawFps (); DrawCoursePosition (ctrl); DrawWind (Wind.Angle (), Wind.Speed (), ctrl); }
// ------------------------------------------------------- void DrawHud (CControl *ctrl) { TVector3 vel; double speed; if (!param.show_hud) return; vel = ctrl->cvel; speed = NormVector (&vel); SetupGuiDisplay (); draw_gauge (speed * 3.6, ctrl->jump_amt); set_gl_options (TEXFONT); glColor4f (1, 1, 1, 1); draw_time(); draw_herring_count (g_game.herring); DrawSpeed (speed * 3.6); DrawFps (); DrawCoursePosition (ctrl); if (g_game.wind_id > 0) DrawWind2 (Wind.Angle (), Wind.Speed (), ctrl); }
static void mp3_do_draw() { GrSetGCForeground(mp3_gc, GR_RGB(255,255,255)); GrFillRect(mp3_wid, mp3_gc, 0, 0, screen_info.cols, screen_info.rows); GrSetGCForeground(mp3_gc, GR_RGB(0,0,0)); GrText(mp3_wid, mp3_gc, 8, 20, current_pos, -1, GR_TFASCII); GrText(mp3_wid, mp3_gc, 8, 34, current_title, -1, GR_TFASCII); GrText(mp3_wid, mp3_gc, 8, 48, current_artist, -1, GR_TFASCII); GrText(mp3_wid, mp3_gc, 8, 62, current_album, -1, GR_TFASCII); rect_x1 = 8; rect_x2 = screen_info.cols - 8; rect_y1 = screen_info.rows - (HEADER_TOPLINE + 1) - 18; rect_y2 = screen_info.rows - (HEADER_TOPLINE + 1) - 8; GrRect(mp3_wid, mp3_gc, rect_x1, rect_y1, rect_x2-rect_x1, rect_y2-rect_y1); rect_wait = 0; draw_time(); }
int main() { struct Timer fps; time_t current; struct tm *current_tm; struct Banner date_banner = { .string = date_string, .offset = 0 }; if (LCD_Init() != 0) { printf("Error initializing LCD\n"); return 1; } LCD_SetBacklight(1); for (;;) { timer_start(&fps); current = time(NULL); current_tm = localtime(¤t); string_print_date(date_string, current_tm); LCD_Clear(); draw_clock_frame(); draw_time(current_tm); update_banner(&date_banner); draw_banner(&date_banner, 0); draw_banner(&date_banner, 38); LCD_Display(); if (timer_get_msecs(&fps) < 1000 / FRAMES_PER_SECOND) { usleep(1000 * ( 1000 / FRAMES_PER_SECOND ) - timer_get_msecs(&fps)); } } return 0; }
void reset_terminal(void){ clear_terminal(); set_display_attribute(BAR_COLOUR); draw_horizontal_line(1,1,WIDTH); set_display_attribute(BAR_COLOUR); draw_vertical_line(40,1,HEIGHT); move_cursor(TITLE_X,TITLE_Y); printf_P(PSTR("FROGGER")); draw_lives(); draw_score(); draw_level(); draw_time(16); display_scores(); draw_status(0); draw_frog(); set_display_attribute(8); }
void DataCheck::DisplayCRC(aui_Surface *surf) const { sint32 x=100, y=80, d=16; if (!m_is_display) return ; if(m_is_display > 1) { draw_crc(surf, "DB", CRC_TYPE_DB, x, y); y+=d; draw_crc(surf, "PROFILE", CRC_TYPE_PROFILE_DB, x, y); y+=d; draw_crc(surf, "STRING", CRC_TYPE_STRING_DB, x, y); y+=d; draw_crc(surf, "ADVANCE", CRC_TYPE_ADVANCE_DB, x, y); y+=d; draw_crc(surf, "ADVANCE_BRANCH", CRC_TYPE_ADVANCE_BRANCH_DB, x, y); y+=d; draw_crc(surf, "ADVANCE_LIST", CRC_TYPE_ADVANCE_LIST_DB, x, y); y+=d; draw_crc(surf, "AGE", CRC_TYPE_AGE_DB, x, y); y+=d; draw_crc(surf, "AGE_CITY_STYLE", CRC_TYPE_AGE_CITY_STYLE_DB, x, y); y+=d; draw_crc(surf, "BUILD_LIST_SEQUENCE", CRC_TYPE_BUILD_LIST_SEQUENCE_DB, x, y); y+=d; draw_crc(surf, "BUILDING", CRC_TYPE_BUILDING_DB, x, y); y+=d; draw_crc(surf, "BUILDING_BUILD_LIST", CRC_TYPE_BUILDING_BUILD_LIST_DB, x, y); y+=d; draw_crc(surf, "CITY_SIZE", CRC_TYPE_CITY_SIZE_DB, x, y); y+=d; draw_crc(surf, "CITY_STYLE", CRC_TYPE_CITY_STYLE_DB, x, y); y+=d; draw_crc(surf, "CIVILISATION", CRC_TYPE_CIVILISATION_DB, x, y); y+=d; draw_crc(surf, "CONST", CRC_TYPE_CONST_DB, x, y); y+=d; draw_crc(surf, "DIFFICULTY", CRC_TYPE_DIFFICULTY_DB, x, y); y+=d; draw_crc(surf, "DIPLOMACY", CRC_TYPE_DIPLOMACY_DB, x, y); y+=d; draw_crc(surf, "DIPLOMACY_PROPOSAL", CRC_TYPE_DIPLOMACY_PROPOSAL_DB, x, y); y+=d; draw_crc(surf, "DIPLOMACY_THREAT", CRC_TYPE_DIPLOMACY_THREAT_DB, x, y); y+=d; draw_crc(surf, "END_GAME_OBJECT", CRC_TYPE_END_GAME_OBJECT_DB, x, y); y+=d; draw_crc(surf, "FEAT", CRC_TYPE_FEAT_DB, x, y); y+=d; draw_crc(surf, "GLOBAL_WARMING", CRC_TYPE_GLOBAL_WARMING_DB, x, y); y+=d; draw_crc(surf, "GOAL", CRC_TYPE_GOAL_DB, x, y); y+=d; draw_crc(surf, "GOVERNMENT", CRC_TYPE_GOVERNMENT_DB, x, y); y+=d; draw_crc(surf, "ICON", CRC_TYPE_ICON_DB, x, y); y+=d; draw_crc(surf, "IMPROVEMENT_LIST", CRC_TYPE_IMPROVEMENT_LIST_DB, x, y); y+=d; draw_crc(surf, "ORDER", CRC_TYPE_ORDER_DB, x, y); y+=d; draw_crc(surf, "OZONE", CRC_TYPE_OZONE_DB, x, y); y+=d; draw_crc(surf, "PERSONALITY", CRC_TYPE_PERSONALITY_DB, x, y); y+=d; draw_crc(surf, "POLLUTION", CRC_TYPE_POLLUTION_DB, x, y); y+=d; draw_crc(surf, "POP", CRC_TYPE_POPULATION_DB, x, y); y+=d; draw_crc(surf, "RESOURCE", CRC_TYPE_RESOURCE_DB, x, y); y+=d; draw_crc(surf, "RISK", CRC_TYPE_RISK_DB, x, y); y+=d; draw_crc(surf, "SOUND", CRC_TYPE_SOUND_DB, x, y); y+=d; draw_crc(surf, "SPECIAL_ATTACK_INFO", CRC_TYPE_SPECIAL_ATTACK_INFO_DB, x, y); y+=d; draw_crc(surf, "SPECIAL_EFFECT", CRC_TYPE_SPECIAL_EFFECT_DB, x, y); y+=d; draw_crc(surf, "SPRITE", CRC_TYPE_SPRITE_DB, x, y); y+=d; draw_crc(surf, "STRATEGY", CRC_TYPE_STRATEGY_DB, x, y); y+=d; draw_crc(surf, "TERRAIN", CRC_TYPE_TERRAIN_DB, x, y); y+=d; draw_crc(surf, "UNIT", CRC_TYPE_UNIT_DB, x, y); y+=d; draw_crc(surf, "UNIT_BUILD_LIST", CRC_TYPE_UNIT_BUILD_LIST_DB, x, y); y+=d; draw_crc(surf, "WONDER", CRC_TYPE_WONDER_DB, x, y); y+=d; draw_crc(surf, "WONDER_BUILD_LIST", CRC_TYPE_WONDER_BUILD_LIST_DB, x, y); y+=25; } x+=300; draw_crc(surf, "GLOBAL", CRC_TYPE_GLOBAL, x, y); y+=d; draw_crc(surf, "RAND", CRC_TYPE_RAND, x, y); y+=d; draw_crc(surf, "AGREEMENT_POOL", CRC_TYPE_AGREEMENTPOOL, x, y); y+=d; draw_crc(surf, "CIVILISATION_POOL", CRC_TYPE_CIVILISATIONPOOL, x, y); y+=d; draw_crc(surf, "DIPLOMACY_REQUEST_POOL", CRC_TYPE_DIPLOMATICREQUESTPOOL, x, y); y+=d; draw_crc(surf, "TERRAINIMPROVEMENT_POOL", CRC_TYPE_TERRAIN_IMPROVEMENT_POOL, x, y); y+=d; draw_crc(surf, "MESSAGE_POOL", CRC_TYPE_MESSAGEPOOL, x, y); y+=d; draw_crc(surf, "TERRAIN_IMPROVEMENT_POOL", CRC_TYPE_TERRAIN_IMPROVEMENT_POOL, x, y); y+=d; draw_crc(surf, "TRADE_POOL", CRC_TYPE_TRADEPOOL, x, y); y+=d; draw_crc(surf, "TRADEOFFER_POOL", CRC_TYPE_TRADEOFFERPOOL, x, y); y+=d; draw_crc(surf, "UNIT_POOL", CRC_TYPE_UNITPOOL, x, y); y+=d; draw_crc(surf, "POLLUTION", CRC_TYPE_POLLUTION, x, y); y+=d; draw_crc(surf, "SELECTED", CRC_TYPE_SELECTED_ITEM, x, y); y+=d; draw_crc(surf, "TOPTEN", CRC_TYPE_TOPTEN, x, y); y+=d; draw_crc(surf, "WORLD", CRC_TYPE_WORLD, x, y); y+=d; draw_crc(surf, "PLAYER", CRC_TYPE_PLAYER, x, y); y+=d; draw_time(surf, x, y); }
int main(int argc, char *argv[]) { char c; int status = 0; printf("Hello World, I'm game!\n"); status = init_display(); if (status != 0) { printf("Error: Failed to init display\n"); return status; } status = init_driver(); if (status != 0) { printf("Error: Failed to init driver\n"); destroy_display(); return status; } status = setup_handler(); if (status != 0) { printf("Error: Failed to init signal handler\n"); destroy_display(); close(file_gamepad_driver); return status; } time_handler(); /* Intializes random number generator */ srand((unsigned) time(&t)); sigset_t myset; (void) sigemptyset(&myset); while(1) { clear_LCD(); draw_game(); draw_score(p1_score, p2_score); redraw(); waitForButton(); printf("start game\n"); while((p1_score < 5) && (p2_score < 5)) { random_timer = (rand() % 3) + 2; startTimer(random_timer); waitForTimer(); random_button = (rand() % 4); draw_button(random_button, true, RED); redraw(); gettimeofday(&time_button_appears, NULL); // start timer startTimer(3); buf = 0; while((playerButtonPressed(random_button) == 0) && (timer_expired == false)) { waitForButton(); } stopTimer(); if (timer_expired == false) { time_elapsed = getGameTime(); draw_time(time_elapsed, BLUE); redraw(); } if (playerButtonPressed(random_button) == P1) { p1_score++; p1_time += time_elapsed; } else if (playerButtonPressed(random_button) == P2) { p2_score++; p2_time += time_elapsed; } draw_score(p1_score, p2_score); reset_button(random_button); redraw(); } // draw winner button_pressed = 0; if (p1_score == 5) { winner = P1; winner_time = p1_time; } else if (p2_score == 5) { winner = P2; winner_time = p2_time; } while(button_pressed == 0) { startTimer(1); winner_blink(winner, winner_time); waitForTimer(); } // print waiting waitForButton(); p1_score = 0; p1_time = 0; p2_score = 0; p2_time = 0; } }
void schedule_application() { unsigned long now = rtc_get_time(); if (now < 1445990399) { // day 1 } else if (now > 1445990399 && now < 1446076799) { // day 2 } else if (now > 1446076799 && now < 1446163199) { // day 3 } else { // day 4 } uint16_t max_event[] = {5, 26, 25, 18, 26, 13}; //write_data(); //gfx_draw_filled_rect(0, 0, gfx_get_width(), gfx_get_height(), GFX_COLOR_BLACK); draw_background(); //gfx_draw_filled_rect(0, 0, 320, 182, GFX_COLOR(20, 20, 20)); draw_time(); // gfx_draw_string_aligned("Schedule - Keynotes", 11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); // gfx_draw_string_aligned("Schedule - Track 1", 11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); // gfx_draw_string_aligned("Schedule - Track 2", 11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); // gfx_draw_string_aligned("Schedule - Track 3", 11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); // gfx_draw_string_aligned("Schedule - Track 4", 11, 2, &sysfont, GFX_COLOR_BLACK, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); event_index = 0; event_track = 0; draw_event(); // Presentors // Location and time // Description struct keyboard_event input; while(mma8451_orientation() != 6) { esp8266_check_buffer(); keyboard_get_key_state(&input); if (input.type == KEYBOARD_RELEASE) { if (input.keycode == KEYBOARD_B) { break; } else if (input.keycode == KEYBOARD_A) { } else if (input.keycode == KEYBOARD_UP) { event_index--; if (event_index < 0) { event_index = 0; } draw_event(); } else if (input.keycode == KEYBOARD_DOWN) { event_index++; if (event_index > max_event[event_track]) { event_index = max_event[event_track]; } draw_event(); } else if (input.keycode == KEYBOARD_RIGHT) { event_index = 0; event_track++; if (event_track > 5) { event_track = 0; } draw_event(); } else if (input.keycode == KEYBOARD_LEFT) { event_index = 0; event_track--; if (event_track < 0) { event_track = 5; } draw_event(); } } if(mma8451_clear_interrupt() && is_low_power()) { exit_low_power(); } } }
void draw_event() { draw_background(); draw_time(); gfx_draw_filled_rect(5, 26, 310, 182, GFX_COLOR(8, 8, 8)); draw_button_hints(); switch(event_track) { case 0: gfx_draw_string_aligned("Schedule - KEYNOTES", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 1: gfx_draw_string_aligned("Schedule - TRACK 1", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 2: gfx_draw_string_aligned("Schedule - TRACK 2", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 3: gfx_draw_string_aligned("Schedule - TRACK 3", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 4: gfx_draw_string_aligned("Schedule - TRACK 4", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 5: gfx_draw_string_aligned("Schedule - TRACK 5", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; } uint16_t keynote = 0x0100; uint16_t track1 = 0x0200; uint16_t track2 = 0x0300; uint16_t track3 = 0x0400; uint16_t track4 = 0x0500; uint16_t track5 = 0x0600; uint16_t addresses[] = {keynote, track1, track2, track3, track4, track5}; //uint16_t max_event[] = {5, 22, 22, 15, 23}; uint8_t ram_buf[AT45DBX_SECTOR_SIZE]; at45dbx_read_sector_open(addresses[event_track] + event_index); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); char *array[6]; uint8_t i = 0; array[i] = strtok(ram_buf,";"); while(array[i] != NULL) { array[++i] = strtok(NULL, ";"); } char *title[256]; uint8_t a = word_wrap(&title, array[0], 30); gfx_draw_string_aligned(title, 11, 27, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); char event_time[36]; snprintf(event_time, sizeof(event_time),"%s - %s", array[1], array[2]); char *names[256]; uint8_t n = word_wrap(&names, array[3], 33); gfx_draw_string_aligned(names, 11, 60+(a*20), &small_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_RED, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); gfx_draw_string_aligned(array[4], 11, 85+(a*20)+(n*20), &tiny_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); gfx_draw_string_aligned(event_time, 11, 100+(a*20)+(n*20), &tiny_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); // } }
void drawBigHour(struct tm* t, GContext* ctx) { draw_date(t, ctx); draw_time(t, ctx); }
//------------------------------------------------------------------------------ // MAIN //------------------------------------------------------------------------------ int main(void) { DDRC = 0x0F; DDRD = 0xF0; DDRB = 0x03 + (1 << 2) + (1 << 3) + (1 << 4); PORTD |= (1 << 2); // f�r Pullup SFIOR &= (1 << PUD); // Timer 2 mit externem 32kHz Quarz betreiben ASSR |= (1 << AS2); TCCR2 = (1 << CS22) + (1 << CS20); // /128 f�r 1Hz Int // Timer 1 f�r LED INT mit ca. 1,2kHz TCCR1A = 0; TCCR1B = (1 << WGM12) + (1 << CS10); OCR1A = 6667; // Timer Interrupts TIMSK = (1 << OCIE1A) + (1 << TOIE2); // set interrupt mask uart_init(); uart_puts_p( "\r\nWordClock V1.0.0, Dez.2009 Martin Steppuhn (www.emsystech.de)\r\n"); hour = 0; minute = 0; second = 0; sei(); // Interrupt ein while (1) { if (sec_flag) //=== 1 Sekunde === { sec_flag = false; if (BUTTON) { time_setup_cnt1++; if (time_setup_cnt1 > 3) { switch (e_SetupState) { case Idle: e_SetupState = StartHour; break; case InputHour: e_SetupState = StartMinute; break; case InputMinute: e_SetupState = Idle; break; case StartHour: case StartMinute: break; } } } else { time_setup_cnt0++; if (time_setup_cnt0 > 5) { e_SetupState = Idle; } } draw_time(); } if (key_flag) //=== 10ms === { key_flag = false; if (!BUTTON && button_mem) // falling Edge { button_mem = false; switch (e_SetupState) { case Idle: break; case StartHour: e_SetupState = InputHour; break; case StartMinute: e_SetupState = InputMinute; break; case InputHour: hour = (hour < 11) ? hour + 1 : 0; break; case InputMinute: minute = (minute < 59) ? minute + 1 : 0; break; } } if (BUTTON) { button_mem = true; time_setup_cnt0 = 0; } else { time_setup_cnt1 = 0; } draw_time(); } // if(uart_kbhit()) { c = uart_getc(); uart_putc(c); } } }