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.

Dependencies:   Puck mbed

Fork of Example_Puck_BLE by Nordic Semiconductor

Committer:
Bobty
Date:
Tue Aug 26 14:13:31 2014 +0000
Revision:
10:a2ba0cef85aa
Parent:
8:87a3708dca9c
Working with 3 channels

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobty 3:a155da1cbde3 1
Bobty 3:a155da1cbde3 2 #ifndef __SampleChannel__H__
Bobty 3:a155da1cbde3 3 #define __SampleChannel__H__
Bobty 3:a155da1cbde3 4
Bobty 3:a155da1cbde3 5 const int NUM_FILTER_VALS = 10;
Bobty 3:a155da1cbde3 6 const int TRIGGER_WINDOW = 3;
Bobty 3:a155da1cbde3 7 const int NUM_RETURN_SAMPLES = 20;
Bobty 3:a155da1cbde3 8
Bobty 3:a155da1cbde3 9 class SampleChannel
Bobty 3:a155da1cbde3 10 {
Bobty 3:a155da1cbde3 11 private:
Bobty 3:a155da1cbde3 12 UUID chanUuid;
Bobty 3:a155da1cbde3 13 uint16_t sampleThreshold;
Bobty 3:a155da1cbde3 14 uint16_t sampleDivisor;
Bobty 3:a155da1cbde3 15 uint16_t filterBuf[NUM_FILTER_VALS];
Bobty 3:a155da1cbde3 16 int curFilterIdx;
Bobty 3:a155da1cbde3 17 uint8_t sampleBuf[NUM_RETURN_SAMPLES];
Bobty 3:a155da1cbde3 18 int curSampleIdx;
Bobty 3:a155da1cbde3 19 bool isCapturing;
Bobty 3:a155da1cbde3 20 void AddSample(uint16_t val);
Bobty 3:a155da1cbde3 21 AnalogIn ain;
Bobty 3:a155da1cbde3 22 int GetAvgOutsideTriggerWindow();
Bobty 3:a155da1cbde3 23 int GetAvgOfTriggerWindow();
Bobty 3:a155da1cbde3 24 uint16_t GetLowest();
Bobty 3:a155da1cbde3 25 Serial* pLocalLogger;
Bobty 3:a155da1cbde3 26 uint16_t sampleBaseVal;
Bobty 3:a155da1cbde3 27
Bobty 3:a155da1cbde3 28 public:
Bobty 3:a155da1cbde3 29 SampleChannel(PinName pin, const UUID uuid, Serial* pLogger);
Bobty 3:a155da1cbde3 30 void SetThreshold(uint16_t threshold);
Bobty 3:a155da1cbde3 31 void SetDivisor(uint16_t divisor);
Bobty 3:a155da1cbde3 32 void Service();
Bobty 3:a155da1cbde3 33 bool IsSampling();
Bobty 3:a155da1cbde3 34 bool AreSamplesReady();
Bobty 3:a155da1cbde3 35 void StopSampling();
Bobty 3:a155da1cbde3 36 void StartSampling();
Bobty 3:a155da1cbde3 37 bool CheckTrigger();
Bobty 3:a155da1cbde3 38 uint8_t *GetSamples();
Bobty 3:a155da1cbde3 39 int GetSamplesLen();
Bobty 3:a155da1cbde3 40 UUID GetUUID() {
Bobty 3:a155da1cbde3 41 return chanUuid;
Bobty 3:a155da1cbde3 42 }
Bobty 3:a155da1cbde3 43 };
Bobty 3:a155da1cbde3 44
Bobty 3:a155da1cbde3 45 #endif