static byte null_InitMouseConfirm(void) { byte c = '\0'; fflush(stdOUT); printk("%s", "\n" " \033[1m ALL MOUSE DRIVERS FAILED.\033[0m\n" "\n" " If you really want to run `twin' without mouse\n" " hit RETURN within 10 seconds to continue,\n" " otherwise hit CTRL-C (or wait 10 seconds) to cancel.\n"); flushk(); SetAlarm(10); read(tty_fd, &c, 1); SetAlarm(0); if (c == '\n' || c == '\r') { null_InitMouse(); return TRUE; } return FALSE; }
void fnAlarm(void) { rt_uint32_t e; uint8_t buf,int_m,t=0; uint16_t delay1,delay2,strength; rt_thread_delay_hmsm(0,0,3,0); int_m = (clock_m+5)%60; rt_kprintf("It is %d:%d now\nAlarm Level %d\n",clock_h,clock_m,t); rt_event_send(reg_event,REG_ALARM_MSK); while (rt_mq_recv(key_mq,&buf,sizeof(uint8_t),0)!=RT_EOK) { if (clock_m==int_m) { t+=1; int_m = (int_m+5)%60; rt_kprintf("Alarm Level %d\n",t); } switch (t) { case 0: delay1 = 500; delay2 = 4500; strength = 400; break; case 1: delay1 = 1000; delay2 = 2000; strength = 600; break; case 2: delay1 = 500; delay2 = 500; strength = 800; break; default: delay1 = 500; delay2 = 250; strength = 1000; break; } SetAlarm(strength); rt_thread_delay_hmsm(0,0,0,delay1); SetAlarm(0); Animate(delay2); } rt_event_recv(reg_event,REG_ALARM_MSK,RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR,0,&e); return; }
SoundBox::SoundBox() { CentSnd.setBuffer( ResourceManager::GetSound("CentSnd") ); CentSnd.setPitch(1); CentSnd.setVolume(25); SpidSnd.setBuffer( ResourceManager::GetSound("SpidSnd") ); SpidSnd.setPitch(1); SpidSnd.setVolume(25); SetAlarm(0, .25f); SetAlarm(1, .25f); }
static int WaitValidNetState(int (*checkingFunction)(void)){ int SemaID, retry_cycles; ee_sema_t SemaData; // Wait for a valid network status; SemaData.option = SemaData.attr = 0; SemaData.init_count = 0; SemaData.max_count = 1; if((SemaID = CreateSema(&SemaData)) < 0) return SemaID; for(retry_cycles = 0; checkingFunction() == 0; retry_cycles++) { SetAlarm(1000 * rmGetHsync(), &EthStatusCheckCb, &SemaID); WaitSema(SemaID); if(retry_cycles >= 30) //30s = 30*1000ms { DeleteSema(SemaID); return -1; } } DeleteSema(SemaID); return 0; }
static int SMapInit ( IPAddr IP, IPAddr NM, IPAddr GW ) { int i; iop_sys_clock_t ClockTicks; dev9IntrDisable ( INTR_BITMSK ); EnableIntr ( IOP_IRQ_DEV9 ); CpuEnableIntr (); UNKN_1464 = 3; if ( ( iSendMutex = CreateMutex ( IOP_MUTEX_UNLOCKED ) ) < 0 ) return 0; if ( ( iSendReqMutex = CreateMutex ( IOP_MUTEX_UNLOCKED ) ) < 0 ) return 0; if ( !SMap_Init () ) return 0; for ( i = 2; i < 7; ++i ) dev9RegisterIntrCb ( i, SMapInterrupt ); USec2SysClock ( TIMER_INTERVAL, &ClockTicks ); SetAlarm ( &ClockTicks, Timer, ( void* )ClockTicks.lo ); netif_add ( &NIF, &IP, &NM, &GW, NULL, SMapIFInit, tcpip_input ); netif_set_default ( &NIF ); return 1; } /* end SMapInit */
static void controlLedSp(BYTE led1, BYTE led2, BYTE sp) { unsigned long ctlmode; ctlmode = led1 + led2*2 + sp*4; SetAlarm(ctlmode); }
void StartTimerLoop(TimerCallback_t init_callback) { EnterMutex(); // At first, TimeDispatch will call init_callback. SetAlarm(NULL, 0, init_callback, 0, 0); LeaveMutex(); }
bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds) { // It's pointless to program an alarm nothing is going to observe ... MOZ_ASSERT(sAlarmObserver); RETURN_PROXY_IF_SANDBOXED(SetAlarm(aSeconds, aNanoseconds), false); }
void ExplosionPlayer::Initialize( sf::Vector2f pos, std::string texture, Blaster* theBlaster ) { Pos = pos; MainSprite = AnimatedSprite( ResourceManager::GetTexture(texture), 3, 2); MainSprite.SetAnimation(0, 5); MainSprite.scale(1,1); MainSprite.setColor( sf::Color::Color(255,180,180) ); MainSprite.setOrigin(MainSprite.getTextureRect().width / 2.0f, MainSprite.getTextureRect().height / 2.0f); MainSprite.setPosition(Pos); blaster = theBlaster; SetAlarm(0, 0.3); }
LoseText::LoseText(){ //only graphics are needed. No collision SetGraphicsObject(GraphicsObjectMaker::CreateGraphicsObjectFlatTexture(AssetManager::GetModel("LoseModel"),AssetManager::GetTexture("BucketTexture") )); SetAlarm(AlarmID_0,10); Matrix temp = Matrix(); winScale.set( SCALE, 5, 5, 5); winRot.set( ROT_XYZ, 0, 0, 0); winPos.set(0,0,0); temp = winScale * winRot * Matrix( TRANS, winPos ); SetGameObjectWorld(temp); }
void StartTimerLoop(TimerCallback_t init_callback) { getElapsedTime(); last_alarm_set = last_time_read; last_occured_alarm = last_alarm_set; init_timer(&timer); timer.function = timer_notify; EnterMutex(); // At first, TimeDispatch will call init_callback. SetAlarm(NULL, 0, init_callback, 0, 0); LeaveMutex(); }
int Application::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: EnableSplitScreen(); break; case 1: SetAlarm((*reinterpret_cast< QString(*)>(_a[1]))); break; default: ; } _id -= 2; } return _id; }
/** * Timer Task */ void timerloop_task_proc(void *arg) { int ret = 0; getElapsedTime(); last_timeout_set = 0; last_occured_alarm = last_time_read; /* trigger first alarm */ SetAlarm(callback_od, 0, init_callback, 0, 0); RTIME current_time; RTIME real_alarm; do{ rt_mutex_acquire(&condition_mutex, TM_INFINITE); if(last_timeout_set == TIMEVAL_MAX) { ret = rt_cond_wait( &timer_set, &condition_mutex, TM_INFINITE ); /* Then sleep until next message*/ rt_mutex_release(&condition_mutex); }else{ current_time = rt_timer_read(); real_alarm = last_time_read + last_timeout_set; ret = rt_cond_wait( /* sleep until next deadline */ &timer_set, &condition_mutex, (real_alarm - current_time)); /* else alarm consider expired */ if(ret == -ETIMEDOUT){ last_occured_alarm = real_alarm; rt_mutex_release(&condition_mutex); EnterMutex(); TimeDispatch(); LeaveMutex(); }else{ rt_mutex_release(&condition_mutex); } } }while ((ret == 0 || ret == -EINTR || ret == -ETIMEDOUT) && !stop_timer); if(exitall){ EnterMutex(); exitall(callback_od, 0); LeaveMutex(); } }
u32_t sys_arch_sem_wait(sys_sem_t Sema,u32_t u32Timeout) { //Wait u32Timeout msec for the Sema to receive a signal. dbgprintf("sys_arch_sem_wait: Sema: %d, Timeout: %x (TID: %d)\n",Sema,u32Timeout,GetThreadId()); if(u32Timeout==0) { //Wait with no timeouts. return WaitSema(Sema)==0 ? 0:SYS_ARCH_TIMEOUT; } else if(u32Timeout==1) { //Poll. return PollSema(Sema)==0 ? 0:SYS_ARCH_TIMEOUT; } else { //Use alarm to timeout. iop_sys_clock_t ClockTicks; iop_sys_clock_t Start; iop_sys_clock_t End; int iPID=GetThreadId(); u32_t u32WaitTime; GetSystemTime(&Start); USec2SysClock(u32Timeout*1000,&ClockTicks); SetAlarm(&ClockTicks,TimeoutHandler,(void*)iPID); if(WaitSema(Sema)!=0) { return SYS_ARCH_TIMEOUT; } CancelAlarm(TimeoutHandler,(void*)iPID); GetSystemTime(&End); u32WaitTime=ComputeTimeDiff(&Start,&End); return u32WaitTime<=u32Timeout ? u32WaitTime:u32Timeout; } }
void ioInit(void) { gIOTerminate = 0; gHandlerCount = 0; gReqList = NULL; gReqEnd = NULL; gDispatcherThreadID = 0; gIOThreadId = 0; gQueueSema.init_count = 1; gQueueSema.max_count = 1; gQueueSema.option = 0; gProcSemaId = CreateSema(&gQueueSema); gEndSemaId = CreateSema(&gQueueSema); gIOPrintfSemaId = CreateSema(&gQueueSema); ChangeThreadPriority ( GetThreadId (), 29 ); // default custom simple action handler ioRegisterHandler(IO_CUSTOM_SIMPLEACTION, &ioSimpleActionHandler); memset(&gIOThread, 0, sizeof(gIOThread)); gIOThread.func = (void *)ioThreadDispatcher; gIOThread.stack = disp_stack; gIOThread.stack_size = THREAD_STACK_SIZE; gIOThread.gp_reg = &_gp; gIOThread.initial_priority = 0; alarmID = SetAlarm( 625, &ioAlarmFunc, NULL); // this one manages the thread switching in alarm intervals gDispatcherThreadID = CreateThread(&gIOThread); StartThread(gDispatcherThreadID, NULL); gIOThread.func = (void *)ioWorkerThread; gIOThread.stack = thread_stack; gIOThread.initial_priority = 30; isIORunning = 1; gIOThreadId = CreateThread(&gIOThread); StartThread(gIOThreadId, NULL); ChangeThreadPriority ( GetThreadId (), 30 ); }
unsigned int sleep(unsigned int seconds) { ee_sema_t sema; struct sleep_data sd; sema.init_count = 0; sema.max_count = 1; sema.option = 0; sd.wait = clock() + seconds * CLOCKS_PER_SEC; sd.s = CreateSema(&sema); SetAlarm(HSYNC_COUNT, _sleep_waker, &sd); WaitSema(sd.s); DeleteSema(sd.s); return 0; }
/*! ** ** ** @param d **/ void startSYNC(CO_Data* d) { if (d->syncTimer != TIMER_NONE) { stopSYNC(d); } RegisterSetODentryCallBack(d, 0x1005, 0, &OnCOB_ID_SyncUpdate); RegisterSetODentryCallBack(d, 0x1006, 0, &OnCOB_ID_SyncUpdate); if (*d->COB_ID_Sync & 0x40000000ul && *d->Sync_Cycle_Period) { d->syncTimer = SetAlarm( d, 0 /*No id needed*/, &SyncAlarm, US_TO_TIMEVAL(*d->Sync_Cycle_Period), US_TO_TIMEVAL(*d->Sync_Cycle_Period)); } }
static u32_t sys_arch_mbox_fetch_internal(sys_mbox_t pMBox, void** ppvMSG, u32_t TimeElaspedout, char block) { void *pmsg; u32_t TimeElasped = 0; iop_sys_clock_t ClockTicks; iop_sys_clock_t Start; iop_sys_clock_t End; int result, iPID; if(block){ iPID=GetThreadId(); if(TimeElaspedout > 0) { GetSystemTime(&Start); USec2SysClock(TimeElaspedout * 1000, &ClockTicks); SetAlarm(&ClockTicks, &TimeoutHandler, (void*)iPID); } if((result=ReceiveMbx(&pmsg, pMBox))!= 0) { return(SYS_ARCH_TIMEOUT); } if(TimeElaspedout > 0) { CancelAlarm(TimeoutHandler,(void*)iPID); GetSystemTime(&End); TimeElasped = ComputeTimeDiff(&Start, &End); } } else{ TimeElasped=((result=PollMbx(&pmsg, pMBox))!=0)?SYS_MBOX_EMPTY:0; } if(result==0){ *ppvMSG = ((arch_message *)pmsg)->sys_msg; free_msg((arch_message *) pmsg); } //Return the number of msec waited. return TimeElasped; }
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) { //Wait TimeElaspedout msec for the Sema to receive a signal. dbgprintf("sys_arch_sem_wait: Sema: %d, Timeout: %x (TID: %d)\n", *sem, timeout, GetThreadId()); u32_t result; if(timeout==0) { //Wait with no timeouts. result=(WaitSema(*sem)==0)?0:SYS_ARCH_TIMEOUT; } else if(timeout==1) { //Poll. result=(PollSema(*sem)==0)?0:SYS_ARCH_TIMEOUT; } else { //Use alarm to timeout. iop_sys_clock_t ClockTicks; iop_sys_clock_t Start; iop_sys_clock_t End; int iPID=GetThreadId(); u32_t u32WaitTime; GetSystemTime(&Start); USec2SysClock(timeout*1000,&ClockTicks); SetAlarm(&ClockTicks, &TimeoutHandler, (void*)iPID); if(WaitSema(*sem)==0){ CancelAlarm(TimeoutHandler,(void*)iPID); GetSystemTime(&End); u32WaitTime=ComputeTimeDiff(&Start, &End); result=(u32WaitTime<=timeout)?u32WaitTime:timeout; }else result=SYS_ARCH_TIMEOUT; } return result; }
u32_t sys_arch_mbox_fetch(sys_mbox_t pMBox,void** ppvMSG,u32_t u32Timeout) { void *pmsg; u32 u32Time = 0; iop_sys_clock_t ClockTicks; iop_sys_clock_t Start; iop_sys_clock_t End; if(PollMbx(&pmsg, pMBox) != 0) { int iPID=GetThreadId(); if(u32Timeout > 0) { GetSystemTime(&Start); USec2SysClock(u32Timeout * 1000, &ClockTicks); SetAlarm(&ClockTicks, TimeoutHandler, (void*)iPID); } if(ReceiveMbx(&pmsg, pMBox) != 0) { return(SYS_ARCH_TIMEOUT); } if(u32Timeout > 0) { CancelAlarm(TimeoutHandler,(void*)iPID); GetSystemTime(&End); u32Time = ComputeTimeDiff(&Start,&End); } } if(ppvMSG) { *ppvMSG = ((arch_message *) pmsg)->sys_msg; } free_msg((arch_message *) pmsg); //Return the number of msec waited. return u32Time; }
int ioBlockOps(int block) { if (block && !isIOBlocked) { isIOBlocked = 1; // wait for all io to finish while (ioHasPendingRequests()) { // TODO: This is in seconds, so can be too coarse sleep(1); } // now all io should be blocked // stop the timer as well... stopIOTimer = 1; ReleaseAlarm(alarmID); } else if (!block && isIOBlocked) { isIOBlocked = 0; stopIOTimer = 0; // create the alarm again alarmID = SetAlarm( 625, &ioAlarmFunc, NULL); } return IO_OK; }
void OS_SCHEDULER(void) { DINT; DRTM; /* Restore context of scheduler */ //Nos movemos a la pila global asm(" MOV DP,#_PtrStack_Global"); asm(" MOVL ACC,@_PtrStack_Global"); asm(" MOV SP,ACC"); unsigned int i; unsigned int j; unsigned long int WaitTime; unsigned int GroupSize; TaskType NextTask; /* sort Ready tasks by WaitTime */ (void)Sort(ReadyTasks, NO_TASKS, WAIT_TIME); /* Check integrity of task stacks */ CheckTaskOverflow(); /* find and sort by Priority group of tasks of same WaitTime */ for(i=0; i<NO_TASKS; ) { GroupSize = 1; WaitTime = ReadyTasks[i].WaitTime; /* search for tasks with same WaitTime */ for(j=i+1; j<NO_TASKS; j++) { if(ReadyTasks[j].WaitTime>WaitTime) { /* another group starts at j-th task, break the search */ break; } else { /* j-th task is from the same group as task i */ GroupSize++; } } if(GroupSize>1) { /* sort group of tasks by Priority */ (void)Sort(&ReadyTasks[i], GroupSize, PRIORITY); } /* find next group of tasks */ i = j; } /* the first task in the list is the shortest wait time and higher priority */ if(ReadyTasks[0].WaitTime == 0) { /* it's time to activate task */ NextTask.State = TSK_INVALID; /* find the next higher priority task (0 is the highest priority) */ for(i=1; i<NO_TASKS; i++) { if(ReadyTasks[i].Priority < ReadyTasks[0].Priority) { /* the scheduler shall be executed again in ReadyTasks[i].WaitTime */ NextTask = ReadyTasks[i]; break; } } if(NextTask.State == TSK_INVALID) { /* there is no task with higher priority than the task about to be activated */ /* the scheduler will be called whenever the coming task finishes */ } else { /* the scheduler shall be called again in NextTask.WaitTime */ SetAlarm(NextTask.WaitTime); } ActiveTask = ReadyTasks[0]; /* Remove task to be activated from the ReadyTasks list */ for(i=1; i<NO_TASKS; i++) { ReadyTasks[i-1] = ReadyTasks[i]; } ReadyTasks[i-1].Id = 0; ReadyTasks[i-1].Priority = 0; ReadyTasks[i-1].State = TSK_INVALID; ReadyTasks[i-1].WaitTime = 0; ReadyTasks[i-1].StackDesc.StackBottom = 0; ReadyTasks[i-1].StackDesc.StackTop = 0; ReadyTasks[i-1].StackDesc.StackPointer = 0; /* Restore context of task to be executed */ switch( ActiveTask.State ) { /* Scheduler was called from OS_SLEEP function */ case TSK_SLEPT : ActiveTask.State = TSK_ACTIVE; RestoreSleptTaskContext(ActiveTask.StackDesc); break; /* Scheduler was called from interrupt routine */ case TSK_INTERRUPTED : ActiveTask.State = TSK_ACTIVE; RestoreInterruptedTaskContext(ActiveTask.StackDesc); break; /* Task is ready to run */ case TSK_READY : ActiveTask.State = TSK_ACTIVE; SET_SP(ActiveTask.StackDesc.StackPointer); RESTORE_REGISTERS_BEGINNING(ActiveTask.StackDesc.StackBottom[0]); break; /* Invalid caller */ default : break; } } else { /* set a timer to delay activation of the task */ SetAlarm(ReadyTasks[0].WaitTime); } for(;;); } // fin void SCHEDULER(void)
void BellManager(int fd, struct BellConfigurationSt BellConf, struct BellHnd Bell) { int JustRing = 0; SetAlarm(fd); //log_message(LOG_FILE, "SetAlarm executed"); /* Read the current alarm settings */ retval = ioctl(fd, RTC_ALM_READ, &ring_tm); if (retval == -1) { log_message(LOG_FILE, "RTC_ALM_READ ioctl error"); perror("RTC_ALM_READ ioctl"); exit(errno); } fprintf(stderr, "Alarm time now set to %02d:%02d:%02d.\n", ring_tm.tm_hour, ring_tm.tm_min, ring_tm.tm_sec); fprintf(stderr, "Waiting for alarm...\r\n"); fflush(stderr); // /* Enable alarm interrupts */ // retval = ioctl(fd, RTC_AIE_ON, 0); // if (retval == -1) // { // log_message(LOG_FILE, "RTC_AIE_ON ioctl error"); // perror("RTC_AIE_ON ioctl"); // exit(errno); // } /* Enable every second interrupts */ retval = ioctl(fd, RTC_PIE_ON, 0); if (retval == -1) { log_message(LOG_FILE, "RTC_PIE_ON ioctl error"); perror("RTC_AIE_ON ioctl"); exit(errno); } /* This blocks until the alarm ring causes an interrupt */ retval = read(fd, &data, sizeof(unsigned long)); if (retval == -1) { log_message(LOG_FILE, "RTC read error"); perror("read"); exit(errno); } irqcount++; //log_message(LOG_FILE, "okay! Alarm rang."); /* Read the RTC time/date */ retval = ioctl(fd, RTC_RD_TIME, &rtc_tm); if (retval == -1) { log_message(LOG_FILE, "RTC_RD_TIME ioctl error"); perror("RTC_RD_TIME ioctl"); exit(errno); } /* reset alarm only whe the min 00 is passed*/ if(rtc_tm.tm_min != 00 && rtc_tm.tm_min != 15 && rtc_tm.tm_min != 30 && rtc_tm.tm_min != 45) { alarm_checked = 0; } /*check alarm if it set*/ if (rtc_tm.tm_min == 00 && alarm_checked == 0) { fprintf(stderr, "It's %02d:%02d:%02d. Ring From:%d to:%d enable:%d \n", ring_tm.tm_hour, ring_tm.tm_min, ring_tm.tm_sec, BellConf.RingFrom,BellConf.RingTo, BellConf.HoursEnable); JustRing = CheckMessa(rtc_tm,BellConf,Bell); /* check the No Sound Zone*/ if(ring_tm.tm_hour >= BellConf.RingFrom && ring_tm.tm_hour <= BellConf.RingTo && BellConf.HoursEnable && JustRing == 0) { for (i = 0;i< (ring_tm.tm_hour > 12 ?ring_tm.tm_hour - 12 : ring_tm.tm_hour); i++) { /*play bells TODO support ring to 00h if necessary*/ playBell(&Bell.IDBellHamH, BellConf.DelayTime_0); log_message(LOG_FILE, "Ora piena."); } } /* */ alarm_checked =1; /*set next alarm*/ ring_tm = setNextQuarterPastHourAlarm(rtc_tm); } if (rtc_tm.tm_min == 15 && alarm_checked == 0) { fprintf(stderr, "It's %02d:%02d:%02d. Ring From:%d to:%d enable:%d \n", ring_tm.tm_hour, ring_tm.tm_min, ring_tm.tm_sec, BellConf.RingFrom,BellConf.RingTo, BellConf.QuarterEnable); JustRing = CheckMessa(rtc_tm,BellConf,Bell); /* check the No Sound Zone*/ if(ring_tm.tm_hour >= BellConf.RingFrom && ring_tm.tm_hour <= BellConf.RingTo && BellConf.QuarterEnable && JustRing == 0) { /*play bells*/ playBell(&Bell.IDBellHamHH, BellConf.DelayTime_0); log_message(LOG_FILE, "Quarto d'ora."); /*set next alarm*/ } alarm_checked =1; ring_tm = setNextHalfHourAlarm(rtc_tm); } if (rtc_tm.tm_min == 30 && alarm_checked == 0) { fprintf(stderr, "It's %02d:%02d:%02d. Ring From:%d to:%d enable:%d \n", ring_tm.tm_hour, ring_tm.tm_min, ring_tm.tm_sec, BellConf.RingFrom,BellConf.RingTo, BellConf.HalfEnable); JustRing = CheckMessa(rtc_tm,BellConf,Bell); /* check the No Sound Zone*/ if(ring_tm.tm_hour >= BellConf.RingFrom && ring_tm.tm_hour <= BellConf.RingTo && BellConf.HalfEnable && JustRing == 0) { /*play bells*/ playBell(&Bell.IDBellHamHH, BellConf.DelayTime_0); log_message(LOG_FILE, "Ora mezza."); } alarm_checked =1; /*set next alarm*/ ring_tm = setNextQuarterToHourAlarm(rtc_tm); } if (rtc_tm.tm_min == 45 && alarm_checked == 0) { fprintf(stderr, "It's %02d:%02d:%02d. Ring From:%d to:%d enable:%d \n", ring_tm.tm_hour, ring_tm.tm_min, ring_tm.tm_sec, BellConf.RingFrom,BellConf.RingTo, BellConf.QuarterEnable); JustRing = CheckMessa(rtc_tm,BellConf,Bell); /* check the No Sound Zone*/ if(ring_tm.tm_hour >= BellConf.RingFrom && ring_tm.tm_hour <= BellConf.RingTo && BellConf.QuarterEnable && JustRing == 0) { /*play bells*/ playBell(&Bell.IDBellHamHH, BellConf.DelayTime_0); log_message(LOG_FILE, "Quarto d'ora."); } alarm_checked =1; /*set next alarm*/ ring_tm = setNextHourAlarm(rtc_tm); } UnSetAlarm(fd); }
void SoundBox::Alarm0() { CentSnd.play(); SetAlarm(0, .25f); }
void SoundBox::Alarm1() { SpidSnd.play(); SetAlarm(1, .75f); }
//发生某些事件时,会触发的函数 static SYS_MSG SystemEventHandler(SYS_EVT SysEvent ,int IntParam, void *pSysParam) { GUI_REGION DrawRegion; switch(SysEvent) { case Sys_PreGotoPage: break; case Sys_PageInit: //系统每次打开这个页面,会处理这个事件 case Sys_SubPageReturn: //如果从子页面返回,就不会触发Sys_Page_Init事件,而是Sys_SubPage_Return #if 1 //画模拟背景,这样可以快速显示 DrawRegion.x=0; DrawRegion.y=0; DrawRegion.w=240; DrawRegion.h=320; DrawRegion.Color=FatColor(NO_TRANS); Gui_DrawImgBin("Theme/F/AppListPage/Bg/Bg.bin",&DrawRegion); #else //画背景 DrawRegion.x=0; DrawRegion.y=21; DrawRegion.w=240; DrawRegion.h=320-21; DrawRegion.Color=FatColor(0x8b8a8a); Gui_FillBlock(&DrawRegion); //画标题栏 DrawRegion.x=DrawRegion.y=0; DrawRegion.w=240; DrawRegion.h=21; DrawRegion.Color=FatColor(NO_TRANS); Gui_FillImgArray((u8 *)gImage_StatusBar1,1,21,&DrawRegion); DrawTitle1(ASC14B_FONT,"Applications",(240-strlen("Applications")*GUI_ASC14B_ASCII_WIDTH)>>1,strlen("Applications"),FatColor(0xe0e0e0));//写标题 //画框 DrawFrame1(25,291); #endif break; case Sys_TouchSetOk: break; case Sys_TouchSetOk_SR: if(strcmp((void *)Q_GetPageByTrack(1)->Name,"SettingsPage")==0)//从设置页面返回 {//从设置页面返回时,IntParam为当初添加选项头时传入的ID号,pSysParam为当初建立的缓存 switch(IntParam) { case OSID_NULL://当IntParam为0时,表示没有修改任何值,所以当初传入的ID不能为0,否则有状态遗失 break; case OSID_SYS: ModifySysSettings(pSysParam); break; case OSID_CLOCK: ModifyClock(pSysParam); break; case OSID_ALARM: SetAlarm(pSysParam); break; } Q_PageFree(pSysParam);//从设置页面返回必须释放当初进入时分配的内存,否则会造成泄漏 } else if(strcmp((void *)Q_GetPageByTrack(1)->Name,"FileListPage")==0)//从文件浏览页面返回 { Debug("FileScan Return,Select %s\n\r",(u8 *)pSysParam); Q_PageFree(pSysParam);//从文件列表页面返回必须释放当初进入时分配的内存,否则会造成泄漏 } else if(strcmp((void *)Q_GetPageByTrack(1)->Name,"KeyBoardPage")==0)//从键盘页面返回 { Debug("KeyBoard Return,input:%s\n\r",(u8 *)pSysParam); Q_PageFree(pSysParam);//从键盘页面返回必须释放当初进入时分配的内存,否则会造成泄漏 } break; case Sys_PageClean: case Sys_PreSubPage: break; default: //需要响应的事件未定义 Debug("%s SystemEventHandler:This System Event Handler case unfinish! SysEvent:%d\n\r",Q_GetCurrPageName(),SysEvent); //while(1); } return 0; }
void Player::Alarm(int index){ if (index == 0){ DEBUG_LOG_WRITE_V("Alarm", "Alarm Entity"); SetAlarm(0, 150); } }
void AMWMot::Relax() { Sensor->LookStraight(); SetAlarm(0.f); }
/*------------------------------------------------------*/ int PcLinkDecode (char *c) { /* long i; rtime t1,t2; char cc[128]; double a,b,aa; */ switch(*c) { case '=': LoadFromPc(++c); break; case ':': puts_rld(++c); return(eof); case '*': puts_C100(++c); puts_C100("\r"); return(eof); case '.': GpsComm(++c); return(eof); case '@': WriteSophie(++c); return(eof); case '-': DeleteFromPc(++c); break; case '?': ListToPc(++c); break; case '#': SetAlarm(); break; #ifndef WIN32 case '!': sector_erase(SYSPAR,0); SavePar(SYSPAR,0); sector_erase(FONTS,0); fonts=FONTS; WriteGunData(Guns,&fonts); fonts=SaveZone(SaveFonts(fonts)); break; #endif /* testiranje hitrosti case 'r': sscanf(++c,"%ld,%lf",&i,&a); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) b=sqrt(a); PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; case 'm': sscanf(++c,"%ld,%lf,&lf",&i,&a,&b); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) aa=a*b; PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; case 'p': sscanf(++c,"%ld,%lf,&lf",&i,&a,&b); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) aa=pow(a,b); PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; case 'e': sscanf(++c,"%ld,%lf",&i,&a); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) aa=exp(a); PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; case 's': sscanf(++c,"%ld,%lf",&i,&a); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) aa=sin(a); PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; case 't': sscanf(++c,"%ld,%lf",&i,&a); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) aa=tan(a); PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; case 'a': sscanf(++c,"%ld,%lf",&i,&a); ReadTime(&t1); watchdog(); PIT_disable(); while(i--) aa=atan(a); PIT_enable(); wait(5); ReadTime(&t2); sprintf(cc,">>> %lf\r\n",dtime(&t2,&t1)); puts_pc(cc); beep(100); break; */ default: if(chrtx(c)) Ungetch(chrtx(c),0); break; } return(null); }
void sleeping_beauty() { /* sleep around 3 seconds on NTSC */ SetAlarm(15734*3, wakeup, 0); while (locked); }