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
00001 00002 #ifndef __SampleChannel__H__ 00003 #define __SampleChannel__H__ 00004 00005 const int NUM_FILTER_VALS = 10; 00006 const int TRIGGER_WINDOW = 3; 00007 const int NUM_RETURN_SAMPLES = 20; 00008 00009 class SampleChannel 00010 { 00011 private: 00012 UUID chanUuid; 00013 uint16_t sampleThreshold; 00014 uint16_t sampleDivisor; 00015 uint16_t filterBuf[NUM_FILTER_VALS]; 00016 int curFilterIdx; 00017 uint8_t sampleBuf[NUM_RETURN_SAMPLES]; 00018 int curSampleIdx; 00019 bool isCapturing; 00020 void AddSample(uint16_t val); 00021 AnalogIn ain; 00022 int GetAvgOutsideTriggerWindow(); 00023 int GetAvgOfTriggerWindow(); 00024 uint16_t GetLowest(); 00025 Serial* pLocalLogger; 00026 uint16_t sampleBaseVal; 00027 00028 public: 00029 SampleChannel(PinName pin, const UUID uuid, Serial* pLogger); 00030 void SetThreshold(uint16_t threshold); 00031 void SetDivisor(uint16_t divisor); 00032 void Service(); 00033 bool IsSampling(); 00034 bool AreSamplesReady(); 00035 void StopSampling(); 00036 void StartSampling(); 00037 bool CheckTrigger(); 00038 uint8_t *GetSamples(); 00039 int GetSamplesLen(); 00040 UUID GetUUID() { 00041 return chanUuid; 00042 } 00043 }; 00044 00045 #endif
Generated on Wed Jul 13 2022 12:34:33 by 1.7.2