Subversion Repositories idreammicro-avr

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 jlesech 1
/**************************************************************************//**
2
 * \brief MAX7219 library
3
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
4
 * \version 1.0
5
 * \date 20110908
6
 *
7
 * This file is part of the iDreamMicro library.
8
 *
9
 * This library is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU Lesser General Public License as published by the Free
11
 * Software Foundation, either version 3 of the License, or (at your option) any
12
 * later version.
13
 *
14
 * This library is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with this program. If not, see http://www.gnu.org/licenses/
21
 ******************************************************************************/
22
 
23
/**************************************************************************//**
24
 * \headerfile max7219.h
25
 ******************************************************************************/
26
 
27
#ifndef H__IDREAMMICRO__MAX7219__H
28
#define H__IDREAMMICRO__MAX7219__H
29
 
30
#ifdef _cplusplus
31
extern "C"{
32
#endif
33
 
34
/******************************************************************************
35
 * Header file inclusions.
36
 ******************************************************************************/
37
 
38
#include <stdbool.h>
39
 
40
/******************************************************************************
41
 * Public types.
42
 ******************************************************************************/
43
 
44
/**************************************************************************//**
45
 * \enum max7219__decode_modes
46
 * \typedef max7219__decode_mode_t
47
 ******************************************************************************/
48
typedef enum max7219__decode_modes
49
{
50
    max7219__decode_mode__none          = 0x00,
51
    max7219__decode_mode__digit_0       = 0x01,
52
    max7219__decode_mode__digit_1       = 0x02,
53
    max7219__decode_mode__digit_2       = 0x04,
54
    max7219__decode_mode__digit_3       = 0x08,
55
    max7219__decode_mode__digit_4       = 0x10,
56
    max7219__decode_mode__digit_5       = 0x20,
57
    max7219__decode_mode__digit_6       = 0x40,
58
    max7219__decode_mode__digit_7       = 0x80,
59
    max7219__decode_mode__all_digits    = 0xFF
60
} max7219__decode_mode_t;
61
 
62
/**************************************************************************//**
63
 * \enum max7219__intensities
64
 * \typedef max7219__intensity_t
65
 ******************************************************************************/
66
typedef enum max7219__intensities
67
{
68
    max7219__intensity__level_0     = 0x00,
69
    max7219__intensity__level_1     = 0x01,
70
    max7219__intensity__level_2     = 0x02,
71
    max7219__intensity__level_3     = 0x03,
72
    max7219__intensity__level_4     = 0x04,
73
    max7219__intensity__level_5     = 0x05,
74
    max7219__intensity__level_6     = 0x06,
75
    max7219__intensity__level_7     = 0x07,
76
    max7219__intensity__level_8     = 0x08,
77
    max7219__intensity__level_9     = 0x09,
78
    max7219__intensity__level_10    = 0x0A,
79
    max7219__intensity__level_11    = 0x0B,
80
    max7219__intensity__level_12    = 0x0C,
81
    max7219__intensity__level_13    = 0x0D,
82
    max7219__intensity__level_14    = 0x0E,
83
    max7219__intensity__level_15    = 0x0F
84
} max7219__intensity_t;
85
 
86
/**************************************************************************//**
87
 * \enum max7219__scan_limits
88
 * \typedef max7219__scan_limit_t
89
 ******************************************************************************/
90
typedef enum max7219__scan_limits
91
{  
92
    max7219__scan_limit__digit_0        = 0x00,
93
    max7219__scan_limit__digit_0_to_1   = 0x01,
94
    max7219__scan_limit__digit_0_to_2   = 0x02,
95
    max7219__scan_limit__digit_0_to_3   = 0x03,
96
    max7219__scan_limit__digit_0_to_4   = 0x04,
97
    max7219__scan_limit__digit_0_to_5   = 0x05,
98
    max7219__scan_limit__digit_0_to_6   = 0x06,
99
    max7219__scan_limit__digit_0_to_7   = 0x07
100
} max7219__scan_limit_t;
101
 
102
/**************************************************************************//**
103
 * \enum max7219__shutdown_modes
104
 * \typedef max7219__shutdown_mode_t
105
 ******************************************************************************/
106
typedef enum max7219__shutdown_modes
107
{
108
    max7219__shutdown_mode__shutdown            = 0x00,
109
    max7219__shutdown_mode__normal_operation    = 0x01
110
} max7219__shutdown_mode_t;
111
 
112
/**************************************************************************//**
113
 * \enum max7219__display_test_modes
114
 * \typedef max7219__display_test_mode_t
115
 ******************************************************************************/
116
typedef enum max7219__display_test_modes
117
{
118
    max7219__display_test_mode__normal_operation    = 0x00,
119
    max7219__display_test_mode__test_mode           = 0x01
120
} max7219__display_test_mode_t;
121
 
122
/**************************************************************************//**
123
 * \enum max7219__digits
124
 * \typedef max7219__digit_t
125
 ******************************************************************************/
126
typedef enum max7219__digits
127
{
128
    max7219__digit__0   = 0x01,
129
    max7219__digit__1   = 0x02,
130
    max7219__digit__2   = 0x03,
131
    max7219__digit__3   = 0x04,
132
    max7219__digit__4   = 0x05,
133
    max7219__digit__5   = 0x06,
134
    max7219__digit__6   = 0x07,
135
    max7219__digit__7   = 0x08
136
} max7219__digit_t;
137
 
138
/**************************************************************************//**
139
 * \enum max7219__characters
140
 * \typedef max7219__character_t
141
 ******************************************************************************/
142
typedef enum max7219__characters
143
{
144
    max7219__character__zero    = 0x00,
145
    max7219__character__one     = 0x01,
146
    max7219__character__two     = 0x02,
147
    max7219__character__three   = 0x03,
148
    max7219__character__four    = 0x04,
149
    max7219__character__five    = 0x05,
150
    max7219__character__six     = 0x06,
151
    max7219__character__seven   = 0x07,
152
    max7219__character__eight   = 0x08,
153
    max7219__character__nine    = 0x09,
154
    max7219__character__dash    = 0x0A,
155
    max7219__character__e       = 0x0B,
156
    max7219__character__h       = 0x0C,
157
    max7219__character__l       = 0x0D,
158
    max7219__character__p       = 0x0E,
159
    max7219__character__blank   = 0x0F
160
} max7219__character_t;
161
 
162
/**************************************************************************//**
163
 * \enum max7219__segments
164
 * \typedef max7219__segment_t
165
 ******************************************************************************/
166
typedef enum max7219__segments
167
{
168
    max7219__segment__DP    = 0x80,
169
    max7219__segment__A     = 0x40,
170
    max7219__segment__B     = 0x20,
171
    max7219__segment__C     = 0x10,
172
    max7219__segment__D     = 0x08,
173
    max7219__segment__E     = 0x04,
174
    max7219__segment__F     = 0x02,
175
    max7219__segment__G     = 0x01
176
} max7219__segment_t;
177
 
178
/******************************************************************************
179
 * Public function prototypes.
180
 ******************************************************************************/
181
 
182
/**************************************************************************//**
183
 * \fn void max7219__initialize(void)
184
 *
185
 * \brief Initialize SPI to drive MAX7219.
186
 ******************************************************************************/
187
void
188
max7219__initialize
189
(
190
    void
191
);    
192
 
193
/**************************************************************************//**
194
 * \fn void max7219__set_decode_mode(max7219__decode_mode_t mode)
195
 *
196
 * \brief Set MAX7219 decode mode.
197
 *
198
 * \param       mode    Decode mode to set.
199
 ******************************************************************************/
200
void
201
max7219__set_decode_mode
202
(
203
    max7219__decode_mode_t  mode
204
);
205
 
206
/**************************************************************************//**
207
 * \fn void max7219__set_intensity(max7219__intensity_t intensity)
208
 *
209
 * \brief Set MAX7219 intensity.
210
 *
211
 * \param       itensity        Intensity to set.
212
 ******************************************************************************/
213
void
214
max7219__set_intensity
215
(
216
    max7219__intensity_t    intensity
217
);
218
 
219
/**************************************************************************//**
220
 * \fn void max7219__set_scan_limit(max7219__scan_limit_t limit)
221
 *
222
 * \brief Set MAX7219 scan limit.
223
 *
224
 * \param       limit   Scan limit to set.
225
 ******************************************************************************/
226
void
227
max7219__set_scan_limit
228
(
229
    max7219__scan_limit_t   limit
230
);
231
 
232
/**************************************************************************//**
233
 * \fn void max7219__set_shutdown_mode(max7219__shutdown_mode_t mode)
234
 *
235
 * \brief Set MAX7219 shutdown mode.
236
 *
237
 * \param       mode    Shutdown mode to set.
238
 ******************************************************************************/
239
void
240
max7219__set_shutdown_mode
241
(
242
    max7219__shutdown_mode_t    mode
243
);
244
 
245
/**************************************************************************//**
246
 * \fn void max7219__set_display_test_mode(max7219__display_test_mode_t mode)
247
 *
248
 * \brief Set MAX7219 display test mode.
249
 *
250
 * \param       mode    Display test mode to set.
251
 *****************************************************************************/
252
void
253
max7219__set_display_test_mode
254
(
255
    max7219__display_test_mode_t    mode
256
);
257
 
258
/**************************************************************************//**
259
 * \fn void max7219__write_char_on_digit(
260
 * max7219__digit_t     digit,
261
 * max7219__character_t character,
262
 * bool                 decimal_point)
263
 *
264
 * \brief Write character on digit.
265
 *
266
 * \param       digit               Digit to write.
267
 * \param       character           Character to write.
268
 * \param   decimal_point   Display decimal point.
269
 ******************************************************************************/
270
void
271
max7219__write_char_on_digit
272
(
273
    max7219__digit_t        digit,
274
    max7219__character_t    character,
275
    bool                    decimal_point
276
);
277
 
278
/**************************************************************************//**
279
 * \fn void max7219__write_segments_on_digit(
280
 * max7219__digit_t     digit,
281
 * max7219__segment_t   segments)
282
 *
283
 * \brief Set segment(s) on digit.
284
 *
285
 * \param       digit   Digit to write.
286
 * \param       segment Segment(s) to set.
287
 ******************************************************************************/
288
void
289
max7219__write_segments_on_digit
290
(
291
    max7219__digit_t    digit,
292
    max7219__segment_t  segment
293
);
294
 
295
#ifdef _cplusplus
296
}
297
#endif
298
 
299
#endif /* H__IDREAMMICRO__MAX7219__H */