RT-AICHIP-sample
mode_controlRun.c
[詳解]
1 /* ------------------------------------------------------------ *
2 File mode_controlRun.c
3 
4 コースの状況に応じてモーターのdutyを変えながら走るモード
5 
6 操作:
7  右SW: スタート,ストップの切り替え
8  左SW: 長押しでモード選択へ繊維
9 
10 * ------------------------------------------------------------ */
11 #include "mode_Debug.h"
12 #include "type.h"
13 #include "AICHIPFunction.h"
14 #include "UserInterface.h"
15 #include "SystemTickTimer.h"
16 #include "debug.h"
17 
18 
19 void mode_controlRun(void)
20 {
21  float duty_straight = 1.0;
22  float duty_curve = 0.3;
23  float duty_slope = 0.4;
24 
25  turnGreenLED(1);
26 
27  myPrintfUART("############ control run mode ################\n");
28  wait1msec(1000);
29  while(1)
30  {
31  wait1msec(1);
32  if( getLeftSWcount()>0 ){
33  while(getRightSWcount() != 0 );
34  break; //左SWを押したら走り始める
35  }
36 
37  }
39  setDegree(0.0);
40 
41  while(1)
42  {
43  wait1msec(10);
44 
45  if(isSlope() == 1) setDutyMotor(duty_slope);
46  else if(isCurve == 1) setDutyMotor(duty_curve);
47  else setDutyMotor(duty_straight);
48 
49  //モード選択へ遷移
50  if( getLeftSWcount() > 1000)
51  {
52  setDutyMotor(0.0);
53  turnGreenLED(0);
54  myPrintfUART("\t return mode select \n");
55  break;
56  }
57  }
58 }
59 
60 /******************************************************************************
61 ** End Of File
62 ******************************************************************************/
int myPrintfUART(const char *fmt,...)
Definition: debug.c:42
uint8_t isSlope(void)
void setDutyMotor(float pwm_duty)
void setDegree(float deg)
void mode_controlRun(void)
uint16_t getRightSWcount(void)
uint8_t isCurve(void)
uint16_t getLeftSWcount(void)
Definition: UserInterface.c:98
void wait1msec(uint32_t wait_count)
void turnGreenLED(uint8_t state)
void resetElapsedTime(void)