201708能代のメインマイコンの保存データ送信用プログラム(データ送信部分を繰り返しタイマー割り込みにした)
Dependencies: MPU6050 MS5607 mbed
Fork of data_sousin by
Revision 7:33f48fc8fe7b, committed 2017-08-18
- Comitter:
- oichan
- Date:
- Fri Aug 18 15:12:08 2017 +0000
- Parent:
- 6:69546ac823b1
- Commit message:
- ?data_sousin??????????????while????????????????????????
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 69546ac823b1 -r 33f48fc8fe7b main.cpp --- a/main.cpp Wed Aug 16 12:05:21 2017 +0000 +++ b/main.cpp Fri Aug 18 15:12:08 2017 +0000 @@ -5,7 +5,6 @@ 送信データが時間順にならないため、検証時は並び替えが必要 ************************************************************/ -//TODO: 30分以上の動作試験 #include "mbed.h" #include "MPU6050.h" @@ -21,6 +20,7 @@ MS5607I2C ms5607(p9,p10,false); Serial subCP(p28, p27); Ticker log_timer; +Ticker send_timer; Timer t; float Time[2][BUFFNUM] = {}; @@ -33,27 +33,16 @@ int Moji_cnt = 0; void _log(); +void _send(); int main(){ t.start(); log_timer.attach(_log,1.0/RATE); - while(1){ - if(Moji_cnt==0){ - sprintf(&Moji[Row][Send_cnt][0],"%f, %f, %f",Time[!Row][Send_cnt],Acc[!Row][Send_cnt],Alt[!Row][Send_cnt]); - } - subCP.putc(Moji[Row][Send_cnt][Moji_cnt]); - Moji_cnt++; - if(Moji_cnt==CHARANUM || Moji[Row][Send_cnt][Moji_cnt]=='\0'){ - Moji_cnt = 0; - subCP.putc('$'); - Send_cnt++; - if(Send_cnt==BUFFNUM){ - Send_cnt = 0; - } - } - } + send_timer.attach(_send,0.0001); + while(1); } + /* データ取得関数 */ void _log(){ mpu.getAccelero(&Acc[Row][Col]); @@ -69,3 +58,19 @@ } } +/* データ送信関数 */ +void _send(){ + if(Moji_cnt==0){ + sprintf(&Moji[Row][Send_cnt][0],"%f, %f, %f",Time[!Row][Send_cnt],Acc[!Row][Send_cnt],Alt[!Row][Send_cnt]); + } + subCP.putc(Moji[Row][Send_cnt][Moji_cnt]); + Moji_cnt++; + if(Moji_cnt==CHARANUM || Moji[Row][Send_cnt][Moji_cnt]=='\0'){ + Moji_cnt = 0; + subCP.putc('$'); + Send_cnt++; + if(Send_cnt==BUFFNUM){ + Send_cnt = 0; + } + } +}