static PyObject * py_ds1302_set_time(PyObject *self, PyObject *args) { const unsigned char hour, min, sec; if (!PyArg_ParseTuple(args, "bbb", &hour, &min, &sec)) return NULL; time_set(RTC_HOUR, to_bcd(hour)); time_set(RTC_MIN, to_bcd(min)); time_set(RTC_SEC, to_bcd(sec)); Py_RETURN_NONE; }
void on_lcd_update_lap(Watch *w){ if(w->mode == START_STOP){ return; }else{ Time lap,split; time_set(&lap,w->lap); time_set(&split,w->split); format(w->line1," LAP",&lap); format(w->line2,"SPLIT",&split); } }
static PyObject * py_ds1302_set_date(PyObject *self, PyObject *args) { const unsigned char date, month; const unsigned int year; if (!PyArg_ParseTuple(args, "ibb", &year, &month, &date)) return NULL; time_set(RTC_DATE, to_bcd(date)); time_set(RTC_MONTH, to_bcd(month)); time_set(RTC_YEAR, to_bcd((unsigned char)(year - 2000))); Py_RETURN_NONE; }
void on_lcd_update_run(Watch *w){ if(w->mode == START_STOP){ Time now; Time start; time_set(&now,w->time); time_set(&start,w->start); format(w->line1,"START",&start); format(w->line2," STOP",&now); }else{ Time split; time_set(&split,w->split+w->time); format(w->line1," LAP",&split); format(w->line2,"SPLIT",&split); } }
void on_lcd_update_idle(Watch *w){ Time now; time_set(&now,w->time); format(w->line1," LAP",&now); format(w->line2,"SPLIT",&now); }
//定时器处理函数 void time_handler(int sig, siginfo_t *si, void *uc) { if(si->si_value.sival_ptr == &timerid){ printf("timer handler is running\n"); time_set(timerid, 0, 0); } }
//数据的获取与保存 //dir:方向 0--获取时间; 1--设置时间 void time_change_data( STATUS_RW_FLASH_TypeDef rw, TIME_DATA_TypeDef *pTime ) { tTime t; uint16_t temp; if(READ_FLASH == rw) { time_cycle(); t = get_time(); //获取时间 numtochar(2,t.usYear % 100,pTime[0].buff); //获取年 numtochar(2,t.ucMon,pTime[2].buff); //获取月 numtochar(2,t.ucMday,pTime[4].buff); //获取日 numtochar(2,t.ucHour,pTime[1].buff); //获取时 numtochar(2,t.ucMin,pTime[3].buff); //获取分 numtochar(2,t.ucSec,pTime[5].buff); //获取秒 } else { temp = ustrtoul(pTime[0].buff,0,10); //设置年 temp += 2000; t.usYear = temp; t.ucMon = ustrtoul(pTime[2].buff,0,10); //设置月 t.ucMday = ustrtoul(pTime[4].buff,0,10); //设置日 t.ucHour = ustrtoul(pTime[1].buff,0,10); //设置时 t.ucMin = ustrtoul(pTime[3].buff,0,10); //设置分 t.ucSec = ustrtoul(pTime[5].buff,0,10); //设置秒 time_set(t); } }
static void one_iter () { SDL_Event event; int flag; flag = SDL_PollEvent (&event); if (0 < flag) { switch (event.type) { case SDL_QUIT: exit (0); break; case SDL_KEYDOWN: keyevent (&(event.key)); break; case SDL_VIDEORESIZE: window_width = event.resize.w; window_height = event.resize.h; surface = SDL_SetVideoMode (window_width, window_height, 0, SDL_OPENGL | SDL_RESIZABLE); break; default: break; } } else { time_set(); key_input (); timer_flame (); opengl_expose (); SDL_GL_SwapBuffers (); } }
void menu_timer(void) { long data32; switch (CMD_buffer[3]) { case 's': //set V2X time time_set(menu_sample_number(CMD_buffer+4)); usb_tx_string_PV(PSTR("Time has been set\r")); break; case 'g': //get V2X time usb_tx_string_P(PSTR("UET: ")); menu_print_int(time_get()); usb_tx_string_P(PSTR("\rTime: ")); time_print_human_readable(); menu_send_n(); break; case 'a': //absolute alarm time_alarm_set(menu_sample_number(CMD_buffer+4)); usb_tx_string_PV(PSTR("Alarm has been set")); break; case 'r': //relative alarm time_alarm_set_relative(menu_sample_number(CMD_buffer+4)); usb_tx_string_PV(PSTR("Alarm has been set")); break; case 'z': //set time zone time_zone_set(menu_sample_number(CMD_buffer+4)); usb_tx_string_P(PSTR("TZN=")); menu_print_int(time_zone_get()); break; case 'd': //set time zone usb_tx_string_P(PSTR("DST=")); if (menu_sample_number(CMD_buffer+4)) { time_dst_set(1); menu_send_1(); } else { time_dst_set(0); menu_send_0(); } break; case 'i': //timer system information usb_tx_string_P(PSTR("The timer module uses Unix Epoch timestamps (UET) \rH24: clock has been set/sync within 24hrs\rALM: alarm is set for the future\r")); break; case 'q': //timer inquery menu_timer_status(); break; case 'u': //usb_tx_string_P(PSTR("GPS update\r")); GSM_time_job(); break; case '?': //Menu options default: usb_tx_string_P(PSTR("*** Timer Menu ***\rSn: Set V2X time (UET)\rDn: Daylight Savings Time\rG: Get V2X time\rAn: Set absolute alarm (UET) \rRn: Set relative alarm (Seconds)\rI: timer information\rQ: Timer inquery\rU: Update using gps\rZn: Set timezone\r")); break; } }
void rtc_reset() { time_set(RTC_SEC, 0x0); time_set(RTC_MIN, 0x0); time_set(RTC_HOUR, 0x0); time_set(RTC_DATE, 0x01); time_set(RTC_MONTH, 0x01); time_set(RTC_YEAR, 0x1); }
void main() { ANSEL = 0x00; TRISA = 0xFF; TRISB = 0b00000100; // Structure that holds human readable time information; struct tm tinfo; // Local time to get time_t now; // Store last time we sent the information uint32_t last = 0; // Set time manually to 13:55:30 Jan 1st 2014 tinfo.tm_year = 14; tinfo.tm_mon = 1; tinfo.tm_mday = 1; tinfo.tm_hour = 13; tinfo.tm_min = 55; tinfo.tm_sec = 30; // Tick Initialization tick_init(); // Convert time structure to timestamp initialt = time_make(&tinfo); // Set system time counter time_set(initialt); // Set the function to get accurate time time_set_provider(&time_provider, TIME_SECS_PER_DAY); printf("TimeLib Test Program\r\n"); E_ for (;;) { // Display the time every second if (tick_get() - last > TICK_SECOND) { last = tick_get(); // Send to serial port printf("Time: %02d:%02d:%02d Date: %02d/%02d/%02d\r\n", hour(), minute(), second(), day(), month(), year()); } } }
static void ap_time_tdt_found(u32 para1, u32 para2) { time_set_t t_set; utc_time_t time; sys_status_get_time(&t_set); if(t_set.gmt_usage)//gmt useage is on { //time.value = ((utc_time_t *)¶1)->value; memcpy(&time, ((utc_time_t *)para1), sizeof(utc_time_t)); time.reserved = 1; is_tdt_found = TRUE; //printf_time(&time, "##@@tdt found"); time_set(&time); } }
//定时器初始化 void time_init() { struct sigevent sev; long long freq_nanosecs; sigset_t mask; struct sigaction sa; DEBUG("Establishing handler for signal %d\n", SIG); sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = time_handler; sigemptyset(&sa.sa_mask); sigaction(SIG, &sa, NULL); sev.sigev_notify = SIGEV_SIGNAL; sev.sigev_signo = SIG; sev.sigev_value.sival_ptr = &timerid; timer_create(CLOCKID, &sev, &timerid); time_set(timerid, TIMER_INTERVAL, 0); }
static int test_get_set(struct harness_t *harness) { struct time_t time1; struct time_t time2; /* Start by getting the current time. */ BTASSERT(time_get(&time1) == 0); std_printf(FSTR("time1: seconds = %lu, nanoseconds = %lu\r\n"), time1.seconds, time1.nanoseconds); /* Wait a while and verify that the time has changed. */ thrd_sleep_us(100000); BTASSERT(time_get(&time2) == 0); std_printf(FSTR("time2: seconds = %lu, nanoseconds = %lu\r\n"), time2.seconds, time2.nanoseconds); BTASSERT((time2.seconds > time1.seconds) || (time2.nanoseconds > time1.nanoseconds)); /* Set the time to a high value. */ time1.seconds = 100; time1.nanoseconds = 350000000; BTASSERT(time_set(&time1) == 0); /* Get the new time. */ BTASSERT(time_get(&time1) == 0); std_printf(FSTR("time1: seconds = %lu, nanoseconds = %lu\r\n"), time1.seconds, time1.nanoseconds); /* Wait a while and verify that the time has changed. */ thrd_sleep_us(100000); BTASSERT(time_get(&time2) == 0); std_printf(FSTR("time2: seconds = %lu, nanoseconds = %lu\r\n"), time2.seconds, time2.nanoseconds); BTASSERT((time2.seconds > time1.seconds) || (time2.nanoseconds > time1.nanoseconds)); return (0); }
uint8_t user1_irq(void) { struct nmea_data_t result; char buf[BUFLEN]; uint8_t i; nmea_buf[nmea_buf_len] = '\0'; for (i = 0; i < sizeof(buf); i++) buf[i] = nmea_buf[i]; result = parse_nmea(buf); nmea_buf_len = 0; switch (result.tag) { case NMEA_TIMESTAMP: if (result.timestamp > last_time_sync + TIME_SYNC_INTERVAL) { time_set(result.timestamp); last_time_sync = result.timestamp; send_time_can(TYPE_value_explicit); } break; case NMEA_COORDS: coords_read_time = now; cur_lat = result.cur_lat; cur_lon = result.cur_lon; break; case NMEA_NUM_SATS: num_sats_read_time = now; num_sats = result.num_sats; break; default: break; } return 0; }
void ram() { for(int x = 63; x >= 0; x--) { lcdFill(0); DoString(x, 0, "Setting Highscore"); lcdDisplay(); } highscore_set(23542, "Pentagon V1LLAG3"); delayms_queue(500); for(int x = 63; x >= 0; x--) { lcdFill(0); DoString(x, 0, "Setting ..."); lcdDisplay(); } foo_set("PwnedPwnedPwnedPwnedPwnedPwned "); bar_set("http://chaosbay.camp.ccc.de/ "); delayms_queue(500); time_set(1313803870); }
static RET_CODE on_conditional_accept_worktime_timedit_unselect(control_t *p_ctrl, u16 msg, u32 para1, u32 para2) { #if 0 control_t *p_cont, *p_date, *p_time; utc_time_t loc_time = {0}; utc_time_t gmt_time = {0}; p_cont = ctrl_get_parent(ctrl_get_parent(p_ctrl)); p_date = ctrl_get_child_by_id(p_cont, IDC_DATE); p_time = ctrl_get_child_by_id(p_cont, IDC_TIME); ui_comm_timedit_get_time(p_date, &loc_time); ui_comm_timedit_get_time(p_time, &loc_time); time_to_gmt(&loc_time, &gmt_time); time_set(&gmt_time); #endif return ERR_NOFEATURE; }
/*********************************************************** ***** ***** 主函数 ***** ***********************************************************/ void main( void ) { timer0_init(); time_set(5, 0); //设置5小时倒计时 while(1) { time_display(); //显示时间 if(countTime <= 10) { dpFlag = 0; } else if(countTime <= 20) { dpFlag = 1; } else { countTime = 0; time_judge(); } } }
/// Handler for button 2, "+" void button2_handler(uint8_t on) { if (on) { switch (set_state) { case SET_NONE: switch (mode_get()) { case MMSS: time_set(-1,-1,0); fadeto(time_get_mmss()); break; case HHMM: set_state = SET_HOUR; blinkmode_set(BLINK_HH); fade_set(FADE_OFF); dotmode_set(DOT_ON); fadeto(time_get_hhmm()); break; default: break; } break; case SET_HOUR: set_state = SET_MINUTE; blinkmode_set(BLINK_MM); break; case SET_MINUTE: default: set_state = SET_NONE; blinkmode_set(BLINK_NONE); fade_set(FADE_SLOW); dotmode_set(DOT_BLINK); break; } } else { cli(); blinkhandler = NULL; sei(); } }
static void saveTimeDate() { time_set(&timeDataSet); }
static void msg( void *plcdmsg ) { LCD_MSG * plcd_msg = (LCD_MSG* )plcdmsg; char ch,buf[100]; uint32_t i; void *pmsg; if( plcd_msg->id == LCD_MSG_ID_GPS ) { if( ( gps_fixed_sec == 0 ) && ( plcd_msg->info.gps_rmc.gps_av == 'A' ) ) { gps_fixed_sec = rt_tick_get( ) * 10 / 1000; test_flag|=TEST_BIT_GPS; sprintf( buf, "%02d:%02d", gps_fixed_sec / 60, gps_fixed_sec % 60 ); lcd_asc0608( 0, 8, buf, LCD_MODE_SET ); i=sprintf(buf,"AT%%TTS=2,3,5,\"475053D2D1B6A8CEBB\"\r\n",ch+0x30); buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } year=plcd_msg->info.gps_rmc.year; month=plcd_msg->info.gps_rmc.month; day= plcd_msg->info.gps_rmc.day; hour= plcd_msg->info.gps_rmc.hour; minute= plcd_msg->info.gps_rmc.minitue; sec= plcd_msg->info.gps_rmc.sec; time_set(hour,minute,sec); date_set(year,month,day); sprintf( buf, "%c%02d-%02d %02d:%02d:%02d", plcd_msg->info.gps_rmc.gps_av,month,day,hour,minute,sec ); lcd_asc0608( 122 - 6 * 15, 8, buf, LCD_MODE_SET ); } if( plcd_msg->id == LCD_MSG_ID_GSM ) { if( plcd_msg->info.payload[0] == 1 ) /*通话*/ { rt_kprintf( "\r\nIncoming Call" ); pscr = &scr_2_call; pscr->show( &scr_1_idle ); } } if(plcd_msg->id == LCD_MSG_ID_GPRS) { gprs_ok_past_sec=rt_tick_get()/100; test_flag|=TEST_BIT_GPRS; } if(plcd_msg->id == LCD_MSG_ID_MEMS) { mems_status=plcd_msg->info.payload[0]; } if(plcd_msg->id == LCD_MSG_ID_CAM) { ch=plcd_msg->info.payload[0]; switch(ch) { case 1: test_flag|=TEST_BIT_CAM1; break; case 2: test_flag|=TEST_BIT_CAM2; break; case 3: test_flag|=TEST_BIT_CAM3; break; case 4: test_flag|=TEST_BIT_CAM4; break; } if(plcd_msg->info.payload[1]==SUCCESS) { i=sprintf(buf,"AT%%TTS=2,3,5,\"C5C4D5D5%02xD5FDB3A3\"\r\n",ch+0x30); cam_ch[ch-1]=0x30+ch; lcd_asc0608( 122 - 6*8-4, 24, cam_ch, LCD_MODE_SET ); } else { i=sprintf(buf,"AT%%TTS=2,3,5,\"C5C4D5D5%02xD2ECB3A3\"\r\n",ch+0x30); } buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(plcd_msg->id == LCD_MSG_ID_ICCARD) { iccard_beep_timeout=10; card_status=plcd_msg->info.payload[0]; if(card_status==IC_PLUG_OUT) { i=sprintf(buf,"AT%%TTS=2,3,5,\"4943BFA8B0CEB3F6\"\r\n\0");/*IC卡拔出*/ pmsg=rt_malloc(i); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(card_status==IC_READ_OK) { i=sprintf(buf,"AT%%TTS=2,3,5,\"4943BFA8D5FDB3A3\"\r\n\0"); /*IC卡正常*/ pmsg=rt_malloc(i); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(card_status==IC_READ_ERR) { i=sprintf(buf,"AT%%TTS=2,3,5,\"4943BFA8B4EDCEF3\"\r\n\0"); /*IC卡错误*/ pmsg=rt_malloc(i); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } test_flag|=TEST_BIT_ICCARD; } if(plcd_msg->id == LCD_MSG_ID_RTC) { memset(buf,0,32); if(plcd_msg->info.payload[0]==SUCCESS) { i=sprintf(buf,"AT%%TTS=2,3,5,\"525443D5FDB3A3\"\r\n",ch+0x30); test_flag|=TEST_BIT_RTC; rtc_ok=1; } else { i=sprintf(buf,"AT%%TTS=2,3,5,\"525443D2ECB3A3\"\r\n",ch+0x30); } rt_kprintf("\r\nRTC len=%d\r\n",i); buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(plcd_msg->id == LCD_MSG_ID_CSQ) { gsm_csq=plcd_msg->info.payload[0]; rt_kprintf("\r\ncsq=%d",gsm_csq); } if(test_flag==TEST_BIT_ALL) { i=sprintf(buf,"AT%%TTS=2,3,5,\"B2E2CAD4CDEAB3C9\"\r\n"); buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } showinfo(); }