etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
app.cpp
[詳解]
1 
9 #include "ev3api.h"
10 
11 #include "Controller.h"
12 #include "EtRobocon2018.h" // ETロボコン2017
13 #include "app.h"
14 
15 // 参考: https://devkitpro.org/viewtopic.php?f=13&t=8643&start=10
16 extern "C" void __sync_synchronize() {}
17 
18 #if defined(BUILD_MODULE)
19 #include "module_cfg.h"
20 #else
21 #include "kernel_cfg.h"
22 #endif
23 
24 #define DEBUG
25 
26 #ifdef DEBUG
27 #define _debug(x) (x)
28 #else
29 #define _debug(x)
30 #endif
31 
32 static int g_bluetooth_command = 0; // Bluetoothコマンド 1:リモートスタート
33 static FILE* g_bluetooth = NULL; // Bluetoothファイルハンドル
34 
35 /* メインタスク */
36 void main_task(intptr_t unused)
37 {
38  /* Open Bluetooth file */
39  g_bluetooth = ev3_serial_open_file(EV3_SERIAL_BT);
40  assert(g_bluetooth != NULL);
41 
42  /* Bluetooth通信タスクの起動 */
43  Controller controller;
44  controller.printDisplay(1, "ET-Robocon2018");
45  controller.printDisplay(2, " create from github.com/korosuke613/etrobocon2018");
46 
47  EtRobocon2018 etrobocon;
48  etrobocon.start(g_bluetooth_command);
49 
50  fclose(g_bluetooth);
51 
52  ext_tsk();
53 }
54 
62 void bt_task(intptr_t unused)
63 {
64  /*
65  while(1) {
66  uint8_t c = fgetc(g_bluetooth); // 受信
67  switch(c) {
68  case '1':
69  g_bluetooth_command = 1;
70  break;
71  default:
72  break;
73  }
74  fputc(c, g_bluetooth); /* エコーバック
75  }*/
76 }
77 rgb_raw_t rgb;
78 void sensor_log_task(intptr_t unused)
79 {
80  /*
81  FILE* file;
82  Controller controller;
83  int volt = 0;
84  int amp = 0;
85  int time_now = 0; // 開始時間からの経過時間を取得
86  int32_t left_motor_counts = 0; //左モータのオフセット付き角位置取得
87  int32_t right_motor_counts = 0; //右モータのオフセット付き角位置取得
88  int log_file_number = 0;
89  char log_file_name[16];
90  bool flag = true;
91  while(flag == true) {
92  sprintf(log_file_name, "%s%d%s", "/Log/log", log_file_number, ".csv");
93  controller.printDisplay(3, log_file_name);
94  file = fopen(log_file_name, "r");
95  if(file == NULL) { // ファイル名がダブらない場合
96  fclose(file);
97  file = fopen(log_file_name, "a");
98  fprintf(file, "Time(msec), Voltage, Ampere, leftMotorCounts, rightMotorCounts\n");
99  flag = false;
100 
101  } else { // 同じlogファイル名が存在する場合
102  log_file_number++;
103  }
104  }
105  ev3_speaker_play_tone(NOTE_FS6, 200);
106  while(1) {
107  if(ev3_button_is_pressed(BACK_BUTTON)) { // 戻るボタンを押すとlog取得終了
108  ev3_speaker_play_tone(NOTE_FS6, 500); // 終了音
109  fclose(file);
110  unl_mtx(LOG); //処理の終了
111  break;
112  }
113  time_now = controller.clock.now();
114  volt = ev3_battery_voltage_mV();
115  amp = ev3_battery_current_mA();
116  left_motor_counts = controller.leftWheel.getCount();
117  right_motor_counts = controller.rightWheel.getCount();
118  fprintf(file, "%d,%d,%d,%ld,%ld\n", time_now, volt, amp, left_motor_counts, right_motor_counts);
119  // 20msec周期起動
120  tslp_tsk(20);
121  }
122  */
123 }
void main_task(intptr_t unused)
Definition: app.cpp:37
void start(int)
void sensor_log_task(intptr_t unused)
Definition: color_check.cpp:95
void __sync_synchronize()
Definition: app.cpp:16
void bt_task(intptr_t unused)
Definition: app.cpp:97
void printDisplay(int8_t row, const char *format,...)
Definition: Controller.cpp:79
main的なクラス