![]() |
Speeduino
|
Represents a 16-bit value as a byte. Useful for I/O. More...
#include <int16_byte.h>
Public Member Functions | |
constexpr | int16_byte (uint8_t factor) |
Construct. More... | |
byte | to_byte (int16_t value) const |
Convert to a byte . More... | |
int16_t | from_byte (byte in) const |
Convert from a byte . More... | |
Represents a 16-bit value as a byte. Useful for I/O.
Often we need to deal internally with values that fit in 16-bits but do not require much accuracy. E.g. table axes in RPM. For these values we can save storage space (EEPROM) by scaling to/from 8-bits using a fixed divisor.
|
inlineconstexpr |
Construct.
factor | The factor to multiply when converting byte to int16_t |
divider | The factor to divide by when converting int16_t to byte |
divider
could be computed from factor
, but including it as a parameter allows callers to create factor
instances at compile time.
|
inline |
Convert from a byte
.
|
inline |
Convert to a byte
.