Speeduino
Loading...
Searching...
No Matches
Public Member Functions | List of all members
int16_byte Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ int16_byte()

constexpr int16_byte::int16_byte ( uint8_t  factor)
inlineconstexpr

Construct.

Parameters
factorThe factor to multiply when converting byte to int16_t
dividerThe 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.

Member Function Documentation

◆ from_byte()

int16_t int16_byte::from_byte ( byte  in) const
inline

Convert from a byte.

Here is the caller graph for this function:

◆ to_byte()

byte int16_byte::to_byte ( int16_t  value) const
inline

Convert to a byte.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: