本文整理汇总了C++中SimpleTimer::toggle方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleTimer::toggle方法的具体用法?C++ SimpleTimer::toggle怎么用?C++ SimpleTimer::toggle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleTimer
的用法示例。
在下文中一共展示了SimpleTimer::toggle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CenterSmartUpdate
inline void CenterSmartUpdate()
{
center = analogRead(CENTER_SENSOR);
if (centerTimeoutCount)
centerTimeoutCount += 1;
if (!centerOldHigh && (center > centerSchmittHigh.Value)) // On switch-to-high
{
centerOldHigh = true; // Switch current center state to high
if((intersectionSignalRecent + 1) == INTERSECTION_COUNT_ORIGIN) // If the start/stop signal is encountered, toggle clock.
// This is done on when it switches high (instead of waiting for timeout) to save a bit of clock-time.
{
lapTimer.toggle(0);
if (!lapTimer.isEnabled(0))
{
// Stop motors before entering menu
MotorSpeed(LEFT_MOTOR, 0);
MotorSpeed(RIGHT_MOTOR, 0);
Clear();
Cursor(TOP, 0);
Print("Finish!");
currentState = menu;
delay(800);
return;
}
}
switch(intersectionTurnFlag)
{
case INTERSECTION_COUNT_LEFT: // First intersection after left signal
currentState = turnLeft;
break;
case INTERSECTION_COUNT_RIGHT: // First intersection after right signal
currentState = turnRight;
break;
default: // Else
currentState = moveStraight;
intersectionSignalRecent += 1;
break;
}
centerTimeoutCount = 0; // Stop timeout counter
intersectionTurnFlag = 0; // Reset flag
}
else if (centerOldHigh && (center < centerSchmittLow.Value)) // On switch-to-low
{
centerOldHigh = false; // Swtich current center state to low
centerTimeoutCount = 1; // Start timeout counter
}
if (centerTimeoutCount >= (centerTimeoutLimit.Value * 2)) // Timeout
{
if (intersectionTurnFlag < intersectionSignalRecent) // Do not let false signals effect the flag
intersectionTurnFlag = intersectionSignalRecent; // Set flag
intersectionSignalRecent = 0; // Reset signal counter
centerTimeoutCount = 0; // Stop timeout counter
}
}