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: main.cpp
- Branch:
- MPU-9250-MagSensServo
- Revision:
- 11:f23a77c2296d
- Parent:
- 10:f5a805d998d6
diff -r f5a805d998d6 -r f23a77c2296d main.cpp --- a/main.cpp Wed Feb 03 06:01:27 2021 +0000 +++ b/main.cpp Wed Feb 10 21:59:00 2021 +0000 @@ -88,7 +88,7 @@ Mseries m; // M-series update flag -#define M_TERM 100; +#define M_TERM 200; int m_cnt = M_TERM; #define BINARY_MODE 0 @@ -97,6 +97,7 @@ #define CSV_TITLE_COLUMN "smpl_cnt,time[sec],M_stat,accX,accY,accZ,gyroX,gyroY,gyroZ,magX,magY,magZ,accX,accY,accZ,gyroX,gyroY,gyroZ,magX,magY,magZ,\r\n" +void stop_dump(void); void servo_test(void) { @@ -104,7 +105,7 @@ if(m.update()) pwm_.pulsewidth_us(ONDOT_SERVO_KRS2572HV_USEC_MIN); else - pwm_.pulsewidth_us(KONDO_SERVO_KRS2572HV_USEC_180); + pwm_.pulsewidth_us(KONDO_SERVO_KRS2572HV_USEC_90); wait(.5); } @@ -204,7 +205,7 @@ if(m.get()) pwm_.pulsewidth_us(ONDOT_SERVO_KRS2572HV_USEC_MIN); else - pwm_.pulsewidth_us(KONDO_SERVO_KRS2572HV_USEC_180); + pwm_.pulsewidth_us(KONDO_SERVO_KRS2572HV_USEC_90); m_cnt = M_TERM; } @@ -267,6 +268,16 @@ putc(13, stdout); //0x0d CR(復帰) putc(10, stdout); //0x0a LF(改行) + + // auto-stop when 15sec after + if(smpl_cnt>3000){stop_dump();} +} + +void stop_dump(void) +{ + ticker.detach(); + timer.stop(); + smpl_cnt = 0; } int main() @@ -282,9 +293,7 @@ switch(c) { case 'r': - ticker.detach(); - timer.stop(); - smpl_cnt = 0; + stop_dump(); break; case 'R':