Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: System/Process/Process.cpp
- Revision:
- 0:562021ed1ba9
- Child:
- 1:e73cf2469f83
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/System/Process/Process.cpp Sat Jan 13 13:33:09 2018 +0000
@@ -0,0 +1,112 @@
+#include "Process.h"
+
+#include "mbed.h"
+#include "../../Communication/XBee/XBee.h"
+#include "../../Input/Switch/Switch.h"
+#include "../../Output/Motor/Motor.h"
+//_____________________
+/*---------------- HOW TO WRITE ----------------/
+
+ ・motor の割り当てを決める
+ #define TIRE_L 1
+
+ ・リミットスイッチの割り当てを決める
+ #define ARM_L 1
+
+ ・他にも自由に定義してもいいです (pwmとか)
+
+/---------------- HOW TO WRITE ----------------*/
+//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
+
+
+
+
+
+
+
+
+//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
+//_____________________
+
+// #define USE_USB_SERIAL
+#ifdef USE_USB_SERIAL
+Serial pc(SERIAL_TX, SERIAL_RX);
+#endif
+XBEE::ControllerData *controller;
+MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
+
+using namespace SWITCH;
+
+void SystemProcess(void) {
+ while(true) {
+ controller = XBEE::Controller::GetData();
+//____________________________
+/*------------------------ HOW TO WRITE ------------------------/
+
+ ここにメインのプログラムを書く
+
+ ・コントローラから受け取ったデータをもとに動作のプログラムを書く
+ (コントローラのデータは controller-> で取る)
+
+ if(controller->Button.RIGHT) {
+ motor[TIRE_L].dir = FOR;
+ motor[TIRE_R].dir = BACK;
+ motor[TIRE_L].dir = 12.3;
+ motor[TIRE_R].dir = 12.3;
+ }
+
+ motor[0].dirは FRONT (正転)
+ BACK (逆転)
+ BRAKE (ブレーキ)
+ FREE (フリー)
+
+ motor[0].pwmは 0.0(%) ~ 100.0(%)
+
+ controllerは XBee.hの構造体の中身
+
+ (AnalogL・Rを使いたかったら、頑張って考える or 聞いてください)
+
+ ・リミットスイッチの値をもとに動作のプログラムを書く
+
+ if(Switch::CheckPushed(ARM_L))
+ {
+ if(controller->Button.L)
+ {
+ motor[ARM].dir = FRONT;
+ motor[ARM].pwm = 80.0;
+ }
+ if(motor[ARM].dir == BACK)
+ {
+ motor[ARM].dir = BRAKE;
+ }
+ }
+
+ →関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false)
+
+ ・他にもやりたいことがあったら自由にどうぞ
+
+ ps.わからないことがあったら聞いてください
+
+/------------------------ HOW TO WRITE ------------------------*/
+//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
+//____________________________
+
+ MOTOR::Motor::Update(motor);
+ }
+}
+