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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define C7SEGRGB_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
53  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
54 
60 #define C7SEGRGB_RETVAL uint8_t
61 
62 #define C7SEGRGB_OK 0x00
63 #define C7SEGRGB_INIT_ERROR 0xFF
64 
70 #define C7SEGRGB_ONE 0x06
71 #define C7SEGRGB_TWO 0x5B
72 #define C7SEGRGB_THREE 0x4F
73 #define C7SEGRGB_FOUR 0x66
74 #define C7SEGRGB_FIVE 0x6D
75 #define C7SEGRGB_SIX 0x7D
76 #define C7SEGRGB_SEVEN 0x07
77 #define C7SEGRGB_EIGHT 0x7F
78 #define C7SEGRGB_NINE 0x6F
79 #define C7SEGRGB_ZERO 0x3F
80 #define C7SEGRGB_POINT 0x80
81 
86 typedef void ( *drv_logic_t ) ( void );
87 
88 
89  // End group macro
91 // --------------------------------------------------------------- PUBLIC TYPES
100 typedef struct
101 {
102  bool logic_lvl;
103  uint8_t green;
104  uint8_t red;
105  uint8_t blue;
106 
108 
112 typedef struct
113 {
114  // Output pins
115  digital_out_t cs;
116  digital_out_t pwm;
117 
118  // Function pointers for logic zero and logic one
121 
122  //Pointer to segments data that is array of 8 items for each segment and point on click board
124 
125 } c7segrgb_t;
126 
130 typedef struct
131 {
132  // Additional gpio pins
133  pin_name_t cs;
134  pin_name_t pwm;
135 
136  // Function pointers for logic zero and logic one
139 
141  // End types group
143 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
144 
150 #ifdef __cplusplus
151 extern "C"{
152 #endif
153 
162 void c7segrgb_cfg_setup ( c7segrgb_cfg_t *cfg );
163 
172 
180 void c7segrgb_cs_low ( c7segrgb_t *ctx );
181 
189 void c7segrgb_cs_high ( c7segrgb_t *ctx );
190 
198 void c7segrgb_pwm_low ( c7segrgb_t *ctx );
199 
207 void c7segrgb_pwm_high( c7segrgb_t *ctx );
208 
235 void c7segrgb_set_num ( c7segrgb_t *ctx, uint8_t character, uint8_t green_brightness, uint8_t red_brightness, uint8_t blue_brightness );
236 
244 void c7segrgb_set_seven_seg ( c7segrgb_t *ctx );
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 #endif // _C7SEGRGB_H_
250  // End public_function group
253 
254 // ------------------------------------------------------------------------- END
c7segrgb_cfg_t::pwm
pin_name_t pwm
Definition: c7segrgb.h:134
c7segrgb_t::logic_one
drv_logic_t logic_one
Definition: c7segrgb.h:120
c7segrgb_t::logic_zero
drv_logic_t logic_zero
Definition: c7segrgb.h:119
c7segrgb_cfg_t::logic_one
drv_logic_t logic_one
Definition: c7segrgb.h:138
c7segrgb_cs_low
void c7segrgb_cs_low(c7segrgb_t *ctx)
Sets the state low of CS pin function.
c7segrgb_t::segments
c7segrgb_segment_t * segments
Definition: c7segrgb.h:123
c7segrgb_set_num
void c7segrgb_set_num(c7segrgb_t *ctx, uint8_t character, uint8_t green_brightness, uint8_t red_brightness, uint8_t blue_brightness)
Sets the state high of PWM pin function.
c7segrgb_cfg_t
Click configuration structure definition.
Definition: c7segrgb.h:130
c7segrgb_cfg_t::logic_zero
drv_logic_t logic_zero
Definition: c7segrgb.h:137
c7segrgb_segment_t::logic_lvl
bool logic_lvl
Definition: c7segrgb.h:102
c7segrgb_cfg_t::cs
pin_name_t cs
Definition: c7segrgb.h:133
c7segrgb_segment_t::blue
uint8_t blue
Definition: c7segrgb.h:105
c7segrgb_set_seven_seg
void c7segrgb_set_seven_seg(c7segrgb_t *ctx)
Sets all segments data.
C7SEGRGB_RETVAL
#define C7SEGRGB_RETVAL
Definition: c7segrgb.h:60
c7segrgb_segment_t::red
uint8_t red
Definition: c7segrgb.h:104
c7segrgb_t::pwm
digital_out_t pwm
Definition: c7segrgb.h:116
c7segrgb_segment_t
Click segments data.
Definition: c7segrgb.h:100
c7segrgb_cs_high
void c7segrgb_cs_high(c7segrgb_t *ctx)
Sets the state high of CS pin function.
c7segrgb_init
C7SEGRGB_RETVAL c7segrgb_init(c7segrgb_t *ctx, c7segrgb_cfg_t *cfg)
Initialization function.
c7segrgb_t::cs
digital_out_t cs
Definition: c7segrgb.h:115
c7segrgb_cfg_setup
void c7segrgb_cfg_setup(c7segrgb_cfg_t *cfg)
Config Object Initialization function.
c7segrgb_pwm_low
void c7segrgb_pwm_low(c7segrgb_t *ctx)
Sets the state low of PWM pin function.
drv_logic_t
void(* drv_logic_t)(void)
Function pointer for logic level one and zero.
Definition: c7segrgb.h:86
c7segrgb_segment_t::green
uint8_t green
Definition: c7segrgb.h:103
c7segrgb_t
Click ctx object definition.
Definition: c7segrgb.h:112
c7segrgb_pwm_high
void c7segrgb_pwm_high(c7segrgb_t *ctx)
Sets the state high of PWM pin function.