本文整理汇总了C++中LED::IsOn方法的典型用法代码示例。如果您正苦于以下问题:C++ LED::IsOn方法的具体用法?C++ LED::IsOn怎么用?C++ LED::IsOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LED
的用法示例。
在下文中一共展示了LED::IsOn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateWithLightTransition
// this function simulates normal light condition when called at every loop
// it automatically transitions from green to red signal by using the OrangeTransitionCounter
void UpdateWithLightTransition(bool goSignal, bool turnLight, bool pedLight, int orangeLightTime) {
// if green or go signal turn off transitioning process
// and only light up the green light
if (goSignal) {
transitionState = 0;
GreenLight();
}
// if red signal and green light was previously on
// start transitioning to red by firt turning on the
// orange light
else if(!goSignal && ledGreen.IsOn() && transitionState == 0) {
OrangeLight();
transitionState = 1;
OrangeTransitionCounter.Reset();
}
// if red signal and greenlight was not on, directly
// switch on the red light
else if(!goSignal && !ledGreen.IsOn() && transitionState == 0)
RedLight();
// check if we are still transitioning to red light
// if orangeTransitionCounter has passed orangeLightTime interval
// turn on the Red light only
if (transitionState == 1) {
if (OrangeTransitionCounter.GetCounter() < orangeLightTime)
OrangeLight();
else
transitionState = 2;
}
if (transitionState == 2)
RedLight();
if (turnLight)
ledFilterTurn.SwitchOn();
else
ledFilterTurn.SwitchOff();
// ped lights turn on only when the normal lights are in red signal
if (pedLight && ledRed.IsOn())
ledPed.SwitchOn();
else
ledPed.SwitchOff();
}