TM1638 LED controller. Max 80 LEDs, Max 24 Key scan. Supports LED&KEY, QYF-TM1638 and JY-LKM1638 module.

Dependents:   mbed_TM1638 Otjimaniya RL0201-V1

Embed: (wiki syntax)

« Back to documentation index

TM1638 Class Reference

TM1638 Class Reference

A class for driving TM1638 LED controller. More...

#include <TM1638.h>

Inherited by TM1638_LEDKEY8, TM1638_LKM1638, and TM1638_QYF.

Public Types

typedef char DisplayData_t [TM1638_DISPLAY_MEM]
 Datatype for display data.
typedef char KeyData_t [TM1638_KEY_MEM]
 Datatypes for keymatrix data.

Public Member Functions

 TM1638 (PinName mosi, PinName miso, PinName sclk, PinName cs)
 Constructor for class for driving TM1638 LED controller.
void cls ()
 Clear the screen and locate to 0.
void writeData (char data, int address)
 Write databyte to TM1638.
void writeData (DisplayData_t data, int length=(TM1638_MAX_NR_GRIDS *TM1638_BYTES_PER_GRID), int address=0)
 Write Display datablock to TM1638.
bool getKeys (KeyData_t *keydata)
 Read keydata block from TM1638.
void setBrightness (char brightness=TM1638_BRT_DEF)
 Set Brightness.
void setDisplay (bool on)
 Set the Display mode On/off.

Detailed Description

A class for driving TM1638 LED controller.

Supports 8 Grids @ 10 Segments. Also supports a scanned keyboard of upto 24 keys. SPI bus interface device.

Definition at line 121 of file TM1638.h.


Member Typedef Documentation

typedef char DisplayData_t[TM1638_DISPLAY_MEM]

Datatype for display data.

Definition at line 124 of file TM1638.h.

typedef char KeyData_t[TM1638_KEY_MEM]

Datatypes for keymatrix data.

Definition at line 127 of file TM1638.h.


Constructor & Destructor Documentation

TM1638 ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs 
)

Constructor for class for driving TM1638 LED controller.

Constructor for class for driving TM1638 LED controller with SPI bus interface device.

Supports 8 Grids @ 10 segments. Also supports a scanned keyboard of upto 24 keys. SPI bus interface device.

Parameters:
PinNamemosi, miso, sclk, cs SPI bus pins

Supports 8 digits @ 10 segments. Also supports a scanned keyboard of upto 24 keys.

Parameters:
PinNamemosi, miso, sclk, cs SPI bus pins

Definition at line 33 of file TM1638.cpp.


Member Function Documentation

void cls (  )

Clear the screen and locate to 0.

Definition at line 60 of file TM1638.cpp.

bool getKeys ( KeyData_t keydata )

Read keydata block from TM1638.

Parameters:
*keydataPtr to Array of TM1638_KEY_MEM (=4) bytes for keydata
Returns:
bool keypress True when at least one key was pressed

Note: Due to the hardware configuration the TM1638 key matrix scanner will detect multiple keys pressed at same time, but this may result in some spurious keys also being set in keypress data array. It may be best to ignore all keys in those situations. That option is implemented in this method depending on define setting.

Parameters:
*keydataPtr to Array of TM1638_KEY_MEM (=4) bytes for keydata
Returns:
bool keypress True when at least one key was pressed

Note: Due to the hardware configuration the TM1638 key matrix scanner will detect multiple keys pressed at same time, but this may also result in some spurious keys being set in keypress data array. It may be best to ignore all keys in those situations. That option is implemented in this method depending on define setting.

Definition at line 156 of file TM1638.cpp.

void setBrightness ( char  brightness = TM1638_BRT_DEF )

Set Brightness.

Parameters:
charbrightness (3 significant bits, valid range 0..7 (1/16 .. 14/16 dutycycle)
Returns:
none
Parameters:
charbrightness (3 significant bits, valid range 0..7 (1/16 .. 14/14 dutycycle)
Returns:
none

Definition at line 79 of file TM1638.cpp.

void setDisplay ( bool  on )

Set the Display mode On/off.

Parameters:
booldisplay mode

Definition at line 90 of file TM1638.cpp.

void writeData ( char  data,
int  address 
)

Write databyte to TM1638.

Parameters:
chardata byte written at given address
intaddress display memory location to write byte
Returns:
none

Reimplemented in TM1638_LEDKEY8, TM1638_QYF, and TM1638_LKM1638.

Definition at line 108 of file TM1638.cpp.

void writeData ( DisplayData_t  data,
int  length = (TM1638_MAX_NR_GRIDS * TM1638_BYTES_PER_GRID),
int  address = 0 
)

Write Display datablock to TM1638.

Parameters:
DisplayData_tdata Array of TM1638_DISPLAY_MEM (=16) bytes for displaydata
lengthnumber bytes to write (valid range 0..(TM1638_MAX_NR_GRIDS * TM1638_BYTES_PER_GRID) (=16), when starting at address 0)
intaddress display memory location to write bytes (default = 0)
Returns:
none
Parameters:
DisplayData_tdata Array of TM1638_DISPLAY_MEM (=16) bytes for displaydata
lengthnumber bytes to write (valid range 0..TM1638_DISPLAY_MEM (=16), when starting at address 0)
intaddress display memory location to write bytes (default = 0)
Returns:
none

Reimplemented in TM1638_LEDKEY8, TM1638_QYF, and TM1638_LKM1638.

Definition at line 126 of file TM1638.cpp.