33 lines
685 B
C
33 lines
685 B
C
|
#include <cstdint>
|
||
|
|
||
|
|
||
|
class MockScale
|
||
|
{
|
||
|
public:
|
||
|
MockScale( uint16_t valueMin=0, uint16_t valueMax=50)
|
||
|
: valueMin_(valueMin), valueMax_(valueMax), currentValue_(valueMin), direction(1)
|
||
|
{}
|
||
|
|
||
|
bool measure(uint16_t & measurementOut) {
|
||
|
currentValue_ += direction;
|
||
|
if ( currentValue_ >= valueMax_)
|
||
|
direction = -1;
|
||
|
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;
|
||
|
};
|