void Robot::TeleopInit() { double startTime = GetRTC(); printf("Robot: TeleopInit at %f seconds, %d ticks", startTime, ticks); // If we'd previously run an autonomous, record how long it lasted if (m_startTicks > 0) { double elapsedTime = startTime - m_startTime; int elapsedTicks = ticks - m_startTicks; printf(", prior autonomous ran for %f seconds, %d ticks, %5.2f tps.", elapsedTime, elapsedTicks, elapsedTicks/elapsedTime); } printf("\n"); m_startTicks = ticks; m_startTime = startTime; // uncomment only for calibrating vision // CommandBase::navXSubsystem->zeroYaw(0); if (mp_autonomousCommand != NULL) { mp_autonomousCommand->Cancel(); } // begin teleop "polling" commands CommandBase::driveJoystickCommand->Start(); CommandBase::intakeRollerCommand->Start(); CommandBase::flapCommand->Start(); SetLeds(NORMAL); }
__myevic__ void DTMenuOnEnter() { dt_sel = 2; GetRTC( &rtd ); ScreenDuration = 120; }
//========================================================================= __myevic__ void ShowRTCAdjust() { S_RTC_TIME_DATA_T rtd; DrawString( String_ClkAdjust, 4, 6 ); DrawHLine( 0, 16, 63, 1 ); GetRTC( &rtd ); DrawTime( 5, 40, &rtd, 0x1F ); }
__myevic__ void ShowRTCSpeed() { unsigned int cs; S_RTC_TIME_DATA_T rtd; DrawString( String_ClkSpeed, 4, 6 ); DrawHLine( 0, 16, 63, 1 ); GetRTC( &rtd ); DrawTimeSmall( 12, 20, &rtd, 0x1F ); cs = RTCGetClockSpeed(); DrawValue( 12, 40, cs, 0, 0x1F, 5 ); }
//----清除全部刷卡记录----------------------------------------------------- void clear_CardID() { char DateSt[12], TimeSt[12]; storeaddrlist.RecordCount = 0; storeaddrlist.CountAddrOffset = 0; timeoutaddrlist.RecordCount = 0; timeoutaddrlist.CountAddrOffset = 0; LastSaveTime = GetRTC(DateSt, TimeSt);///获取当前时间,秒数 //需要优化; //清除记录区 FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FLASH_ErasePage(PLACELASTID); FLASH_ErasePage(POINTOFSECTION); FLASH_Lock(); }
void Robot::DisabledInit() { double startTime = GetRTC(); printf("Robot: Disabled at %f seconds, %d ticks", startTime, ticks); // If we'd previously run an autonomous, record how long it lasted if (m_startTicks > 0) { double elapsedTime = startTime - m_startTime; int elapsedTicks = ticks - m_startTicks; printf(", prior state ran for %f seconds, %d ticks, %5.2f tps.", elapsedTime, elapsedTicks, elapsedTicks/elapsedTime); } printf("\n"); m_startTicks = ticks; m_startTime = startTime; if (mp_autonomousCommand != NULL) { mp_autonomousCommand->Cancel(); } printf("LEDs: Turning off\n"); SetLeds(OFF); }
void Robot::AutonomousInit() { m_startTicks = ticks; m_startTime = GetRTC(); printf("Robot: AutononmousInit at %f seconds, %d ticks\n", m_startTime, ticks); int pos = m_fieldInfo.GetPosition(); int def = m_fieldInfo.GetDefense(); int target = m_fieldInfo.GetTarget(); bool slow = m_fieldInfo.IsCrossingSlowly(); printf("Autonomous: Position %d | Defense %d | Target %d, Speed %s\n", pos, def, target, slow ? "SLOW" : "NORMAL"); // make sure we don't inadvertently leave the LED ring off CommandBase::visionSubsystem->setLedRingState(true); // if we've already run auto, delete the existing auto command if (mp_autonomousCommand != NULL) { delete mp_autonomousCommand; mp_autonomousCommand = NULL; } // create a new dynamic auto command with the selected parameters from the SmartDashboard mp_autonomousCommand = new AutonomousDriveAndShoot(pos, def, target); mp_autonomousCommand->Start(); // reset our coordinate system to where the robot is currently located / oriented // assume robot was set up correctly (there's nothing else we can do) // Robot will start out wedges first, or intake first, depending on the defense CommandBase::navXSubsystem->zeroYaw(m_fieldInfo.GetInitialOrientation()); CommandBase::navXSubsystem->ResetDisplacement(); CommandBase::driveSubsystem->SetInitialPosition(FieldInfo::startingLocations[pos].x, FieldInfo::startingLocations[pos].y); CommandBase::driveJoystickCommand->Cancel(); CommandBase::intakeRollerCommand->Cancel(); CommandBase::flapCommand->Cancel(); SetLeds(NORMAL); }
//========================================================================= //----- (00000148) -------------------------------------------------------- __myevic__ void Main() { InitDevices(); InitVariables(); // Enable chip temp sensor sampling by ADC if ( ISRX300 ) { SYS->IVSCTL |= SYS_IVSCTL_VTEMPEN_Msk; } InitHardware(); myprintf( "\n\nJoyetech APROM\n" ); myprintf( "CPU @ %dHz(PLL@ %dHz)\n", SystemCoreClock, PllClock ); SetBatteryModel(); gFlags.sample_vbat = 1; ReadBatteryVoltage(); gFlags.sample_btemp = 1; ReadBoardTemp(); InitDisplay(); MainView(); SplashTimer = 3; CustomStartup(); if ( !PD3 ) { DrawScreen(); while ( !PD3 ) ; } while ( 1 ) { while ( gFlags.playing_fb ) { // Flappy Bird game loop fbCallTimeouts(); if ( gFlags.tick_100hz ) { // 100Hz gFlags.tick_100hz = 0; ResetWatchDog(); TimedItems(); SleepIfIdle(); GetUserInput(); if ( !PE0 ) SleepTimer = 3000; } if ( gFlags.tick_10hz ) { // 10Hz gFlags.tick_10hz = 0; DataFlashUpdateTick(); } } if ( gFlags.firing ) { ReadAtoCurrent(); } if ( gFlags.tick_5khz ) { // 5000Hz gFlags.tick_5khz = 0; if ( gFlags.firing ) { RegulateBuckBoost(); } } if ( gFlags.tick_1khz ) { // 1000Hz gFlags.tick_1khz = 0; if ( gFlags.firing ) { ReadAtomizer(); if ( ISMODETC(dfMode) ) { if ( gFlags.check_mode ) { CheckMode(); } TweakTargetVoltsTC(); } else if ( ISMODEVW(dfMode) ) { TweakTargetVoltsVW(); } } if ( dfStatus.vcom ) { VCOM_Poll(); } } if ( gFlags.tick_100hz ) { // 100Hz gFlags.tick_100hz = 0; ResetWatchDog(); if ( gFlags.read_battery ) { gFlags.read_battery = 0; } TimedItems(); SleepIfIdle(); ReadBatteryVoltage(); ReadBoardTemp(); if ( gFlags.firing && BoardTemp >= 70 ) { Overtemp(); } if ( ISVTCDUAL ) { BatteryChargeDual(); } else if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { BatteryCharge(); } if (( gFlags.anim3d ) && ( Screen == 1 ) && ( !EditModeTimer )) { anim3d( 0 ); } if ( Screen == 60 ) { AnimateScreenSaver(); } if ( gFlags.firing ) { if ( gFlags.read_bir && ( FireDuration > 10 ) ) { ReadInternalResistance(); } if ( PreheatTimer && !--PreheatTimer ) { uint16_t pwr; if ( dfMode == 6 ) { pwr = dfSavedCfgPwr[ConfigIndex]; } else { pwr = dfPower; } if ( pwr > BatteryMaxPwr ) { gFlags.limit_power = 1; PowerScale = 100 * BatteryMaxPwr / pwr; } else { gFlags.limit_power = 0; PowerScale = 100; } } } if ( KeyTicks >= 5 ) { KeyRepeat(); } GetUserInput(); } if ( gFlags.tick_10hz ) { // 10Hz gFlags.tick_10hz = 0; DataFlashUpdateTick(); LEDTimerTick(); if ( gFlags.firing ) { ++FireDuration; if ( gFlags.monitoring ) { Monitor(); } } if ( ShowWeakBatFlag ) --ShowWeakBatFlag; if ( ShowProfNum ) --ShowProfNum; if ( !( gFlags.firing && ISMODETC(dfMode) ) ) { DrawScreen(); } if ( KeyTicks < 5 ) { KeyRepeat(); } } if ( gFlags.tick_5hz ) { // 5Hz gFlags.tick_5hz = 0; if ( !gFlags.rtcinit && NumBatteries ) { InitRTC(); } if ( gFlags.firing ) { if ( TargetVolts == 0 ) { ProbeAtomizer(); } } else { if ( !dfStatus.off && Event == 0 && ( AtoProbeCount < 12 ) && ( Screen == 0 || Screen == 1 || Screen == 5 ) ) { ProbeAtomizer(); } } if ( IsClockOnScreen() ) { static uint8_t u8Seconds = 61; S_RTC_TIME_DATA_T rtd; GetRTC( &rtd ); if ( (uint8_t)rtd.u32Second != u8Seconds ) { u8Seconds = (uint8_t)rtd.u32Second; gFlags.refresh_display = 1; } } } if ( gFlags.tick_2hz ) { // 2Hz gFlags.tick_2hz = 0; gFlags.osc_1hz ^= 1; if ( gFlags.firing ) { if ( ISMODETC(dfMode) ) { DrawScreen(); } } else { if ( !dfStatus.off && Event == 0 && ( AtoProbeCount >= 12 ) && ( Screen == 0 || Screen == 1 || Screen == 5 ) ) { ProbeAtomizer(); } if ( gFlags.monitoring ) { Monitor(); } } } if ( gFlags.tick_1hz ) { // 1Hz gFlags.tick_1hz = 0; if ( SplashTimer ) { --SplashTimer; if ( !SplashTimer ) { MainView(); } } if ( !gFlags.firing && !dfStatus.off && !EditModeTimer ) { if ( HideLogo ) { if ( Screen == 1 ) { --HideLogo; if ( !HideLogo ) { gFlags.refresh_display = 1; } } } } } EventHandler(); } }