etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
EtRobocon2018.cpp
[詳解]
1 #include "EtRobocon2018.h"
2 
11 /*
12  * touch_sensor = EV3_PORT_1;
13  * sonar_sensor = EV3_PORT_2;
14  * color_sensor = EV3_PORT_3;
15  * gyro_sensor = EV3_PORT_4;
16  *
17  * left_motor = EV3_PORT_C;
18  * right_motor = EV3_PORT_B;
19  * lift_motor = EV3_PORT_A;
20  * tail_motor = EV3_PORT_D;
21  */
22 
30 {
32  controller.speakerSetVolume(100);
33 }
34 
35 void EtRobocon2018::start(int bluetooth_command)
36 {
37  UserInterface ui{ controller };
38 #ifdef IS_RIGHT_COURSE
39  ui.inputFirstCode();
40  firstCode = ui.getFirstCode();
41 #else
42 #endif
43  ui.setBrightnessWithColor(light_white, "white");
44  ui.setBrightnessWithColor(light_black, "black");
45  ui.setBrightnessWithColor(light_gray, "gray");
46  target_brightness = (light_black + light_white) / 2;
47  controller.printDisplay(7, "Brightness W:%d, B:%d, T:%d", light_white, light_black,
48  target_brightness);
49  controller.ledSetColorOrange();
50  waitStarter(bluetooth_command);
51  controller.ledSetColorGreen();
52 
53  loop();
54 }
55 
57 {
58  // Rコースを走らせるときは1, Lコースを走らせるときは0
59  auto brightness = target_brightness;
60 #ifdef IS_RIGHT_COURSE
61  RightCourse rightCourse{ controller, firstCode };
62  rightCourse.run(brightness, light_black, light_white, light_gray);
63 #else
64  LeftCourse leftCourse{ controller };
65  leftCourse.run(brightness, light_black, light_white, light_gray);
66 #endif
67 }
68 
69 void EtRobocon2018::waitStarter(int bluetooth_command)
70 {
71  /* スタート待機 */
72  while(1) {
73  if(bluetooth_command == 1) {
74  break; /* リモートスタート */
75  }
76 
77  if(controller.touchSensor.isPressed() == 1) {
78  controller.tslpTsk(500);
79  break; /* タッチセンサが押された */
80  }
81 
82  controller.tslpTsk(10); /* 10msecウェイト */
83  }
84 }
走行体が走り出す前にユーザが入力するインターフェースを提供するクラス
Definition: UserInterface.h:25
void tslpTsk(int16_t time)
Definition: Controller.cpp:74
TouchSensor touchSensor
Definition: Controller.h:42
void start(int)
void ledSetColorOrange()
Definition: Controller.cpp:14
void waitStarter(int)
bool isPressed(void) const
Definition: TouchSensor.cpp:20
void ledSetColorGreen()
Definition: Controller.cpp:19
void printDisplay(int8_t row, const char *format,...)
Definition: Controller.cpp:79
void speakerSetVolume(uint8_t volume)
Definition: Controller.cpp:4
main的なクラス