本文整理汇总了C++中Led::run方法的典型用法代码示例。如果您正苦于以下问题:C++ Led::run方法的具体用法?C++ Led::run怎么用?C++ Led::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Led
的用法示例。
在下文中一共展示了Led::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/// Must be called at least every ms
void
run()
{
led->run();
if (timer.isExpired() && (isBlinking || state == FIRST_BREAK || state == SECOND_BREAK))
{
switch (state)
{
case FIRST_FLASH:
led->on(onFade);
timer.restart(on1);
state = FIRST_BREAK;
break;
case FIRST_BREAK:
led->off(offFade);
timer.restart(pause1);
state = SECOND_FLASH;
break;
case SECOND_FLASH:
led->on(onFade);
if (isCounting && !--counter) {
isBlinking = false;
isCounting = false;
}
timer.restart(on2);
state = SECOND_BREAK;
break;
case SECOND_BREAK:
led->off(offFade);
timer.restart(pause2);
default:
state = FIRST_FLASH;
break;
}
}
}
示例2:
/// Must be called at least every ms
void
run()
{
led->run();
if (!led->isFading() && (isPulsing || !pulseDirection))
{
if (pulseDirection) {
led->on(halfPeriod);
if (isCounting && !--counter) {
isPulsing = false;
isCounting = false;
}
}
else {
led->off(halfPeriod);
}
pulseDirection = !pulseDirection;
}
}