c10x10rgb 2.0.0.0
c10x10rgb.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef C10X10RGB_H
36#define C10X10RGB_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define C10X10RGB_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.di_pin = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
67 cfg.do_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
70#define SELECT_INVERT( pos , x ) ( ( pos == 0 ) ? x : ( 8 - x ) )
71#define SELECT_ROTATE( pos , x , y ) ( ( pos == 0 ) ? ( 10 * y + x ) : ( 10 * x + y ) )
72#define SELECT_INV_BYTE_POS( rotate, x ) ( ( ( rotate & 0x11 ) == 0x11 || ( rotate & 0x11 ) == 0x00 ) ? x : ( 9 - x ) )
73
78#define C10X10RGB_RETVAL uint8_t
79
80#define C10X10RGB_OK 0x00
81#define C10X10RGB_INIT_ERROR 0xFF
88#define LOGIC_ONE 0x01
89#define LOGIC_ZERO 0x00
90
91#define NUM_DATA_BITS 24
92#define NUM_MATRIX_BYTE 100
93#define NUX_MAX_CHAR 40
94
95#define COLOR_DEFAULT 0x00000000
96#define BG_COLOR_DEFAULT 0x00000000
97#define ROTATE_DEFAULT 0x00
98
99#define C10X10RGB_BYTE_ROTATE_H_UP 0x00
100#define C10X10RGB_BYTE_ROTATE_H_DOWN 0x01
101#define C10X10RGB_BYTE_ROTATE_V_RIGHT 0x11
102#define C10X10RGB_BYTE_ROTATE_V_LEFT 0x10
103
104#define C10X10RGB_SCROLL_ROTATE_H 0x00
105#define C10X10RGB_SCROLL_ROTATE_V 0x11
106
107#define C10X10RGB_CTRL_PIN_LOW 0x00
108#define C10X10RGB_CTRL_PIN_HIGH 0x01
115#define C10X10RGB_COLOR_WHITE_100 0x002F2F2F
116#define C10X10RGB_COLOR_WHITE_75 0x00232323
117#define C10X10RGB_COLOR_WHITE_50 0x00181818
118#define C10X10RGB_COLOR_WHITE_25 0x000C0C0C
119
120#define C10X10RGB_COLOR_RED_100 0x00002F00
121#define C10X10RGB_COLOR_RED_75 0x00002300
122#define C10X10RGB_COLOR_RED_50 0x00001800
123#define C10X10RGB_COLOR_RED_25 0x00000C00
124
125#define C10X10RGB_COLOR_GREEN_100 0x002F0000
126#define C10X10RGB_COLOR_GREEN_75 0x00230000
127#define C10X10RGB_COLOR_GREEN_50 0x00180000
128#define C10X10RGB_COLOR_GREEN_25 0x000C0000
129
130#define C10X10RGB_COLOR_BLUE_100 0x0000002F
131#define C10X10RGB_COLOR_BLUE_75 0x00000023
132#define C10X10RGB_COLOR_BLUE_50 0x00000018
133#define C10X10RGB_COLOR_BLUE_25 0x0000000C
134
135#define C10X10RGB_COLOR_LIGHT_BLUE_100 0x002F002F
136#define C10X10RGB_COLOR_LIGHT_BLUE_75 0x00230023
137#define C10X10RGB_COLOR_LIGHT_BLUE_50 0x00180018
138#define C10X10RGB_COLOR_LIGHT_BLUE_25 0x000C000C
139
140#define C10X10RGB_COLOR_YELLOW_100 0x002F2F00
141#define C10X10RGB_COLOR_YELLOW_75 0x00232300
142#define C10X10RGB_COLOR_YELLOW_50 0x00181800
143#define C10X10RGB_COLOR_YELLOW_25 0x000C0C00
144
145#define C10X10RGB_COLOR_PURPLE_100 0x00002F2F
146#define C10X10RGB_COLOR_PURPLE_75 0x00002323
147#define C10X10RGB_COLOR_PURPLE_50 0x00001818
148#define C10X10RGB_COLOR_PURPLE_25 0x00000C0C
149
150#define C10X10RGB_COLOR_OFF 0x00000000
153 // End group macro
154// --------------------------------------------------------------- PUBLIC TYPES
160typedef void ( *drv_logic_t ) ( void );
161
165typedef struct
166{
168 uint32_t color;
169 uint32_t bg_color;
170 uint8_t rotate;
171
173
177typedef struct
178{
179 uint8_t new_data;
180 uint8_t rotate;
181 uint8_t line_pos;
182 uint32_t color;
183 uint32_t bg_color;
184
186
190typedef struct
191{
192 c10x10rgb_byte_t buffer[ 200 ];
193 uint8_t len;
194
196
200typedef struct
201{
202 // Output pins
203 digital_out_t di_pin;
204
205 // Input pins
206 digital_in_t do_pin;
207
208 // Function pointers
211
212 uint32_t matrix[ NUM_MATRIX_BYTE ];
213
215
219typedef struct
220{
221 // Additional gpio pins
222 pin_name_t di_pin;
223 pin_name_t do_pin;
224
225 // Function pointers
228
230
231 // End types group
232// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
233
239#ifdef __cplusplus
240extern "C"{
241#endif
242
251void c10x10rgb_cfg_setup ( c10x10rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one );
252
261
270void c10x10rgb_write_data ( c10x10rgb_t *ctx, uint32_t w_data );
271
280void c10x10rgb_fill_screen ( c10x10rgb_t *ctx, uint32_t screen_color );
281
293uint32_t c10x10rgb_make_color ( uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness );
294
303void c10x10rgb_display_image ( c10x10rgb_t *ctx, const uint32_t *demo_image );
304
314
326 uint8_t len, uint16_t speed_ms );
327
337void c10x10rgb_demo_rainbow ( c10x10rgb_t *ctx, uint8_t brightness, uint16_t speed_ms );
338
339#ifdef __cplusplus
340}
341#endif
342#endif // _C10X10RGB_H_
343
344 // End public_function group
346
347// ------------------------------------------------------------------------- END
#define NUM_MATRIX_BYTE
Definition c10x10rgb.h:92
#define C10X10RGB_RETVAL
Definition c10x10rgb.h:78
void c10x10rgb_cfg_setup(c10x10rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one)
Config Object Initialization function.
void c10x10rgb_fill_screen(c10x10rgb_t *ctx, uint32_t screen_color)
Fill screen function.
void c10x10rgb_write_data(c10x10rgb_t *ctx, uint32_t w_data)
Write data function.
void c10x10rgb_demo_rainbow(c10x10rgb_t *ctx, uint8_t brightness, uint16_t speed_ms)
Demo rainbow function.
void c10x10rgb_display_byte(c10x10rgb_t *ctx, c10x10rgb_byte_t *data_obj)
Display byte function.
void c10x10rgb_display_image(c10x10rgb_t *ctx, const uint32_t *demo_image)
Display image function.
uint32_t c10x10rgb_make_color(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness)
Make color function.
void c10x10rgb_display_string(c10x10rgb_t *ctx, c10x10rgb_byte_t *data_obj, uint8_t len, uint16_t speed_ms)
Display string function.
C10X10RGB_RETVAL c10x10rgb_init(c10x10rgb_t *ctx, c10x10rgb_cfg_t *cfg)
Initialization function.
void(* drv_logic_t)(void)
Definition c10x10rgb.h:160
Byte object definition.
Definition c10x10rgb.h:166
uint32_t color
Definition c10x10rgb.h:168
uint32_t bg_color
Definition c10x10rgb.h:169
uint8_t rotate
Definition c10x10rgb.h:170
char data_byte
Definition c10x10rgb.h:167
Click configuration structure definition.
Definition c10x10rgb.h:220
pin_name_t do_pin
Definition c10x10rgb.h:223
drv_logic_t logic_one
Definition c10x10rgb.h:227
drv_logic_t logic_zero
Definition c10x10rgb.h:226
pin_name_t di_pin
Definition c10x10rgb.h:222
Click ctx object definition.
Definition c10x10rgb.h:201
digital_in_t do_pin
Definition c10x10rgb.h:206
digital_out_t di_pin
Definition c10x10rgb.h:203
drv_logic_t logic_one
Definition c10x10rgb.h:210
drv_logic_t logic_zero
Definition c10x10rgb.h:209
Scroll buffer object definition.
Definition c10x10rgb.h:191
uint8_t len
Definition c10x10rgb.h:193
Update line object definition.
Definition c10x10rgb.h:178
uint32_t color
Definition c10x10rgb.h:182
uint8_t line_pos
Definition c10x10rgb.h:181
uint32_t bg_color
Definition c10x10rgb.h:183
uint8_t rotate
Definition c10x10rgb.h:180
uint8_t new_data
Definition c10x10rgb.h:179