Authors: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: March 23, 2018 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
More...
#include <cs_RecognizeSwitch.h>
|
FoundSwitch | detect (const CircularBuffer< adc_buffer_id_t > &bufQueue, adc_channel_id_t voltageChannelId, uint8_t iteration) |
| Check if a switch is detected in the given buffers. More...
|
|
FoundSwitch | detectSwitch (const CircularBuffer< adc_buffer_id_t > &bufQueue, adc_channel_id_t voltageChannelId) |
| Check if a switch is detected in the given buffers. More...
|
|
float | calcDiff (const CircularBuffer< adc_buffer_id_t > &bufQueue, const adc_channel_id_t voltageChannelId, const adc_buffer_id_t bufIndex1, const adc_buffer_id_t bufIndex2, const adc_sample_value_id_t startIndex, const adc_sample_value_id_t numSamples) |
|
bool | ignoreSample (const adc_sample_value_t value1, const adc_sample_value_t value2) |
|
bool | ignoreSample (const adc_sample_value_t value0, const adc_sample_value_t value1, const adc_sample_value_t value2) |
|
void | setLastDetection (bool aboveThreshold, const CircularBuffer< adc_buffer_id_t > &bufQueue, adc_channel_id_t voltageChannelId) |
|
Authors: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: March 23, 2018 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
◆ FoundSwitch
Enumerator |
---|
True | |
Almost | |
False | |
◆ RecognizeSwitch()
Constructor: sets some default config values.
◆ calcDiff()
◆ configure()
void RecognizeSwitch::configure |
( |
float |
threshold | ) |
|
Configure threshold.
- Parameters
-
[in] | threshold | Sets threshold different and similar. |
◆ deinit()
void RecognizeSwitch::deinit |
( |
| ) |
|
Deinitialize: deallocate buffers.
◆ detect() [1/2]
Recognize switch event.
- Parameters
-
[in] | bufQueue | The queue of available buffers. |
[in] | voltageChannelId | Channel in which the voltage values can be found. |
- Returns
- True when switch event was detected.
◆ detect() [2/2]
Check if a switch is detected in the given buffers.
◆ detectSwitch()
Check if a switch is detected in the given buffers.
Different way of calculating, using calcDiff(). Seems to go slower though.
◆ getInstance()
◆ getLastDetection()
Get the samples of the last (almost) detected switch event.
- Parameters
-
[in] | type | Either SWITCHCRAFT or SWITCHCRAFT_NON_TRIGGERED. |
| [in/out] | Result with buffer to fill with data (header + samples), and result code to set. |
◆ ignoreSample() [1/2]
◆ ignoreSample() [2/2]
◆ init()
void RecognizeSwitch::init |
( |
| ) |
|
Initialize: set initial values and allocate buffers.
◆ setLastDetection()
◆ skip()
void RecognizeSwitch::skip |
( |
uint16_t |
num | ) |
|
Don't detect anything for num detect() calls.
◆ start()
void RecognizeSwitch::start |
( |
| ) |
|
◆ stop()
void RecognizeSwitch::stop |
( |
| ) |
|
◆ _lastAlmostDetection
◆ _lastAlmostDetectionSamples
◆ _lastDetection
◆ _lastDetectionSamples
◆ _numBuffersRequired
const uint8_t RecognizeSwitch::_numBuffersRequired = 4 |
|
staticprivate |
◆ _numStoredBuffers
◆ _running
bool RecognizeSwitch::_running = false |
|
private |
◆ _skipSwitchDetectionTriggers
uint8_t RecognizeSwitch::_skipSwitchDetectionTriggers = 200 |
|
private |
◆ _thresholdDifferent
◆ _thresholdRatio
float RecognizeSwitch::_thresholdRatio = 100.0 |
|
private |
◆ _thresholdSimilar
The documentation for this class was generated from the following file: