TM1637 Pico  1.1
Functions
PicoTM1637.h File Reference
#include <stdbool.h>
Include dependency graph for PicoTM1637.h:

Go to the source code of this file.

Functions

void TM1637_init (uint clk, uint dio)
 Initiate TM1637 display. More...
 
void TM1637_put_2_bytes (uint startPos, uint data)
 Display one or two bytes of raw data on the display. More...
 
void TM1637_put_4_bytes (uint startPos, uint data)
 Display one to four bytes of raw data on the display. More...
 
void TM1637_display (int number, bool leadingZeros)
 Display a positive number with 4 digits or a negative number with 3 digits. More...
 
void TM1637_display_word (char *word, bool leftAlign)
 Display a string of characters. More...
 
void TM1637_display_left (int number, bool leadingZeros)
 Display a positive number on the 2 leftmost digits on the display. More...
 
void TM1637_display_right (int number, bool leadingZeros)
 Display a positive number on the 2 rightmost digits on the display. More...
 
void TM1637_display_both (int leftNumber, int rightNumber, bool leadingZeros)
 Display two (2 digit positive) numbers on the display. More...
 
void TM1637_set_colon (bool on)
 Turn the colon led on or off. More...
 
void TM1637_set_brightness (int val)
 Set the display brightness. More...
 
int TM1637_get_brightness ()
 Get the current brightness level. More...
 
void TM1637_clear ()
 Clear the display. More...
 
void TM1637_refresh_frequency ()
 Reset the frequency at which TM1637 recives data. More...
 
void TM1637_wait ()
 Wait for the TM1637 display. More...
 

Function Documentation

◆ TM1637_clear()

void TM1637_clear ( )

Clear the display.

◆ TM1637_display()

void TM1637_display ( int  number,
bool  leadingZeros 
)

Display a positive number with 4 digits or a negative number with 3 digits.

Parameters
numberThe number to display.
leadingZerosIf leading zeros should be displayed or not.

◆ TM1637_display_both()

void TM1637_display_both ( int  leftNumber,
int  rightNumber,
bool  leadingZeros 
)

Display two (2 digit positive) numbers on the display.

A colon is by default shown in between. To turn this off use TM1637_set_colon(bool false).

◆ TM1637_display_left()

void TM1637_display_left ( int  number,
bool  leadingZeros 
)

Display a positive number on the 2 leftmost digits on the display.

A colon is by default shown. To turn this off use TM1637_set_colon(bool false).

Avoid using this function. It will cause the right side to flicker. Instead use TM1637_display_both().

◆ TM1637_display_right()

void TM1637_display_right ( int  number,
bool  leadingZeros 
)

Display a positive number on the 2 rightmost digits on the display.

A colon is by default shown. To turn this off use TM1637_set_colon(bool false).

◆ TM1637_display_word()

void TM1637_display_word ( char *  word,
bool  leftAlign 
)

Display a string of characters.

Parameters
wordThe word to display. May be at most 4 letters long.
leftAligntrue if left alignment is desired, false for right alignment. Has no effect if all 4 chars are used.

All English alphabet letters are supported in lower or upper case. If the desired case is not found, the other will be displayed instead. If a character is not found at all it will be replaced by white space. For a full list of supported characters, as well as their hexadecimal representation please look at char_table.txt.

You can also include a colon (:) in the string. This character is not counted in the word length as the colon internaly belongs to the character before it. Will only work if aligned with the colon spot on the display.

◆ TM1637_get_brightness()

int TM1637_get_brightness ( )

Get the current brightness level.

Returns an integer from 0 to 7 represenging current brightness level.

◆ TM1637_init()

void TM1637_init ( uint  clk,
uint  dio 
)

Initiate TM1637 display.

Parameters
clkis the clock GPIO pin number.
diois the data GPIO pin number.

◆ TM1637_put_2_bytes()

void TM1637_put_2_bytes ( uint  startPos,
uint  data 
)

Display one or two bytes of raw data on the display.

Parameters
startPosThe digit index to start at. Ranges from 0 to 3, where 0 is to the left
dataThe data for one or two bytes, the least significant byte will be put to the left.

For example TM1637_put_2_bytes(2, 0x3f05) will show the number 10 on the right half of the display.

◆ TM1637_put_4_bytes()

void TM1637_put_4_bytes ( uint  startPos,
uint  data 
)

Display one to four bytes of raw data on the display.

Parameters
startPosThe digit index to start at. Ranges from 0 to 3, where 0 is to the left
dataThe data for one to four bytes, the least significant byte will be put to the left.

◆ TM1637_refresh_frequency()

void TM1637_refresh_frequency ( )

Reset the frequency at which TM1637 recives data.

Call this function in case the system clock frequency has been changed since the call of TM1637_init().

◆ TM1637_set_brightness()

void TM1637_set_brightness ( int  val)

Set the display brightness.

Display brightness is not immediately updated, but next time something is displayed it will have the new brightness.

Parameters
valcan be a value from 0 to 7. The default brightness is 0.

◆ TM1637_set_colon()

void TM1637_set_colon ( bool  on)

Turn the colon led on or off.

Default is on.

The colon is not immediately updated, but will be next time something is displayed (with a colon supporting function).

◆ TM1637_wait()

void TM1637_wait ( )

Wait for the TM1637 display.

When calling a function such as TM1637_display() the result is actually not immediately sent to the display. This is because the PIO hardware on the pico is running slower than the CPU. Usually this is fine, it's fast enough to appear instant, but sometimes you want to wait for it to finish. For example if you will enter sleep mode and want the display to update beforehand.