|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
65 enum class Register {
NO_OP,
DIGIT_ZERO = 0x11,
DIGIT_ONE = 0x12,
DIGIT_TWO = 0x13,
DIGIT_THREE = 0x14,
DIGIT_FOUR = 0x15,
DIGIT_FIVE = 0x16,
DIGIT_SIX = 0x17,
DIGIT_SEVEN = 0x18,
DECODE_MODE = 0x19,
INTENSITY = 0x1A,
SCAN_LIMIT = 0x1B,
SHUTDOWN = 0x1C,
DISPLAY_TEST = 0x1D
111 static const uint8_t DEFAULT_INTENSITY = 15;
112 static const uint8_t DEFAULT_SCAN_LIMIT = 7;
113 static const uint8_t DEFAULT_BCD_DECODE_BITS = 0xFF;
114 static const uint8_t DECIMAL_POINT = BIT_7;
138 m_cs(csMask,
Pin::Dir::OUT),
139 m_alwaysSetMode(alwaysSetSPIMode) {
140 if (!alwaysSetSPIMode)
152 : m_bus(&
SPI::get_instance()),
153 m_cs(csMask,
Pin::Dir::OUT),
154 m_alwaysSetMode(alwaysSetSPIMode) {
155 if (!alwaysSetSPIMode)
167 this->m_alwaysSetMode = alwaysSetMode;
180 void start (
const uint8_t intensity = DEFAULT_INTENSITY,
const uint8_t scanLimit = DEFAULT_SCAN_LIMIT,
181 const uint8_t bcdDecodeBits = DEFAULT_BCD_DECODE_BITS)
const {
255 const bool isNegative = 0 >
x;
262 const uint8_t digit =
static_cast<const uint8_t
>(
x % 10);
267 }
while (
x && 8 > i);
276 this->
write(
to_register(i),
static_cast<const uint8_t
>(BcdCharacter::DASH));
289 for (uint8_t i = 0; i < 8; ++i)
290 this->
write(
to_register(i),
static_cast<const uint8_t
>(BcdCharacter::BLANK));
301 void write (
const Register address,
const uint8_t value,
const bool decimal =
false)
const {
302 if (this->m_alwaysSetMode)
306 this->m_bus->
shift_out(8,
static_cast<uint32_t
>(address));
308 this->m_bus->
shift_out(8, value | DECIMAL_POINT);
317 bool m_alwaysSetMode;
Serially interfaced, 8-Digit LED display driver.
static Register to_register(unsigned int zeroIndexedDigit)
Get the Register address of the requested 0-indexed digit on the device.
void set_scan_limit(const uint8_t scanLimit) const
Enables or disables specific digits on the device.
void clear() const
Write BcdCharacter::BLANK to all eight digits.
static const SPI::Mode SPI_MODE
SPI serial communications library; Core functionality comes from a dedicated assembly cog.
Register
Register addresses.
MAX72xx(const Pin::Mask csMask, const bool alwaysSetSPIMode=true)
Create an object which communicates over the shared SPI bus.
Utility class to handle general purpose I/O pins.
void put_int(int32_t x, const BcdCharacter fillChar=BcdCharacter::BLANK, unsigned int width=0) const
Write an integer to the device.
BcdCharacter
Characters that will utilize the device's built-in font.
void set_test_mode(const bool enableTestMode) const
Enable or disable the test mode of the device. When enable, all LED segments will be lit....
void shift_out(uint8_t bits, uint32_t value) const
Send a value out to a peripheral device.
void set_decode_mode(const uint8_t bcdDecodeBits) const
Determines which digits will be decoded and which ones will be converted to the build-in font prior t...
void set() const
Set selected output port high (set all pins to 1)
void set_intensity(const uint8_t intensity) const
Set the device's brightness.
void set_mode(const Mode mode)
Set the mode of SPI communication.
void always_set_spi_mode(const bool alwaysSetMode)
Choose whether to always set the SPI mode before writing to the device; Useful when multiple devices ...
void shutdown() const
Disable the device by writing to the SHUTDOWN register. Values in other registers will not be lost.
Generic definitions and functions for the Parallax Propeller.
void clear() const
Clear selected output port (set it to 0)
MAX72xx(SPI &bus, const Pin::Mask csMask, const bool alwaysSetSPIMode=false)
Create an object which communicates over the given SPI bus.
void start(const uint8_t intensity=DEFAULT_INTENSITY, const uint8_t scanLimit=DEFAULT_SCAN_LIMIT, const uint8_t bcdDecodeBits=DEFAULT_BCD_DECODE_BITS) const
Initialize the device after power-on.
void write(const Register address, const uint8_t value, const bool decimal=false) const
Perform a manual write to the device.
Mode
Descriptor for SPI signal as defined by Motorola modes.