oledswitch 2.0.0.0
oledswitch.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 OLEDSWITCH_H
36#define OLEDSWITCH_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#include "drv_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define OLEDSWITCH_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.cd = MIKROBUS( mikrobus, MIKROBUS_PWM )
80#define OLEDSWITCH_RETVAL uint8_t
81
82#define OLEDSWITCH_OK 0x00
83#define OLEDSWITCH_INIT_ERROR 0xFF
90#define OLEDSWITCH_15_CONTRAST_FOR_COLOR_A_1 0x81
91#define OLEDSWITCH_15_CONTRAST_FOR_COLOR_A_2 0x19
92#define OLEDSWITCH_15_CONTRAST_FOR_COLOR_B_1 0x82
93#define OLEDSWITCH_15_CONTRAST_FOR_COLOR_B_2 0x14
94#define OLEDSWITCH_15_CONTRAST_FOR_COLOR_C_1 0x83
95#define OLEDSWITCH_15_CONTRAST_FOR_COLOR_C_2 0x24
96
97#define OLEDSWITCH_30_CONTRAST_FOR_COLOR_A_1 0x81
98#define OLEDSWITCH_30_CONTRAST_FOR_COLOR_A_2 0x15
99#define OLEDSWITCH_30_CONTRAST_FOR_COLOR_B_1 0x82
100#define OLEDSWITCH_30_CONTRAST_FOR_COLOR_B_2 0x1A
101#define OLEDSWITCH_30_CONTRAST_FOR_COLOR_C_1 0x83
102#define OLEDSWITCH_30_CONTRAST_FOR_COLOR_C_2 0x17
103
104#define OLEDSWITCH_MASTER_CURRENT_CONTROL_1 0x87
105#define OLEDSWITCH_MASTER_CURRENT_CONTROL_2 0x0F
106
107#define OLEDSWITCH_REMAP_AND_COLOR_DEPTH_SETTING_1 0xA0
108#define OLEDSWITCH_REMAP_AND_COLOR_DEPTH_SETTING_2 0x70
109
110#define OLEDSWITCH_SET_DISPLAY_START_LINE_1 0xA1
111#define OLEDSWITCH_SET_DISPLAY_START_LINE_2 0x00
112
113#define OLEDSWITCH_SET_DISPLAY_OFFSET_1 0xA2
114#define OLEDSWITCH_SET_DISPLAY_OFFSET_2 0x10
115
116#define OLEDSWITCH_NORMAL_DISPLAY 0xA4
117
118#define OLEDSWITCH_MULTIPLEX_RATIO_1 0xA8
119#define OLEDSWITCH_MULTIPLEX_RATIO_2 0x2F
120
121#define OLEDSWITCH_DIM_MODE_SETTING_FOR_COLOR_A_B_C_1 0xAB
122#define OLEDSWITCH_DIM_MODE_SETTING_FOR_COLOR_A_B_C_2 0x00
123#define OLEDSWITCH_DIM_MODE_SETTING_FOR_COLOR_A_B_C_3 0x12
124#define OLEDSWITCH_DIM_MODE_SETTING_FOR_COLOR_A_B_C_4 0x0C
125#define OLEDSWITCH_DIM_MODE_SETTING_FOR_COLOR_A_B_C_5 0x14
126#define OLEDSWITCH_DIM_MODE_SETTING_FOR_COLOR_A_B_C_6 0x12
127
128#define OLEDSWITCH_MASTER_CONFIGURATION_1 0xAD
129#define OLEDSWITCH_MASTER_CONFIGURATION_2 0x8E
130
131#define OLEDSWITCH_POWER_SAVE_MODE_1 0xB0
132#define OLEDSWITCH_POWER_SAVE_MODE_2 0x0B
133
134#define OLEDSWITCH_PHASE_1_AND_2_PERIOD_ADJUSTMENT_1 0xB1
135#define OLEDSWITCH_PHASE_1_AND_2_PERIOD_ADJUSTMENT_2 0x44
136
137#define OLEDSWITCH_DISPLAY_CLOCK_DIVIDER_OSCILLATOR_FREQUENCY_1 0xB3
138#define OLEDSWITCH_DISPLAY_CLOCK_DIVIDER_OSCILLATOR_FREQUENCY_2 0xA0
139
140#define OLEDSWITCH_ENABLE_LINEAR_GRAY_SCALE 0xB9
141
142#define OLEDSWITCH_PRE_CHARGE_LEVEL_1 0xBB
143#define OLEDSWITCH_PRE_CHARGE_LEVEL_2 0x12
144
145#define OLEDSWITCH_15_SET_VCOMH_1 0xBE
146#define OLEDSWITCH_15_SET_VCOMH_2 0x28
147
148#define OLEDSWITCH_30_SET_VCOMH_1 0xBE
149#define OLEDSWITCH_30_SET_VCOMH_2 0x3E
150
151#define OLEDSWITCH_DISPLAY_ON_IN_NORMAL_MODE 0xAF
158#define OLEDSWITCH_BUFFER_SIZE_BIG 0x00
159#define OLEDSWITCH_BUFFER_SIZE_SMALL 0x01
160
161#define OLEDSWITCH_FILL_ENABLE_DISABLE 0x26
162
163#define OLEDSWITCH_ROW_RANGE 0x75
164
165#define OLEDSWITCH_COLUMN_RANGE 0x15
166
167#define OLEDSWITCH_CLEAR_WINDOW 0x25
168
169#define OLEDSWITCH_DEACTIVATE_SCROLLING 0x2E
170
171#define OLEDSWITCH_ACTIVATE_SCROLLING 0x2F
172
173#define OLEDSWITCH_SCROLLING_SETUP 0x27
174
175#define OLEDSWITCH_IMG_SIZE_NORMAL 6144
176#define OLEDSWITCH_IMG_SIZE_BIG 12288
186 // End group macro
187// --------------------------------------------------------------- PUBLIC TYPES
205
209typedef struct
210{
212 uint8_t column_end;
213 uint8_t row_start;
214 uint8_t row_end;
215
217
221typedef struct
222{
223 uint8_t r;
224 uint8_t g;
225 uint8_t b;
226
228
232typedef struct
233{
234 uint8_t a;
235 uint8_t b;
236 uint8_t c;
237
239
243typedef struct
244{
245 // Output pins
246
247 digital_out_t rst;
248 digital_out_t cd;
249 digital_out_t cs;
250
251 // Modules
252
253 spi_master_t spi;
254 pin_name_t chip_select;
255
260
262
266typedef struct
267{
268 // Communication gpio pins
269
270 pin_name_t miso;
271 pin_name_t mosi;
272 pin_name_t sck;
273 pin_name_t cs;
274
275 // Additional gpio pins
276
277 pin_name_t rst;
278 pin_name_t cd;
279
280 // static variable
281
282 uint32_t spi_speed;
283 spi_master_mode_t spi_mode;
284 spi_master_chip_select_polarity_t cs_polarity;
285
287
288 // End types group
289// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
290
295#ifdef __cplusplus
296extern "C"{
297#endif
298
308
317
325void oledswitch_default_cfg ( oledswitch_t *ctx, uint8_t buffer_size );
326
336void oledswitch_reg_write ( oledswitch_t *ctx, uint8_t *write_buf, uint8_t len );
337
347void oledswitch_draw_image ( oledswitch_t *ctx, const uint8_t *image_buf, uint16_t image_size );
348
357
366
375
384
393
402
411
420
429
438
447
457
466
475
484
493
503void oledswitch_set_row_range ( oledswitch_t *ctx, uint8_t start, uint8_t end );
504
514void oledswitch_set_column_range ( oledswitch_t *ctx, uint8_t start, uint8_t end );
515
525
534
543
552
561
569void oledswitch_digital_write_pwm ( oledswitch_t *ctx, uint8_t signal );
570
578void oledswitch_digital_write_rst ( oledswitch_t *ctx, uint8_t signal );
579
580#ifdef __cplusplus
581}
582#endif
583#endif // _OLEDSWITCH_H_
584
585 // End public_function group
587
588// ------------------------------------------------------------------------- END
#define OLEDSWITCH_RETVAL
Definition oledswitch.h:80
void oledswitch_set_column_range(oledswitch_t *ctx, uint8_t start, uint8_t end)
Set column range function.
void oledswitch_default_cfg(oledswitch_t *ctx, uint8_t buffer_size)
Click Default Configuration function.
void oledswitch_digital_write_pwm(oledswitch_t *ctx, uint8_t signal)
Digital write pwm function.
void oledswitch_set_phase_period_adjustment(oledswitch_t *ctx)
Set phase period adjustment function.
void oledswitch_clear_window(oledswitch_t *ctx)
Clear window function.
void oledswitch_set_normal_display(oledswitch_t *ctx)
Set normal display function.
void oledswitch_digital_write_rst(oledswitch_t *ctx, uint8_t signal)
Digital write reset function.
void oledswitch_set_master_config(oledswitch_t *ctx)
Set master config function.
void oledswitch_set_row_range(oledswitch_t *ctx, uint8_t start, uint8_t end)
Set row range function.
void oledswitch_reg_write(oledswitch_t *ctx, uint8_t *write_buf, uint8_t len)
Register write function.
void oledswitch_set_display_start_line(oledswitch_t *ctx)
Set display start line function.
void oledswitch_display_clock_divider_oscillator_frequency(oledswitch_t *ctx)
Display clock divider oscillator frequency function.
void oledswitch_set_display_offset(oledswitch_t *ctx)
Set display offset function.
void oledswitch_pre_charge_level(oledswitch_t *ctx)
Set pre-charge level function.
void oledswitch_enable_linear_gray_scale(oledswitch_t *ctx)
Enable linear gray scale function.
OLEDSWITCH_RETVAL oledswitch_init(oledswitch_t *ctx, oledswitch_cfg_t *cfg)
Initialization function.
void oledswitch_set_master_current(oledswitch_t *ctx)
Set master current function.
void oledswitch_activate_scrolling(oledswitch_t *ctx)
Activate scrolling function.
void oledswitch_set_remap_color_depth(oledswitch_t *ctx)
Set remap color depth function.
void oledswitch_software_reset(oledswitch_t *ctx)
Software reset function.
void oledswitch_demo_scrolling_setup(oledswitch_t *ctx)
Demo scroling setup function.
void oledswitch_set_contrast(oledswitch_t *ctx)
Set contrast function.
void oledswitch_deactivate_scrolling(oledswitch_t *ctx)
Deactivate scrolling function.
void oledswitch_set_dim_mode(oledswitch_t *ctx)
Set dim mode function.
void oledswitch_set_vcomh(oledswitch_t *ctx)
Set vcomh function.
void oledswitch_set_multiplex_ratio(oledswitch_t *ctx)
Set multiplex ratio function.
void oledswitch_display_normal_mode(oledswitch_t *ctx)
Display normal mode function.
void oledswitch_cfg_setup(oledswitch_cfg_t *cfg)
Config Object Initialization function.
void oledswitch_set_power_save_mode(oledswitch_t *ctx)
Set power save mode function.
void oledswitch_draw_image(oledswitch_t *ctx, const uint8_t *image_buf, uint16_t image_size)
Register write function.
Click configuration structure definition.
Definition oledswitch.h:267
spi_master_chip_select_polarity_t cs_polarity
Definition oledswitch.h:284
pin_name_t sck
Definition oledswitch.h:272
spi_master_mode_t spi_mode
Definition oledswitch.h:283
pin_name_t cd
Definition oledswitch.h:278
pin_name_t mosi
Definition oledswitch.h:271
uint32_t spi_speed
Definition oledswitch.h:282
pin_name_t miso
Definition oledswitch.h:270
pin_name_t rst
Definition oledswitch.h:277
pin_name_t cs
Definition oledswitch.h:273
Color structure.
Definition oledswitch.h:222
uint8_t g
Definition oledswitch.h:224
uint8_t b
Definition oledswitch.h:225
uint8_t r
Definition oledswitch.h:223
Contrast structure.
Definition oledswitch.h:233
uint8_t c
Definition oledswitch.h:236
uint8_t b
Definition oledswitch.h:235
uint8_t a
Definition oledswitch.h:234
Coordinate structure.
Definition oledswitch.h:210
uint8_t column_start
Definition oledswitch.h:211
uint8_t column_end
Definition oledswitch.h:212
uint8_t row_start
Definition oledswitch.h:213
uint8_t row_end
Definition oledswitch.h:214
Scroll structure.
Definition oledswitch.h:197
uint8_t row_horizontal_shift
Definition oledswitch.h:199
uint8_t interval
Definition oledswitch.h:202
uint8_t row_vertical_shift
Definition oledswitch.h:200
uint8_t row_offset
Definition oledswitch.h:201
uint8_t column_horizontal_shift
Definition oledswitch.h:198
Click ctx object definition.
Definition oledswitch.h:244
digital_out_t cs
Definition oledswitch.h:249
spi_master_t spi
Definition oledswitch.h:253
digital_out_t cd
Definition oledswitch.h:248
oledswitch_coordinate_t coordinate
Definition oledswitch.h:256
oledswitch_scroll_t scroll
Definition oledswitch.h:258
oledswitch_contrast_t contrast
Definition oledswitch.h:257
digital_out_t rst
Definition oledswitch.h:247
pin_name_t chip_select
Definition oledswitch.h:254
oledswitch_color_t color
Definition oledswitch.h:259