示例#1
0
			/// 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
0
文件: pulse.hpp 项目: Alex0704t/xpcc
			/// 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;
				}
			}