-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
max7219.h
74 lines (62 loc) · 1.82 KB
/
max7219.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
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Copyright (c) 2017, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com>
*
* This is tinyAVR (ATtiny13, ATtiny25, ATtiny45, ATtiny85) library for 7-segment LED tube modules based on MAX7219/MAX7221 chip.
*
* Features:
* - display digits
* - display dots
* - clear display
* - brightness control
*
* References:
* - library: https://github.com/lpodkalicki/attiny-max7219-led-tube-display-library
* - documentation: https://github.com/lpodkalicki/attiny-max7219-led-tube-display-library/blob/master/README.md
* - MAX7219/MAX7221 datasheet: https://github.com/lpodkalicki/attiny-max7219-led-tube-display-library/blob/master/docs/max7219.pdf
*/
#ifndef _ATTINY_MAX7219_H_
#define _ATTINY_MAX7219_H_
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#ifndef MAX7219_DIN_PIN
# define MAX7219_DIN_PIN PB0
#endif /* !MAX7219_DIN_PIN */
#ifndef MAX7219_CLK_PIN
# define MAX7219_CLK_PIN PB1
#endif /* !MAX7219_CLK_PIN */
#ifndef MAX7219_CS_PIN
# define MAX7219_CS_PIN PB2
#endif /* !MAX7219_CS_PIN */
/**
* Initialize display driver.
* Clock pin, data pin and chip select pin
* are defined at the top of this file.
*/
void MAX7219_init(void);
/**
* Display single digit at position.
* @param position: digit position from range <0, 7>
* @param digit: value from range <0, 9>
*/
void MAX7219_display_digit(uint8_t position, uint8_t digit);
/**
* Light up 'dot' at position.
* @param position: dot position from range <0, 7>
*/
void MAX7219_display_dot(uint8_t position);
/**
* Turn off 'dot' at position.
* @param position: dot position from range <0, 7>
*/
void MAX7219_clear_dot(uint8_t position);
/**
* Set brightness of the display.
* @param value: intensity from range <0, 15>
*/
void MAX7219_set_intensity(uint8_t value);
/**
* Clear display.
*/
void MAX7219_clear(void);
#endif /* !_ATTINY_MAX7219_H_ */