upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

API for the TM1637 7-Segment Display. More...

Detailed Description

TM1637 is a display controller for LED-based 7-segment displays. It can be used to address and write data to multiple display digits. This driver is based on the Grove version of the TM1637 display that uses 4 digits, thus making it ideal for clock displays, timers, counters, or even score displays in a two-player arcade game.

tm1637.jpeg
// TM1637 on pins 0 (clk) and 1 (dio)
upm_tm1637.TM1637 myDisplay = new upm_tm1637.TM1637(0, 1);
// Start a box using 7-segment encoding
myDisplay.write(0x39, 0x09, 0x09);
// Finish box using writeAt function
myDisplay.writeAt(3, ']');
// Wait 3 seconds
Thread.sleep(3000);
LocalDateTime now;
while (true) {
now = LocalDateTime.now();
int hour = now.getHour();
int min = now.getMinute();
int sec = now.getSecond();
System.out.println(hour + ":" + min + ":" + sec);
myDisplay.writeString(hour + ":" + min);
Thread.sleep(1000);
}

Classes

class  M_FAST_GPIO
 

Public Member Functions

synchronized void delete ()
 
 TM1637 (int clk_pin, int dio_pin, int bright, TM1637.M_FAST_GPIO mmio)
 
 TM1637 (int clk_pin, int dio_pin, int bright)
 
 TM1637 (int clk_pin, int dio_pin)
 
int writeArray (short digits)
 
int write (int d, int digit1, int digit2, int digit3, int digit4)
 
int write (int d, int digit1, int digit2, int digit3)
 
int write (int d, int digit1, int digit2)
 
int write (int d, int digit1)
 
int write (int d)
 
int writeAt (int index, char symbol)
 
int writeString (String digits)
 
void setColon (boolean value)
 
void setBrightness (int value)
 

Constructor & Destructor Documentation

TM1637 ( int  clk_pin,
int  dio_pin,
int  bright,
TM1637.M_FAST_GPIO  mmio 
)

TM1637 constructor

Parameters
clk_pinClock pin the sensor is connected to
dio_pinData pin the sensor is connected to
brightInitial brightness, from 0 (dark) to 7 (bright) (default is 3)
mmioFast memory-mapped GPIO writes; default is yes

Member Function Documentation

void setBrightness ( int  value)

Controls the brightness of the display

Parameters
valueBrightness, from 0 (darkest) to 7 (brightest)
void setColon ( boolean  value)

Toggles the colon between digits on the display

Parameters
valueTrue to turn the colon on, false to turn it off
int write ( int  d)

Writes digits to the display in a 7-segment encoding

Parameters
digitsArray of digits to send to the display
Returns
0 if successful, error code otherwise
int writeAt ( int  index,
char  symbol 
)

Writes a symbol (digit or letter) to the display in a specified index

Parameters
index0-based index of the digit to change from the left
symbolDigit or letter to display
Returns
0 if successful, error code otherwise

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