-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeLEDMatrix.h
330 lines (298 loc) · 7.29 KB
/
MeLEDMatrix.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/**
* \par Copyright (C), 2012-2016, MakeBlock
* \class MeLEDMatrix
* \brief Driver for Me LED Matrix module.
* @file MeLEDMatrix.h
* @author MakeBlock
* @version V1.0.3
* @date 2016/01/29
* @brief Header for MeLEDMatrix.cpp module
*
* \par Copyright
* This software is Copyright (C), 2012-2016, MakeBlock. Use is subject to license \n
* conditions. The main licensing options available are GPL V2 or Commercial: \n
*
* \par Open Source Licensing GPL V2
* This is the appropriate option if you want to share the source code of your \n
* application with everyone you distribute it to, and you also want to give them \n
* the right to share who uses it. If you wish to use this software under Open \n
* Source Licensing, you must contribute all your source code to the open source \n
* community in accordance with the GPL Version 2 when your application is \n
* distributed. See http://www.gnu.org/copyleft/gpl.html
*
* \par Description
* This file is a drive for Me LED Matrix device
*
* \par Method List:
*
* 1. void MeLEDMatrix::clearScreen();
* 2. void MeLEDMatrix::setBrightness(uint8_t Bright);
* 3. void MeLEDMatrix::setColorIndex(bool Color_Number);
* 4. void MeLEDMatrix::drawBitmap(int8_t x, int8_t y, uint8_t Bitmap_Width, uint8_t *Bitmap);
* 5. void MeLEDMatrix::drawStr(int16_t X_position, int8_t Y_position, const char *str);
* 6. void MeLEDMatrix::showClock(uint8_t hour, uint8_t minute, bool point_flag);
* 7. void MeLEDMatrix::showNum(float value,uint8_t digits);
* 8. void MeLEDMatrix::reset(uint8_t port);
*
* \par History:
* <pre>
* `<Author>` `<Time>` `<Version>` `<Descr>`
* forfish 2015/11/09 1.0.0 Add description
* Mark Yan 2016/01/19 1.0.1 Add some new symbol
* Mark Yan 2016/01/27 1.0.2 Add digital printing
* Mark Yan 2016/01/29 1.0.3 Fix issue when show integer number
* </pre>
*
* @example Me_LEDMatrixTest.ino
*/
#ifndef _ME_LED_MATRIX_H_
#define _ME_LED_MATRIX_H_
#include "MePort.h"
#define PointOn 1
#define PointOff 0
#define LED_BUFFER_SIZE 16
#define STRING_DISPLAY_BUFFER_SIZE 20
//Define Data Command Parameters
#define Mode_Address_Auto_Add_1 0x40 //0100 0000 B
#define Mode_Permanent_Address 0x44 //0100 0100 B
//Define Address Command Parameters
#define ADDRESS(addr) (0xC0 | addr)
typedef enum
{
Brightness_0 = 0,
Brightness_1,
Brightness_2,
Brightness_3,
Brightness_4,
Brightness_5,
Brightness_6,
Brightness_7,
Brightness_8
}LED_Matrix_Brightness_TypeDef;
/* Me LED Matrix 8X16 */
/**
* Class: MeLEDMatrix
* \par Description
* Declaration of Class MeLEDMatrix.
*/
class MeLEDMatrix:public MePort
{
public:
/**
* Alternate Constructor which can call your own function to map the LED Matrix to arduino port,
* no pins are used or initialized here.
* \param[in]
* None
*/
MeLEDMatrix();
/**
* Alternate Constructor which can call your own function to map the LED Matrix to arduino port,
* If the hardware serial was selected, we will used the hardware serial.
* \param[in]
* port - RJ25 port from PORT_1 to M2
*/
MeLEDMatrix(uint8_t port);
/**
* Alternate Constructor which can call your own function to map the Buzzer to arduino port,
* you can set any slot for the buzzer device.
* \param[in]
* SCK_Pin - The SCk of LED Matrix.
* \param[in]
* DIN_Pin - Put in parameter.
*/
MeLEDMatrix(uint8_t SCK_Pin, uint8_t DIN_Pin);
/**
* \par Function
* clearScreen
* \par Description
* Clear the screen.
* \param[in]
* None
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void clearScreen();
/**
* \par Function
* setBrightness
* \par Description
* Set the brightness of LED Matrix.
* \param[in]
* Bright - The brightness of LED Matrix.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void setBrightness(uint8_t Bright);
/**
* \par Function
* setColorIndex
* \par Description
* Set the color index for LED Matrix.
* \param[in]
* Color_Number - The number of LED Matrix's color.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void setColorIndex(bool Color_Number);
/**
* \par Function
* drawBitmap
* \par Description
* Draw a bitmap.
* \param[in]
* x - The x coordinate of bitmap.
* \param[in]
* y - The y coordinate of bitmap.
* \param[in]
* Bitmap_Width - The width of bitmap.
* \param[in]
* Bitmap - A pointer to bitmap.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void drawBitmap(int8_t x, int8_t y, uint8_t Bitmap_Width, uint8_t *Bitmap);
/**
* \par Function
* drawStr
* \par Description
* Draw a string.
* \param[in]
* x - The x coordinate for the beginning of string.
* \param[in]
* y - The y coordinate for the beginning of string.
* \param[in]
* str - A pointer to string.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void drawStr(int16_t X_position, int8_t Y_position, const char *str);
/**
* \par Function
* showClock
* \par Description
* Show the clock on LED Matrix.
* \param[in]
* hour - The part of hour in clock.
* \param[in]
* minute - The part of minute in clock.
* \param[in]
* PointOn - Point on or not.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void showClock(uint8_t hour, uint8_t minute, bool = PointOn);
/**
* \par Function
* showNum
* \par Description
* Show the number on LED Matrix.
* \param[in]
* value - The float data need show.
* \param[in]
* digits - Number of digits to display.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void showNum(float value,uint8_t = 3);
/**
* \par Function
* reset
* \par Description
* Reset the port of LED Matrix.
* \param[in]
* port - The port of LED Matrix.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void reset(uint8_t port);
private:
uint8_t u8_SCKPin;
uint8_t u8_DINPin;
bool b_Color_Index;
bool b_Draw_Str_Flag;
uint8_t u8_Display_Buffer[LED_BUFFER_SIZE];
int16_t i16_Str_Display_X_Position;
int8_t i8_Str_Display_Y_Position;
int16_t i16_Number_of_Character_of_Str;
char i8_Str_Display_Buffer[STRING_DISPLAY_BUFFER_SIZE];
/**
* \par Function
* writeByte
* \par Description
* Write byte to LED Matrix.
* \param[in]
* data - The data wrote to LED Matrix.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void writeByte(uint8_t data);
/**
* \par Function
* writeBytesToAddress
* \par Description
* Write byte to LED Matrix's address.
* \param[in]
* Address - The address you want to write in LED Matrix.
* \param[in]
* P_data - The pointer points to data.
* \param[in]
* count_of_data - The length of data.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void writeBytesToAddress(uint8_t Address, const uint8_t *P_data, uint8_t count_of_data);
/**
* \par Function
* showStr
* \par Description
* Show the string in LED Matrix.
* \par Output
* None
* \Return
* None.
* \par Others
* None
*/
void showStr();
};
#endif