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.
main.cpp
- Committer:
- naoya1687
- Date:
- 2017-02-16
- Revision:
- 32:13aba70baa4b
- Parent:
- 31:cef6ee7af014
- Child:
- 33:d939479e7b13
File content as of revision 32:13aba70baa4b:
//@todo Initのコマンドモード化or別プログラム化 //@todo Initで設定した値の反映をスマートに(ServoMやControllerMでupdate毎にGlobalから設定値を取り込むのではなく,paramSet的な関数を作って更新時に呼び出し) //てかそもそもInit情報Globalに入れる必要ないのでは? //@todo Cadence, Airspeed内でNC,Encorderクラスから継承 //@todo Buttonクラスを作り,TrimとSelectorの親クラスにする //@todo 使っているライブラリの関数の説明追加 //servo回りはシリアルに変更 //selector周りはコメントアウトしてる //タスクの数に上限があるっぽい(6個以下) // #include "mbed.h" #include "rtos.h" #include "Global.h" #include "Init.h" #include "ServoManager.h" #include "ControllerManager.h" #include "Trim.h" #include "Airspeed.h" #include "Atmpress.h" #include "BatteryChecker.h" #include "Display.h" //#include "Selector.h" #include "TweLite_Sensors.h" #define CADENCE 0 #define ULTSONIC 1 RawSerial pc(USBTX, USBRX); Atmpress atmpress(PB_7, PA_15);//sda, scl Display display(PC_4, PA_10, NC);//tx, rx, sw ControllerManager controllerManager(PC_0,PC_1,PA_4,PA_1);//ele, rud, eletrimup, eletrimdown BatteryChecker batteryChecker(p18);//どのピンか確認 ServoManager servoManager(p21, p22);//ele, rud // 要変更 //Selector selector(p25); DigitalOut wdt(PA_14); Airspeed airspeed(PA_13, NC, NC);//p19,p20をInterruptInに使ってはいけない TweLite_Sensors tweLite_Sensors(PC_12,PD_2); void pc_rx(){ while(pc.readable()==1){ //コマンドモードのon,offはここに入れるといい char buf = (char)pc.getc(); Global::initqueue.put((char*)buf); } } void initializeTask(void const *pvParameters){ while(1){ Init::getSerial(); } } void controlTask(void const *pvParameters){ while(1){ //この中でpc.printfはしないほうがいいみたい(9600bpsだと遅延が起こる) controllerManager.update(); servoManager.update(); //selector.update(); wdt = !wdt;//ウォッチドッグタイマのkickに相当 Thread::wait(50); } } void sensorTask500(void const *pvParameters){ while(1){ //batteryCheckerとatmpressを入れ替えると10minくらいで停止する。わけわからん airspeed.update(); tweLite_Sensors.update(CADENCE);//こっちでそれぞれのbatteryをupdata tweLite_Sensors.update(ULTSONIC);//BatteryCheckerにまとめたい batteryChecker.update(); atmpress.update(); Thread::wait(500); } } void displayTask(void const *pvParameters){ while(1){ display.update(); Thread::wait(50); } } int main(void){ printf("start\n"); pc.attach(pc_rx,Serial::RxIrq); Global::initialize(); Thread InitializeTask(initializeTask); Thread ControlTask(controlTask, NULL, osPriorityRealtime); Thread SensorTask500(sensorTask500); Thread DisplayTask(displayTask); printf("Task end\n"); Thread::wait(osWaitForever); }