int main(void) { Ttime j; Ttime time[M]; Ttime dur; Ttime smal; int i = 0; printf("How many times you have? "); scanf("%d", &j); for(i = 0; i<j; i++) { printf("Give the time %d (hh mm)? ", i+1); read_time(&time[i]); } smal = smallest(time, j); //printf("%d" , smal); //display_time(&smal); printf("Result list:\n"); for(i = 0; i<j; i++) { time_diff(&smal, &time[i], &dur); display_time(&time[i]); printf(" "); display_time(&dur); printf("\n"); } return 0; }
int main(void) { fd_set readfds; struct timeval timeout; int ret; FD_ZERO(&readfds); FD_SET(0,&readfds); while(1) { timeout.tv_sec=10; timeout.tv_usec=0; display_time("before select"); ret=select(1,&readfds,NULL,NULL,&timeout); display_time("after select"); switch(ret) { case 0:printf("there are no data!\n"); exit(1); break; case -1:perror("select"); exit(1); break; default:getchar(); printf("Data is available now.\n"); } } return 0; }
int main( void ) { fd_set readfds; struct timeval timeout; int ret; //监视文件描述符0是否有输入,文件描述符0表示输入,即键盘输入 FD_ZERO( &readfds ); FD_SET( 0 , &readfds ); //设置阻塞时间为10秒 timeout.tv_sec = 10 ; timeout.tv_usec = 0 ; while( 1 ){ display_time("before select"); ret = select( 1 , &readfds , NULL , NULL , &timeout ); display_time("after select"); switch( ret ){ case 0 : printf("No data in ten seconds.\n"); exit( 0 ); break; case -1 : perror( "select" ); break; default: getchar(); printf("Data is avaliable now.\n"); } } return 0; }
static void display_domain_info(struct netr_DELTA_DOMAIN *r) { time_t u_logout; struct netr_AcctLockStr *lockstr = NULL; NTSTATUS status; TALLOC_CTX *mem_ctx = talloc_tos(); status = pull_netr_AcctLockStr(mem_ctx, &r->account_lockout, &lockstr); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to pull account lockout string: %s\n", nt_errstr(status)); } u_logout = uint64s_nt_time_to_unix_abs((const uint64 *)&r->force_logoff_time); d_printf("Domain name: %s\n", r->domain_name.string); d_printf("Minimal Password Length: %d\n", r->min_password_length); d_printf("Password History Length: %d\n", r->password_history_length); d_printf("Force Logoff: %d\n", (int)u_logout); d_printf("Max Password Age: %s\n", display_time(r->max_password_age)); d_printf("Min Password Age: %s\n", display_time(r->min_password_age)); if (lockstr) { d_printf("Lockout Time: %s\n", display_time((NTTIME)lockstr->lockout_duration)); d_printf("Lockout Reset Time: %s\n", display_time((NTTIME)lockstr->reset_count)); d_printf("Bad Attempt Lockout: %d\n", lockstr->bad_attempt_lockout); } d_printf("User must logon to change password: %d\n", r->logon_to_chgpass); }
static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1) { printf("Minimum password length: %d\n", info1->min_length_password); printf("Password uniqueness (remember x passwords): %d\n", info1->password_history); printf("flag: "); if(info1->flag&&2==2) printf("users must open a session to change password "); printf("\n"); printf("password expire in: %s\n", display_time(info1->expire)); printf("Min password age (allow changing in x days): %s\n", display_time(info1->min_passwordage)); }
void loop() { while (1) { reset_screens(); display_time(&time1); display_time(&time2); display_time(&time3); display_time(&time4); update_clock(&cclock); sleep(60); } }
static void main_window_load(Window *window) { time_t now = time(NULL); struct tm *tick_time = localtime(&now); display_time(tick_time); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }
void RTC_IRQHandler(void) { // Check to see which counter has triggered if (RTC->IF & RTC_IF_COMP0) { // Within 10 seconds allows us to speed up the clock for testing if ((RTC->CNT - time_keeper.timer_start_seconds) < 10) { run_sprinkler(); RTC_CompareSet(0, time_keeper.timer_stop_seconds); } else { RTC_IntDisable(0); stop_sprinkler(); } RTC_IntClear(RTC_IFC_COMP0); } else // A minute update has occurred { if (RTC->CNT >= END_OF_DAY) { RTC->CNT = 0; } RTC_CompareSet(1, RTC->CNT + 60); RTC_IntClear(RTC_IFC_COMP1); display_hours = get_time(HOURS); display_minutes = get_time(MINUTES); display_time(display_hours, display_minutes); } }
static void timer_complete(){ //buzz, display, the whole nine running = false; text_layer_set_text(text_layer, "00:00"); vibrate(); display_time(); }
static void down_click_handler(ClickRecognizerRef recognizer, void *context) { if (remaining >= 500 * 60) { add_time(-500 * 60); } display_time(); }
/* clock_task: clock task */ void clock_task(void) { si_time next_time; /* local copies of the current time */ int alarm_hours, alarm_minutes, alarm_seconds, hours, minutes, seconds, enable; si_get_current_time(&next_time); /* infinite loop */ while (1) { /* increment time */ //printf("%d\n",1); increment_time(); /* read and display current time */ get_time(&hours, &minutes, &seconds, &enable); get_alarm_time(&alarm_hours, &alarm_minutes, &alarm_seconds); display_time(hours, minutes, seconds); if (enable && alarm_hours == hours && alarm_minutes == minutes && alarm_seconds == seconds) { enable_alarm(); } si_time_add_n_ms(&next_time,1000); /* wait one second */ si_wait_until_time(&next_time); } }
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) { (void)t; (void)ctx; display_time(t->tick_time); }
static void handle_second_tick(struct tm *tick_time, TimeUnits units_changed) { if (request_timezone_tries_left) { // If we don't already have a UTC offset, ask the phone for one. request_timezone(); } display_time(tick_time); }
void handle_timer(AppContextRef ctx, AppTimerHandle handle, uint32_t cookie) { (void)handle; if(cookie == TIMER_UPDATE) { if(started) { remaining_time -= 1; if (remaining_time == 0){ if (working_mode){ vibes_short_pulse(); } else{ vibes_double_pulse(); } start_timer(SHORT_TIMER_DELAY); }else{ if (remaining_time < 0){ if (working_mode){ reset_relax_count_down(); } else{ reset_work_count_down(); } }else{ display_time(); } start_timer(TIMER_DELAY); } } } }
int main() { InitData(); while(1) { ReadTimeAndJudgeAlarmArrival(); switch (mainLoop) { case 0: display_time(); break; case 1: display_data(); break; case 2: display_alarm(); break; case 3: display_sWatch(); break; } KeyScan(); } return 0; }
void handle_init() { // Configure window window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, BKGD_COLOR); window_set_fullscreen(window, true); Layer *window_layer = window_get_root_layer(window); // Dynamic allocation of assets minuteFrame = GRect(53, 16, 40, 40); minuteLayer = text_layer_create(minuteFrame); hourLayer = bitmap_layer_create(GRect(0, 0, 144, 148)); batteryLogoLayer = bitmap_layer_create(GRect(65, 151, 10, 15)); batteryPercentLayer = text_layer_create(GRect(78, 150, 30, 167-150)); dateLayer = text_layer_create(GRect(3, 150, 38, 167-150)); dayLayer = text_layer_create(GRect(141-30, 150, 30, 167-150)); text_layer_set_text_alignment(dayLayer, GTextAlignmentRight); bottomBarLayer = layer_create(GRect(1, 149, 142, 18)); // Setup minute layer text_layer_set_text_color(minuteLayer, TEXT_COLOR); text_layer_set_background_color(minuteLayer, GColorClear); text_layer_set_font(minuteLayer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MINUTE_38))); // Setup date & day layer text_layer_set_text_color(dateLayer, TEXT_COLOR); text_layer_set_background_color(dateLayer, GColorClear); text_layer_set_text_color(dayLayer, TEXT_COLOR); text_layer_set_background_color(dayLayer, GColorClear); // Setup battery layers text_layer_set_text_color(batteryPercentLayer, TEXT_COLOR); text_layer_set_background_color(batteryPercentLayer, GColorClear); // Setup line layer layer_set_update_proc(bottomBarLayer, bottom_bar_layer_update_callback); // Add layers into hierachy layer_add_child(bitmap_layer_get_layer(hourLayer), text_layer_get_layer(minuteLayer)); layer_add_child(window_layer, bitmap_layer_get_layer(hourLayer)); layer_add_child(window_layer, bottomBarLayer); layer_add_child(window_layer, bitmap_layer_get_layer(batteryLogoLayer)); layer_add_child(window_layer, text_layer_get_layer(batteryPercentLayer)); layer_add_child(window_layer, text_layer_get_layer(dateLayer)); layer_add_child(window_layer, text_layer_get_layer(dayLayer)); // Avoids a blank screen on watch start. time_t tick_time = time(NULL); display_time(localtime(&tick_time)); handle_battery(battery_state_service_peek()); handle_bluetooth(bluetooth_connection_service_peek()); tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick); battery_state_service_subscribe(&handle_battery); bluetooth_connection_service_subscribe(&handle_bluetooth); initialized = true; }
int handle_cmd_measurement_peak(uint8_t *buffer, short length) { unsigned int data; if(length != 5) return FAIL; display_time(); data = (*(buffer+4)<<16) | (*(buffer+3)<<8) | (*(buffer+2)); printf("CMD_MEAS_PEAK: %16u\n", data); return OK; }
static void show_time(struct tm *tick_time) { clock_time = tick_time; display_time(); if (tick_time->tm_min == 0 || !date_shown) { show_weeks(tick_time->tm_mon,tick_time->tm_mday,tick_time->tm_wday,tick_time->tm_year); date_shown = true; } }
static prg_t basic_prg(void) { char cnt = 0; for (;;) { if (HOUR || MINU) { if (!--d_s) { if (MINU) MINU--; else if (HOUR) { HOUR--; MINU = 59; } if (!MINU && !HOUR) next_timer(); if (!power[0]) return PRG_SHOW_STOP; d_s = 60*4; } } if ((MINU || HOUR) && cnt++ & 0x4) display_time(HOUR, MINU); else display_int(power[0]); switch (buttons_get()) { case BTN_UP: case BTN_UP_LONG: power_inc(0); cnt = 0; break; case BTN_DOWN: case BTN_DOWN_LONG: power_dec(0); cnt = 0; break; case BTN_BOTH: return PRG_SET_TIMER1; case BTN_IDLE: case BTN_UNDEFINED: case BTN_RESET: break; } sleep(); } }
int display_qvariant(char *buf) { char *orig_buf=buf; uint32_t type = *((uint32_t*)buf); type=ntohl(type); buf+=4; char null=*buf; buf++; if(null) { //Nothing to do } switch(type) { case 1: buf+=display_bool(buf); break; case 2: case 3: buf+=display_int(buf, type); break; case 7: //UTF16 byte buf+=display_short(buf); break; case 8: buf+=display_map(buf); break; case 9: buf+=display_list(buf); break; case 10: buf+=display_string(buf); break; case 11: buf+=display_stringlist(buf); break; case 12: buf+=display_bytearray(buf); break; case 15: buf+=display_time(buf); break; case 16: buf+=display_date(buf); break; case 127: //User type ! buf+=display_usertype(buf); break; case 133: buf+=display_short(buf); break; default: printf("Unknown QVariant type: %d\n", type); exit(-1); break; }; return buf-orig_buf; }
static void handle_init(void) { GRect dummy_frame = { {0, 0}, {0, 0} }; time_t t = time(NULL); struct tm *time = localtime(&t); window = window_create(); if (window == NULL) { APP_LOG(APP_LOG_LEVEL_DEBUG, "...couldn't allocate window memory..."); return; } window_set_fullscreen(window, true); window_stack_push(window, true /* Animated */); Layer *window_layer = window_get_root_layer(window); blockp_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLOCKP); blockp_layer = bitmap_layer_create(dummy_frame); bitmap_layer_set_bitmap(blockp_layer, blockp_image); window_set_click_config_provider(window, click_config_provider); strcpy(line1Str[0], ""); strcpy(line1Str[1], ""); strcpy(line2Str[0], ""); strcpy(line2Str[1], ""); strcpy(line3Str[0], ""); strcpy(line3Str[1], ""); // 1st line layers line1 = text_layer_create(GRect(0, 0, 144, 168)); configure_bold_layer(line1); // 2nd layers line2 = text_layer_create(GRect(0, 55, 144, 50)); configure_light_layer(line2); // 3rd layers line3 = text_layer_create(GRect(0, 110, 144, 50)); configure_light_layer(line3); splash_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SPLASH); splash_layer = bitmap_layer_create(dummy_frame); bitmap_layer_set_bitmap(splash_layer, splash_image); layer_add_child(window_layer, bitmap_layer_get_layer(splash_layer)); set_bitmap_image(&splash_image, splash_layer, RESOURCE_ID_IMAGE_SPLASH, GPoint (0, 0)); // Configure time on init display_time(time); accel_tap_service_subscribe(&handle_accel_tap); tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick); } // handle_init()
static void stop (Boolean toggle) { if (running && ((MidiGetTime() - gTimeOffset) > 100)) { running = false; gtk_timeout_remove (gTimeID); display_time(0); if (toggle) { gLoopFlag++; gtk_toggle_button_set_active ((GtkToggleButton *)gRun, FALSE); } } }
static void inbox_received_callback(DictionaryIterator *iterator, void *context) { // Get the first pair Tuple *t = dict_read_first(iterator); int nNewValue; bool bNewValue, bNeedUpdate = false; // Process all pairs present while(t != NULL) { // Process this pair's key //APP_LOG(APP_LOG_LEVEL_DEBUG, "Key:%d received with value:%d", (int)t->key, (int)t->value->int32); switch (t->key) { case KEY_VIBES: nNewValue = t->value->int32; if (m_nVibes != nNewValue) { m_nVibes = nNewValue; } break; case KEY_ROW2: bNewValue = !!t->value->int32; if (m_bUseMMDD != bNewValue) { m_bUseMMDD = bNewValue; bNeedUpdate = true; } break; case KEY_ROW4: bNewValue = !!t->value->int32; if (m_bDualTime != bNewValue) { m_bDualTime = bNewValue; bNeedUpdate = true; } break; case KEY_TIMEZONE2: nNewValue = t->value->int32; if (m_nTimezone2 != nNewValue) { m_nTimezone2 = nNewValue; bNeedUpdate = true; } break; } // Get next pair, if any t = dict_read_next(iterator); } if (bNeedUpdate) { time_t now = time(NULL); struct tm *tick_time = localtime(&now); display_time(tick_time); } }
void redraw_retro() { text_layer_set_text_color(hour_text, COLOR_BACKGROUND); text_layer_set_text_color(minute_text, COLOR_BACKGROUND); text_layer_set_text_color(day_text, COLOR_BACKGROUND); text_layer_set_text_color(ampm_text, COLOR_BACKGROUND); text_layer_set_text_color(date_text, COLOR_BACKGROUND); text_layer_set_text_color(month_text, COLOR_BACKGROUND); text_layer_set_text_color(year_text, COLOR_BACKGROUND); update_date_format(); display_time(NULL); }
int handle_cmd_measurement_truck(uint8_t *buffer, short length) { unsigned int data; uint8_t wheels; if(length != 6) return FAIL; display_time(); wheels = *(buffer+2); data = (*(buffer+6)<<24) | (*(buffer+5)<<16) | (*(buffer+4)<<8) | *(buffer+3); printf("CMD_MEAS_TRUCK WHEELS: %u WEIGHT: %16u\n", wheels, data); return OK; }
static void init() { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); // Avoids a blank screen on watch start. time_t now = time(NULL); struct tm *tick_time = localtime(&now); display_time(tick_time); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }
// Blink time segments given by the segment_enum // Only one time enum at a time void blink(uint16_t segment) { if (segment) { blink_timer = set_timeout_ms(BLINK_HALF_PERIOD_MS); blink_segment = segment; } else { blink_segment = NONE; display_time(display_hours, display_minutes); } }
void setup_lcd() { // Enable LCD without voltage boost SegmentLCD_Init(false); // Turn on the colon in the time display SegmentLCD_Symbol(LCD_SYMBOL_COL10, 1); display_time(0,0); SegmentLCD_Write("OFF"); blink(TIME); }
void handle_init(AppContextRef ctx) { window_init(&window, "Big Time watch"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); // Avoids a blank screen on watch start. PblTm tick_time; get_time(&tick_time); display_time(&tick_time); }
static void timer_handler(){ if (!running) { return; } remaining -= 1000; if (remaining > 0) { set_timer(); display_time(); } else { timer_complete(); } }