summaryrefslogtreecommitdiffstats
path: root/libleds.h
blob: 2af1325e068cc112406b27fa43bbcc51e2a054b2 (plain)
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
#ifndef LIBLEDS_H
#define LIBLEDS_H
#include <stdio.h>

struct led_color {
	unsigned char red;
	unsigned char green;
	unsigned char blue;
};

struct led_obj {
	/*
	 * port to use as output.
	 *
	 * The port must already be configured for output.
	 *
	 * currently this is not used and PORTD is used instead.
	 */
	uint16_t port;

	/*
	 * bitmask specifing with ports to use.
	 *
	 * currently this is not used and 0xFF is used instead.
	 */
	unsigned char pins;

	/*
	 * the width of the object.
	 * 
	 * Might be 0 if the width is unknown. Some function that depend on
	 * knowing the number of elements will not work.
	 */
	unsigned int width;

	/*
	 * the height of the object.
	 *
	 * Might be 0 if the height is unknown. Some function that depend on
	 * knowing the number of elements will not work.
	 *
	 * If the object is not a rectangle this should be set to 1.
	 * width is then the number of leds in the strip / star / ...
	 */
	unsigned int height;
};

void led_write_rgb(uint16_t const port, unsigned char const pins,
		struct led_color color);

void led_write_rgb_all(struct led_obj const obj, struct led_color const color);

void led_latch();

#endif /* !LIBLEDS_H */