oledc  2.0.0.0
oledc.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef _OLEDC_H_
36 #define _OLEDC_H_
37 
38 #include "drv_digital_out.h"
39 #include "drv_spi_master.h"
40 
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define OLEDC_FO_HORIZONTAL 0x00
53 #define OLEDC_FO_VERTICAL 0x01
54 #define OLEDC_FO_VERTICAL_COLUMN 0x02
55 
61 #define OLEDC_RMP_INC_HOR 0x00
62 #define OLEDC_RMP_INC_VER 0x01
63 #define OLEDC_RMP_COLOR_NOR 0x00
64 #define OLEDC_RMP_COLOR_REV 0x02
65 #define OLEDC_RMP_SEQ_RGB 0x00
66 #define OLEDC_RMP_SEQ_BGR 0x04
67 #define OLEDC_RMP_SCAN_NOR 0x00
68 #define OLEDC_RMP_SCAN_REV 0x10
69 #define OLEDC_RMP_SPLIT_DISABLE 0x00
70 #define OLEDC_RMP_SPLIT_ENABLE 0x20
71 #define OLEDC_COLOR_65K 0x00
72 #define OLEDC_COLOR_262K 0x80
73 #define OLEDC_IMG_HEAD 0x06
74 
80 #define OLEDC_SCREEN_WIDTH 0x60
81 #define OLEDC_SCREEN_HEIGHT 0x60
82 #define OLEDC_SCREEN_SIZE 0x2400
83 #define OLEDC_ROW_OFF 0x00
84 #define OLEDC_COL_OFF 0x10
85 
91 #define OLEDC_SET_COL_ADDRESS 0x15
92 #define OLEDC_SET_ROW_ADDRESS 0x75
93 #define OLEDC_WRITE_RAM 0x5C
94 #define OLEDC_READ_RAM 0x5D
95 #define OLEDC_SET_REMAP 0xA0
96 #define OLEDC_SET_START_LINE 0xA1
97 #define OLEDC_SET_OFFSET 0xA2
98 #define OLEDC_MODE_OFF 0xA4
99 #define OLEDC_MODE_ON 0xA5
100 #define OLEDC_MODE_NORMAL 0xA6
101 #define OLEDC_MODE_INVERSE 0xA7
102 #define OLEDC_FUNCTION 0xAB
103 #define OLEDC_SLEEP_ON 0xAE
104 #define OLEDC_SLEEP_OFF 0xAF
105 #define OLEDC_NOP 0xB0
106 #define OLEDC_SET_RESET_PRECH 0xB1
107 #define OLEDC_ENHANCEMENT 0xB2
108 #define OLEDC_CLOCK_DIV 0xB3
109 #define OLEDC_VSL 0xB4
110 #define OLEDC_GPIO 0xB5
111 #define OLEDC_SETSEC_PRECH 0xB6
112 #define OLEDC_GREY_SCALE 0xB8
113 #define OLEDC_LUT 0xB9
114 #define OLEDC_PRECH_VOL 0xBB
115 #define OLEDC_VCOMH 0xBE
116 #define OLEDC_CONTRAST 0xC1
117 #define OLEDC_MASTER_CONTRAST 0xC7
118 #define OLEDC_MUX_RATIO 0xCA
119 #define OLEDC_COMMAND_LOCK 0xFD
120 #define OLEDC_SCROLL_HOR 0x96
121 #define OLEDC_START_MOV 0x9E
122 #define OLEDC_STOP_MOV 0x9F
123 
129 #define OLEDC_MAP_MIKROBUS( cfg, mikrobus ) \
130  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
131  cfg.dc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
132  cfg.en = MIKROBUS( mikrobus, MIKROBUS_INT ); \
133  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
134  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
135  cfg.sdo = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
136  cfg.sdi = MIKROBUS( mikrobus, MIKROBUS_MOSI )
137  // End macros group
140 // --------------------------------------------------------------- PUBLIC TYPES
149 typedef struct
150 {
151  // Module.
152  spi_master_t spi;
153 
154  // Control pins.
155  digital_out_t rst;
156  digital_out_t dc;
157  digital_out_t en;
158 
159  // Control variables.
160  const uint8_t * font;
161  uint16_t font_color;
163  uint16_t font_first_char;
164  uint16_t font_last_char;
165  uint16_t font_height;
166  uint16_t x_coord;
167  uint16_t y_coord;
168 
169 } oledc_t;
170 
174 typedef struct
175 {
176  // Used mikrobus pins.
177  pin_name_t rst;
178  pin_name_t dc;
179  pin_name_t en;
180  pin_name_t cs;
181  pin_name_t sck;
182  pin_name_t sdo;
183  pin_name_t sdi;
184 
185 } oledc_cfg_t;
186  // End types group
188 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
194 #ifdef __cplusplus
195 extern "C"{
196 #endif
197 
207 void
209 
222 int8_t
223 oledc_init( oledc_t *ctx, oledc_cfg_t *cfg );
224 
232 void
233 oledc_default_cfg( oledc_t *ctx );
234 
242 void
243 oledc_reset( oledc_t *ctx );
244 
253 void
254 oledc_enable( oledc_t *ctx, uint8_t state );
255 
266 void
267 oledc_command( oledc_t *ctx, uint8_t cmd, uint8_t *args, uint16_t args_len );
268 
277 void
278 oledc_fill_screen( oledc_t *ctx, uint16_t color );
279 
292 void
293 oledc_rectangle( oledc_t *ctx, uint8_t col_off, uint8_t row_off,
294  uint8_t col_end, uint8_t row_end, uint16_t color );
295 
308 void
309 oledc_image( oledc_t *ctx, const uint8_t *img, uint8_t column_off,
310  uint8_t row_off );
311 
322 void
323 oledc_text( oledc_t *ctx, uint8_t *text, uint16_t col_off, uint16_t row_off );
324 
337 void
338 oledc_set_font( oledc_t *ctx, const uint8_t *font, uint16_t color,
339  uint8_t orientation );
340 
353 void oledc_fill_area( oledc_t *ctx, uint16_t top, uint16_t left,
354  uint16_t bottom, uint16_t right, uint16_t color );
355 
368 void
369 oledc_begin_frame( oledc_t *ctx, uint16_t top, uint16_t left, uint16_t bottom,
370  uint16_t right );
371 
380 void
381 oledc_frame_data( oledc_t *ctx, uint16_t color );
382 
390 void
391 oledc_end_frame( oledc_t *ctx );
392 
393 #ifdef __cplusplus
394 }
395 #endif
396 #endif // _OLEDC_H_
397  // End public_function group
400 
401 // ------------------------------------------------------------------------ END
spi_master_t spi
Definition: oledc.h:152
pin_name_t rst
Definition: oledc.h:177
void oledc_end_frame(oledc_t *ctx)
End Frame.
pin_name_t dc
Definition: oledc.h:178
void oledc_fill_screen(oledc_t *ctx, uint16_t color)
Fill Screen.
uint8_t font_orientation
Definition: oledc.h:162
pin_name_t sdo
Definition: oledc.h:182
void oledc_frame_data(oledc_t *ctx, uint16_t color)
Frame Data.
digital_out_t rst
Definition: oledc.h:155
void oledc_set_font(oledc_t *ctx, const uint8_t *font, uint16_t color, uint8_t orientation)
Font Setup.
digital_out_t dc
Definition: oledc.h:156
digital_out_t en
Definition: oledc.h:157
void oledc_text(oledc_t *ctx, uint8_t *text, uint16_t col_off, uint16_t row_off)
Draw Text.
void oledc_fill_area(oledc_t *ctx, uint16_t top, uint16_t left, uint16_t bottom, uint16_t right, uint16_t color)
Fill Area.
void oledc_cfg_setup(oledc_cfg_t *cfg)
Configuartion Object Setup.
void oledc_image(oledc_t *ctx, const uint8_t *img, uint8_t column_off, uint8_t row_off)
Draw BMP Image.
pin_name_t cs
Definition: oledc.h:180
uint16_t font_height
Definition: oledc.h:165
void oledc_enable(oledc_t *ctx, uint8_t state)
Click Enable/Disable.
uint16_t font_color
Definition: oledc.h:161
pin_name_t sdi
Definition: oledc.h:183
pin_name_t sck
Definition: oledc.h:181
void oledc_begin_frame(oledc_t *ctx, uint16_t top, uint16_t left, uint16_t bottom, uint16_t right)
Begin Frame.
pin_name_t en
Definition: oledc.h:179
uint16_t x_coord
Definition: oledc.h:166
void oledc_default_cfg(oledc_t *ctx)
Click Default Configuration.
uint16_t font_last_char
Definition: oledc.h:164
void oledc_command(oledc_t *ctx, uint8_t cmd, uint8_t *args, uint16_t args_len)
Command Send.
const uint8_t * font
Definition: oledc.h:160
void oledc_reset(oledc_t *ctx)
Click Hardware Reset.
Click context object definition.
Definition: oledc.h:149
void oledc_rectangle(oledc_t *ctx, uint8_t col_off, uint8_t row_off, uint8_t col_end, uint8_t row_end, uint16_t color)
Draw Rectangle.
int8_t oledc_init(oledc_t *ctx, oledc_cfg_t *cfg)
Click Initialization.
Click configuration structure definition.
Definition: oledc.h:174
uint16_t y_coord
Definition: oledc.h:167
uint16_t font_first_char
Definition: oledc.h:163