SSD1306 OLED display driver  1.3.3
This library is developed to control SSD1306 i2c/spi OLED display
pcd8544_84x48.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 "pcd8544_84x48.h"
21 #include "lcd_common.h"
22 #include "pcd8544_commands.h"
23 #include "intf/ssd1306_interface.h"
24 #include "spi/ssd1306_spi.h"
25 
26 static const uint8_t PROGMEM s_lcd84x48_initData[] =
27 {
28  PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION, // switch to extented commands
29  PCD8544_SETVOP | 0x12, // Set vop contrast
30  PCD8544_SETTEMP,
31  PCD8544_SETBIAS | 0x04, // Set bias mode
32  PCD8544_FUNCTIONSET, // switch to basic commands
33  PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL
34 };
35 
36 static uint8_t s_column;
37 static uint8_t s_page;
38 static uint8_t s_width;
39 
40 static void pcd8544_setBlock(uint8_t x, uint8_t y, uint8_t w)
41 {
42  s_width = w;
43  s_column = x;
44  s_page = y;
46  if (w == 1) ssd1306_sendByte( 0x22 ); else ssd1306_sendByte( 0x20 );
47  ssd1306_sendByte(0x80 | x);
48  ssd1306_sendByte(0x40 | y);
50 }
51 
52 static void pcd8544_nextPage()
53 {
54  if ( s_width != 1)
55  {
57  pcd8544_setBlock(s_column, s_page+1, s_width);
59  }
60 }
61 
63 {
65  s_displayWidth = 84;
66  s_displayHeight = 48;
68  ssd1306_setRamBlock = pcd8544_setBlock;
69  ssd1306_nextRamPage = pcd8544_nextPage;
70  ssd1306_setRamPos = NULL;
71  for( uint8_t i=0; i<sizeof(s_lcd84x48_initData); i++)
72  {
73  ssd1306_sendByte(pgm_read_byte(&s_lcd84x48_initData[i]));
74  }
76 }
77 
78 void pcd8544_84x48_spi_init(int8_t rstPin, int8_t cesPin, int8_t dcPin)
79 {
80  if (rstPin >=0)
81  {
82  pinMode(rstPin, OUTPUT);
83  digitalWrite(rstPin, HIGH);
84  /* Wait at least 30ms after VCC is up for LCD */
85  delay(30);
86  /* Perform reset operation of LCD display */
87  digitalWrite(rstPin, LOW);
88  delay(1);
89  digitalWrite(rstPin, HIGH);
90  }
91  ssd1306_spiInit(cesPin, dcPin);
93 }
void(* ssd1306_sendByte)(uint8_t data)
void(* ssd1306_dataStart)()
void(* ssd1306_endTransmission)()
void(* ssd1306_nextRamPage)()
void pcd8544_84x48_spi_init(int8_t rstPin, int8_t cesPin, int8_t dcPin)
Definition: pcd8544_84x48.c:78
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 pcd8544_84x48_init()
Inits 84x48 LED display (based on PCD8544 controller).
Definition: pcd8544_84x48.c:62
void(* ssd1306_setRamPos)(uint8_t x, uint8_t y)
void ssd1306_spiInit(int8_t cesPin, int8_t dcPin)
Definition: ssd1306_spi.cpp:30
uint8_t s_displayWidth
Definition: ssd1306.cpp:31