-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
tm1637.h
62 lines (50 loc) · 1.92 KB
/
tm1637.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _TM1637_H_
#define _TM1637_H_
/*
* Author: Nima Askari
* WebSite: https://www.github.com/NimaLTD
* Instagram: https://www.instagram.com/github.NimaLTD
* LinkedIn: https://www.linkedin.com/in/NimaLTD
* Youtube: https://www.youtube.com/channel/UCUhY7qY1klJm1d2kulr9ckw
*/
/*
* Version: 1.1.2
*
* History:
*
* (1.1.2): Add Fill segments
* (1.1.1): Add tm1637_show_zero(), show or hide lower zero in tm1637_show_float() function.
* (1.1.0): Add tm1637_write_int() and tm1637_write_float() functions.
* (1.0.0): First release.
*
* */
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include "main.h"
//####################################################################################################################
typedef struct
{
uint8_t lock;
uint8_t brightness;
bool show_zero;
GPIO_TypeDef *gpio_clk;
GPIO_TypeDef *gpio_dat;
uint16_t pin_clk;
uint16_t pin_dat;
}tm1637_t;
//####################################################################################################################
void tm1637_init(tm1637_t *tm1637, GPIO_TypeDef *gpio_clk, uint16_t pin_clk, GPIO_TypeDef *gpio_dat, uint16_t pin_dat);
void tm1637_brightness(tm1637_t *tm1637, uint8_t brightness_0_to_7);
void tm1637_write_segment(tm1637_t *tm1637, const uint8_t *segments, uint8_t length, uint8_t pos);
void tm1637_write_int(tm1637_t *tm1637, int32_t digit, uint8_t pos);
void tm1637_write_float(tm1637_t *tm1637, float digit, uint8_t floating_digit, uint8_t pos);
void tm1637_show_zero(tm1637_t *tm1637, bool enable);
void tm1637_fill(tm1637_t *tm1637, bool enable);
//####################################################################################################################
#ifdef __cplusplus
}
#endif
#endif