![]() |
Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
|
Drive MAX7219 seven segment displays. More...
#include <MAX7219_7SEG_RDL.hpp>
Public Member Functions | |
MAX7219_SS_RPI (uint8_t clock, uint8_t chipSelect, uint8_t data, int gpioDev) | |
Constructor for class MAX7219_SS_RPI software SPI. | |
MAX7219_SS_RPI (int device, int channel, int speed, int flags) | |
Constructor for class MAX7219_SS_RPI hardware SPI. | |
rdlib::Return_Codes_e | InitDisplay (ScanLimit_e numDigits, DecodeMode_e decodeMode) |
Init the display. | |
void | ClearDisplay (void) |
Clear the display. | |
rdlib::Return_Codes_e | DisplayEndOperations (void) |
End display operations, called at end of program. | |
void | SetBrightness (uint8_t brightness) |
sets the brighttness of display | |
void | DisplayTestMode (bool OnOff) |
Turn on and off the Display Test Mode. | |
void | ShutdownMode (bool OnOff) |
Turn on and off the Shutdown Mode. | |
uint16_t | GetCommDelay (void) |
Get the communication delay value. | |
void | SetCommDelay (uint16_t commDelay) |
Set the communication delay value. | |
bool | GetHardwareSPI (void) |
get value of _HardwareSPI , true hardware SPI on , false off. | |
uint8_t | GetCurrentDisplayNumber (void) |
Get the Current Display Number. | |
void | SetCurrentDisplayNumber (uint8_t) |
Set the Current Display Number. | |
void | DisplayChar (uint8_t digit, uint8_t value, DecimalPoint_e decimalPoint) |
Displays a character on display. | |
void | DisplayText (char *text, TextAlignment_e TextAlignment) |
Displays a text string on display. | |
void | DisplayText (char *text) |
Displays a text string on display. | |
void | DisplayIntNum (unsigned long number, TextAlignment_e TextAlignment) |
Display an integer and leading zeros optional. | |
void | DisplayDecNumNibble (uint16_t numberUpper, uint16_t numberLower, TextAlignment_e TextAlignment) |
Display an integer in a nibble (4 digits on display) | |
void | DisplayBCDChar (uint8_t digit, CodeBFont_e value) |
Displays a character on display using MAX7219 Built in BCD code B font. | |
void | DisplayBCDText (char *text) |
Displays a BCD text string on display using MAX7219 Built in BCD code B font. | |
void | SetSegment (uint8_t digit, uint8_t segment) |
Set a seven segment LED ON. | |
Private Member Functions | |
void | HighFreqshiftOut (uint8_t value) |
Shifts out a uint8_t of data on to the MAX7219 SPI-like bus. | |
void | WriteDisplay (uint8_t RegisterCode, uint8_t data) |
Write to the MAX7219 display register. | |
uint8_t | ASCIIFetch (uint8_t character, DecimalPoint_e decimalPoint) |
Fetch's the seven segment code for a given ASCII code from the font. | |
void | SetDecodeMode (DecodeMode_e mode) |
Set the decode mode of the MAX7219 decode mode register. | |
void | SetScanLimit (ScanLimit_e numDigits) |
Set the decode mode of the MAX7219 decode mode register. | |
uint8_t | flipBitsPreserveMSB (uint8_t byte) |
Flips the positions of bits in a byte while preserving the MSB bit. | |
Private Attributes | |
uint8_t | _Display_CS |
uint8_t | _Display_SDATA |
uint8_t | _Display_SCLK |
uint16_t | _CommDelay = 0 |
uint8_t | _NoDigits = 8 |
int | _DeviceNumGpioChip = 0 |
int | _GpioHandle = 0 |
int | _spiHandle = 0 |
int | _spiDev = 0 |
int | _spiChan = 0 |
int | _spiBaud = 50000 |
int | _spiFlags = 0 |
bool | _HardwareSPI = false |
DecodeMode_e | CurrentDecodeMode |
uint8_t | _CurrentDisplayNumber = 1 |
Drive MAX7219 seven segment displays.
enum MAX7219_SS_RPI::CodeBFont_e : uint8_t |
sets BCD code B font (0-9, E, H, L,P, and -) Built-in font
enum MAX7219_SS_RPI::DecimalPoint_e : uint8_t |
enum MAX7219_SS_RPI::DecodeMode_e : uint8_t |
The decode-mode register sets BCD code B or no-decode operation for each digit
enum MAX7219_SS_RPI::Intensity_e : uint8_t |
enum MAX7219_SS_RPI::RegisterModes_e : uint8_t |
Register opcodes of the MAZ7219 chip, Register Address Map
enum MAX7219_SS_RPI::ScanLimit_e : uint8_t |
The scan-limit register sets how many digits are displayed
enum MAX7219_SS_RPI::TextAlignment_e : uint8_t |
MAX7219_SS_RPI::MAX7219_SS_RPI | ( | uint8_t | clock, |
uint8_t | chipSelect, | ||
uint8_t | data, | ||
int | gpioDev | ||
) |
Constructor for class MAX7219_SS_RPI software SPI.
clock | CLk pin |
chipSelect | CS pin |
data | DIO pin |
gpioDev | The device number of a gpiochip. @ |
MAX7219_SS_RPI::MAX7219_SS_RPI | ( | int | device, |
int | channel, | ||
int | speed, | ||
int | flags | ||
) |
Constructor for class MAX7219_SS_RPI hardware SPI.
device | A SPI device, >= 0. |
channel | A SPI channel, >= 0. |
speed | The speed of serial communication in bits per second. |
flags | The flags may be used to modify the default behaviour. Set to 0(mode 0) for this device. |
|
private |
Fetch's the seven segment code for a given ASCII code from the font.
character | The ASCII character to lookup |
decimalPoint | Is the decimal point(dp) to be set or not. |
void MAX7219_SS_RPI::DisplayBCDChar | ( | uint8_t | digit, |
CodeBFont_e | value | ||
) |
Displays a character on display using MAX7219 Built in BCD code B font.
digit | The digit to display character in, 7-0 ,7 = LHS 0 =RHS |
value | The BCD character to display |
void MAX7219_SS_RPI::DisplayBCDText | ( | char * | text | ) |
Displays a BCD text string on display using MAX7219 Built in BCD code B font.
text | pointer to character array containg text string |
void MAX7219_SS_RPI::DisplayChar | ( | uint8_t | digit, |
uint8_t | character, | ||
DecimalPoint_e | decimalPoint | ||
) |
Displays a character on display.
digit | The digit to display character in, 7-0 ,7 = LHS 0 =RHS |
character | The ASCII character to display |
decimalPoint | Is the decimal point(dp) to be set or not. |
void MAX7219_SS_RPI::DisplayDecNumNibble | ( | uint16_t | numberUpper, |
uint16_t | numberLower, | ||
TextAlignment_e | TextAlignment | ||
) |
Display an integer in a nibble (4 digits on display)
numberUpper | upper nibble integer 2^16 |
numberLower | lower nibble integer 2^16 |
TextAlignment | left or right alignment or leading zeros |
rdlib::Return_Codes_e MAX7219_SS_RPI::DisplayEndOperations | ( | void | ) |
End display operations, called at end of program.
void MAX7219_SS_RPI::DisplayIntNum | ( | unsigned long | number, |
TextAlignment_e | TextAlignment | ||
) |
Display an integer and leading zeros optional.
number | integer to display 2^32 |
TextAlignment | enum text alignment, left or right alignment or leading zeros |
void MAX7219_SS_RPI::DisplayTestMode | ( | bool | OnOff | ) |
Turn on and off the Display Test Mode.
OnOff | true = display test mode on , false display Test Mode off |
void MAX7219_SS_RPI::DisplayText | ( | char * | text | ) |
Displays a text string on display.
text | pointer to character array containg text string |
void MAX7219_SS_RPI::DisplayText | ( | char * | text, |
TextAlignment_e | TextAlignment | ||
) |
Displays a text string on display.
text | pointer to character array containg text string |
TextAlignment | left or right alignment or leading zeros |
|
private |
Flips the positions of bits in a byte while preserving the MSB bit.
byte | A byte of data, ASCII character |
The reason for this function is that the MAX7219 requires ASCII segment data in following order : dp-abcdefg but the font we use is dp-gfedcba where letters represent seven segment LEDS, and dp represents decimal point.. We flip the bits in the code rather than change the font data in font file because the font data is used by other modules(TM1638 + TM1637) and they use dp-gfedcba order. Thus we can share same font file between all seven segment modules.
uint16_t MAX7219_SS_RPI::GetCommDelay | ( | void | ) |
Get the communication delay value.
uint8_t MAX7219_SS_RPI::GetCurrentDisplayNumber | ( | void | ) |
Get the Current Display Number.
bool MAX7219_SS_RPI::GetHardwareSPI | ( | void | ) |
get value of _HardwareSPI , true hardware SPI on , false off.
|
private |
Shifts out a uint8_t of data on to the MAX7219 SPI-like bus.
value | The uint8_t of data to shift out |
rdlib::Return_Codes_e MAX7219_SS_RPI::InitDisplay | ( | ScanLimit_e | numDigits, |
DecodeMode_e | decodeMode | ||
) |
Init the display.
numDigits | scan limit set to 8 normally , advanced use only |
decodeMode | Must users will use 0x00 here |
void MAX7219_SS_RPI::SetBrightness | ( | uint8_t | brightness | ) |
sets the brighttness of display
brightness | rang 0x00 to 0x0F , 0x00 being least bright. |
void MAX7219_SS_RPI::SetCommDelay | ( | uint16_t | commDelay | ) |
Set the communication delay value.
commDelay | Set the communication delay value uS software SPI |
void MAX7219_SS_RPI::SetCurrentDisplayNumber | ( | uint8_t | DisplayNum | ) |
Set the Current Display Number.
DisplayNum | Set the Current Display Number |
|
private |
Set the decode mode of the MAX7219 decode mode register.
mode | Set to 0x00 for most users |
|
private |
Set the decode mode of the MAX7219 decode mode register.
numDigits | Usually set to 7(digit 8) The scan-limit register sets how many digits are displayed, from 1 to 8. |
void MAX7219_SS_RPI::SetSegment | ( | uint8_t | digit, |
uint8_t | segment | ||
) |
Set a seven segment LED ON.
digit | The digit to set segment in, 7-0 ,7 = LHS 0 =RHS |
segment | The segment of seven segment to set dpabcdefg |
void MAX7219_SS_RPI::ShutdownMode | ( | bool | OnOff | ) |
Turn on and off the Shutdown Mode.
OnOff | true = Shutdown mode on , false shutdown mode off |
|
private |
Write to the MAX7219 display register.
RegisterCode | the register to write to |
data | The data byte to send to register |
|
private |
uS delay used in communications SW SPI, User adjust
|
private |
Which display the user wishes to write to in a cascade of connected displays
|
private |
SWSPI The device number of a gpiochip ls /dev/gpio
|
private |
GPIO connected to CS on MAX7219, SW SPI only
|
private |
GPIO connected to CLK on MAX7219, SW SPI only
|
private |
GPIO connected to DIO on MAX7219, SW SPI only
|
private |
This holds a handle to a device opened by lgGpiochipOpen
|
private |
Is the Hardware SPI on , true yes , false SW SPI
|
private |
Number of digits in display
|
private |
The speed of serial communication in bits per second.
|
private |
A SPI channel, >= 0.
|
private |
A SPI device, >= 0.
|
private |
The flags 2 LSB defines SPI mode See MAX7219_SS_RPI constructor notes
|
private |
Hold a handle for the SPI device on the channel lgSpiOpen(
|
private |
Enum to store current decode mode