Class for TM1637 Model 4.
More...
#include <TM1637plus_Model4_RDL.hpp>
|
| TM1637plus_Model4 (uint8_t clock, uint8_t data, int gpioDev, int delay, int DisplaySize) |
| Initialize a TM1637 object.
|
|
rdlib::Return_Codes_e | displayBegin (void) |
| Begin method , set and claims GPIO.
|
|
rdlib::Return_Codes_e | displayClose (void) |
| Close method , frees GPIO and deactivate display.
|
|
void | displayClear (void) |
| Clears the display.
|
|
void | setBrightness (uint8_t brightness, bool on) |
| Sets the brightness of the display.
|
|
void | setSegments (const uint8_t segments[], uint8_t length, uint8_t pos) |
| Display data on the module.
|
|
void | DisplayDecimal (int num, bool leading_zero, uint8_t length, uint8_t pos) |
| Displays a decimal number.
|
|
void | DisplayDecimalwDot (int num, uint8_t dots, bool leading_zero, uint8_t length, uint8_t pos) |
| Displays a decimal number, with decimal point control.
|
|
rdlib::Return_Codes_e | DisplayString (const char *numStr, uint8_t dots, uint8_t length, uint8_t position) |
| Displays a character array.
|
|
unsigned char | encodeCharacter (unsigned char digit) |
| Translate a single Character into 7 segment code.
|
|
|
void | CommBitDelay (void) |
| Sets the delay, in microseconds, between bit transition on the serial bus connected to the display.
|
|
void | CommStart (void) |
| Starts the communication sequence.
|
|
void | CommStop (void) |
| Stops the communication sequence.
|
|
bool | writeByte (uint8_t byte) |
| Writes a byte to the Display.
|
|
Class for TM1637 Model 4.
◆ TM1637plus_Model4()
TM1637plus_Model4::TM1637plus_Model4 |
( |
uint8_t |
clock, |
|
|
uint8_t |
data, |
|
|
int |
gpioDev, |
|
|
int |
delay, |
|
|
int |
displaySize |
|
) |
| |
Initialize a TM1637 object.
- Parameters
-
clock | GPIO connected to the clock pin of the module |
data | GPIO connected to the DIO pin of the module |
gpioDev | The device number of a gpiochip. |
delay | microseconds delay, between bit transition on the serial bus connected to the display |
displaySize | number of digits in display. |
◆ displayBegin()
◆ displayClose()
◆ DisplayDecimal()
void TM1637plus_Model4::DisplayDecimal |
( |
int |
number, |
|
|
bool |
leading_zero, |
|
|
uint8_t |
length, |
|
|
uint8_t |
position |
|
) |
| |
Displays a decimal number.
Displays the given argument as a decimal number
- Parameters
-
number | The number to be shown |
leading_zero | When true, leading zeros are displayed. Otherwise unnecessary digits are blank |
length | The number of digits to set. The user must ensure that the number to be shown fits to the number of digits requested (for example, if two digits are to be displayed, the number must be between 0 to 99) |
position | The position most significant digit (0 - leftmost, 3 - rightmost) |
◆ DisplayDecimalwDot()
void TM1637plus_Model4::DisplayDecimalwDot |
( |
int |
number, |
|
|
uint8_t |
dots, |
|
|
bool |
leading_zero, |
|
|
uint8_t |
length, |
|
|
uint8_t |
position |
|
) |
| |
Displays a decimal number, with decimal point control.
Displays the given argument as a decimal number. The dots between the digits (or colon) can be individually controlled
- Parameters
-
number | The number to be shown |
dots | decimal point enable. The argument is a bitmask, with each bit corresponding to a dot between the digits (or colon mark, as implemented by each module). The MSB is the leftmost dot of the digit being update. For example, if pos is 1, the MSB of dots will correspond the dot near digit no. 2 from the left. Dots are updated only on those digits actually being update (that is, no more than len digits) |
leading_zero | When true, leading zeros are displayed. Otherwise unnecessary digits are blank |
length | The number of digits to set. The user must ensure that the number to be shown fits to the number of digits requested (for example, if two digits are to be displayed, the number must be between 0 to 99) |
position | The position least significant digit (0 - leftmost, 3 - rightmost) |
◆ DisplayString()
rdlib::Return_Codes_e TM1637plus_Model4::DisplayString |
( |
const char * |
numStr, |
|
|
uint8_t |
dots, |
|
|
uint8_t |
length, |
|
|
uint8_t |
position |
|
) |
| |
Displays a character array.
- Parameters
-
numStr | The character array to be shown |
dots | decimal point enable. The argument is a bitmask, with each bit corresponding to a dot between the digits (or colon mark, as implemented by each module). The MSB is the leftmost dot of the digit being update. For example, if pos is 1, the MSB of dots will correspond the dot near digit no. 2 from the left. Dots are updated only on those digits actually being update (that is, no more than len digits) |
length | The number of digits to set. The user must ensure that the number to be shown fits to the number of digits requested |
position | The position most significant digit (0 - leftmost, 3 - rightmost) |
- Returns
- codes
- Success
- CharArrayNullptr
- GenericError ( if The number of digits to set is greater than DisplaySzie)
◆ encodeCharacter()
unsigned char TM1637plus_Model4::encodeCharacter |
( |
unsigned char |
digit | ) |
|
Translate a single Character into 7 segment code.
The method accepts a ASCII character and converts it to the seven segment code required to display the number on a 7 segment display. by referencing the ASCII font table on file.
- Parameters
-
- Returns
- A code representing the 7 segment image of the digit (LSB - segment A; bit 6 - segment G; bit 7 - always zero) from the font.
◆ setBrightness()
void TM1637plus_Model4::setBrightness |
( |
uint8_t |
brightness, |
|
|
bool |
on |
|
) |
| |
Sets the brightness of the display.
- Parameters
-
brightness | A number from 0 to 7 (highest brightness) |
on | Turn display on or off |
- Note
- The setting takes effect when a command is given to change the data being displayed.
◆ setSegments()
void TM1637plus_Model4::setSegments |
( |
const uint8_t |
segments[], |
|
|
uint8_t |
length, |
|
|
uint8_t |
position |
|
) |
| |
Display data on the module.
This function receives segment values as input and displays them. The segment data is given as a byte array, each byte corresponding to a single digit. Within each byte, bit 0 is segment A, bit 1 is segment B etc. The function may either set the entire display or any desirable part on its own. The first digit is given by the reference position argument with 0 being the leftmost digit. The reference length argument is the number of digits to be set. Other digits are not affected.
- Parameters
-
segments | An array of size length containing the raw segment values |
length | The number of digits to be modified |
position | The position from which to start the modification (0 - leftmost, 3 - rightmost) |
◆ writeByte()
bool TM1637plus_Model4::writeByte |
( |
uint8_t |
byte | ) |
|
|
private |
Writes a byte to the Display.
- Parameters
-
- Returns
- status of acknowledge bit
◆ _ASCIIOffset
const uint8_t TM1637plus_Model4::_ASCIIOffset = 0x20 |
|
private |
Offset in the ASCII table for font Start position
◆ _BitDelayUS
int TM1637plus_Model4::_BitDelayUS = 75 |
|
private |
Us second delay used in communications
◆ _brightness
uint8_t TM1637plus_Model4::_brightness = 7 |
|
private |
◆ _DeviceNumGpioChip
int TM1637plus_Model4::_DeviceNumGpioChip = 0 |
|
private |
The device number of a gpiochip usually 0 , ls /dev/gpio
◆ _Display_SCLK
uint8_t TM1637plus_Model4::_Display_SCLK |
|
private |
GPIO connected to CLk on Tm1637
◆ _Display_SDATA
uint8_t TM1637plus_Model4::_Display_SDATA |
|
private |
GPIO connected to DIO on Tm1637
◆ _DisplaySize
uint8_t TM1637plus_Model4::_DisplaySize = 4 |
|
private |
size of display in digits
◆ _GpioHandle
int TM1637plus_Model4::_GpioHandle = 0 |
|
private |
This returns a handle to a gpiochip device.
◆ TM1637_COMMAND_1
constexpr uint8_t TM1637plus_Model4::TM1637_COMMAND_1 = 0x40 |
|
staticconstexprprivate |
Automatic data incrementing
◆ TM1637_COMMAND_2
constexpr uint8_t TM1637plus_Model4::TM1637_COMMAND_2 = 0xC0 |
|
staticconstexprprivate |
Data Data1~N: Transfer display data
◆ TM1637_COMMAND_3
constexpr uint8_t TM1637plus_Model4::TM1637_COMMAND_3 = 0x80 |
|
staticconstexprprivate |
The documentation for this class was generated from the following files: