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
SampleChannel.h
- Committer:
- Bobty
- Date:
- 2014-08-21
- Revision:
- 3:a155da1cbde3
- Child:
- 8:87a3708dca9c
File content as of revision 3:a155da1cbde3:
#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