rgbdriver 2.0.0.0
rgbdriver.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 RGBDRIVER_H
36#define RGBDRIVER_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_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define RGBDRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
75#define RGBDRIVER_RETVAL uint8_t
76
77#define RGBDRIVER_OK 0x00
78#define RGBDRIVER_INIT_ERROR 0xFF
86#define RGBDRIVER_COLOR_RED_HIGH_INTENSITY 0x7F8040
87#define RGBDRIVER_COLOR_ORANGE_HIGH_INTENSITY 0x7F8240
88#define RGBDRIVER_COLOR_YELLOW_HIGH_INTENSITY 0x7F9440
89#define RGBDRIVER_COLOR_GREEN_HIGH_INTENSITY 0x609F40
90#define RGBDRIVER_COLOR_BLUE_HIGH_INTENSITY 0x60805F
91#define RGBDRIVER_COLOR_WHITE_HIGH_INTENSITY 0x7F9F5F
92#define RGBDRIVER_COLOR_PURPLE_HIGH_INTENSITY 0x78805C
93
94#define RGBDRIVER_COLOR_RED_LOW_INTENSITY 0x618040
95#define RGBDRIVER_COLOR_ORANGE_LOW_INTENSITY 0x6A8140
96#define RGBDRIVER_COLOR_YELLOW_LOW_INTENSITY 0x6A8540
97#define RGBDRIVER_COLOR_GREEN_LOW_INTENSITY 0x608140
98#define RGBDRIVER_COLOR_BLUE_LOW_INTENSITY 0x608041
99#define RGBDRIVER_COLOR_WHITE_LOW_INTENSITY 0x618141
100#define RGBDRIVER_COLOR_PURPLE_LOW_INTENSITY 0x658044
101
102#define RGBDRIVER_COLOR_OFF 0x000000
105 // End group macro
106// --------------------------------------------------------------- PUBLIC TYPES
115typedef struct
116{
117 // Modules
118
119 i2c_master_t i2c;
120
121 // ctx variable
122
124
126
130typedef struct
131{
132 // Communication gpio pins
133
134 pin_name_t scl;
135 pin_name_t sda;
136
137 // static variable
138
139 uint32_t i2c_speed;
140 uint8_t i2c_address;
141
143
144 // End types group
145// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
146
152#ifdef __cplusplus
153extern "C"{
154#endif
155
165
175
184
194void rgbdriver_generic_write ( rgbdriver_t *ctx, uint8_t *data_buf, uint8_t len );
195
206void rgbdriver_set_rgb_color ( rgbdriver_t *ctx, uint8_t red, uint8_t green, uint8_t blue );
207
226void rgbdriver_set_color ( rgbdriver_t *ctx, uint32_t color );
227
236
237#ifdef __cplusplus
238}
239#endif
240#endif // _RGBDRIVER_H_
241
242 // End public_function group
244
245// ------------------------------------------------------------------------- END
#define RGBDRIVER_RETVAL
Definition rgbdriver.h:75
void rgbdriver_generic_write(rgbdriver_t *ctx, uint8_t *data_buf, uint8_t len)
Generic write function.
RGBDRIVER_RETVAL rgbdriver_default_cfg(rgbdriver_t *ctx)
Click Default Configuration function.
void rgbdriver_set_rgb_color(rgbdriver_t *ctx, uint8_t red, uint8_t green, uint8_t blue)
Function set RGB color.
void rgbdriver_set_color(rgbdriver_t *ctx, uint32_t color)
Function set color.
RGBDRIVER_RETVAL rgbdriver_init(rgbdriver_t *ctx, rgbdriver_cfg_t *cfg)
Initialization function.
void rgbdriver_cfg_setup(rgbdriver_cfg_t *cfg)
Config Object Initialization function.
void rgbdriver_shut_down(rgbdriver_t *ctx)
Shut down function.
Click configuration structure definition.
Definition rgbdriver.h:131
uint32_t i2c_speed
Definition rgbdriver.h:139
pin_name_t scl
Definition rgbdriver.h:134
pin_name_t sda
Definition rgbdriver.h:135
uint8_t i2c_address
Definition rgbdriver.h:140
Click ctx object definition.
Definition rgbdriver.h:116
i2c_master_t i2c
Definition rgbdriver.h:119
uint8_t slave_address
Definition rgbdriver.h:123