Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TM1637plus_Model4 Class Reference

Class for TM1637 Model 4. More...

#include <TM1637plus_Model4_RDL.hpp>

Public Member Functions

 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.
 

Private Member Functions

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.
 

Private Attributes

uint8_t _Display_SDATA
 
uint8_t _Display_SCLK
 
uint8_t _DisplaySize = 4
 
int _DeviceNumGpioChip = 0
 
int _GpioHandle = 0
 
int _BitDelayUS = 75
 
uint8_t _brightness = 7
 
const uint8_t _ASCIIOffset = 0x20
 

Static Private Attributes

static constexpr uint8_t TM1637_COMMAND_1 = 0x40
 
static constexpr uint8_t TM1637_COMMAND_2 = 0xC0
 
static constexpr uint8_t TM1637_COMMAND_3 = 0x80
 

Detailed Description

Class for TM1637 Model 4.

Constructor & Destructor Documentation

◆ TM1637plus_Model4()

TM1637plus_Model4::TM1637plus_Model4 ( uint8_t  clock,
uint8_t  data,
int  gpioDev,
int  delay,
int  displaySize 
)

Initialize a TM1637 object.

Parameters
clockGPIO connected to the clock pin of the module
dataGPIO connected to the DIO pin of the module
gpioDevThe device number of a gpiochip.
delaymicroseconds delay, between bit transition on the serial bus connected to the display
displaySizenumber of digits in display.

Member Function Documentation

◆ displayBegin()

rdlib::Return_Codes_e TM1637plus_Model4::displayBegin ( void  )

Begin method , set and claims GPIO.

Returns
  1. rdlib::Success
  2. rdlib::GpioChipDevice
  3. rdlib::GpioPinClaim
Note
Call in Setup

◆ displayClose()

rdlib::Return_Codes_e TM1637plus_Model4::displayClose ( void  )

Close method , frees GPIO and deactivate display.

Returns
  1. rdlib::Success
  2. rdlib::GpioChipDevice
  3. rdlib::GpioPinFree
Note
call at end of program

◆ 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
numberThe number to be shown
leading_zeroWhen true, leading zeros are displayed. Otherwise unnecessary digits are blank
lengthThe 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)
positionThe 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
numberThe number to be shown
dotsdecimal 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_zeroWhen true, leading zeros are displayed. Otherwise unnecessary digits are blank
lengthThe 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)
positionThe 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
numStrThe character array to be shown
dotsdecimal 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)
lengthThe number of digits to set. The user must ensure that the number to be shown fits to the number of digits requested
positionThe position most significant digit (0 - leftmost, 3 - rightmost)
Returns
codes
  1. Success
  2. CharArrayNullptr
  3. 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
digitAn ASCII character
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
brightnessA number from 0 to 7 (highest brightness)
onTurn 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
segmentsAn array of size length containing the raw segment values
lengthThe number of digits to be modified
positionThe 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
bytethe Byte to write
Returns
status of acknowledge bit

Member Data Documentation

◆ _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

Brightness level 0-7

◆ _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

Display intensity


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