にいむら にいむら
/
NRPmainprogram2019
aa
System/Process/Process.cpp@0:2e7a61458dc3, 2019-01-28 (annotated)
- Committer:
- M_souta
- Date:
- Mon Jan 28 08:34:36 2019 +0000
- Revision:
- 0:2e7a61458dc3
- Child:
- 1:e1e9671724e7
NRP2019
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
M_souta | 0:2e7a61458dc3 | 1 | #include "Process.h" |
M_souta | 0:2e7a61458dc3 | 2 | |
M_souta | 0:2e7a61458dc3 | 3 | #include "mbed.h" |
M_souta | 0:2e7a61458dc3 | 4 | #include "../../Communication/XBee/XBee.h" |
M_souta | 0:2e7a61458dc3 | 5 | #include "../../Input/Switch/Switch.h" |
M_souta | 0:2e7a61458dc3 | 6 | #include "../../Output/Motor/Motor.h" |
M_souta | 0:2e7a61458dc3 | 7 | |
M_souta | 0:2e7a61458dc3 | 8 | /*---------- DEFINE ----------*/ |
M_souta | 0:2e7a61458dc3 | 9 | |
M_souta | 0:2e7a61458dc3 | 10 | /*----------------------------*/ |
M_souta | 0:2e7a61458dc3 | 11 | |
M_souta | 0:2e7a61458dc3 | 12 | // #define USE_USB_SERIAL |
M_souta | 0:2e7a61458dc3 | 13 | #ifdef USE_USB_SERIAL |
M_souta | 0:2e7a61458dc3 | 14 | Serial pc(SERIAL_TX,SERIAL_RX); |
M_souta | 0:2e7a61458dc3 | 15 | #endif |
M_souta | 0:2e7a61458dc3 | 16 | |
M_souta | 0:2e7a61458dc3 | 17 | XBEE::ControllerData *controller; |
M_souta | 0:2e7a61458dc3 | 18 | MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM]; |
M_souta | 0:2e7a61458dc3 | 19 | |
M_souta | 0:2e7a61458dc3 | 20 | using namespace SWITCH; |
M_souta | 0:2e7a61458dc3 | 21 | |
M_souta | 0:2e7a61458dc3 | 22 | void SystemProcess(void){ |
M_souta | 0:2e7a61458dc3 | 23 | while(true){ |
M_souta | 0:2e7a61458dc3 | 24 | controller = XBEE::Controller::GetData(); |
M_souta | 0:2e7a61458dc3 | 25 | |
M_souta | 0:2e7a61458dc3 | 26 | /*------------------- how to write ------------------/ |
M_souta | 0:2e7a61458dc3 | 27 | |
M_souta | 0:2e7a61458dc3 | 28 | ここにメインプログラムを書く |
M_souta | 0:2e7a61458dc3 | 29 | |
M_souta | 0:2e7a61458dc3 | 30 | ・コントローラーから受けっ取ったデータをもとに動作のプログラムを書く |
M_souta | 0:2e7a61458dc3 | 31 | (コントローラーのデータは controller-> で取る |
M_souta | 0:2e7a61458dc3 | 32 | |
M_souta | 0:2e7a61458dc3 | 33 | if(controller->Button.RIGHT){ |
M_souta | 0:2e7a61458dc3 | 34 | motor[TIRE_L].dir = FOR; |
M_souta | 0:2e7a61458dc3 | 35 | motor[TIRE_R].dir = BACK; |
M_souta | 0:2e7a61458dc3 | 36 | motor[TIRE_L].pwm = 12.3; |
M_souta | 0:2e7a61458dc3 | 37 | motor[TIRE_R].pwm = 12.3; |
M_souta | 0:2e7a61458dc3 | 38 | } |
M_souta | 0:2e7a61458dc3 | 39 | |
M_souta | 0:2e7a61458dc3 | 40 | motor[0].dirは FOR (正転) |
M_souta | 0:2e7a61458dc3 | 41 | BACK (逆転) |
M_souta | 0:2e7a61458dc3 | 42 | FREE (ブレーキ) |
M_souta | 0:2e7a61458dc3 | 43 | BRAKE (フリー) |
M_souta | 0:2e7a61458dc3 | 44 | |
M_souta | 0:2e7a61458dc3 | 45 | motor[0].pwmは 0.0(%) ~ 100.0(%) |
M_souta | 0:2e7a61458dc3 | 46 | |
M_souta | 0:2e7a61458dc3 | 47 | controllerは XBee.hの構造体の中身 |
M_souta | 0:2e7a61458dc3 | 48 | |
M_souta | 0:2e7a61458dc3 | 49 | ・リミットスイッチの値をもとに動作のプログラムを書く |
M_souta | 0:2e7a61458dc3 | 50 | |
M_souta | 0:2e7a61458dc3 | 51 | if(Switch::CheckPushed(ARM_L)){ |
M_souta | 0:2e7a61458dc3 | 52 | |
M_souta | 0:2e7a61458dc3 | 53 | } |
M_souta | 0:2e7a61458dc3 | 54 | |
M_souta | 0:2e7a61458dc3 | 55 | 関数 Switch::CheckPushed の引数はリミットスイッチの名前 , 返り値はbool型(true or false) |
M_souta | 0:2e7a61458dc3 | 56 | |
M_souta | 0:2e7a61458dc3 | 57 | ここより下に書いて |
M_souta | 0:2e7a61458dc3 | 58 | -------------------*/ |
M_souta | 0:2e7a61458dc3 | 59 | |
M_souta | 0:2e7a61458dc3 | 60 | |
M_souta | 0:2e7a61458dc3 | 61 | |
M_souta | 0:2e7a61458dc3 | 62 | MOTOR::Motor::Update(motor); |
M_souta | 0:2e7a61458dc3 | 63 | } |
M_souta | 0:2e7a61458dc3 | 64 | } |
M_souta | 0:2e7a61458dc3 | 65 |