SSD1306 Library  1.0.0
Library for SSD1306 OLed Driver based on libohiboard
ssd1306.h
Go to the documentation of this file.
1 /*
2  * SSD1306 - Library for SSD1306 OLed Driver based on libohiboard
3  * Copyright (C) 2017-2019 Marco Giammarini
4  *
5  * Authors:
6  * Marco Giammarini <m.giammarini@warcomeb.it>
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 
28 #ifndef __WARCOMEB_SSD1306_H
29 #define __WARCOMEB_SSD1306_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
123 #define WARCOMEB_SSD1306_LIBRARY_VERSION_MAJOR (0x1ul)
124 #define WARCOMEB_SSD1306_LIBRARY_VERSION_MINOR (0x0ul)
125 #define WARCOMEB_SSD1306_LIBRARY_VERSION_BUG (0x0ul)
126 #define WARCOMEB_SSD1306_LIBRARY_VERSION ((WARCOMEB_SSD1306_LIBRARY_VERSION_MAJOR << 16)\
127  |(WARCOMEB_SSD1306_LIBRARY_VERSION_MINOR << 8 )\
128  |(WARCOMEB_SSD1306_LIBRARY_VERSION_BUG ))
129 #define WARCOMEB_SSD1306_LIBRARY_TIME 1569878719
130 
131 #include "ssd1306type.h"
132 #include "../GDL/gdl.h"
133 
134 #define SSD1306_MAX_DISPLAY_HEIGHT 64
135 #define SSD1306_MAX_DISPLAY_WIDTH 128
136 #define SSD1306_BUFFER_DIMENSION (SSD1306_MAX_DISPLAY_WIDTH*SSD1306_MAX_DISPLAY_HEIGHT/8)
137 
147 typedef struct _SSD1306_Config_t
148 {
149  uint16_t product;
150 
151  Gpio_Pins rd;
152  Gpio_Pins dc;
153  Gpio_Pins rs;
154  Gpio_Pins cs;
155  Gpio_Pins wr;
156 
157  Gpio_Pins d0;
158  Gpio_Pins d1;
159  Gpio_Pins d2;
160  Gpio_Pins d3;
161  Gpio_Pins d4;
162  Gpio_Pins d5;
163  Gpio_Pins d6;
164  Gpio_Pins d7;
165 
166  Gpio_Pins rstPin;
168 #if defined (LIBOHIBOARD_IIC)
169 
170  Iic_DeviceHandle iicDev;
171  Iic_Config iicConfig;
172 
173 #endif
174 
175 #if defined (LIBOHIBOARD_SPI)
176 
177 
178 #endif
179 
181 
185 typedef struct _SSD1306_Device_t
186 {
187  GDL_Device_t gdl;
190 
192 
193  uint8_t protocolType;
194 
195 #if defined (LIBOHIBOARD_IIC)
196  uint8_t address;
197 #endif
198 
199  uint8_t page;
200  uint8_t column;
201 
204 
206 
214 
225 GDL_Errors_t SSD1306_drawPixel (SSD1306_DeviceHandle_t dev,
226  uint8_t xPos,
227  uint8_t yPos,
228  SSD1306_Color_t color);
229 
243  uint8_t xStart,
244  uint8_t yStart,
245  uint8_t xStop,
246  uint8_t yStop,
247  SSD1306_Color_t color);
248 
261  uint8_t xStart,
262  uint8_t yStart,
263  uint8_t width,
264  SSD1306_Color_t color);
265 
278  uint8_t xStart,
279  uint8_t yStart,
280  uint8_t height,
281  SSD1306_Color_t color);
282 
296  uint16_t xStart,
297  uint16_t yStart,
298  uint16_t width,
299  uint16_t height,
300  uint8_t color,
301  bool isFill);
302 
320 GDL_Errors_t SSD1306_drawChar (SSD1306_DeviceHandle_t dev,
321  uint16_t xPos,
322  uint16_t yPos,
323  uint8_t c,
324  uint8_t color,
325  uint8_t size);
326 
345  uint16_t xPos,
346  uint16_t yPos,
347  const char* text,
348  uint8_t color,
349  uint8_t size);
350 
370  uint16_t xPos,
371  uint16_t yPos,
372  uint16_t width,
373  uint16_t height,
374  const uint8_t* picture);
375 
382 
389 
400 void SSD1306_scroll (SSD1306_DeviceHandle_t dev, bool scroll);
401 
409 
417 
424 
431 
439 void SSD1306_setContrast (SSD1306_DeviceHandle_t dev, uint8_t value);
440 
449 #ifdef __cplusplus
450 }
451 #endif
452 
453 #endif // __WARCOMEB_SSD1306_H
SSD1306_setContrast
void SSD1306_setContrast(SSD1306_DeviceHandle_t dev, uint8_t value)
Definition: ssd1306.c:550
_SSD1306_Config_t::rstPin
Gpio_Pins rstPin
Definition: ssd1306.h:166
SSD1306_init
void SSD1306_init(SSD1306_DeviceHandle_t dev, SSD1306_Config_t *config)
Definition: ssd1306.c:208
_SSD1306_Device_t::config
SSD1306_Config_t config
Definition: ssd1306.h:189
SSD1306_DeviceHandle_t
struct _SSD1306_Device_t * SSD1306_DeviceHandle_t
_SSD1306_Config_t::dc
Gpio_Pins dc
Definition: ssd1306.h:152
_SSD1306_Config_t::product
uint16_t product
Definition: ssd1306.h:149
SSD1306_drawLine
void SSD1306_drawLine(SSD1306_DeviceHandle_t dev, uint8_t xStart, uint8_t yStart, uint8_t xStop, uint8_t yStop, SSD1306_Color_t color)
Definition: ssd1306.c:406
ssd1306type.h
SSD1306_inverseDisplay
void SSD1306_inverseDisplay(SSD1306_DeviceHandle_t dev)
Definition: ssd1306.c:496
_SSD1306_Config_t::d6
Gpio_Pins d6
Definition: ssd1306.h:163
_SSD1306_Device_t
Definition: ssd1306.h:185
_SSD1306_Config_t::wr
Gpio_Pins wr
Definition: ssd1306.h:155
_SSD1306_Device_t::page
uint8_t page
Definition: ssd1306.h:199
_SSD1306_Device_t::column
uint8_t column
Definition: ssd1306.h:200
_SSD1306_Device_t::isChargePump
bool isChargePump
Definition: ssd1306.h:191
_SSD1306_Config_t::rs
Gpio_Pins rs
Definition: ssd1306.h:153
_SSD1306_Config_t::d3
Gpio_Pins d3
Definition: ssd1306.h:160
_SSD1306_Config_t::d7
Gpio_Pins d7
Definition: ssd1306.h:164
_SSD1306_Config_t::d0
Gpio_Pins d0
Definition: ssd1306.h:157
_SSD1306_Config_t::d4
Gpio_Pins d4
Definition: ssd1306.h:161
SSD1306_drawPicture
GDL_Errors_t SSD1306_drawPicture(SSD1306_DeviceHandle_t dev, uint16_t xPos, uint16_t yPos, uint16_t width, uint16_t height, const uint8_t *picture)
Definition: ssd1306.c:486
_SSD1306_Config_t::cs
Gpio_Pins cs
Definition: ssd1306.h:154
_SSD1306_Device_t::gdl
GDL_Device_t gdl
Definition: ssd1306.h:187
SSD1306_Config_t
struct _SSD1306_Config_t SSD1306_Config_t
SSD1306_drawHLine
void SSD1306_drawHLine(SSD1306_DeviceHandle_t dev, uint8_t xStart, uint8_t yStart, uint8_t width, SSD1306_Color_t color)
Definition: ssd1306.c:419
SSD1306_clear
void SSD1306_clear(SSD1306_DeviceHandle_t dev)
Definition: ssd1306.c:532
_SSD1306_Config_t::d2
Gpio_Pins d2
Definition: ssd1306.h:159
_SSD1306_Device_t::protocolType
uint8_t protocolType
Definition: ssd1306.h:193
SSD1306_drawChar
GDL_Errors_t SSD1306_drawChar(SSD1306_DeviceHandle_t dev, uint16_t xPos, uint16_t yPos, uint8_t c, uint8_t color, uint8_t size)
Definition: ssd1306.c:451
SSD1306_BUFFER_DIMENSION
#define SSD1306_BUFFER_DIMENSION
Definition: ssd1306.h:136
SSD1306_drawVLine
void SSD1306_drawVLine(SSD1306_DeviceHandle_t dev, uint8_t xStart, uint8_t yStart, uint8_t height, SSD1306_Color_t color)
Definition: ssd1306.c:428
SSD1306_Device_t
struct _SSD1306_Device_t SSD1306_Device_t
_SSD1306_Config_t
Definition: ssd1306.h:147
SSD1306_off
void SSD1306_off(SSD1306_DeviceHandle_t dev)
Definition: ssd1306.c:545
SSD1306_drawString
GDL_Errors_t SSD1306_drawString(SSD1306_DeviceHandle_t dev, uint16_t xPos, uint16_t yPos, const char *text, uint8_t color, uint8_t size)
Definition: ssd1306.c:468
SSD1306_flush
void SSD1306_flush(SSD1306_DeviceHandle_t dev)
Definition: ssd1306.c:518
SSD1306_drawPixel
GDL_Errors_t SSD1306_drawPixel(SSD1306_DeviceHandle_t dev, uint8_t xPos, uint8_t yPos, SSD1306_Color_t color)
Definition: ssd1306.c:388
SSD1306_drawRectangle
void SSD1306_drawRectangle(SSD1306_DeviceHandle_t dev, uint16_t xStart, uint16_t yStart, uint16_t width, uint16_t height, uint8_t color, bool isFill)
Definition: ssd1306.c:437
_SSD1306_Device_t::buffer
uint8_t buffer[SSD1306_BUFFER_DIMENSION]
Definition: ssd1306.h:203
SSD1306_normalDisplay
void SSD1306_normalDisplay(SSD1306_DeviceHandle_t dev)
Definition: ssd1306.c:501
_SSD1306_Config_t::d1
Gpio_Pins d1
Definition: ssd1306.h:158
_SSD1306_Config_t::d5
Gpio_Pins d5
Definition: ssd1306.h:162
SSD1306_scroll
void SSD1306_scroll(SSD1306_DeviceHandle_t dev, bool scroll)
Definition: ssd1306.c:506
_SSD1306_Config_t::rd
Gpio_Pins rd
Definition: ssd1306.h:151
SSD1306_Color_t
enum _SSD1306_Color_t SSD1306_Color_t
SSD1306_on
void SSD1306_on(SSD1306_DeviceHandle_t dev)
Definition: ssd1306.c:540