//---------------------------------------------------------------------------------------------------- // gobal logging handler void Logging_Update(void) { static uint16_t logtimer = 0; static logfilestate_t logstate = LOGFILE_IDLE; if(SD_SWITCH) // a card is in slot { if(CheckDelay(logtimer)) { logtimer = SetDelay(10); // faster makes no sense // call the logger handlers if no error has occured if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval); if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval); // a logging error has occured if(logstate == LOGFILE_ERROR) { if(Fat16_IsValid()) // wait for reinizialization of fat16 from outside { Logging_Init(); // initialize the logs logstate = LOGFILE_IDLE; logtimer = SetDelay(10); // try next log in 10 mili sec } else { // retry in 5 seconds logtimer = SetDelay(5000); // try again in 5 sec } } //EOF logfile error } // EOF CheckDelay }// EOF Card in Slot }
// // Called when the contents of the delay editbox change // void CAccessDialog::OnChangeDelay() { // Update the delay time if it's not blank. if (m_EDelayTime.LineLength()) { SetDelay(GetDlgItemInt(EDelayTime)); } else if (GetFocus() != &m_EDelayTime) { // Entry box is empty and it no longer has focus. // Revert to the value in the access spec. SetDelay(GetDelay()); } }
//------------------------------------------------------------------------- //-- Enables/Disables timer events void CAutoSave::SetEnabled(boolean bIsEnabled) { if (bIsEnabled) { if (CAutoSave::m_nDelay == 0) { // Force minimal delay SetDelay(1); } } else { SetDelay(0); } }
bool Player::Shot(Game_Manager* gm_, coord_def c, float focus_, int item_num) { if(GetStop()) return false; Item* item_ = NULL; switch(item_num) { case 0: item_ = current_weapon; break; case 1: item_ = main_weapon; break; case 2: item_ = sub_weapon[0]; break; case 3: item_ = sub_weapon[1]; break; case 4: item_ = melee_weapon; break; } if(!GetDelay() && item_) { focus_ += GetFocusSum(); InitNoneMoveCount(); if(SetDelay(item_->Shot(gm_, this, GetTeam(), GetPos(), c, focus_)) == -1) { SetDelay(0); if(item_ == main_weapon) { Reload(gm_); } return false; } else { if(item_ == main_weapon) { if(GetFocus() < main_weapon->GetFocusMaxReact()) UpDownFocus(main_weapon->GetFocusReact()); } return true; } } return false; }
void cPlayer::StartSuperAttack() { SetState(STATE_SUPERATTACK); SetFrame(0); SetDelay(0); }
void UART0_TransmitTxData(void) { if(DebugUART == UART0) return; UART0_Transmit(); // output pending bytes in tx buffer if(UART0_tx_buffer.Locked == TRUE) return; else if(UART0_Request_ErrorMessage && (UART0_tx_buffer.Locked == FALSE)) { MKProtocol_CreateSerialFrame(&UART0_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); UART0_Request_ErrorMessage = FALSE; } else if(UART0_Request_VersionInfo && (UART0_tx_buffer.Locked == FALSE)) { MKProtocol_CreateSerialFrame(&UART0_tx_buffer, 'V', NC_ADDRESS,1, (u8 *)&UART_VersionInfo, sizeof(UART_VersionInfo)); UART0_Request_VersionInfo = FALSE; } else if(( ((UART0_NaviData_Interval >0) && CheckDelay(UART0_NaviData_Timer) ) || UART0_Request_NaviData) && (UART0_tx_buffer.Locked == FALSE)) { NaviData.Errorcode = ErrorCode; MKProtocol_CreateSerialFrame(&UART0_tx_buffer, 'O', NC_ADDRESS,1, (u8 *)&NaviData, sizeof(NaviData)); UART0_NaviData_Timer = SetDelay(UART0_NaviData_Interval); UART0_Request_NaviData = FALSE; } UART0_Transmit(); // output pending bytes in tx buffer }
XImlib2Background::XImlib2Background(AbstractContainer * c, AbstractConfig * con): TimerControl(), container(c), config(con),delay(0), mode(0), save(NULL), show(NULL), srctime(0), images(""), directory(""), OneShot(false) { cmap = imlib_context_get_colormap(); visual = imlib_context_get_visual(); DesktopConfig * dConfig = dynamic_cast<DesktopConfig *>(config); if( !show) { show = &data[0]; save = &data[1]; } int d = dConfig->getDelayBackground(); directory = dConfig->getSourceBackground(); if(d == 0 || directory == "None"){ OneShot = true; } srand( (unsigned)time(0) ); if(OneShot){ SetOneImage(); }else{ ScanImages(); SetDelay( d ); } }
u8 UART0_UBXSendCFGMsg(u8* pData, u16 Len) { u32 timeout; u8 retval = 0; // if data are not a CFG MSG if(pData[0]!= UBX_CLASS_CFG) return(retval); // prepare rx msg filter UbxMsg.Hdr.Class = UBX_CLASS_ACK; UbxMsg.Hdr.Id = 0xFF; UbxMsg.Hdr.Length = 0; UbxMsg.ClassMask = 0xFF; UbxMsg.IdMask = 0x00; UbxMsg.Status = INVALID; UART0_UBXSendMsg(pData, Len); // check for acknowledge msg timeout = SetDelay(100); do { if(UbxMsg.Status == NEWDATA) break; }while(!CheckDelay(timeout)); if(UbxMsg.Status == NEWDATA) { // 2 bytes payload if((UbxMsg.Data[0] == pData[0]) && (UbxMsg.Data[1] == pData[1]) && (UbxMsg.Hdr.Length == 2)) retval = UbxMsg.Hdr.Id; } UbxMsg.Status = INVALID; return(retval); }
EnemyMelee::EnemyMelee(void) { Flush = false; AccumulatedTime = 0.0; SetDelay(0.5); }
BOOL ArmDev::ConfigParameters(ST_ARM_CONSOLE_DEV_INF_PARA stIntfPara) { if (!m_bDevInterfaceOK) { TRACE(TEXT("ARM_DEVICE_NOT_EIST \r\n")); return FALSE; } if (!SetDelay(stIntfPara.iDelayTime)) { TRACE(TEXT("SetDelay Failed \r\n")); return FALSE; } Sleep(50); if (!SetPeriod(stIntfPara.iPriodTime)) { TRACE(TEXT("SetPeriod Failed \r\n")); return FALSE; } Sleep(50); if (!SetPulseNum(stIntfPara.iPulseNum)) { TRACE(TEXT("SetPulseNum Failed \r\n")); return FALSE; } return TRUE; }
void LipoDetection(unsigned char print) { #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO unsigned int timer, cells; if(print) printf("\n\rBatt:"); if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung { timer = SetDelay(500); if(print) while (!CheckDelay(timer)); // up to 6s LiPo, less than 2s is technical impossible for(cells = 2; cells < 7; cells++) { if(UBat < cells * MAX_CELL_VOLTAGE) break; } BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; if(print) { Piep(cells, 200); printf(" %d Cells ", cells); } } else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); }
CStdMultimediaTimerProc::CStdMultimediaTimerProc(uint32_t iDelay) { fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); if (fd == -1) Log("timerfd_create failed"); SetDelay(iDelay); }
u8 UART0_GetMKOSDVersion(void) { u32 timeout; u8 msg[64]; u8 retval = 0; MKOSD_VersionInfo.SWMajor = 0xFF; MKOSD_VersionInfo.SWMinor = 0xFF; MKOSD_VersionInfo.SWPatch = 0xFF; if(UART0_Muxer != UART0_MKGPS) UART0_Connect_to_MKGPS(UART0_BAUD_RATE); while(UART0_tx_buffer.Locked == TRUE) UART0_Transmit(); // output pending bytes in tx buffer; MKProtocol_CreateSerialFrame(&UART0_tx_buffer, 'v', MKOSD_ADDRESS, 0); // request for version info while(UART0_tx_buffer.Locked == TRUE) UART0_Transmit(); // output pending bytes in tx buffer; timeout = SetDelay(500); do { UART0_ProcessRxData(); if(MKOSD_VersionInfo.SWMajor != 0xFF) break; }while(!CheckDelay(timeout)); if(MKOSD_VersionInfo.SWMajor != 0xFF) { sprintf(msg, "\n\r MK-OSD V%d.%d%c", MKOSD_VersionInfo.SWMajor, MKOSD_VersionInfo.SWMinor, 'a'+MKOSD_VersionInfo.SWPatch); UART1_PutString(msg); retval = 1; } //else UART1_PutString("\n\r No version information from MK-OSD."); return(retval); }
u8 UART0_GetUBXVersion(void) { u32 timeout; u8 retval = 0xFF; u8 ubxmsg[]={0x0A, 0x04, 0x00, 0x00}; //MON-VER // prepare rx msg filter UbxMsg.Hdr.Class = 0x0A; UbxMsg.Hdr.Id = 0x04; UbxMsg.Hdr.Length = 0; UbxMsg.ClassMask = 0xFF; UbxMsg.IdMask = 0xFF; UbxMsg.Status = INVALID; UART0_UBXSendMsg(ubxmsg, sizeof(ubxmsg)); // check for answer timeout = SetDelay(100); do { if(UbxMsg.Status == NEWDATA) break; }while(!CheckDelay(timeout)); if((UbxMsg.Hdr.Length >= 40) && (UbxMsg.Status == NEWDATA)) { UbxMsg.Data[4] = 0; //Only the fisrt 4 chsracters UbxMsg.Data[39] = 0; UART1_PutString(" V"); UART1_PutString((u8*)&UbxMsg.Data); UART1_PutString(" HW:"); UART1_PutString((u8*)&UbxMsg.Data[30]); retval = UbxMsg.Data[0]-'0'; // major sw version } UbxMsg.Status = INVALID; return(retval); }
//------------------------------------------------------------ SetDelay() // void SetDelay(long int ns){ struct timespec ts_req, ts_rem; ts_req.tv_sec = 0; ts_req.tv_nsec = ns; /* Recursive call in case of signal reception*/ if (nanosleep(&ts_req, &ts_rem)==-1) SetDelay(ts_rem.tv_nsec); }
void InitializeLCD(int Index) { if (Index == ChoosePort) { SetByte(0, LCD_Read); // Start all control lines low, float databus WriteLCD(LCD_FunctionSet|TwoLine|FiveByElevenFont); WriteLCD(LCD_DisplayControl|EnableDisplay); WriteLCD(LCD_ClearDisplay); SetDelay(1600); // Insert 1.6 msec after a ClearDisplay SignOnLCD(); } }
void InitTimer(uint8_t timer){ switch(timer){ case RIT_TIMER: Chip_RIT_Init(LPC_RITIMER); SetDelay(RIT_TIMER,100); break; default: break; } }
//############################################################################ //启动代码,pwm为启动时的占空比 char Anwerfen(unsigned char pwm) //############################################################################ { unsigned long timer = 300,i; DISABLE_SENSE_INT; //关掉模拟比较器中断 PWM = 5; SetPWM(); Manuell(); // Delay_ms(200); MinUpmPulse = SetDelay(300); /* * 延时300ms,期间不断检测电流,如果电流大于12A,关掉所有MOSFET,红灯闪10下 */ while(!CheckDelay(MinUpmPulse)) { FastADConvert(); if(Strom > 120) { STEUER_OFF; // Abschalten wegen Kurzschluss RotBlink(10); return(0); // 启动失败 } } PWM = pwm; // pwm = 10 while(1) // main starup program { for(i=0;i<timer; i++) // timer = 300 { if(!UebertragungAbgeschlossen) SendUart(); //UebertragungAbgeschlossen用来表示串口当前是否正忙,0不忙,1忙 else DatenUebertragung(); Wait(100); // wait 100us } DebugAusgaben(); //将一些当前信息写到调试结构中去 FastADConvert(); if(Strom > 60) { STEUER_OFF; // Abschalten wegen Kurzschluss RotBlink(10); return(0); } timer-= timer/15+1; // actually, 14/15 of timer if(timer < 25) { if(TEST_MANUELL) timer = 25; else return(1); } // timer is going to converge, utiil it is less than 25, it stops. Manuell(); Phase++; Phase %= 6; AdConvert(); //检测shunt上电流 PWM = pwm; SetPWM(); if(SENSE) //若模拟比较器中断位置标志,则此表达式为非零 { PORTD ^= GRUEN; } } }
bool Monster::Shot(Game_Manager* gm_, coord_def c, float focus_, int item_num) { if(GetShotStop()) return false; if(GetStop()) return false; if(!GetDelay() && weapon) { focus_ += weapon->GetFocusBase()+GetFocusSum(); while(SetDelay(weapon->Shot(gm_, this, GetTeam(), GetPos(), c, focus_)*panalty) < 0) { SetDelay(0.0f); weapon->Reload(); //몬스터는 무한 리로드한다. } if(GetFocus() < weapon->GetFocusMaxReact()) UpDownFocus(weapon->GetFocusReact()); return true; } return false; }
void C4ApplicationGameTimer::SetGameTickDelay(uint32_t iDelay) { // Remember delay iGameTickDelay = iDelay; // Smaller than minimum refresh delay? if (iDelay < uint32_t(Config.Graphics.MaxRefreshDelay)) { // Set critical timer SetDelay(iDelay); // No additional breaking needed iExtraGameTickDelay = 0; } else { // Set critical timer SetDelay(Config.Graphics.MaxRefreshDelay); // Slow down game tick iExtraGameTickDelay = iDelay; } }
CFX_RGBLedAnimationColorBlink::CFX_RGBLedAnimationColorBlink(unsigned long onTime, unsigned long offTime, unsigned long startdelay, CFX_Color color, CFX_LedBase* output) : CFX_AnimationBase() { m_blinkOnTime = onTime; m_blinkOffTime = offTime; m_output = output; m_previousUpdateTime = millis(); m_blinkon = false; m_color = color; SetDelay(startdelay); }
bool Player::Reload(Game_Manager * gm_) {//³ªÁß¿¡ bulletÀÇ °¹¼ö¿¡ ÀÇÇؼ ¸®·ÎµùÇÏ°Ô ÇÏÀÚ if(current_weapon && current_weapon == main_weapon) { float need_bullet = 1.0f-((float)main_weapon->GetBullet()/(int)main_weapon->GetMaxBullet()); if(need_bullet && bullet > 0.0f) { main_weapon->PlayReloadSE(gm_); need_bullet = min(need_bullet,bullet); bullet -= need_bullet; SetDelay(main_weapon->Reload(need_bullet)); } else if(blood_reload && GetHp()>blood_reload) { main_weapon->PlayReloadSE(gm_); UpDownHp(-(int)(blood_reload*need_bullet+0.99f)); SetDelay(main_weapon->Reload(need_bullet)); } } return true; }
Player::Player(jframe::Window* window, jvis::Texture* tex, LevelLoader* level, const jmath::vec4& rect, int cols, int frames, int delay) : p_Window(window), m_CanJump(true), m_JumpBtnHeld(false), m_Health(0), // 28 m_TimerJump(0), m_Direction(Mega::Direction::RIGHT), jvis::AnimatedSprite(tex, rect, cols, 1, delay) { p_Level = level; SetDelay(delay); // Physics setup SetSize(jmath::vec2(32, 32)); GetRigidBody()->SetFriction(1.f); GetRigidBody()->SetMass(15.f); GetRigidBody()->SetDimensions(jmath::vec3(18, 28, 0)); GetRigidBody()->SetCollisionType(jphys::CollisionType::BOX_REACTIVE); // Collision flags are removed because m_CollisionX and Y will deal with it GetRigidBody()->RemoveCollisionFlags(jphys::CollisionFlags::ResolveX); GetRigidBody()->RemoveCollisionFlags(jphys::CollisionFlags::ResolveY); // Collision resolution setup - these are to resolve X and Y collision separately m_CollisionY.GetRigidBody()->SetCollisionType(jphys::CollisionType::BOX_REACTIVE); m_CollisionY.GetRigidBody()->SetCollisionFlags(jphys::CollisionFlags::ResolveY); m_CollisionY.SetSize(jmath::vec2(8, 28)); m_CollisionY.GetRigidBody()->MoveY(-3); m_CollisionX.GetRigidBody()->SetCollisionType(jphys::CollisionType::BOX_REACTIVE); m_CollisionX.GetRigidBody()->SetCollisionFlags(jphys::CollisionFlags::ResolveX); m_CollisionX.SetSize(jmath::vec2(18, 24)); m_CollisionX.GetRigidBody()->MoveY(-3); // The 12 sprites that move outwards upon death for (int i = 0; i < 12; ++i) { m_DeathSprites.push_back(AnimatedSprite()); m_DeathSprites.back().SetRectangle(jmath::vec4(8, 184, 16, 16)); m_DeathSprites.back().SetSize(jmath::vec2(16)); m_DeathSprites.back().SetNumColumns(4); m_DeathSprites.back().SetNumFrames(4); m_DeathSprites.back().SetTexture(GetTexture()); } m_TimerDeath.SetTime(JTime::Milliseconds(DEATH_ANIMATION_TIME)); m_TimerInvincibility.SetTime(JTime::Milliseconds(INVINCIBILITY_TIME)); m_TimerBulletAnimationDelay.SetTime(JTime::Milliseconds(FIRING_ANIMATION_DELAY)); }
void cPlayer::NextFrame(int max) { SetDelay(GetDelay()+1); if(GetState() == STATE_ATTACKUP || GetState() == STATE_ATTACKRIGHT || GetState() == STATE_ATTACKDOWN || GetState() == STATE_ATTACKLEFT || GetState() == STATE_SUPERATTACK) { if(GetDelay() == frame_attack_delay) { SetFrame(GetFrame()+1); SetFrame(GetFrame()%max); SetDelay(0); } } else { if(GetDelay() == frame_walk_delay) { SetFrame(GetFrame()+1); SetFrame(GetFrame()%max); SetDelay(0); } } }
int PitchBendWT::Load(XmlSynthElem *elem) { float dval; short ival; if (elem->GetAttribute("pbamp", dval) == 0) SetLevel(AmpValue(dval)); if (elem->GetAttribute("pbwt", ival) == 0) SetWavetable((int)ival); if (elem->GetAttribute("pbdur", dval) == 0) SetDuration(FrqValue(dval)); else SetDuration(1.0); if (elem->GetAttribute("pbdly", dval) == 0) SetDelay(FrqValue(dval)); else SetDelay(0.0); if (elem->GetAttribute("pbmode", ival) == 0) SetMode((int)ival); else SetMode(0); return 0; }
void PitchBendWT::Init(int n, float *f) { if (n > 0) SetLevel(AmpValue(f[0])); if (n > 1) SetWavetable((int) f[1]); if (n > 2) SetDuration(FrqValue(f[2])); if (n > 3) SetDelay(FrqValue(f[3])); if (n > 4) SetMode((int)f[4]); Reset(0); }
void CHwX11Cursor::PushFrame(int index, float delay) { if (index >= int(cimages.size())) return; if (cimages[index]->delay != delay) { // make a copy of the existing one XcursorImage* ci = cimages[index]; PushImage( ci->width, ci->height, ci->pixels ); SetDelay(delay); } else { cimages.push_back( cimages[index] ); } }
//------------------------------------------------------------ // check for new GPS data void GPS_Update(void) { static uint16_t GPS_Timeout = 0; static uint16_t beep_rythm = 0; switch(GPSData.Status) { case INVALID: Error |= ERROR_GPS_RX_TIMEOUT; GPS_ClearPosition(&(FollowMe.Position)); // clear followme position break; case PROCESSED: // wait for timeout if(CheckDelay(GPS_Timeout)) { GPSData.Status = INVALID; } break; case NEWDATA: GPS_Timeout = SetDelay(GPS_TIMEOUT); // reset gps timeout Error &= ~ERROR_GPS_RX_TIMEOUT; // clear possible error beep_rythm++; // update data in the follow me message if((GPSData.SatFix & SATFIX_3D) && (GPSData.NumOfSats >= GPS_MINSATS)) { GPS_CopyPosition(&(GPSData.Position),&(FollowMe.Position)); } else { GPS_ClearPosition(&(FollowMe.Position)); // clear followme position } // NC like sound on bad gps signals if(SysState == STATE_SEND_FOLLOWME) { if(!(GPSData.Flags & FLAG_GPSFIXOK) && !(beep_rythm % 5)) BeepTime = 100; else if ((GPSData.NumOfSats < GPS_MINSATS) && !(beep_rythm % 5)) BeepTime = 10; } GPSData.Status = PROCESSED; // set to processed unlocks the buffer for new data break; default: GPSData.Status = INVALID; break; } }
// ----------------------------------------------------------- // the menu functions // ----------------------------------------------------------- void Menu_Status(uint8_t key) { //0123456789ABCDEF #if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP) JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10); if(NaviDataOkay) { JetiBox_printfxy(6,0,"%3d%c %03dm%c",ErsatzKompassInGrad, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter); } else { JetiBox_printfxy(6,0,"Status"); } #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) if(NC_ErrorCode) { static unsigned int timer; static char toggle = 1; if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);}; if(toggle) { LIBFC_JetiBox_SetPos(0); _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0); } else { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); // if(MotorenEin) JetiBeep = 'O'; } } else if(ShowSettingNameTime) { LIBFC_JetiBox_Clear(); JetiBox_printfxy(0,1,"Set%d:%s ",ActiveParamSet,EE_Parameter.Name); return; // nichts weiter ausgeben } #else if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'S';}; #endif JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) { JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); } #endif }
unsigned char GetKeyboard(void) { static char taste1 = 0, taste2 = 0,taste3 = 0,taste4 = 0,taste5 = 0; unsigned char ret = 0; if(CheckDelay(KeyTimer)) { if(_TASTE1) { if(taste1++ == 0 || taste1 == CNT_TASTE) ret |= KEY1; if(taste1 == CNT_TASTE) taste1 = CNT_TASTE-CNT_TASTE/3;} else taste1 = 0; if(_TASTE2) { if(taste2++ == 0 || taste2 == CNT_TASTE) ret |= KEY2; if(taste2 == CNT_TASTE) taste2 = CNT_TASTE-CNT_TASTE/3;} else taste2 = 0; if(_TASTE3) { if(taste3++ == 0 || taste3 == CNT_TASTE) ret |= KEY3; if(taste3 == CNT_TASTE) taste3 = CNT_TASTE-CNT_TASTE/3;} else taste3 = 0; if(_TASTE4) { if(taste4++ == 0 || taste4 == CNT_TASTE) ret |= KEY4; if(taste4 == CNT_TASTE) taste4 = CNT_TASTE-CNT_TASTE/3;} else taste4 = 0; if(_TASTE5) { if(taste5++ == 0 || taste5 == CNT_TASTE) ret |= KEY5; if(taste5 == CNT_TASTE) taste5 = CNT_TASTE-CNT_TASTE/3;} else taste5 = 0; KeyTimer = SetDelay(KEY_DELAY_MS); } return(ret); }