MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
Loading...
Searching...
No Matches
max_matrix::Byte Class Reference

A byte of raw data: eight dots of a column or a row, or the value of a register of the MAX7219. More...

#include <Byte.h>

Public Member Functions

 Byte ()=default
 Makes a byte whose bits are not set to anything, as std::byte; Byte{} has none set.
constexpr Byte (uint8_t value)
 Makes a byte of the bits of value.
MAXMATRIX_NODISCARD constexpr uint8_t ToInteger () const
 Returns the bits as a number.
constexpr Byte operator~ () const
 Returns the bits that are not set in this byte.

Friends

constexpr bool operator== (Byte left, Byte right)
 Returns whether two bytes have the same bits.
constexpr bool operator!= (Byte left, Byte right)
 Returns whether two bytes differ in a bit.
constexpr Byte operator& (Byte left, Byte right)
 Returns the bits set in both bytes.
constexpr Byte operator| (Byte left, Byte right)
 Returns the bits set in either byte.
constexpr Byte operator<< (Byte value, uint8_t shift)
 Returns the bits moved shift places up; those beyond bit 7 fall out.
constexpr Byte operator>> (Byte value, uint8_t shift)
 Returns the bits moved shift places down; those below bit 0 fall out.

Detailed Description

A byte of raw data: eight dots of a column or a row, or the value of a register of the MAX7219.

It takes only the bitwise operators, and is a number only through ToInteger(), so that a column cannot be passed where its value is meant, nor the other way round. A sketch makes one from a number in braces:

matrix.SetColumn(3, max_matrix::Byte{0x3C});
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

As std::byte, which it stands in for until every target has C++17, a byte made without braces holds any bits, and one made with empty braces none: Byte column{};. It is one uint8_t and costs no RAM of its own; the examples are 34 to 50 bytes of flash smaller with it than with uint8_t on the Uno (OIL 41).

Constructor & Destructor Documentation

◆ Byte()

max_matrix::Byte::Byte ( uint8_t value)
inlineexplicitconstexpr

Makes a byte of the bits of value.

Parameters
[in]valueThe bits, bit 0 the first dot.

◆ operator!=

bool operator!= ( Byte left,
Byte right )
friend

Returns whether two bytes differ in a bit.

Parameters
[in]leftThe one byte.
[in]rightThe other.

◆ operator&

Byte operator& ( Byte left,
Byte right )
friend

Returns the bits set in both bytes.

Parameters
[in]leftThe one byte.
[in]rightThe other.

◆ operator<<

Byte operator<< ( Byte value,
uint8_t shift )
friend

Returns the bits moved shift places up; those beyond bit 7 fall out.

Parameters
[in]valueThe byte.
[in]shiftThe places, less than 8.

◆ operator==

bool operator== ( Byte left,
Byte right )
friend

Returns whether two bytes have the same bits.

Parameters
[in]leftThe one byte.
[in]rightThe other.

◆ operator>>

Byte operator>> ( Byte value,
uint8_t shift )
friend

Returns the bits moved shift places down; those below bit 0 fall out.

Parameters
[in]valueThe byte.
[in]shiftThe places, less than 8.

◆ operator|

Byte operator| ( Byte left,
Byte right )
friend

Returns the bits set in either byte.

Parameters
[in]leftThe one byte.
[in]rightThe other.

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