CuVoodoo STM32F1 firmware template
Macros | Functions | Variables
led_tm1637.c File Reference

library to communicate with a Titan Micro TM1637 IC attached to a 7-segment displays (code) More...

Go to the source code of this file.

Macros

#define LED_TM1637_CLK_PORT   B
 port for CLK signal
 
#define LED_TM1637_CLK_PIN   6
 pin for CLK signal
 
#define LED_TM1637_DIO_PORT   B
 port for DIO signal
 
#define LED_TM1637_DIO_PIN   7
 pin for DIO signal
 
#define LED_TM1637_TIMER   3
 timer to create signal
 

Functions

void led_tm1637_setup (void)
 setup communication with TM1637 IC
 
static void led_tm1637_tick (void)
 wait until clock tick (timer overflow) occurred
 
static bool led_tm1637_write (const uint8_t *data, uint8_t length)
 write data on bus More...
 
static bool led_tm1637_send_data (uint8_t *address_command, uint8_t length)
 write commands on bus to send data More...
 
bool led_tm1637_off (void)
 switch display on More...
 
void led_tm1637_brightness (enum led_tm1637_brightness_t brightness)
 set display brightness More...
 
bool led_tm1637_number (uint16_t number)
 display number More...
 
bool led_tm1637_time (uint8_t hours, uint8_t minutes)
 display time More...
 
bool led_tm1637_text (char *text)
 display text More...
 

Variables

enum led_tm1637_brightness_t display_brightness = LED_TM1637_14DIV16
 display brightness
 
static const uint8_t ascii_7segments []
 ASCII characters encoded for the 7 segments digit block. More...
 

Detailed Description

library to communicate with a Titan Micro TM1637 IC attached to a 7-segment displays (code)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2017
Note
peripherals used: GPIO GPIO used to communication with TM1637 IC, timer timer used to communication with TM1637 IC
only 4-digit 7-segment displays are considered as this is the most common case
Warning
all calls are blocking
Note
the protocol is very similar to I2C but incompatible for the following reasons: the pin capacitance is too large for open-drain type output with weak pull-up resistors (push-pull needs to be used, preventing to get ACKs since no indication of the ACK timing is provided); the devices doesn't use addresses; the STM32 I2C will switch to receiver mode when the first sent byte (the I2C address) has last bit set to 1 (such as for address commands with B7=1 where B7 is transmitted last), preventing to send further bytes (the data byte after the address)

bit vs segment: 0bpgfedcba +a+ f b p +g+ e c p +d+

Definition in file led_tm1637.c.

Function Documentation

◆ led_tm1637_brightness()

void led_tm1637_brightness ( enum led_tm1637_brightness_t  brightness)

set display brightness

Parameters
[in]brightnessbrightness level to set

Definition at line 289 of file led_tm1637.c.

◆ led_tm1637_number()

bool led_tm1637_number ( uint16_t  number)

display number

Parameters
[in]numbernumber to display (0-9999)
Returns
if transmission succeeded

Definition at line 294 of file led_tm1637.c.

◆ led_tm1637_off()

bool led_tm1637_off ( void  )

switch display on

Returns
if transmission succeeded

Definition at line 276 of file led_tm1637.c.

◆ led_tm1637_send_data()

static bool led_tm1637_send_data ( uint8_t *  address_command,
uint8_t  length 
)
static

write commands on bus to send data

Parameters
[in]address_commanddata data to send (including address as first byte)
[in]lengthlength of data
Returns
if send succeeded

Definition at line 260 of file led_tm1637.c.

◆ led_tm1637_text()

bool led_tm1637_text ( char *  text)

display text

Parameters
[in]texttext to display (4 characters)
Note
use first bit of each character to enable dot
Returns
if transmission succeeded

Definition at line 306 of file led_tm1637.c.

◆ led_tm1637_time()

bool led_tm1637_time ( uint8_t  hours,
uint8_t  minutes 
)

display time

Parameters
[in]hourshours to display (0-99)
[in]minutesminutes to display (0-99)
Note
display separator between hours and minutes
Returns
if transmission succeeded

Definition at line 300 of file led_tm1637.c.

◆ led_tm1637_write()

static bool led_tm1637_write ( const uint8_t *  data,
uint8_t  length 
)
static

write data on bus

Parameters
[in]databytes to write
[in]lengthnumber of bytes to write
Returns
if write succeeded
Note
includes start and stop conditions

Definition at line 200 of file led_tm1637.c.

Variable Documentation

◆ ascii_7segments

const uint8_t ascii_7segments[]
static

ASCII characters encoded for the 7 segments digit block.

Note
starts with space

Definition at line 67 of file led_tm1637.c.