Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
MAX7219_7SEG_RDL.hpp
Go to the documentation of this file.
1
9#pragma once
10
11// Libraries
12#include <cstring>
13#include <cstdio> //snprintf
14#include <lgpio.h>
16#include "common_data_RDL.hpp"
17
18
23{
24public:
25 MAX7219_SS_RPI(uint8_t clock, uint8_t chipSelect ,uint8_t data, int gpioDev);
26 MAX7219_SS_RPI(int device, int channel, int speed, int flags);
27
29 enum DecodeMode_e : uint8_t
30 {
34 DecodeModeBCDThree = 0xFF
35 };
36
57
59 enum TextAlignment_e : uint8_t
60 {
64 };
65
67 enum DecimalPoint_e : uint8_t
68 {
70 DecPointOn = 1
71 };
72
74 enum Intensity_e : uint8_t
75 {
76 IntensityMin = 0x00,
78 IntensityMax = 0x0F
79 };
80
82 enum ScanLimit_e : uint8_t
83 {
84 ScanOneDigit = 0x00,
85 ScanTwoDigit = 0x01,
89 ScanSixDigit = 0x05,
91 ScanEightDigit = 0x07
92 };
93
108
110 void ClearDisplay(void);
112
113 void SetBrightness(uint8_t brightness);
114 void DisplayTestMode(bool OnOff);
115 void ShutdownMode(bool OnOff);
116
117 uint16_t GetCommDelay(void);
118 void SetCommDelay(uint16_t commDelay);
119
120 bool GetHardwareSPI(void);
121
122
123 uint8_t GetCurrentDisplayNumber(void);
124 void SetCurrentDisplayNumber(uint8_t);
125
126 void DisplayChar(uint8_t digit, uint8_t value, DecimalPoint_e decimalPoint);
127 void DisplayText(char *text, TextAlignment_e TextAlignment);
128 void DisplayText(char *text);
129 void DisplayIntNum(unsigned long number, TextAlignment_e TextAlignment);
130 void DisplayDecNumNibble(uint16_t numberUpper, uint16_t numberLower, TextAlignment_e TextAlignment);
131 void DisplayBCDChar(uint8_t digit, CodeBFont_e value);
132 void DisplayBCDText(char *text);
133 void SetSegment(uint8_t digit, uint8_t segment);
134
135protected:
136
137
138private:
139
140 uint8_t _Display_CS;
144 uint16_t _CommDelay = 0;
145 uint8_t _NoDigits = 8;
148 int _GpioHandle = 0;
149 int _spiHandle = 0;
150 int _spiDev = 0;
151 int _spiChan = 0;
152 int _spiBaud = 50000;
153 int _spiFlags = 0;
154 bool _HardwareSPI = false;
160 void HighFreqshiftOut(uint8_t value);
161 void WriteDisplay(uint8_t RegisterCode, uint8_t data);
162 uint8_t ASCIIFetch(uint8_t character,DecimalPoint_e decimalPoint);
163 void SetDecodeMode(DecodeMode_e mode);
164 void SetScanLimit(ScanLimit_e numDigits);
165 uint8_t flipBitsPreserveMSB(uint8_t byte);
166};
167
Drive MAX7219 seven segment displays.
Definition MAX7219_7SEG_RDL.hpp:23
uint8_t _Display_CS
Definition MAX7219_7SEG_RDL.hpp:140
RegisterModes_e
Definition MAX7219_7SEG_RDL.hpp:96
@ MAX7219_REG_DecodeMode
Definition MAX7219_7SEG_RDL.hpp:98
@ MAX7219_REG_ScanLimit
Definition MAX7219_7SEG_RDL.hpp:100
@ MAX7219_REG_DisplayTest
Definition MAX7219_7SEG_RDL.hpp:105
@ MAX7219_REG_Intensity
Definition MAX7219_7SEG_RDL.hpp:99
@ MAX7219_REG_NOP
Definition MAX7219_7SEG_RDL.hpp:97
@ MAX7219_REG_ShutDown
Definition MAX7219_7SEG_RDL.hpp:101
void WriteDisplay(uint8_t RegisterCode, uint8_t data)
Write to the MAX7219 display register.
Definition MAX7219_7SEG_RDL.cpp:569
CodeBFont_e
Definition MAX7219_7SEG_RDL.hpp:39
@ CodeBFontNine
Definition MAX7219_7SEG_RDL.hpp:49
@ CodeBFontTwo
Definition MAX7219_7SEG_RDL.hpp:42
@ CodeBFontEight
Definition MAX7219_7SEG_RDL.hpp:48
@ CodeBFontZero
Definition MAX7219_7SEG_RDL.hpp:40
@ CodeBFontL
Definition MAX7219_7SEG_RDL.hpp:53
@ CodeBFontFour
Definition MAX7219_7SEG_RDL.hpp:44
@ CodeBFontP
Definition MAX7219_7SEG_RDL.hpp:54
@ CodeBFontSeven
Definition MAX7219_7SEG_RDL.hpp:47
@ CodeBFontOne
Definition MAX7219_7SEG_RDL.hpp:41
@ CodeBFontThree
Definition MAX7219_7SEG_RDL.hpp:43
@ CodeBFontSpace
Definition MAX7219_7SEG_RDL.hpp:55
@ CodeBFontH
Definition MAX7219_7SEG_RDL.hpp:52
@ CodeBFontE
Definition MAX7219_7SEG_RDL.hpp:51
@ CodeBFontDash
Definition MAX7219_7SEG_RDL.hpp:50
@ CodeBFontSix
Definition MAX7219_7SEG_RDL.hpp:46
@ CodeBFontFive
Definition MAX7219_7SEG_RDL.hpp:45
uint8_t _CurrentDisplayNumber
Definition MAX7219_7SEG_RDL.hpp:158
void DisplayChar(uint8_t digit, uint8_t value, DecimalPoint_e decimalPoint)
Displays a character on display.
Definition MAX7219_7SEG_RDL.cpp:255
void SetDecodeMode(DecodeMode_e mode)
Set the decode mode of the MAX7219 decode mode register.
Definition MAX7219_7SEG_RDL.cpp:611
void ShutdownMode(bool OnOff)
Turn on and off the Shutdown Mode.
Definition MAX7219_7SEG_RDL.cpp:405
void HighFreqshiftOut(uint8_t value)
Shifts out a uint8_t of data on to the MAX7219 SPI-like bus.
Definition MAX7219_7SEG_RDL.cpp:522
uint16_t _CommDelay
Definition MAX7219_7SEG_RDL.hpp:144
void SetBrightness(uint8_t brightness)
sets the brighttness of display
Definition MAX7219_7SEG_RDL.cpp:393
uint16_t GetCommDelay(void)
Get the communication delay value.
Definition MAX7219_7SEG_RDL.cpp:432
void DisplayBCDText(char *text)
Displays a BCD text string on display using MAX7219 Built in BCD code B font.
Definition MAX7219_7SEG_RDL.cpp:346
uint8_t _NoDigits
Definition MAX7219_7SEG_RDL.hpp:145
int _DeviceNumGpioChip
Definition MAX7219_7SEG_RDL.hpp:147
TextAlignment_e
Definition MAX7219_7SEG_RDL.hpp:60
@ AlignRight
Definition MAX7219_7SEG_RDL.hpp:62
@ AlignRightZeros
Definition MAX7219_7SEG_RDL.hpp:63
@ AlignLeft
Definition MAX7219_7SEG_RDL.hpp:61
void ClearDisplay(void)
Clear the display.
Definition MAX7219_7SEG_RDL.cpp:201
void DisplayText(char *text, TextAlignment_e TextAlignment)
Displays a text string on display.
Definition MAX7219_7SEG_RDL.cpp:276
int _spiBaud
Definition MAX7219_7SEG_RDL.hpp:152
void SetSegment(uint8_t digit, uint8_t segment)
Set a seven segment LED ON.
Definition MAX7219_7SEG_RDL.cpp:265
Intensity_e
Definition MAX7219_7SEG_RDL.hpp:75
@ IntensityMin
Definition MAX7219_7SEG_RDL.hpp:76
@ IntensityDefault
Definition MAX7219_7SEG_RDL.hpp:77
@ IntensityMax
Definition MAX7219_7SEG_RDL.hpp:78
DecimalPoint_e
Definition MAX7219_7SEG_RDL.hpp:68
@ DecPointOn
Definition MAX7219_7SEG_RDL.hpp:70
@ DecPointOff
Definition MAX7219_7SEG_RDL.hpp:69
uint8_t ASCIIFetch(uint8_t character, DecimalPoint_e decimalPoint)
Fetch's the seven segment code for a given ASCII code from the font.
Definition MAX7219_7SEG_RDL.cpp:542
void DisplayTestMode(bool OnOff)
Turn on and off the Display Test Mode.
Definition MAX7219_7SEG_RDL.cpp:416
void DisplayBCDChar(uint8_t digit, CodeBFont_e value)
Displays a character on display using MAX7219 Built in BCD code B font.
Definition MAX7219_7SEG_RDL.cpp:244
int _spiChan
Definition MAX7219_7SEG_RDL.hpp:151
DecodeMode_e
Definition MAX7219_7SEG_RDL.hpp:30
@ DecodeModeNone
Definition MAX7219_7SEG_RDL.hpp:31
@ DecodeModeBCDOne
Definition MAX7219_7SEG_RDL.hpp:32
@ DecodeModeBCDTwo
Definition MAX7219_7SEG_RDL.hpp:33
@ DecodeModeBCDThree
Definition MAX7219_7SEG_RDL.hpp:34
void SetCommDelay(uint16_t commDelay)
Set the communication delay value.
Definition MAX7219_7SEG_RDL.cpp:426
void SetCurrentDisplayNumber(uint8_t)
Set the Current Display Number.
Definition MAX7219_7SEG_RDL.cpp:444
ScanLimit_e
Definition MAX7219_7SEG_RDL.hpp:83
@ ScanSevenDigit
Definition MAX7219_7SEG_RDL.hpp:90
@ ScanOneDigit
Definition MAX7219_7SEG_RDL.hpp:84
@ ScanEightDigit
Definition MAX7219_7SEG_RDL.hpp:91
@ ScanFourDigit
Definition MAX7219_7SEG_RDL.hpp:87
@ ScanSixDigit
Definition MAX7219_7SEG_RDL.hpp:89
@ ScanTwoDigit
Definition MAX7219_7SEG_RDL.hpp:85
@ ScanFiveDigit
Definition MAX7219_7SEG_RDL.hpp:88
@ ScanThreeDigit
Definition MAX7219_7SEG_RDL.hpp:86
int _spiHandle
Definition MAX7219_7SEG_RDL.hpp:149
DecodeMode_e CurrentDecodeMode
Definition MAX7219_7SEG_RDL.hpp:156
uint8_t flipBitsPreserveMSB(uint8_t byte)
Flips the positions of bits in a byte while preserving the MSB bit.
Definition MAX7219_7SEG_RDL.cpp:638
rdlib::Return_Codes_e InitDisplay(ScanLimit_e numDigits, DecodeMode_e decodeMode)
Init the display.
Definition MAX7219_7SEG_RDL.cpp:136
uint8_t _Display_SCLK
Definition MAX7219_7SEG_RDL.hpp:142
int _spiDev
Definition MAX7219_7SEG_RDL.hpp:150
void SetScanLimit(ScanLimit_e numDigits)
Set the decode mode of the MAX7219 decode mode register.
Definition MAX7219_7SEG_RDL.cpp:622
int _spiFlags
Definition MAX7219_7SEG_RDL.hpp:153
int _GpioHandle
Definition MAX7219_7SEG_RDL.hpp:148
uint8_t _Display_SDATA
Definition MAX7219_7SEG_RDL.hpp:141
rdlib::Return_Codes_e DisplayEndOperations(void)
End display operations, called at end of program.
Definition MAX7219_7SEG_RDL.cpp:53
uint8_t GetCurrentDisplayNumber(void)
Get the Current Display Number.
Definition MAX7219_7SEG_RDL.cpp:438
bool _HardwareSPI
Definition MAX7219_7SEG_RDL.hpp:154
bool GetHardwareSPI(void)
get value of _HardwareSPI , true hardware SPI on , false off.
Definition MAX7219_7SEG_RDL.cpp:121
void DisplayDecNumNibble(uint16_t numberUpper, uint16_t numberLower, TextAlignment_e TextAlignment)
Display an integer in a nibble (4 digits on display)
Definition MAX7219_7SEG_RDL.cpp:490
void DisplayIntNum(unsigned long number, TextAlignment_e TextAlignment)
Display an integer and leading zeros optional.
Definition MAX7219_7SEG_RDL.cpp:456
file to hold common data and functions used by many Displays Project Name: Display_Lib_RPI
LED segment font data file for ht16k33 tm1638, tm1637 & max7219 modules.
Return_Codes_e
Definition common_data_RDL.hpp:22