1
0
Fork 0

retain low-end resolution

This commit is contained in:
Kevin Matz 2023-03-30 14:40:29 -04:00
parent 2c72607dc3
commit 9c5654b34d
1 changed files with 6 additions and 1 deletions

View File

@ -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;
};
};