2019-08-22 21:33:36 +02:00
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
|
|
class MockScale
|
|
|
|
{
|
|
|
|
public:
|
2020-06-05 20:55:01 +02:00
|
|
|
MockScale( uint16_t valueMin=0, uint16_t valueMax=10)
|
2019-08-22 21:33:36 +02:00
|
|
|
: valueMin_(valueMin), valueMax_(valueMax), currentValue_(valueMin), direction(1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool measure(uint16_t & measurementOut) {
|
|
|
|
currentValue_ += direction;
|
2020-06-05 20:55:01 +02:00
|
|
|
if ( currentValue_ >= valueMax_) {
|
2019-08-22 21:33:36 +02:00
|
|
|
direction = -1;
|
2020-06-05 20:55:01 +02:00
|
|
|
valueMax_ += 2;
|
|
|
|
}
|
2019-08-22 21:33:36 +02:00
|
|
|
else if ( currentValue_ <= valueMin_ )
|
|
|
|
direction = +1;
|
|
|
|
|
|
|
|
measurementOut = currentValue_;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void begin(uint32_t , uint32_t ) {
|
|
|
|
};
|
|
|
|
|
|
|
|
void tare(uint32_t ) {
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
uint16_t valueMin_;
|
|
|
|
uint16_t valueMax_;
|
|
|
|
uint16_t currentValue_;
|
|
|
|
int direction;
|
|
|
|
};
|