TM1638_plus 2.1.0
Arduino library for Tm1638 modules
Public Member Functions | List of all members
TM1637plus_modelX Class Reference

Class for TM1637 Model 4. More...

#include <TM1637plus.h>

Inheritance diagram for TM1637plus_modelX:
Inheritance graph
[legend]

Public Member Functions

 TM1637plus_modelX (uint8_t clock, uint8_t data, int delay, int DisplaySize)
 Initialize a TM1637 object.
 
void displayBegin (void)
 Begin method , set and claims GPIO.
 
void displayClose (void)
 Close method.
 
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.
 
int 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.
 

Additional Inherited Members

- Public Types inherited from CommonData
enum  DecimalPoint_e : uint8_t { DecPointOff = 0 , DecPointOn = 1 }
 Switch on or off decimal point on a digit. More...
 
- Public Attributes inherited from CommonData
bool displaylib_LED_debug = false
 
- Static Public Attributes inherited from CommonData
static constexpr uint16_t displaylib_LED_VersionNum = 210
 
- Static Protected Member Functions inherited from SevenSegmentFont
static const uint8_t * pFontSevenSegptr ()
 Retrieves a pointer to the seven-segment font data table.
 
- Static Protected Attributes inherited from CommonData
static constexpr uint8_t _ASCII_FONT_OFFSET = 0x20
 
static constexpr uint8_t _ASCII_FONT_END = 0x7B
 
static constexpr uint8_t _ASCII_FONT_HEX_OFFSET = 0x10
 
static constexpr uint8_t DEC_POINT_7_MASK = 0x80
 

Detailed Description

Class for TM1637 Model 4.

Constructor & Destructor Documentation

◆ TM1637plus_modelX()

TM1637plus_modelX::TM1637plus_modelX ( uint8_t  clock,
uint8_t  data,
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
delaymicroseconds delay, between bit transition on the serial bus connected to the display
displaySizenumber of digits in display.

Member Function Documentation

◆ displayBegin()

void TM1637plus_modelX::displayBegin ( void  )

Begin method , set and claims GPIO.

Note
Call in Setup

◆ DisplayDecimal()

void TM1637plus_modelX::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_modelX::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) For model 4 semi-colon display set to 0x40 to turn on the colon.
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()

int TM1637plus_modelX::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) For model 4 semi-colon display set to 0x40 to turn on the colon.
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
Zero for success , -2 for nullptr, -3 input string size not equal to specified length.

◆ encodeCharacter()

unsigned char TM1637plus_modelX::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. Will return zero(0x3F) if ASCII digit not in font.

◆ setBrightness()

void TM1637plus_modelX::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_modelX::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, check font in seven_segment_font_data.hpp
lengthThe number of digits to be modified
positionThe position from which to start the modification (0 - leftmost, 3 - rightmost)

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