38 #include <libopencmsis/core_cm3.h> 39 #include <libopencm3/stm32/rcc.h> 40 #include <libopencm3/stm32/gpio.h> 41 #include <libopencm3/stm32/timer.h> 49 #define LED_TM1637_CLK_PORT B 50 #define LED_TM1637_CLK_PIN 6 51 #define LED_TM1637_DIO_PORT B 52 #define LED_TM1637_DIO_PIN 7 58 #define LED_TM1637_TIMER 3 62 enum led_tm1637_brightness_t display_brightness = LED_TM1637_14DIV16; 179 timer_set_mode(
TIM(
LED_TM1637_TIMER), TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
202 bool to_return =
true;
203 if (NULL==data || 0==length) {
219 for (uint8_t i=0; i<length; i++) {
220 uint8_t byte = data[i];
221 for (uint8_t b=0; b<8; b++) {
263 if (0==length && NULL==address_command) {
267 uint8_t data_command[] = { 0x40 };
279 uint8_t data_command[] = { 0x40 };
280 uint8_t address_command[] = { 0xc0, 0x00, 0x00, 0x00, 0x00 };
281 uint8_t display_command[] = { 0x80 };
296 uint8_t data[] = { 0xc0,
ascii_7segments[((number/1000)%10)+
'0'-
' '],
ascii_7segments[((number/100)%10)+
'0'-
' '], ascii_7segments[((number/10)%10)+
'0'-
' '], ascii_7segments[((number/1)%10)+
'0'-
' '] };
308 if (strlen(text)!=4) {
311 for (uint8_t i=0; i<4; i++) {
static const uint8_t ascii_7segments[]
ASCII characters encoded for the 7 segments digit block.
bool led_tm1637_number(uint16_t number)
display number
#define RCC_GPIO(x)
get RCC for GPIO based on GPIO identifier
static void led_tm1637_tick(void)
wait until clock tick (timer overflow) occurred
library to communicate with a Titan Micro TM1637 IC attached to a 7-segment displays (API) ...
static bool led_tm1637_write(const uint8_t *data, uint8_t length)
write data on bus
enum led_tm1637_brightness_t display_brightness
display brightness
global definitions and methods (API)
#define GPIO(x)
get GPIO based on GPIO identifier
#define LED_TM1637_CLK_PIN
pin for CLK signal
#define RCC_TIM(x)
get RCC for timer based on TIM identifier
void led_tm1637_brightness(enum led_tm1637_brightness_t brightness)
set display brightness
#define LED_TM1637_DIO_PORT
port for DIO signal
led_tm1637_brightness_t
display brightness levels
#define LED_TM1637_CLK_PORT
port for CLK signal
void led_tm1637_setup(void)
setup communication with TM1637 IC
bool led_tm1637_off(void)
switch display on
#define LENGTH(x)
get the length of an array
#define LED_TM1637_DIO_PIN
pin for DIO signal
bool led_tm1637_time(uint8_t hours, uint8_t minutes)
display time
#define TIM(x)
get TIM based on TIM identifier
static bool led_tm1637_send_data(uint8_t *address_command, uint8_t length)
write commands on bus to send data
#define LED_TM1637_TIMER
timer to create signal
bool led_tm1637_text(char *text)
display text