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

Class for Model 1 and Model 3. More...

#include <TM1638plus.h>

Inheritance diagram for TM1638plus:
Inheritance graph
[legend]
Collaboration diagram for TM1638plus:
Collaboration graph
[legend]

Public Member Functions

 TM1638plus (uint8_t strobe, uint8_t clock, uint8_t data, bool highfreq=false)
 Constructor for class TM1638plus. More...
 
uint8_t readButtons (void)
 Read buttons values from display. More...
 
void setLEDs (uint16_t greenred)
 Set all LED's on or off Model 1 & 3. More...
 
void setLED (uint8_t position, uint8_t value)
 Set ONE LED on or off Model 1 & 3. More...
 
void displayText (const char *text)
 Display a text string on display. More...
 
void displayASCII (uint8_t position, uint8_t ascii)
 Display an ASCII character on display. More...
 
void displayASCIIwDot (uint8_t position, uint8_t ascii)
 Display an ASCII character with decimal point turned on. More...
 
void displayHex (uint8_t position, uint8_t hex)
 Send Hexadecimal value to seven segment. More...
 
void display7Seg (uint8_t position, uint8_t value)
 Send seven segment value to seven segment. More...
 
void displayIntNum (unsigned long number, boolean leadingZeros=true, AlignTextType_e=TMAlignTextLeft)
 Display an integer and leading zeros optional. More...
 
void DisplayDecNumNibble (uint16_t numberUpper, uint16_t numberLower, boolean leadingZeros=true, AlignTextType_e=TMAlignTextLeft)
 Display an integer in a nibble (4 digits on display) More...
 
- Public Member Functions inherited from TM1638plus_common
 TM1638plus_common ()
 Constructor for class TM1638plus_common.
 
void displayBegin ()
 Begin method , sets pin modes and activate display. More...
 
void reset (void)
 Reset / clear the display. More...
 
void brightness (uint8_t brightness)
 Sets the brightness level of segments in display on a scale of brightness. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TM1638plus_common
uint8_t HighFreqshiftin (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder)
 Shifts in a byte of data from the Tm1638 SPI-like bus. More...
 
void HighFreqshiftOut (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
 Shifts out a byte of data on to the Tm1638 SPI-like bus. More...
 
void sendCommand (uint8_t value)
 Send command to display. More...
 
void sendData (uint8_t data)
 Send Data to display. More...
 
- Protected Attributes inherited from TM1638plus_common
uint8_t _STROBE_IO
 
uint8_t _DATA_IO
 
uint8_t _CLOCK_IO
 
bool _HIGH_FREQ = false
 

Detailed Description

Class for Model 1 and Model 3.

Constructor & Destructor Documentation

◆ TM1638plus()

TM1638plus::TM1638plus ( uint8_t  strobe,
uint8_t  clock,
uint8_t  data,
bool  highfreq = false 
)

Constructor for class TM1638plus.

Parameters
strobeGPIO STB pin
clockGPIO CLK pin
dataGPIO DIO pin
highfreqChanges the value of parameter _HIGH_FREQ which is default false.
Note
_HIGH_FREQ is used when running high freq MCU CPU (~>100Mhz) because of issues with button function. Pass true to turn on.

Member Function Documentation

◆ display7Seg()

void TM1638plus::display7Seg ( uint8_t  position,
uint8_t  value 
)

Send seven segment value to seven segment.

Parameters
positionThe position on display 0-7
valuebyte of data corresponding to segments (dp)gfedcba
Note
0b01000001 in value will set g and a on.

◆ displayASCII()

void TM1638plus::displayASCII ( uint8_t  position,
uint8_t  ascii 
)

Display an ASCII character on display.

Parameters
positionThe position on display 0-7
asciiThe ASCII value from font table to display

◆ displayASCIIwDot()

void TM1638plus::displayASCIIwDot ( uint8_t  position,
uint8_t  ascii 
)

Display an ASCII character with decimal point turned on.

Parameters
positionThe position on display 0-7
asciiThe ASCII value from font table to display

◆ DisplayDecNumNibble()

void TM1638plus::DisplayDecNumNibble ( uint16_t  numberUpper,
uint16_t  numberLower,
boolean  leadingZeros = true,
AlignTextType_e  TextAlignment = TMAlignTextLeft 
)

Display an integer in a nibble (4 digits on display)

Parameters
numberUpperupper nibble integer 2^16
numberLowerlower nibble integer 2^16
leadingZerosleading zeros set, true on , false off
TextAlignmentleft or right text alignment on display
Note
Divides the display into two nibbles and displays a Decimal number in each. takes in two numbers 0-9999 for each nibble.

◆ displayHex()

void TM1638plus::displayHex ( uint8_t  position,
uint8_t  hex 
)

Send Hexadecimal value to seven segment.

Parameters
positionThe position on display 0-7
hexhexadecimal value (DEC) 0-15 (0x00 - 0x0F)

◆ displayIntNum()

void TM1638plus::displayIntNum ( unsigned long  number,
boolean  leadingZeros = true,
AlignTextType_e  TextAlignment = TMAlignTextLeft 
)

Display an integer and leading zeros optional.

Parameters
numberinteger to display 2^32
leadingZerosleading zeros set, true on , false off
TextAlignmentleft or right text alignment on display

◆ displayText()

void TM1638plus::displayText ( const char *  text)

Display a text string on display.

Parameters
textpointer to a character array
Note
Dots are removed from string and dot on preceding digit switched on "abc.def" will be shown as "abcdef" with c decimal point turned on.

◆ readButtons()

uint8_t TM1638plus::readButtons ( void  )

Read buttons values from display.

Returns
byte with value of buttons 1-8 b7b6b5b4b3b2b1b0 1 pressed, 0 not pressed.
Note
User may have to debounce buttons depending on application.

◆ setLED()

void TM1638plus::setLED ( uint8_t  position,
uint8_t  value 
)

Set ONE LED on or off Model 1 & 3.

Parameters
position0-7 == L1-L8 on PCB
value0 off 1 on

◆ setLEDs()

void TM1638plus::setLEDs ( uint16_t  ledvalues)

Set all LED's on or off Model 1 & 3.

Parameters
ledvaluessee note behaviour differs depending on Model.
Note
  1. Model 3
    1. Upper byte for the green LEDs, Lower byte for the red LEDs (0xgreenred) (0xGGRR)
    2. ie. 0xE007 1110 0000 0000 0111 results in L8-L0 GGGX XRRR, L8 is RHS on display
  2. MODEL 1:
    1. Upper byte 1 for LED data , Lower byte n/a set to 0x00 (0xleds, 0x00)
    2. i.e 0xF100 1111 0000 L8-L0 RRRR XXXX , L8 is RHS on display

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