void WashingMachineController::dispendSoap() {
	command = soap.getOpenCommand();
	char response = uartTask(command[0], command[1]);
	
	command = soap.getCloseCommand();
	response = uartTask(command[0], command[1]);
}
void WashingMachineController::signalLed(bool on) {
	if (on) {
		char response = uartTask(SIGNAL_LED_REQ, ON_CMD);
	}
	else {
		char response = uartTask(SIGNAL_LED_REQ, OFF_CMD);
	}
}
void WashingMachineController::doorlock(bool lock) {
	if (lock) {
		char response = uartTask(DOOR_LOCK_REQ, LOCK_CMD);
	}
	else {
		char response = uartTask(DOOR_LOCK_REQ, UNLOCK_CMD);
	}
}
void WaterController::pumping(bool on) {
	if (on) {
		command = pump.getOnCommand();
	}
	else {
		command = pump.getOffCommand();
	}
	char response = uartTask(command[0], command[1]);
}
void WaterController::valving(bool on) {
	char * command;
	if (on) {
		command = valve.getOnCommand();
	}
	else {
		command = valve.getOffCommand();
	}
	char response = uartTask(command[0], command[1]);
}
void WaterController::pumping(bool on) {
	if (on) {
		command = pump.getOnCommand();
	}
	else {
		command = pump.getOffCommand();
	}
	//std::cout << unsigned(command[0]) << unsigned(command[1]) << " pump command\n";
	char response = uartTask(command[0], command[1]);
}
bool WashingMachineController::getDoorStatus() {
	char command[3] = { DOOR_LOCK_REQ , STATUS_CMD, '\0' };
	char response = uartTask(command[0], command[1]);
	int status = unsigned(response);

	if (status == OPENED) {
		return 0;
	}
	else {
		return 1;
	}
	return status;
}
int WaterController::getWaterLevel() {
	command = watersensor.getWaterLevelCommand();
	char response = uartTask(command[0], command[1]);
	return response;
}
int WaterController::getWaterLevel() {
	command = watersensor.getWaterLevelCommand();
	//std::cout << "getting waterlevel from uart\n";
	char response = uartTask(command[0], command[1]);
	return response;
}
Beispiel #10
0
/********************************************************************
* Function: 	main()
********************************************************************/
INT main(void)
{
   DWORD count1 = 0;
   BYTE timer_ro = 1;

   // switch to FRC w/PLL to keep up at higher baud rates (120MHz!
   PLLFBD=63;
   CLKDIVbits.PLLPOST = 0;
   CLKDIVbits.PLLPRE = 0;

    __builtin_write_OSCCONH(0x01);
   __builtin_write_OSCCONL(OSCCON | 0x01);

   while (OSCCONbits.COSC != 0b001);
   while (OSCCONbits.LOCK != 1);

   // Initialize I/O, UART and timer (interrupt)
   initIO();

   led1Off();
   led2Off();
   led3Off();

   printString("BL:V1.00:");
   
   if (ValidAppPresent())
   {
      while(count1<20)
      {
         if ((SWITCH1 == 0) || (SWITCH2 == 0))  // if either switch gets released, start app
            JumpToApp();

         // Blink LEDs
         if (timer_ro)
         {
            if (TMR1 > 7000)
            {
               blinkLEDs();
               count1++;
               timer_ro = 0;
            }
         }
         else if (TMR1 < 7000)
            timer_ro = 1;
      }
      printString("PB:");
   }
   else
   {
      printString("NA:");                    // No app present, enter bootloader regardless
   }

   T1CONbits.TON = 0;
   PR1 = 50000;                              // slow down blinking
   T1CONbits.TON = 1;

   blink_mode = 1;

   // Be in loop till framework recieves "run application" command from PC
   while(!ExitFirmwareUpgradeMode()) 
   {
      uartTask();          // Run Transport layer tasks
      if(FrameWorkTask())  // Run frame work related tasks (Handling Rx frame, process frame and so on)
      {
         blink_mode = 2;   // If we've communicated with the PC, use progress flashing
      }

      // Blink LEDs
      if (timer_ro)
      {
         if (TMR1 > 25000)
         {
            if (SWITCH1 && (SWITCH2 == 0))   // reset the device on SWITCH1 press
               reset();
            
            blinkLEDs();
            timer_ro = 0;
         }
      }
      else if (TMR1 < 25000)
         timer_ro = 1;
   }
   
	JumpToApp();
	return 0;
}