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

Class for Model 1 tm1638. More...

#include <TM1638plus.h>

Inheritance diagram for TM1638plus:
Inheritance graph
[legend]

Public Member Functions

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

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
 
- 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.
 
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.
 
void sendCommand (uint8_t value)
 Send command to display.
 
void sendData (uint8_t data)
 Send Data to display.
 
- Static Protected Member Functions inherited from SevenSegmentFont
static const uint8_t * pFontSevenSegptr ()
 Retrieves a pointer to the seven-segment font data table.
 
- Protected Attributes inherited from TM1638plus_common
uint8_t _STROBE_IO
 
uint8_t _DATA_IO
 
uint8_t _CLOCK_IO
 
bool _HIGH_FREQ = false
 
uint8_t _HFIN_DELAY = 1
 
uint8_t _HFOUT_DELAY = 1
 
- Static Protected Attributes inherited from TM1638plus_common
static constexpr uint8_t TM_ACTIVATE = 0x8F
 
static constexpr uint8_t TM_BUTTONS_MODE = 0x42
 
static constexpr uint8_t TM_WRITE_LOC = 0x44
 
static constexpr uint8_t TM_WRITE_INC = 0x40
 
static constexpr uint8_t TM_SEG_ADR = 0xC0
 
static constexpr uint8_t TM_LEDS_ADR = 0xC1
 
static constexpr uint8_t TM_BRIGHT_ADR = 0x88
 
static constexpr uint8_t TM_BRIGHT_MASK = 0x07
 
static constexpr uint8_t TM_DEFAULT_BRIGHTNESS = 0x02
 
static constexpr uint8_t TM_DISPLAY_SIZE = 8
 
- 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 Model 1 tm1638.

Constructor & Destructor Documentation

◆ TM1638plus()

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

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,
DecimalPoint_e  decimalPoint 
)

Display an ASCII character on display.

Parameters
positionThe position on display 0-7
asciiThe ASCII value from font table to display
decimalPointdecimal point or off on the digit.

◆ 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 
)
virtual

Set ONE LED on or off Model 1 & 3.

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

Reimplemented in TM1638plus_model3.

◆ setLEDs()

void TM1638plus::setLEDs ( uint16_t  ledvalues)
virtual

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

Parameters
ledvalues1 on , 0 off , 0xXXLL where LL = L8-L1
Note
MODEL 1:
  1. Upper byte ignored this byte/method is used by sub-class Model 3
  2. Lower byte LED data model 1
  3. setLEDs(0xF0) Displays as XXXX LLLL (L1-L8),NOTE on display L8 is on right hand side.

Reimplemented in TM1638plus_model3.


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