SSD1306 OLED display driver  1.3.1
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 
62 /*
63 static void pcd8544_setPos(uint8_t x, uint8_t y)
64 {
65  ssd1306_commandStart();
66  ssd1306_sendByte(0x80 | x);
67  ssd1306_sendByte(0x40 | y);
68  ssd1306_endTransmission();
69 }*/
70 
71 void pcd8544_84x48_spi_init(int8_t rstPin, int8_t cesPin, int8_t dcPin)
72 {
73  if (rstPin >=0)
74  {
75  pinMode(rstPin, OUTPUT);
76  digitalWrite(rstPin, HIGH);
77  /* Wait at least 30ms after VCC is up for LCD */
78  delay(30);
79  /* Perform reset operation of LCD display */
80  digitalWrite(rstPin, LOW);
81  delay(1);
82  digitalWrite(rstPin, HIGH);
83  }
85  ssd1306_spiInit(cesPin, dcPin);
87  s_displayHeight = 48;
88  s_displayWidth = 84;
89  ssd1306_setRamBlock = pcd8544_setBlock;
90  ssd1306_nextRamPage = pcd8544_nextPage;
91  ssd1306_setRamPos = NULL;
92  // pcd8544 setRamBlock works as setRamPos, we do not need additional function
93 // ssd1306_setRamPos = pcd8544_setPos;
94  for( uint8_t i=0; i<sizeof(s_lcd84x48_initData); i++)
95  {
96  ssd1306_sendByte(pgm_read_byte(&s_lcd84x48_initData[i]));
97  }
99 }
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:71
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)
void ssd1306_spiInit(int8_t cesPin, int8_t dcPin)
Definition: ssd1306_spi.cpp:30
uint8_t s_displayWidth
Definition: ssd1306.cpp:31