retain low-end resolution
This commit is contained in:
parent
2c72607dc3
commit
9c5654b34d
|
@ -38,6 +38,7 @@ struct Transmitter
|
|||
* full on condition.
|
||||
*/
|
||||
const int16_t zero = 0; //!< mV, 0.0 V
|
||||
const int16_t zero_max = 200; //!< mv, 0.2 V
|
||||
const int16_t full = 10000; //!< mV, 10.0 V
|
||||
|
||||
/**
|
||||
|
@ -46,7 +47,11 @@ struct Transmitter
|
|||
* @return
|
||||
*/
|
||||
int16_t millivolts(uint8_t level) const {
|
||||
return full * (level / UINT8_MAX);
|
||||
if (level == 0)
|
||||
return zero;
|
||||
if (level == UINT8_MAX)
|
||||
return full;
|
||||
return ((full - zero_max) * (level / UINT8_MAX)) + zero_max;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue