void mode_BluetoothSetting(void)
{
	turnLED(0);
	myPrintfUART("############ Bluetooth setting mode ################\n");
	wait1msec(300);
	myPrintfUART("$$$");    //コマンドモードに入る
	wait1msec(2000);
	myPrintfUART("SM,0\r");   //動作モードをスレーブモードに変更
	wait1msec(2000);
	myPrintfUART("SU,115K\r");//ボーレートを115200bpsに変更
	wait1msec(2000);
	//myPrintfUART("SN,RT-BLUETOOTH-9AXIS\r");//デバイス名の変更
	wait1msec(2000);
	myPrintfUART("R,1\r"); //リブート
	wait1msec(2000);

	while(1)
	{
		turnLED(1);
		//モード選択へ遷移
		if( getSWcount() > 1000)
		{
			myPrintfUART("\t return mode select \n");
			if(getSWcount() == 0) break;
		}
	}
}
示例#2
0
void buttonAndLED(TaskState* tsk){
  int timeDiff;
  switch((tsk->state))
  {
    case RELEASED:
      if(getButton(tsk->whichButton) == IS_PRESSED)
      {
        turnLED(tsk->whichLED, ON);
        tsk->recordedTime = getTime();
        tsk->state        = PRESSED_ON;
        tsk->buttonReleased = FALSE;
      }
      break;
    case PRESSED_ON:
      if(getButton(tsk->whichButton) == IS_RELEASED)
        tsk->buttonReleased = TRUE;
      else 
      {
        if(tsk->buttonReleased == TRUE) 
          tsk->state  = TURNING_OFF;
          tsk->buttonReleased = FALSE;
          turnLED(tsk->whichLED, OFF);
      }
      timeDiff = getTime() - (tsk->recordedTime);
      if(timeDiff >= tsk->interval)
      {
        turnLED(tsk->whichLED, OFF);
        tsk->recordedTime = getTime();
        tsk->state = PRESSED_OFF;
      }
      break;
    case PRESSED_OFF:
      if(getButton(tsk->whichButton) == IS_RELEASED)
        tsk->buttonReleased = TRUE;
      else
      {
        if(tsk->buttonReleased == TRUE)
        {
            tsk->state = TURNING_OFF;
            tsk->buttonReleased = FALSE;
            turnLED(tsk->whichLED, OFF);
        }
      }
      timeDiff = getTime() - (tsk->recordedTime);
      if(timeDiff >= tsk->interval)
      {
        turnLED(tsk->whichLED, ON);
        tsk->recordedTime = getTime();
        tsk->state = PRESSED_ON;
      }
      break;
    case TURNING_OFF:
      if(getButton(tsk->whichButton) == IS_RELEASED)
      {
        tsk->buttonReleased = TRUE;
        tsk->state  = RELEASED;
      }
      break;
  }
}
void test_turnLED_Function_when_LED1_is_turned_ON_and_OFF(void){

  LED_t* LED1 = createLED();

  turnLED(LED1,ON);

  UnityAssertEqualNumber((_U_SINT)((ON)), (_U_SINT)((LED1->state)), (((void *)0)), (_U_UINT)20, UNITY_DISPLAY_STYLE_INT);

  turnLED(LED1,OFF);

  UnityAssertEqualNumber((_U_SINT)((OFF)), (_U_SINT)((LED1->state)), (((void *)0)), (_U_UINT)22, UNITY_DISPLAY_STYLE_INT);

}