Swimate V2 without RTOS code
Dependencies: Adafruit_GFX_128x64 DS3231 PinDetect SDFileSystem USBDevice mbed RealtimeMath MODSERIAL
Diff: process_data.cpp
- Revision:
- 24:f2503d1256ad
- Parent:
- 21:2fa676f214fe
--- a/process_data.cpp Sun Jun 08 04:08:41 2014 +0000 +++ b/process_data.cpp Mon Jun 09 04:55:16 2014 +0000 @@ -7,6 +7,7 @@ #include "FloatingThresholdPeakDetector.h" #include "SimplePeakDetector.h" #include "main.h" +#include "debug.h" PeakDetector::PeakDetector *peakDetector; PeakDetector::PeakDetector *startDetector; @@ -36,13 +37,19 @@ swimState = TIMING; split_timer.start(); start_time = SystemTime::read_ms(); - OLED_PRINTPF("xpeak - %d ", start_time, 0, 30); + PC_PRINTLNF("xpeak - %d", start_time); } } else if (swimState == TIMING) { + // Potential source of overflow if read_ms rolls over if (peakDetector->onPeak(ydata) && SystemTime::read_ms() - start_time > 5000 ) { - *split = split_timer.read_ms(); - OLED_PRINTPF("ypeak - %d ", *split, 0, 40); - return true; + PC_PRINTLNF("ypeak - %d", split_timer.read_ms()); + static int i = 0; + + if (++i % 2 == 0) { + *split = split_timer.read_ms(); + split_timer.reset(); + return true; + } } }