c7segrgb 2.0.0.0
c7segrgb.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 C7SEGRGB_H
36#define C7SEGRGB_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 C7SEGRGB_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
74#define C7SEGRGB_OK 0
75#define C7SEGRGB_ERROR -1
82#define C7SEGRGB_ONE 0x06
83#define C7SEGRGB_TWO 0x5B
84#define C7SEGRGB_THREE 0x4F
85#define C7SEGRGB_FOUR 0x66
86#define C7SEGRGB_FIVE 0x6D
87#define C7SEGRGB_SIX 0x7D
88#define C7SEGRGB_SEVEN 0x07
89#define C7SEGRGB_EIGHT 0x7F
90#define C7SEGRGB_NINE 0x6F
91#define C7SEGRGB_ZERO 0x3F
92#define C7SEGRGB_POINT 0x80
98typedef void ( *drv_logic_t ) ( void );
99
100 // End group macro
101// --------------------------------------------------------------- PUBLIC TYPES
110typedef struct
111{
112 uint8_t logic_lvl;
113 uint8_t green;
114 uint8_t red;
115 uint8_t blue;
116
118
122typedef struct
123{
124 // Output pins
125 digital_out_t cs;
126 digital_out_t pwm;
127
128 // Function pointers for logic zero and logic one
131
132 // Segments data array of 8 items for each segment
133 c7segrgb_segment_t segments[ 8 ];
134
135} c7segrgb_t;
136
140typedef struct
141{
142 // Additional gpio pins
143 pin_name_t cs;
144 pin_name_t pwm;
145
146 // Function pointers for logic zero and logic one
149
151
152 // End types group
153// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
154
160#ifdef __cplusplus
161extern "C"{
162#endif
163
173
182
191
200
209
218
245void c7segrgb_set_num ( c7segrgb_t *ctx, uint8_t character, uint8_t green_brightness,
246 uint8_t red_brightness, uint8_t blue_brightness );
247
256
257#ifdef __cplusplus
258}
259#endif
260#endif // _C7SEGRGB_H_
261
262 // End public_function group
264
265// ------------------------------------------------------------------------- END
void(* drv_logic_t)(void)
Function pointer for logic level one and zero.
Definition c7segrgb.h:98
void c7segrgb_cs_high(c7segrgb_t *ctx)
Sets the state high of CS pin function.
void c7segrgb_set_seven_seg(c7segrgb_t *ctx)
Sets all segments data.
void c7segrgb_set_num(c7segrgb_t *ctx, uint8_t character, uint8_t green_brightness, uint8_t red_brightness, uint8_t blue_brightness)
Sets the character and its color function.
err_t c7segrgb_init(c7segrgb_t *ctx, c7segrgb_cfg_t *cfg)
Initialization function.
void c7segrgb_pwm_low(c7segrgb_t *ctx)
Sets the state low of PWM pin function.
void c7segrgb_cfg_setup(c7segrgb_cfg_t *cfg)
Config Object Initialization function.
void c7segrgb_cs_low(c7segrgb_t *ctx)
Sets the state low of CS pin function.
void c7segrgb_pwm_high(c7segrgb_t *ctx)
Sets the state high of PWM pin function.
Click configuration structure definition.
Definition c7segrgb.h:141
drv_logic_t logic_one
Definition c7segrgb.h:148
drv_logic_t logic_zero
Definition c7segrgb.h:147
pin_name_t pwm
Definition c7segrgb.h:144
pin_name_t cs
Definition c7segrgb.h:143
Click segments data.
Definition c7segrgb.h:111
uint8_t blue
Definition c7segrgb.h:115
uint8_t green
Definition c7segrgb.h:113
uint8_t logic_lvl
Definition c7segrgb.h:112
uint8_t red
Definition c7segrgb.h:114
Click ctx object definition.
Definition c7segrgb.h:123
digital_out_t cs
Definition c7segrgb.h:125
digital_out_t pwm
Definition c7segrgb.h:126
drv_logic_t logic_one
Definition c7segrgb.h:130
drv_logic_t logic_zero
Definition c7segrgb.h:129