matrixrgb 2.0.0.0
matrixrgb.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 MATRIXRGB_H
36#define MATRIXRGB_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#include "drv_spi_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
68#define MATRIXRGB_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
74 cfg.slp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
75 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT );
82#define MATRIXRGB_RETVAL uint8_t
83
84#define MATRIXRGB_OK 0x00
85#define MATRIXRGB_INIT_ERROR 0xFF
92#define MATRIXRGB_FONT_HORIZONTAL 0
93#define MATRIXRGB_FONT_VERTICAL 1
94#define MATRIXRGB_FONT_VERTICAL_COLUMN 2
101#define MATRIXRGB_PATTERN_1_MAP_5MM 0x00
102#define MATRIXRGB_PATTERN_1_MAP_6MM 0x01
103#define MATRIXRGB_PATTERN_2H_MAP_5MM 0x02
104#define MATRIXRGB_PATTERN_2H_MAP_6MM 0x03
105#define MATRIXRGB_PATTERN_2V_MAP_5MM 0x04
106#define MATRIXRGB_PATTERN_2V_MAP_6MM 0x05
107#define MATRIXRGB_PATTERN_3H_MAP_5MM 0x06
108#define MATRIXRGB_PATTERN_3H_MAP_6MM 0x07
109#define MATRIXRGB_PATTERN_3V_MAP_5MM 0x08
110#define MATRIXRGB_PATTERN_3V_MAP_6MM 0x09
111#define MATRIXRGB_PATTERN_4H_MAP_5MM 0x0A
112#define MATRIXRGB_PATTERN_4H_MAP_6MM 0x0B
113#define MATRIXRGB_PATTERN_4V_MAP_5MM 0x0C
114#define MATRIXRGB_PATTERN_4V_MAP_6MM 0x0D
115#define MATRIXRGB_PATTERN_4S_MAP_5MM 0x0E
116#define MATRIXRGB_PATTERN_4S_MAP_6MM 0x0F
119 // End group macro
120// --------------------------------------------------------------- PUBLIC TYPES
130typedef struct
131{
132 uint8_t *p_font;
133 uint16_t color;
134 uint8_t orientation;
135 uint16_t first_char;
136 uint16_t last_char;
137 uint16_t height;
138
140
141typedef struct
142{
143 uint16_t pixel_width;
144 uint16_t pixel_height;
145 uint16_t ram_size;
146
148
149typedef struct
150{
151 uint16_t x_cord;
152 uint16_t y_cord;
153
155
156typedef struct
157{
158 // Output pins
159
160 digital_out_t rst;
161 digital_out_t slp;
162 digital_out_t cs;
163
164 // Input pins
165
166 digital_in_t rdy;
167
168 // Modules
169
170 spi_master_t spi;
175 pin_name_t chip_select;
176
178
182typedef struct
183{
184 // Communication gpio pins
185
186 pin_name_t miso;
187 pin_name_t mosi;
188 pin_name_t sck;
189 pin_name_t cs;
190
191 // Additional gpio pins
192
193 pin_name_t rst;
194 pin_name_t slp;
195 pin_name_t rdy;
196
197 // static variable
198
199 uint32_t spi_speed;
200 uint8_t spi_mode;
201 spi_master_chip_select_polarity_t cs_polarity;
203
205
206 // End types group
207// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
208
213#ifdef __cplusplus
214extern "C"{
215#endif
216
226
235
245void matrixrgb_pattern_settings ( matrixrgb_t *ctx, uint8_t pattern_type, uint16_t pattern_delay_us );
246
259(
260 matrixrgb_t *ctx,
261 uint8_t *wr_buf,
262 uint16_t wr_len,
263 uint8_t *rd_buf,
264 uint16_t rd_len
265);
266
275
284uint8_t matrixrgb_device_settings ( matrixrgb_t *ctx, uint8_t pattern_id );
285
293void matrixrgb_set_power ( matrixrgb_t *ctx, uint8_t power_state );
294
305void matrixrgb_set_brightness ( matrixrgb_t *ctx, uint8_t brightness );
306
321uint8_t matrixrgb_write_pixel ( matrixrgb_t *ctx, uint16_t x, uint16_t y, uint16_t color );
322
330void matrixrgb_fill_screen ( matrixrgb_t *ctx, uint16_t color );
331
341void matrixrgb_draw_image ( matrixrgb_t *ctx, const uint8_t *device_img );
342
352
370uint8_t matrixrgb_write_text ( matrixrgb_t *ctx, char *text, uint16_t x, uint16_t y );
371
372
373#ifdef __cplusplus
374}
375#endif
376#endif // _MATRIXRGB_H_
377
378 // End public_function group
380
381// ------------------------------------------------------------------------- END
#define MATRIXRGB_RETVAL
Definition matrixrgb.h:82
void matrixrgb_fill_screen(matrixrgb_t *ctx, uint16_t color)
Fill Screen.
void matrixrgb_device_reset(matrixrgb_t *ctx)
Hard reset of the Matrix RGB click.
void matrixrgb_generic_transfer(matrixrgb_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void matrixrgb_set_brightness(matrixrgb_t *ctx, uint8_t brightness)
Set Brightness.
void matrixrgb_set_font(matrixrgb_t *ctx, matrixrgb_font_t *font_cfg)
Set Font Function.
void matrixrgb_cfg_setup(matrixrgb_cfg_t *cfg)
Config Object Initialization function.
void matrixrgb_draw_image(matrixrgb_t *ctx, const uint8_t *device_img)
Draw Image on Panel.
uint8_t matrixrgb_write_text(matrixrgb_t *ctx, char *text, uint16_t x, uint16_t y)
Writes Text.
void matrixrgb_pattern_settings(matrixrgb_t *ctx, uint8_t pattern_type, uint16_t pattern_delay_us)
Click Pattern settings ( Default Configuration ) function.
uint8_t matrixrgb_write_pixel(matrixrgb_t *ctx, uint16_t x, uint16_t y, uint16_t color)
Write Pixel.
void matrixrgb_set_power(matrixrgb_t *ctx, uint8_t power_state)
Set Power.
uint8_t matrixrgb_device_settings(matrixrgb_t *ctx, uint8_t pattern_id)
Firmware Initialization.
MATRIXRGB_RETVAL matrixrgb_init(matrixrgb_t *ctx, matrixrgb_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition matrixrgb.h:183
uint8_t spi_mode
Definition matrixrgb.h:200
pin_name_t slp
Definition matrixrgb.h:194
spi_master_chip_select_polarity_t cs_polarity
Definition matrixrgb.h:201
pin_name_t sck
Definition matrixrgb.h:188
matrixrgb_font_t dev_font
Definition matrixrgb.h:202
pin_name_t mosi
Definition matrixrgb.h:187
uint32_t spi_speed
Definition matrixrgb.h:199
pin_name_t rdy
Definition matrixrgb.h:195
pin_name_t miso
Definition matrixrgb.h:186
pin_name_t rst
Definition matrixrgb.h:193
pin_name_t cs
Definition matrixrgb.h:189
Definition matrixrgb.h:150
uint16_t y_cord
Definition matrixrgb.h:152
uint16_t x_cord
Definition matrixrgb.h:151
Click ctx object definition.
Definition matrixrgb.h:131
uint16_t first_char
Definition matrixrgb.h:135
uint16_t color
Definition matrixrgb.h:133
uint8_t * p_font
Definition matrixrgb.h:132
uint16_t height
Definition matrixrgb.h:137
uint16_t last_char
Definition matrixrgb.h:136
uint8_t orientation
Definition matrixrgb.h:134
Definition matrixrgb.h:142
uint16_t ram_size
Definition matrixrgb.h:145
uint16_t pixel_width
Definition matrixrgb.h:143
uint16_t pixel_height
Definition matrixrgb.h:144
Definition matrixrgb.h:157
digital_out_t cs
Definition matrixrgb.h:162
uint16_t device_pattern_delay
Definition matrixrgb.h:174
spi_master_t spi
Definition matrixrgb.h:170
matrixrgb_font_t device_font
Definition matrixrgb.h:171
digital_out_t slp
Definition matrixrgb.h:161
matrixrgb_cord_t device_font_cord
Definition matrixrgb.h:173
digital_out_t rst
Definition matrixrgb.h:160
matrixrgb_pixel_t device_pixel
Definition matrixrgb.h:172
pin_name_t chip_select
Definition matrixrgb.h:175
digital_in_t rdy
Definition matrixrgb.h:166