oledc 2.0.0.0
oledc.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 OLEDC_H
36#define OLEDC_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_spi_master.h"
41
42
43// -------------------------------------------------------------- PUBLIC MACROS
54#define OLEDC_MAP_MIKROBUS( cfg, mikrobus ) \
55 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59 cfg.rw = MIKROBUS( mikrobus, MIKROBUS_AN ); \
60 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
61 cfg.dc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
62 cfg.en = MIKROBUS( mikrobus, MIKROBUS_INT );
69#define OLEDC_RETVAL uint8_t
70
71#define OLEDC_OK 0x00
72#define OLEDC_INIT_ERROR 0xFF
79#define OLEDC_FO_HORIZONTAL 0x00
80#define OLEDC_FO_VERTICAL 0x01
81#define OLEDC_FO_VERTICAL_COLUMN 0x02
88#define OLEDC_RMP_INC_HOR 0x00
89#define OLEDC_RMP_INC_VER 0x01
90#define OLEDC_RMP_COLOR_NOR 0x00
91#define OLEDC_RMP_COLOR_REV 0x02
92#define OLEDC_RMP_SEQ_RGB 0x00
93#define OLEDC_RMP_SEQ_BGR 0x04
94#define OLEDC_RMP_SCAN_NOR 0x00
95#define OLEDC_RMP_SCAN_REV 0x10
96#define OLEDC_RMP_SPLIT_DISABLE 0x00
97#define OLEDC_RMP_SPLIT_ENABLE 0x20
98#define OLEDC_COLOR_65K 0x00
99#define OLEDC_COLOR_262K 0x80
100#define OLEDC_IMG_HEAD 0x06
107#define OLEDC_SCREEN_WIDTH 0x60
108#define OLEDC_SCREEN_HEIGHT 0x60
109#define OLEDC_SCREEN_SIZE 0x2400
110#define OLEDC_ROW_OFF 0x00
111#define OLEDC_COL_OFF 0x10
118#define OLEDC_SET_COL_ADDRESS 0x15
119#define OLEDC_SET_ROW_ADDRESS 0x75
120#define OLEDC_WRITE_RAM 0x5C
121#define OLEDC_READ_RAM 0x5D
122#define OLEDC_SET_REMAP 0xA0
123#define OLEDC_SET_START_LINE 0xA1
124#define OLEDC_SET_OFFSET 0xA2
125#define OLEDC_MODE_OFF 0xA4
126#define OLEDC_MODE_ON 0xA5
127#define OLEDC_MODE_NORMAL 0xA6
128#define OLEDC_MODE_INVERSE 0xA7
129#define OLEDC_FUNCTION 0xAB
130#define OLEDC_SLEEP_ON 0xAE
131#define OLEDC_SLEEP_OFF 0xAF
132#define OLEDC_NOP 0xB0
133#define OLEDC_SET_RESET_PRECH 0xB1
134#define OLEDC_ENHANCEMENT 0xB2
135#define OLEDC_CLOCK_DIV 0xB3
136#define OLEDC_VSL 0xB4
137#define OLEDC_GPIO 0xB5
138#define OLEDC_SETSEC_PRECH 0xB6
139#define OLEDC_GREY_SCALE 0xB8
140#define OLEDC_LUT 0xB9
141#define OLEDC_PRECH_VOL 0xBB
142#define OLEDC_VCOMH 0xBE
143#define OLEDC_CONTRAST 0xC1
144#define OLEDC_MASTER_CONTRAST 0xC7
145#define OLEDC_MUX_RATIO 0xCA
146#define OLEDC_COMMAND_LOCK 0xFD
147#define OLEDC_SCROLL_HOR 0x96
148#define OLEDC_START_MOV 0x9E
149#define OLEDC_STOP_MOV 0x9F
150
151
152#define OLEDC_DEFAULT_MUX_RATIO 95
153#define OLEDC_DEFAULT_START_LINE 0x80
154#define OLEDC_DEFAULT_OFFSET 0x20
155
156#define OLEDC_DEFAULT_OLED_LOCK 0x12
157#define OLEDC_DEFAULT_CMD_LOCK 0xB1
158#define OLEDC_DEFAULT_DIVSET 0xF1
159#define OLEDC_DEFAULT_PRECHARGE 0x32
160#define OLEDC_DEFAULT_VCOMH 0x05
161#define OLEDC_DEFAULT_MASTER_CONT 0xCF
162#define OLEDC_DEFAULT_PRECHARGE_2 0x01 // End group macro
168// --------------------------------------------------------------- PUBLIC TYPES
177typedef struct
178{
179 // Output pins
180
181 digital_out_t rw;
182 digital_out_t rst;
183 digital_out_t dc;
184 digital_out_t en;
185 digital_out_t cs;
186
187 // Modules
188
189 spi_master_t spi;
190 pin_name_t chip_select;
191
192 const uint8_t* font_obj;
193 uint16_t font_color;
197 uint16_t font_height;
198 uint16_t x_cord;
199 uint16_t y_cord;
200
201} oledc_t;
202
206typedef struct
207{
208 // Communication gpio pins
209
210 pin_name_t miso;
211 pin_name_t mosi;
212 pin_name_t sck;
213 pin_name_t cs;
214
215 // Additional gpio pins
216
217 pin_name_t rw;
218 pin_name_t rst;
219 pin_name_t dc;
220 pin_name_t en;
221
222 // static variable
223
224 uint32_t spi_speed;
225 uint8_t spi_mode;
226 spi_master_chip_select_polarity_t cs_polarity;
227
229 // End types group
231// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
232
237#ifdef __cplusplus
238extern "C"{
239#endif
240
250
259
268
277void oledc_enable ( oledc_t *ctx, uint8_t state );
278
286void oledc_reset( oledc_t *ctx );
287
298void oledc_more_arg_commands ( oledc_t *ctx, uint8_t command, uint8_t *args, uint16_t args_len );
299
309void oledc_one_arg_commands ( oledc_t *ctx, uint8_t command, uint8_t args );
310
319void oledc_fill_screen ( oledc_t *ctx, uint16_t color );
320
333void oledc_rectangle( oledc_t *ctx, uint8_t col_off, uint8_t row_off, uint8_t col_end, uint8_t row_end, uint16_t color );
334
347void oledc_image( oledc_t *ctx, const uint8_t* img, uint8_t col_off, uint8_t row_off );
348
359void oledc_text( oledc_t *ctx, uint8_t *text, uint16_t x, uint16_t y );
360
372void oledc_set_font( oledc_t *ctx, const uint8_t *font_s, uint16_t color );
373
374#ifdef __cplusplus
375}
376#endif
377#endif // _OLEDC_H_
378 // End public_function group
381
382// ------------------------------------------------------------------------- END
#define OLEDC_RETVAL
Definition: oledc.h:69
void oledc_one_arg_commands(oledc_t *ctx, uint8_t command, uint8_t args)
Command Send with one argument.
void oledc_more_arg_commands(oledc_t *ctx, uint8_t command, uint8_t *args, uint16_t args_len)
Command Send with more argument.
OLEDC_RETVAL oledc_init(oledc_t *ctx, oledc_cfg_t *cfg)
Initialization function.
void oledc_fill_screen(oledc_t *ctx, uint16_t color)
Fill Screen.
void oledc_image(oledc_t *ctx, const uint8_t *img, uint8_t col_off, uint8_t row_off)
Draw BMP Image.
void oledc_reset(oledc_t *ctx)
Click Hardware Reset.
void oledc_default_cfg(oledc_t *ctx)
Click Default Configuration function.
void oledc_text(oledc_t *ctx, uint8_t *text, uint16_t x, uint16_t y)
Draw Text.
void oledc_enable(oledc_t *ctx, uint8_t state)
Click Enable/Disable.
void oledc_set_font(oledc_t *ctx, const uint8_t *font_s, uint16_t color)
Font Setup.
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.
void oledc_cfg_setup(oledc_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition: oledc.h:207
uint8_t spi_mode
Definition: oledc.h:225
spi_master_chip_select_polarity_t cs_polarity
Definition: oledc.h:226
pin_name_t sck
Definition: oledc.h:212
pin_name_t dc
Definition: oledc.h:219
pin_name_t mosi
Definition: oledc.h:211
uint32_t spi_speed
Definition: oledc.h:224
pin_name_t en
Definition: oledc.h:220
pin_name_t miso
Definition: oledc.h:210
pin_name_t rst
Definition: oledc.h:218
pin_name_t rw
Definition: oledc.h:217
pin_name_t cs
Definition: oledc.h:213
Click ctx object definition.
Definition: oledc.h:178
digital_out_t cs
Definition: oledc.h:185
spi_master_t spi
Definition: oledc.h:189
uint16_t font_first_char
Definition: oledc.h:195
uint16_t y_cord
Definition: oledc.h:199
digital_out_t dc
Definition: oledc.h:183
uint16_t font_height
Definition: oledc.h:197
digital_out_t en
Definition: oledc.h:184
digital_out_t rst
Definition: oledc.h:182
digital_out_t rw
Definition: oledc.h:181
const uint8_t * font_obj
Definition: oledc.h:192
uint16_t x_cord
Definition: oledc.h:198
pin_name_t chip_select
Definition: oledc.h:190
uint16_t font_color
Definition: oledc.h:193
uint8_t font_orientation
Definition: oledc.h:194
uint16_t font_last_char
Definition: oledc.h:196