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:
- 2016-12-29
- Revision:
- 30:6d3a78bc1925
- Parent:
- 27:5b897e2e0ac6
- Child:
- 31:cef6ee7af014
File content as of revision 30:6d3a78bc1925:
//@todo Initのコマンドモード化or別プログラム化 //@todo Initで設定した値の反映をスマートに(ServoMやControllerMでupdate毎にGlobalから設定値を取り込むのではなく,paramSet的な関数を作って更新時に呼び出し) //てかそもそもInit情報Globalに入れる必要ないのでは? //@todo Cadence, Airspeed内でNC,Encorderクラスから継承 //@todo Buttonクラスを作り,TrimとSelectorの親クラスにする //@todo 使っているライブラリの関数の説明追加 //タスクの数に上限があるっぽい(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 "XBee.h" #include "Selector.h" #include "TweLite_Sensors.h" RawSerial pc(USBTX, USBRX); Atmpress atmpress(p9, p10);//sda, scl Display display(p13, p14, NC);//tx, rx, sw ControllerManager controllerManager(p15,p16,p5,p6);//ele, rud, eletrimup, eletrimdown BatteryChecker batteryChecker(p17, p18); ServoManager servoManager(p21, p22);//ele, rud Selector selector(p25); DigitalOut wdt(p26); XBee xbee(p28, p27);//tx, rx Airspeed airspeed(p29, NC, NC);//p19,p20をInterruptInに使ってはいけない TweLite_Sensors(PinName tx, PinName rx); 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::updata("cadence"); TweLite_Sensors::updata("ultsonic"); batteryChecker.update(); atmpress.update(); Thread::wait(500); } } void displayTask(void const *pvParameters){ while(1){ display.update(); Thread::wait(50); } } void xbeeTask(void const *pvParameters){ while(1){ xbee.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); Thread XbeeTask(xbeeTask); printf("Task end\n"); Thread::wait(osWaitForever); }