oledw 2.0.0.0
oledw.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef _OLEDW_H_
29#define _OLEDW_H_
30
35#ifdef PREINIT_SUPPORTED
36#include "preinit.h"
37#endif
38
39#ifdef MikroCCoreVersion
40 #if MikroCCoreVersion >= 1
41 #include "delays.h"
42 #endif
43#endif
44
45#include "drv_digital_out.h"
46#include "drv_i2c_master.h"
47#include "drv_spi_master.h"
48
49// -------------------------------------------------------------- PUBLIC MACROS
59#define OLEDW_LCDWIDTH 96
60#define OLEDW_LCDHEIGHT 39
61#define OLEDW_DISPLAYOFF 0xAE
62#define OLEDW_SETDISPLAYCLOCKDIV 0xD5
63#define OLEDW_SETMULTIPLEX 0xA8
64#define OLEDW_SETDISPLAYOFFSET 0xD3
65#define OLEDW_SETSTARTLINE 0x40
66#define OLEDW_CHARGEPUMP 0x8D
67#define OLEDW_SETSEGMENTREMAP 0xA1
68#define OLEDW_SEGREMAP 0xA0
69#define OLEDW_COMSCANDEC 0xC8
70#define OLEDW_SETCOMPINS 0xDA
71#define OLEDW_SETCONTRAST 0x81
72#define OLEDW_SETPRECHARGE 0xD9
73#define OLEDW_SETVCOMDETECT 0xDB
74#define OLEDW_DISPLAYALLON_RESUME 0xA4
75#define OLEDW_NORMALDISPLAY 0xA6
76#define OLEDW_DISPLAYON 0xAF
77#define OLEDW_DISPLAYALLON 0xA5
78#define OLEDW_INVERTDISPLAY 0xA7
79#define OLEDW_SETLOWCOLUMN 0x00
80#define OLEDW_SETHIGHCOLUMN 0x10
81#define OLEDW_MEMORYMODE 0x20
82#define OLEDW_COLUMNADDR 0x21
83#define OLEDW_PAGEADDR 0x22
84#define OLEDW_COMSCANINC 0xC0
85#define OLEDW_EXTERNALVCC 0x1
86#define OLEDW_SWITCHCAPVCC 0x2
87#define OLEDW_ACTIVATE_SCROLL 0x2F
88#define OLEDW_DEACTIVATE_SCROLL 0x2E
89#define OLEDW_SET_VERTICAL_SCROLL_AREA 0xA3
90#define OLEDW_RIGHT_HORIZONTAL_SCROLL 0x26
91#define OLEDW_LEFT_HORIZONTAL_SCROLL 0x27
92#define OLEDW_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
93#define OLEDW_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
100#define OLEDW_COMMAND 0x3C
101#define OLEDW_DATA 0x3D
108#define OLEDW_MASTER_I2C 0
109#define OLEDW_MASTER_SPI 1
121#define err_t uint8_t
128#define OLEDW_OK 0x00
129#define OLEDW_INIT_ERROR 0xFF
130#define OLEDW_INVALID_DATA_MODE 0xFE
131#define OLEDW_INVALID_DRIVER_SELECTOR 0xFD
134 // End error group
135
140#define OLEDW_MAP_MIKROBUS( cfg, mikrobus ) \
141 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
142 cfg.dc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
143 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
144 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
145 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
146 cfg.sdi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
147 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
148 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
151 // End macros group
152// --------------------------------------------------------------- PUBLIC TYPES
158typedef uint8_t oledw_drv_select_t;
159
160typedef uint8_t oledw_data_t;
161typedef uint8_t oledw_data_mode_t;
162
163typedef const uint8_t oledw_resources_t;
164
169typedef uint8_t oledw_select_t;
170
174typedef struct oledw_s
175{
176 // Click mikrobus DRV objects.
177 digital_out_t cs;
178 digital_out_t rst;
179 digital_out_t dc;
180
181 // Modules
182 spi_master_t spi;
183 i2c_master_t i2c;
184
185 // ctx variable
186
188 pin_name_t chip_select;
189
190 // Click send function pointer.
193
195
199typedef struct
200{
201 // Used mikrobus pins.
202 pin_name_t rst;
203 pin_name_t dc;
204 pin_name_t cs;
205 pin_name_t sck;
206 pin_name_t sdi;
207 pin_name_t scl;
208 pin_name_t sda;
209 pin_name_t miso;
210
211 // static variable
212
213 uint32_t i2c_speed;
214 uint8_t i2c_address;
215 uint32_t spi_speed;
216 spi_master_mode_t spi_mode;
217 spi_master_chip_select_polarity_t cs_polarity;
218
225
227
228 // End types group
229// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
235#ifdef __cplusplus
236extern "C"{
237#endif
238
250
264
278
287
296void oledw_set_page( oledw_t *ctx, oledw_data_t page_addr );
297
306void oledw_set_column( oledw_t *ctx, oledw_data_t col_addr );
307
318
328
338void oledw_scroll_right( oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr );
339
349void oledw_scroll_left( oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr );
350
360void oledw_scroll_diag_right( oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr );
361
371void oledw_scroll_diag_left( oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr );
372
381
382#ifdef __cplusplus
383}
384#endif
385#endif // OLEDW_H
386
387 // oledw
388
389// ------------------------------------------------------------------------ END
#define err_t
Definition oledw.h:121
void oledw_display_picture(oledw_t *ctx, oledw_resources_t *pic)
Display Picture function.
err_t oledw_send(oledw_t *ctx, oledw_data_t tx_data, oledw_data_mode_t data_mode)
Send function.
void oledw_scroll_left(oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr)
Scroll Left function.
void oledw_scroll_diag_right(oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr)
Scroll Diagonally Right function.
void oledw_stop_scroll(oledw_t *ctx)
Stop Scrolling function.
void oledw_default_cfg(oledw_t *ctx)
Click Default Configuration function.
void oledw_set_column(oledw_t *ctx, oledw_data_t col_addr)
Column Setting function.
void oledw_set_contrast(oledw_t *ctx, oledw_data_t value)
Contrast Setting function.
void oledw_set_page(oledw_t *ctx, oledw_data_t page_addr)
Page Setting function.
err_t oledw_init(oledw_t *ctx, oledw_cfg_t *cfg)
Click Initialization function.
void oledw_scroll_right(oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr)
Scroll Right function.
void oledw_cfg_setup(oledw_cfg_t *cfg)
Configuration Object Setup function.
void oledw_scroll_diag_left(oledw_t *ctx, oledw_data_t start_page_addr, oledw_data_t end_page_addr)
Scroll Diagonally Left function.
struct oledw_s oledw_t
Click context object definition.
uint8_t oledw_select_t
Communication type.
Definition oledw.h:169
uint8_t oledw_data_mode_t
Definition oledw.h:161
err_t(* oledw_master_write_t)(struct oledw_s *, oledw_data_t, oledw_data_mode_t)
Definition oledw.h:165
uint8_t oledw_data_t
Definition oledw.h:160
const uint8_t oledw_resources_t
Definition oledw.h:163
uint8_t oledw_drv_select_t
Definition oledw.h:158
Click configuration structure definition.
Definition oledw.h:200
oledw_select_t sel
Definition oledw.h:224
pin_name_t sdi
Definition oledw.h:206
uint32_t i2c_speed
Definition oledw.h:213
spi_master_chip_select_polarity_t cs_polarity
Definition oledw.h:217
pin_name_t sck
Definition oledw.h:205
spi_master_mode_t spi_mode
Definition oledw.h:216
pin_name_t dc
Definition oledw.h:203
uint32_t spi_speed
Definition oledw.h:215
pin_name_t scl
Definition oledw.h:207
pin_name_t miso
Definition oledw.h:209
pin_name_t sda
Definition oledw.h:208
pin_name_t rst
Definition oledw.h:202
pin_name_t cs
Definition oledw.h:204
uint8_t i2c_address
Definition oledw.h:214
Click context object definition.
Definition oledw.h:175
digital_out_t cs
Definition oledw.h:177
spi_master_t spi
Definition oledw.h:182
oledw_master_write_t send
Definition oledw.h:191
digital_out_t dc
Definition oledw.h:179
i2c_master_t i2c
Definition oledw.h:183
digital_out_t rst
Definition oledw.h:178
uint8_t slave_address
Definition oledw.h:187
oledw_select_t master_sel
Definition oledw.h:192
pin_name_t chip_select
Definition oledw.h:188