Using the MBED BLE library and Nordic Puck library this is a simple scoring application using Bluetooth LE. It monitors three analog inputs and triggers on reception of a pulse on any one recording data for a short period on all three. This is then published via BLE characteristics. It's a demonstrator for a new UI dev toolkit that is under development.
Fork of Example_Puck_BLE by
Diff: SampleChannel.cpp
- Revision:
- 4:cc164ecf6a36
- Parent:
- 3:a155da1cbde3
- Child:
- 8:87a3708dca9c
diff -r a155da1cbde3 -r cc164ecf6a36 SampleChannel.cpp --- a/SampleChannel.cpp Thu Aug 21 11:26:26 2014 +0000 +++ b/SampleChannel.cpp Sat Aug 23 09:31:01 2014 +0000 @@ -32,9 +32,9 @@ void SampleChannel::AddSample(uint16_t val) { testSampleCount++; - if (testSampleCount == 100) + if (testSampleCount == 1000) { - pLocalLogger->printf("%d AvgT %d, AvgW %d, low %d\n", val, GetAvgOfTriggerWindow(), GetAvgOutsideTriggerWindow(), GetLowest()); +// pLocalLogger->printf("%d AvgT %d, AvgW %d, low %d\n", val, GetAvgOfTriggerWindow(), GetAvgOutsideTriggerWindow(), GetLowest()); testSampleCount = 0; } @@ -120,14 +120,10 @@ bool SampleChannel::CheckTrigger() { // Check if the samples in the trigger window are significantly different from the average - for (int i = 0; i < TRIGGER_WINDOW; i++) - { - int spike = GetAvgOfTriggerWindow() - GetAvgOutsideTriggerWindow(); - if (spike < 0) - spike = -spike; - return (spike > sampleThreshold); - } - return false; + int spike = GetAvgOfTriggerWindow() - GetAvgOutsideTriggerWindow(); + if (spike < 0) + spike = -spike; + return spike > sampleThreshold; } uint8_t *SampleChannel::GetSamples()