SSD1306 OLED display driver  1.3.1
This library is developed to control SSD1306 i2c/spi OLED display
ssd1306_128x32.c
1 /*
2  Copyright (C) 2017 Alexey Dynda
3 
4  This file is part of SSD1306 library.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "ssd1306_128x32.h"
21 #include "lcd_common.h"
22 #include "ssd1306_commands.h"
23 #include "intf/ssd1306_interface.h"
24 #include "i2c/ssd1306_i2c.h"
25 
26 static const uint8_t PROGMEM s_oled128x32_initData[] =
27 {
28  SSD1306_DISPLAYOFF, // display off
29  SSD1306_SETDISPLAYCLOCKDIV, 0x80,
30  SSD1306_SETMULTIPLEX, 31,
31  SSD1306_SETDISPLAYOFFSET, 0x00, // --no offset
32  SSD1306_SETSTARTLINE,
33  SSD1306_CHARGEPUMP, 0x14, // 0x10
34  SSD1306_SEGREMAP | 0x01, // Reverse mapping
35  SSD1306_COMSCANDEC,
36  SSD1306_SETCOMPINS, 0x02,
37  SSD1306_SETCONTRAST, 0x7F, // contast value
38  SSD1306_SETPRECHARGE, 0x22, // 0x1F
39  SSD1306_SETVCOMDETECT, 0x40,
40  SSD1306_MEMORYMODE, HORIZONTAL_ADDRESSING_MODE,
41  SSD1306_DISPLAYALLON_RESUME,
42  SSD1306_NORMALDISPLAY,
43  SSD1306_DISPLAYON
44 };
45 
46 static void ssd1306_setBlock(uint8_t x, uint8_t y, uint8_t w)
47 {
49  ssd1306_sendByte(SSD1306_COLUMNADDR);
51  ssd1306_sendByte(x + w - 1);
52  ssd1306_sendByte(SSD1306_PAGEADDR);
56 }
57 
58 static void ssd1306_nextPage()
59 {
60 }
61 
62 
63 /*
64 // We do not need this function, since ssd1306 library works in Horizontal Addressing mode
65 static void ssd1306_setPos(uint8_t x, uint8_t y)
66 {
67  ssd1306_setBlock(0,0,s_displayWidth);
68  ssd1306_commandStart();
69  ssd1306_sendByte(SSD1306_SETPAGE | y);
70  ssd1306_sendByte((x>>4) | SSD1306_SETHIGHCOLUMN);
71  ssd1306_sendByte((x & 0x0f) | SSD1306_SETLOWCOLUMN);
72  ssd1306_endTransmission();
73 }
74 */
75 
77 {
79  s_displayHeight = 32;
80  s_displayWidth = 128;
81  ssd1306_setRamBlock = ssd1306_setBlock;
82  ssd1306_nextRamPage = ssd1306_nextPage;
83  // ssd1306 library doesn't use setRamPos intended for Page Addressing mode
84  ssd1306_setRamPos = NULL; //ssd1306_setPos;
85  for( uint8_t i=0; i < sizeof(s_oled128x32_initData); i++)
86  {
87  ssd1306_sendCommand(pgm_read_byte(&s_oled128x32_initData[i]));
88  }
89 }
90 
91 
93 {
96 }
void(* ssd1306_sendByte)(uint8_t data)
void ssd1306_128x32_init()
Inits 128x32 OLED display (based on ssd1306 controller).
void(* ssd1306_endTransmission)()
void ssd1306_128x32_i2c_init()
Inits 128x32 OLED display over i2c (based on SSD1306 controller).
uint8_t ssd1306_displayHeight()
Definition: ssd1306.cpp:36
void(* ssd1306_nextRamPage)()
void ssd1306_sendCommand(uint8_t command)
void ssd1306_i2cInit()
void(* ssd1306_commandStart)()
uint8_t g_lcd_type
Definition: ssd1306.cpp:32
uint8_t s_displayHeight
Definition: ssd1306.cpp:30
void(* ssd1306_setRamBlock)(uint8_t x, uint8_t y, uint8_t w)
void(* ssd1306_setRamPos)(uint8_t x, uint8_t y)
uint8_t s_displayWidth
Definition: ssd1306.cpp:31