void onDoorStatus()
{
  debug("onDoorStatus()");

  door_status = (DS) cmd.readInt32Arg();
  cmd.sendCmd(GC_Acknowledge, F("door"));

  if( ((door_command == DC_OPEN_DOOR)  && (door_status == DS_Open  )) ||  // door is now open
      ((door_command == DC_CLOSE_DOOR) && (door_status == DS_Closed)) ||  // door is now closed
       (door_command == DC_NONE)                                       )
  {
    door_command = DC_NONE;

    movementWatchdog.stop();

    switch( door_status )
    {
      case DS_Open:
        openLed.on();
        closeLed.off();
        break;

      case DS_Closed:
        closeLed.on();
        openLed.off();
        break;
    }
  }
  else
  {
    switch( door_command )
    {
      case DC_OPEN_DOOR:
        breathe(openLed);
        closeLed.off();
        break;
      
      case DC_CLOSE_DOOR:
        breathe(closeLed);
        openLed.off();
        break;
    }
  }

  updateDisplay();

  Particle.publish(F("Door"), toString(door_status), PRIVATE);

  //lcdPrint(0, toString(door_status));
  //lcdPrint(1, toString(door_command));
}
Пример #2
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;
					}
				}
			}
Пример #3
0
			/// 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;
				}
			}