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.h
- Revision:
- 3:a155da1cbde3
- Child:
- 8:87a3708dca9c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SampleChannel.h Thu Aug 21 11:26:26 2014 +0000 @@ -0,0 +1,46 @@ + +#ifndef __SampleChannel__H__ +#define __SampleChannel__H__ + +const int NUM_FILTER_VALS = 10; +const int TRIGGER_WINDOW = 3; +const int NUM_RETURN_SAMPLES = 20; + +class SampleChannel +{ + private: + UUID chanUuid; + uint16_t sampleThreshold; + uint16_t sampleDivisor; + uint16_t filterBuf[NUM_FILTER_VALS]; + int curFilterIdx; + uint8_t sampleBuf[NUM_RETURN_SAMPLES]; + int curSampleIdx; + bool isCapturing; + void AddSample(uint16_t val); + AnalogIn ain; + int GetAvgOutsideTriggerWindow(); + int GetAvgOfTriggerWindow(); + uint16_t GetLowest(); + Serial* pLocalLogger; + int testSampleCount; + uint16_t sampleBaseVal; + + public: + SampleChannel(PinName pin, const UUID uuid, Serial* pLogger); + void SetThreshold(uint16_t threshold); + void SetDivisor(uint16_t divisor); + void Service(); + bool IsSampling(); + bool AreSamplesReady(); + void StopSampling(); + void StartSampling(); + bool CheckTrigger(); + uint8_t *GetSamples(); + int GetSamplesLen(); + UUID GetUUID() { + return chanUuid; + } +}; + +#endif \ No newline at end of file