forked from mph-/mmculib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chaser.h
97 lines (69 loc) · 1.73 KB
/
chaser.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/** @file chaser.h
@author M. P. Hayes, UCECE
@date 15 May 2007
@brief
*/
#ifndef CHASER_H
#define CHASER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
#include "flasher.h"
#include "font.h"
typedef char chaser_font_index_t;
typedef chaser_font_index_t *chaser_sequence_t;
typedef enum {CHASER_MODE_NORMAL,
CHASER_MODE_CYCLE,
CHASER_MODE_INVERT,
CHASER_MODE_CYCLE_INVERT,
CHASER_MODE_NUM} chaser_mode_t;
typedef struct
{
uint8_t flasher_num;
flasher_t *flashers;
chaser_sequence_t seq;
font_t *font;
uint8_t step;
int8_t dir;
chaser_mode_t mode;
flasher_pattern_t *on_pattern;
flasher_pattern_t *off_pattern;
} chaser_private_t;
typedef chaser_private_t chaser_obj_t;
typedef chaser_obj_t *chaser_t;
extern chaser_t
chaser_init (chaser_obj_t *dev, flasher_t *flashers,
uint8_t flasher_num);
extern void
chaser_sequence_set (chaser_t chaser, chaser_sequence_t seq);
extern void
chaser_mode_set (chaser_t chaser, chaser_mode_t mode);
/* Returns non-zero at end of sequence. */
extern int8_t
chaser_update (chaser_t chaser);
static inline void
chaser_patterns_set (chaser_t chaser,
flasher_pattern_t *on_pattern,
flasher_pattern_t *off_pattern)
{
chaser_private_t *dev = chaser;
dev->on_pattern = on_pattern;
dev->off_pattern = off_pattern;
}
static inline chaser_sequence_t
chaser_sequence_get (chaser_t chaser)
{
chaser_private_t *dev = chaser;
return dev->seq;
}
static inline void
chaser_font_set (chaser_t chaser, font_t *font)
{
chaser_private_t *dev = chaser;
dev->font = font;
}
#ifdef __cplusplus
}
#endif
#endif