37 #include <libopencmsis/core_cm3.h> 38 #include <libopencm3/stm32/rcc.h> 39 #include <libopencm3/stm32/gpio.h> 40 #include <libopencm3/stm32/timer.h> 48 #define LED_TM1637_CLK_PORT B 49 #define LED_TM1637_CLK_PIN 6 50 #define LED_TM1637_DIO_PORT B 51 #define LED_TM1637_DIO_PIN 7 57 #define LED_TM1637_TIMER 3 61 static enum led_tm1637_brightness_t display_brightness = LED_TM1637_14DIV16; 180 timer_set_mode(
TIM(
LED_TM1637_TIMER), TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
203 bool to_return =
true;
204 if (data==NULL || length==0) {
219 for (
size_t i=0; i<length; i++) {
220 uint8_t byte = data[i];
221 for (uint8_t b=0; b<8; b++) {
259 bool to_return =
false;
290 uint8_t write_data[] = { 0x40 };
301 uint8_t write_data[] = { 0x40 };
312 if (strlen(text)!=4) {
315 for (uint8_t i=0; i<4; i++) {
320 uint8_t write_data[] = { 0x40 };
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 4-digit 7-segment (API) ...
static enum led_tm1637_brightness_t display_brightness
display brightness
global definitions and methods (API)
#define GPIO(x)
get GPIO based on GPIO identifier
bool led_tm1637_brightness(enum led_tm1637_brightness_t brightness)
set display brightness
#define LED_TM1637_CLK_PIN
pin for CLK signal
#define RCC_TIM(x)
get RCC for timer based on TIM identifier
#define LED_TM1637_DIO_PORT
port for DIO signal
static bool display_on
if display is on
led_tm1637_brightness_t
display brightness levels
#define LED_TM1637_CLK_PORT
port for CLK signal
static bool led_tm1637_write(const uint8_t *data, size_t length)
write data on bus
void led_tm1637_setup(void)
setup communication with TM1637 IC
bool led_tm1637_off(void)
switch display off
#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
bool led_tm1637_on(void)
switch display on
#define TIM(x)
get TIM based on TIM identifier
#define LED_TM1637_TIMER
timer to create signal
bool led_tm1637_text(char *text)
display text