Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
Diff: utils/MTSCircularBuffer.cpp
- Revision:
- 2:8d3ea0dfce39
- Parent:
- 0:563b70517320
- Child:
- 17:2d7c4ea7491b
--- a/utils/MTSCircularBuffer.cpp Mon Dec 09 16:10:26 2013 +0000 +++ b/utils/MTSCircularBuffer.cpp Wed Dec 11 20:07:02 2013 +0000 @@ -3,7 +3,7 @@ #include "MTSCircularBuffer.h" -MTSCircularBuffer::MTSCircularBuffer(int bufferSize) : bufferSize(bufferSize), readIndex(0), writeIndex(0), threshold(-1), op(Vars::GREATER) +MTSCircularBuffer::MTSCircularBuffer(int bufferSize) : bufferSize(bufferSize), readIndex(0), writeIndex(0), _threshold(-1), _op(Vars::GREATER) { buffer = new char[bufferSize]; } @@ -57,7 +57,7 @@ buffer[writeIndex++] = data[i++]; } checkThreshold(); - return capacity(); + return i; } int MTSCircularBuffer::write(char data) @@ -70,22 +70,7 @@ } buffer[writeIndex++] = data; checkThreshold(); - return capacity(); -} - -void MTSCircularBuffer::attach(void(*fptr)(void), int _threshold, Vars::RelationalOperator _op) -{ - threshold = _threshold; - op = _op; - notify.attach(fptr); -} - -template<typename T> -void MTSCircularBuffer::attach(T *tptr, void(T::*mptr)(void), int threshold, Vars::RelationalOperator op) -{ - this.threshold = threshold; - this.op = op; - notify.attach(tptr, mptr); + return 1; } int MTSCircularBuffer::capacity() @@ -127,32 +112,32 @@ void MTSCircularBuffer::checkThreshold() { - if (threshold == -1) { + if (_threshold == -1) { return; } - switch (op) { + switch (_op) { case Vars::GREATER: - if (available() > threshold) { + if (available() > _threshold) { notify.call(); } break; case Vars::LESS: - if (available() < threshold) { + if (available() < _threshold) { notify.call(); } break; case Vars::GREATER_EQUAL: - if (available() >= threshold) { + if (available() >= _threshold) { notify.call(); } break; case Vars::LESS_EQUAL: - if (available() <= threshold) { + if (available() <= _threshold) { notify.call(); } break; case Vars::EQUAL: - if (available() == threshold) { + if (available() == _threshold) { notify.call(); } break;