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_LKM1638 Class Reference

Constructor for class for driving TM1638 controller as used in LKM1638. More...

#include <TM1638.h>

Inherits TM1638.

Public Types

enum  Icon {
  DP1 = (1<<24) | S7_DP1, DP2 = (2<<24) | S7_DP2, DP3 = (3<<24) | S7_DP3, DP4 = (4<<24) | S7_DP4,
  DP5 = (5<<24) | S7_DP5, DP6 = (6<<24) | S7_DP6, DP7 = (7<<24) | S7_DP7, DP8 = (8<<24) | S7_DP8,
  GR1 = (1<<24) | S7_GR1, GR2 = (2<<24) | S7_GR2, GR3 = (3<<24) | S7_GR3, GR4 = (4<<24) | S7_GR4,
  GR5 = (5<<24) | S7_GR5, GR6 = (6<<24) | S7_GR6, GR7 = (7<<24) | S7_GR7, GR8 = (8<<24) | S7_GR8,
  RD1 = (1<<24) | S7_RD1, RD2 = (2<<24) | S7_RD2, RD3 = (3<<24) | S7_RD3, RD4 = (4<<24) | S7_RD4,
  RD5 = (5<<24) | S7_RD5, RD6 = (6<<24) | S7_RD6, RD7 = (7<<24) | S7_RD7, RD8 = (8<<24) | S7_RD8,
  YL1 = (1<<24) | S7_YL1, YL2 = (2<<24) | S7_YL2, YL3 = (3<<24) | S7_YL3, YL4 = (4<<24) | S7_YL4,
  YL5 = (5<<24) | S7_YL5, YL6 = (6<<24) | S7_YL6, YL7 = (7<<24) | S7_YL7, YL8 = (8<<24) | S7_YL8
}
 

Enums for Icons.

More...
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_LKM1638 (PinName mosi, PinName miso, PinName sclk, PinName cs)
 Constructor for class for driving TM1638 LED controller as used in LKM1638.
int putc (int c)
 Write a character to the Display.
int printf (const char *format,...)
 Write a formatted string to the Display.
void locate (int column)
 Locate cursor to a screen column.
void cls (bool clrAll=false)
 Clear the screen and locate to 0.
void setIcon (Icon icon)
 Set Icon.
void clrIcon (Icon icon)
 Clr Icon.
void setUDC (unsigned char udc_idx, int udc_data)
 Set User Defined Characters (UDC)
int columns ()
 Number of screen columns.
void writeData (char data, int address)
 Write databyte to TM1638.
void writeData (DisplayData_t data, int length=(LKM1638_NR_GRIDS *TM1638_BYTES_PER_GRID), int address=0)
 Write Display datablock to TM1638.
void cls ()
 Clear the screen and locate to 0.
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.

Protected Member Functions

virtual int _putc (int value)
 Write a single character (Stream implementation)

Detailed Description

Constructor for class for driving TM1638 controller as used in LKM1638.

Supports 8 Digits of 7 Segments + DP, Also supports 8 Bi-color LEDs and a scanned keyboard of 8 keys.

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

Definition at line 569 of file TM1638.h.


Member Typedef Documentation

typedef char DisplayData_t[TM1638_DISPLAY_MEM] [inherited]

Datatype for display data.

Definition at line 124 of file TM1638.h.

typedef char KeyData_t[TM1638_KEY_MEM] [inherited]

Datatypes for keymatrix data.

Definition at line 127 of file TM1638.h.


Member Enumeration Documentation

enum Icon

Enums for Icons.

Enumerator:
DP1 

Decimal Point 1.

DP2 

Decimal Point 2.

DP3 

Decimal Point 3.

DP4 

Decimal Point 4.

DP5 

Decimal Point 5.

DP6 

Decimal Point 6.

DP7 

Decimal Point 7.

DP8 

Decimal Point 8.

GR1 

Green LED 1.

GR2 

Green LED 2.

GR3 

Green LED 3.

GR4 

Green LED 4.

GR5 

Green LED 5.

GR6 

Green LED 6.

GR7 

Green LED 7.

GR8 

Green LED 8.

RD1 

Red LED 1.

RD2 

Red LED 2.

RD3 

Red LED 3.

RD4 

Red LED 4.

RD5 

Red LED 5.

RD6 

Red LED 6.

RD7 

Red LED 7.

RD8 

Red LED 8.

YL1 

Yellow LED 1.

YL2 

Yellow LED 2.

YL3 

Yellow LED 3.

YL4 

Yellow LED 4.

YL5 

Yellow LED 5.

YL6 

Yellow LED 6.

YL7 

Yellow LED 7.

YL8 

Yellow LED 8.

Definition at line 574 of file TM1638.h.


Constructor & Destructor Documentation

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

Constructor for class for driving TM1638 LED controller as used in LKM1638.

Supports 8 Digits of 7 Segments + DP Icons. Also supports 8 Bi-Color LEDs and a scanned keyboard of 8 keys.

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

Supports 8 Digits of 7 Segments + DP + Bi-Color LED Icons. Also supports a scanned keyboard of 8.

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

Definition at line 754 of file TM1638.cpp.


Member Function Documentation

int _putc ( int  value ) [protected, virtual]

Write a single character (Stream implementation)

Definition at line 881 of file TM1638.cpp.

void clrIcon ( Icon  icon )

Clr Icon.

Parameters:
Iconicon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs
Returns:
none

Definition at line 847 of file TM1638.cpp.

void cls ( bool  clrAll = false )

Clear the screen and locate to 0.

Parameters:
boolclrAll Clear Icons also (default = false)

Definition at line 802 of file TM1638.cpp.

void cls (  ) [inherited]

Clear the screen and locate to 0.

Definition at line 60 of file TM1638.cpp.

int columns (  )

Number of screen columns.

Parameters:
none
Returns:
columns

Definition at line 794 of file TM1638.cpp.

bool getKeys ( KeyData_t keydata ) [inherited]

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 locate ( int  column )

Locate cursor to a screen column.

Parameters:
columnThe horizontal position from the left, indexed from 0

Definition at line 780 of file TM1638.cpp.

int printf ( const char *  format,
  ... 
)

Write a formatted string to the Display.

Parameters:
formatA printf-style format string, followed by the variables to use in formatting the string.
int putc ( int  c )

Write a character to the Display.

Parameters:
cThe character to write to the display
void setBrightness ( char  brightness = TM1638_BRT_DEF ) [inherited]

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 ) [inherited]

Set the Display mode On/off.

Parameters:
booldisplay mode

Definition at line 90 of file TM1638.cpp.

void setIcon ( Icon  icon )

Set Icon.

Parameters:
Iconicon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs
Returns:
none

Definition at line 828 of file TM1638.cpp.

void setUDC ( unsigned char  udc_idx,
int  udc_data 
)

Set User Defined Characters (UDC)

Parameters:
unsignedchar udc_idx The Index of the UDC (0..7)
intudc_data The bitpattern for the UDC (16 bits)
unsignedchar udc_idx The Index of the UDC (0..7)
intudc_data The bitpattern for the UDC (8 bits)

Definition at line 867 of file TM1638.cpp.

void writeData ( DisplayData_t  data,
int  length = (LKM1638_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..(LKM1638_NR_GRIDS * TM1638_BYTES_PER_GRID) (=16), when starting at address 0)
intaddress display memory location to write bytes (default = 0)
Returns:
none

Reimplemented from TM1638.

Definition at line 692 of file TM1638.h.

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 from TM1638.

Definition at line 682 of file TM1638.h.