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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define c10X10RGB_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.di_pin = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
53  cfg.do_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
54 
56 #define SELECT_INVERT( pos , x ) ( ( pos == 0 ) ? x : ( 8 - x ) )
57 #define SELECT_ROTATE( pos , x , y ) ( ( pos == 0 ) ? ( 10 * y + x ) : ( 10 * x + y ) )
58 #define SELECT_INV_BYTE_POS( rotate, x ) ( ( ( rotate & 0x11 ) == 0x11 || ( rotate & 0x11 ) == 0x00 ) ? x : ( 9 - x ) )
59 
64 #define c10X10RGB_RETVAL uint8_t
65 
66 #define c10X10RGB_OK 0x00
67 #define c10X10RGB_INIT_ERROR 0xFF
68 
74 #define LOGIC_ONE 0x01
75 #define LOGIC_ZERO 0x00
76 
77 #define NUM_DATA_BITS 23
78 #define NUM_MATRIX_BYTE 100
79 #define NUX_MAX_CHAR 40
80 
81 #define COLOR_DEFAULT 0x00000000
82 #define BG_COLOR_DEFAULT 0x00000000
83 #define ROTATE_DEFAULT 0x00
84 
85 #define C10X10RGB_BYTE_ROTATE_H_UP 0x00
86 #define C10X10RGB_BYTE_ROTATE_H_DOWN 0x01
87 #define C10X10RGB_BYTE_ROTATE_V_RIGHT 0x11
88 #define C10X10RGB_BYTE_ROTATE_V_LEFT 0x10
89 
90 #define C10X10RGB_SCROLL_ROTATE_H 0x00
91 #define C10X10RGB_SCROLL_ROTATE_V 0x11
92 
93 #define C10X10RGB_CTRL_PIN_LOW 0x00
94 #define C10X10RGB_CTRL_PIN_HIGH 0x01
95 
101 #define C10X10RGB_COLOR_WHITE_100 0x002F2F2F
102 #define C10X10RGB_COLOR_WHITE_75 0x00232323
103 #define C10X10RGB_COLOR_WHITE_50 0x00181818
104 #define C10X10RGB_COLOR_WHITE_25 0x000C0C0C
105 
106 #define C10X10RGB_COLOR_RED_100 0x00002F00
107 #define C10X10RGB_COLOR_RED_75 0x00002300
108 #define C10X10RGB_COLOR_RED_50 0x00001800
109 #define C10X10RGB_COLOR_RED_25 0x00000C00
110 
111 #define C10X10RGB_COLOR_GREEN_100 0x002F0000
112 #define C10X10RGB_COLOR_GREEN_75 0x00230000
113 #define C10X10RGB_COLOR_GREEN_50 0x00180000
114 #define C10X10RGB_COLOR_GREEN_25 0x000C0000
115 
116 #define C10X10RGB_COLOR_BLUE_100 0x0000002F
117 #define C10X10RGB_COLOR_BLUE_75 0x00000023
118 #define C10X10RGB_COLOR_BLUE_50 0x00000018
119 #define C10X10RGB_COLOR_BLUE_25 0x0000000C
120 
121 #define C10X10RGB_COLOR_LIGHT_BLUE_100 0x002F002F
122 #define C10X10RGB_COLOR_LIGHT_BLUE_75 0x00230023
123 #define C10X10RGB_COLOR_LIGHT_BLUE_50 0x00180018
124 #define C10X10RGB_COLOR_LIGHT_BLUE_25 0x000C000C
125 
126 #define C10X10RGB_COLOR_YELLOW_100 0x002F2F00
127 #define C10X10RGB_COLOR_YELLOW_75 0x00232300
128 #define C10X10RGB_COLOR_YELLOW_50 0x00181800
129 #define C10X10RGB_COLOR_YELLOW_25 0x000C0C00
130 
131 #define C10X10RGB_COLOR_PURPLE_100 0x00002F2F
132 #define C10X10RGB_COLOR_PURPLE_75 0x00002323
133 #define C10X10RGB_COLOR_PURPLE_50 0x00001818
134 #define C10X10RGB_COLOR_PURPLE_25 0x00000C0C
135 
136 #define C10X10RGB_COLOR_OFF 0x00000000
137  // End group macro
140 // --------------------------------------------------------------- PUBLIC TYPES
146 typedef void ( *drv_logic_t ) ( void );
147 
151 typedef struct
152 {
153  char data_byte;
154  uint32_t color;
155  uint32_t bg_color;
156  uint8_t rotate;
157 
159 
163 typedef struct
164 {
165  uint8_t new_data;
166  uint8_t rotate;
167  uint8_t line_pos;
168  uint32_t color;
169  uint32_t bg_color;
170 
172 
176 typedef struct
177 {
178  c10x10rgb_byte_t buffer[ 400 ];
179  uint8_t len;
180 
182 
186 typedef struct
187 {
188  // Output pins
189 
190  digital_out_t di_pin;
191 
192  // Input pins
193 
194  digital_in_t do_pin;
195 
196  // Function pointers
197 
200 
201 } c10x10rgb_t;
202 
206 typedef struct
207 {
208  // Additional gpio pins
209 
210  pin_name_t di_pin;
211  pin_name_t do_pin;
212 
213  // Function pointers
214 
217 
219  // End types group
221 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
222 
228 #ifdef __cplusplus
229 extern "C"{
230 #endif
231 
240 void c10x10rgb_cfg_setup ( c10x10rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one );
241 
250 
259 void c10x10rgb_write_data ( c10x10rgb_t *ctx, uint32_t w_data );
260 
269 void c10x10rgb_fill_screen ( c10x10rgb_t *ctx, uint32_t screen_color );
270 
282 uint32_t c10x10rgb_make_color ( uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness );
283 
292 void c10x10rgb_display_image ( c10x10rgb_t *ctx, uint32_t *demo_image );
293 
302 void c10x10rgb_display_byte ( c10x10rgb_t *ctx, c10x10rgb_byte_t *data_obj );
303 
315  uint8_t len, uint16_t speed_ms );
316 
326 void c10x10rgb_demo_rainbow ( c10x10rgb_t *ctx, uint8_t brightness, uint16_t speed_ms );
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 #endif // _c10X10RGB_H_
332  // End public_function group
335 
336 // ------------------------------------------------------------------------- END
drv_update_line_t
Update line object definition.
Definition: c10x10rgb.h:163
c10x10rgb_byte_t::bg_color
uint32_t bg_color
Definition: c10x10rgb.h:155
c10x10rgb_cfg_t::do_pin
pin_name_t do_pin
Definition: c10x10rgb.h:211
c10x10rgb_t::di_pin
digital_out_t di_pin
Definition: c10x10rgb.h:190
c10x10rgb_t::do_pin
digital_in_t do_pin
Definition: c10x10rgb.h:194
drv_scroll_buf_t::len
uint8_t len
Definition: c10x10rgb.h:179
c10x10rgb_cfg_t::di_pin
pin_name_t di_pin
Definition: c10x10rgb.h:210
drv_logic_t
void(* drv_logic_t)(void)
Definition: c10x10rgb.h:146
c10x10rgb_fill_screen
void c10x10rgb_fill_screen(c10x10rgb_t *ctx, uint32_t screen_color)
Fill screen function.
c10x10rgb_demo_rainbow
void c10x10rgb_demo_rainbow(c10x10rgb_t *ctx, uint8_t brightness, uint16_t speed_ms)
Demo rainbow function.
c10x10rgb_cfg_t::logic_one
drv_logic_t logic_one
Definition: c10x10rgb.h:216
drv_update_line_t::new_data
uint8_t new_data
Definition: c10x10rgb.h:165
c10X10RGB_RETVAL
#define c10X10RGB_RETVAL
Definition: c10x10rgb.h:64
c10x10rgb_display_byte
void c10x10rgb_display_byte(c10x10rgb_t *ctx, c10x10rgb_byte_t *data_obj)
Display byte function.
c10x10rgb_init
c10X10RGB_RETVAL c10x10rgb_init(c10x10rgb_t *ctx, c10x10rgb_cfg_t *cfg)
Initialization function.
c10x10rgb_cfg_t
Click configuration structure definition.
Definition: c10x10rgb.h:206
c10x10rgb_cfg_setup
void c10x10rgb_cfg_setup(c10x10rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one)
Config Object Initialization function.
drv_update_line_t::line_pos
uint8_t line_pos
Definition: c10x10rgb.h:167
c10x10rgb_byte_t
Byte object definition.
Definition: c10x10rgb.h:151
c10x10rgb_write_data
void c10x10rgb_write_data(c10x10rgb_t *ctx, uint32_t w_data)
Write data function.
c10x10rgb_t::logic_one
drv_logic_t logic_one
Definition: c10x10rgb.h:199
c10x10rgb_t
Click ctx object definition.
Definition: c10x10rgb.h:186
c10x10rgb_byte_t::rotate
uint8_t rotate
Definition: c10x10rgb.h:156
drv_update_line_t::color
uint32_t color
Definition: c10x10rgb.h:168
c10x10rgb_cfg_t::logic_zero
drv_logic_t logic_zero
Definition: c10x10rgb.h:215
drv_update_line_t::bg_color
uint32_t bg_color
Definition: c10x10rgb.h:169
c10x10rgb_display_string
void c10x10rgb_display_string(c10x10rgb_t *ctx, c10x10rgb_byte_t *data_obj, uint8_t len, uint16_t speed_ms)
Display string function.
c10x10rgb_t::logic_zero
drv_logic_t logic_zero
Definition: c10x10rgb.h:198
c10x10rgb_display_image
void c10x10rgb_display_image(c10x10rgb_t *ctx, uint32_t *demo_image)
Display image function.
c10x10rgb_byte_t::data_byte
char data_byte
Definition: c10x10rgb.h:153
c10x10rgb_make_color
uint32_t c10x10rgb_make_color(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness)
Make color function.
drv_update_line_t::rotate
uint8_t rotate
Definition: c10x10rgb.h:166
drv_scroll_buf_t
Scroll buffer object definition.
Definition: c10x10rgb.h:176
c10x10rgb_byte_t::color
uint32_t color
Definition: c10x10rgb.h:154