9#ifndef MAXMATRIX_SRC_UTILITY_BYTE_H_
10#define MAXMATRIX_SRC_UTILITY_BYTE_H_
59 constexpr explicit Byte(uint8_t value) : value_{value} {}
68 return Byte{
static_cast<uint8_t
>(~value_)};
78 return left.value_ == right.value_;
88 return !(left == right);
98 return Byte{
static_cast<uint8_t
>(left.value_ & right.value_)};
108 return Byte{
static_cast<uint8_t
>(left.value_ | right.value_)};
119 return Byte{
static_cast<uint8_t
>(value.value_ << shift)};
130 return Byte{
static_cast<uint8_t
>(value.value_ >> shift)};
Single bits and groups of bits of an unsigned integer: the one place where bitwise operators stand (d...
constexpr bool ReadBit(Byte value, uint8_t bit)
Returns whether a bit is set, as the core's bitRead() for a number.
Definition Byte.h:150
constexpr Byte WriteBit(Byte value, uint8_t bit, bool set)
Returns value with one bit set or cleared, as the core's bitWrite() for a number.
Definition Byte.h:162
The attributes of a later standard, as macros, where the compiler has them.
#define MAXMATRIX_NODISCARD
Marks a function whose result must not be dropped: the compiler warns where it is.
Definition MaxMatrixAttributes.h:37
static constexpr bool ReadBit(Integer value, uint8_t position)
Returns whether the bit at position of value is set.
Definition Bit.h:87
static constexpr Integer WriteBit(Integer value, uint8_t position, bool set)
Returns value with the bit at position set or cleared.
Definition Bit.h:99
A byte of raw data: eight dots of a column or a row, or the value of a register of the MAX7219.
Definition Byte.h:45
friend constexpr bool operator==(Byte left, Byte right)
Returns whether two bytes have the same bits.
Definition Byte.h:77
Byte()=default
Makes a byte whose bits are not set to anything, as std::byte; Byte{} has none set.
friend constexpr Byte operator<<(Byte value, uint8_t shift)
Returns the bits moved shift places up; those beyond bit 7 fall out.
Definition Byte.h:118
friend constexpr Byte operator&(Byte left, Byte right)
Returns the bits set in both bytes.
Definition Byte.h:97
MAXMATRIX_NODISCARD constexpr uint8_t ToInteger() const
Returns the bits as a number.
Definition Byte.h:64
constexpr Byte operator~() const
Returns the bits that are not set in this byte.
Definition Byte.h:67
friend constexpr Byte operator|(Byte left, Byte right)
Returns the bits set in either byte.
Definition Byte.h:107
friend constexpr bool operator!=(Byte left, Byte right)
Returns whether two bytes differ in a bit.
Definition Byte.h:87
constexpr Byte(uint8_t value)
Makes a byte of the bits of value.
Definition Byte.h:59
friend constexpr Byte operator>>(Byte value, uint8_t shift)
Returns the bits moved shift places down; those below bit 0 fall out.
Definition Byte.h:129