SSD1306 OLED display driver  1.4.4
This library is developed to control SSD1306/SSD1331 RGB i2c/spi OLED displays and spi PCD8544 LED display
pcd8544_84x48.c
1 /*
2  MIT License
3 
4  Copyright (c) 2017-2018, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
24 
25 #include "pcd8544_84x48.h"
26 #include "lcd_common.h"
27 #include "pcd8544_commands.h"
28 #include "intf/ssd1306_interface.h"
29 #include "spi/ssd1306_spi.h"
30 #include "hal/io.h"
31 
32 #include <stdlib.h>
33 
34 
35 static const uint8_t PROGMEM s_lcd84x48_initData[] =
36 {
37  PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION, // switch to extented commands
38  PCD8544_SETVOP | 0x12, // Set vop contrast
39  PCD8544_SETTEMP,
40  PCD8544_SETBIAS | 0x04, // Set bias mode
41  PCD8544_FUNCTIONSET, // switch to basic commands
42  PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL
43 };
44 
45 static uint8_t s_column;
46 static uint8_t s_page;
47 static uint8_t s_width;
48 
49 static void pcd8544_setBlock(uint8_t x, uint8_t y, uint8_t w)
50 {
51  s_width = w;
52  s_column = x;
53  s_page = y;
55  if (w == 1) ssd1306_sendByte( 0x22 ); else ssd1306_sendByte( 0x20 );
56  ssd1306_sendByte(0x80 | x);
57  ssd1306_sendByte(0x40 | y);
59 }
60 
61 static void pcd8544_nextPage()
62 {
63  if ( s_width != 1)
64  {
66  pcd8544_setBlock(s_column, s_page+1, s_width);
68  }
69 }
70 
72 {
74  s_displayWidth = 84;
75  s_displayHeight = 48;
77  ssd1306_setRamBlock = pcd8544_setBlock;
78  ssd1306_nextRamPage = pcd8544_nextPage;
80  for( uint8_t i=0; i<sizeof(s_lcd84x48_initData); i++)
81  {
82  ssd1306_sendByte(pgm_read_byte(&s_lcd84x48_initData[i]));
83  }
85 }
86 
87 void pcd8544_84x48_spi_init(int8_t rstPin, int8_t cesPin, int8_t dcPin)
88 {
89  if (rstPin >=0)
90  {
91  pinMode(rstPin, OUTPUT);
92  digitalWrite(rstPin, HIGH);
93  /* Wait at least 30ms after VCC is up for LCD */
94  delay(30);
95  /* Perform reset operation of LCD display */
96  digitalWrite(rstPin, LOW);
97  delay(1);
98  digitalWrite(rstPin, HIGH);
99  }
100  ssd1306_spiInit(cesPin, dcPin);
102 }
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:87
void(* ssd1306_commandStart)()
uint8_t g_lcd_type
Definition: ssd1306.c:38
uint8_t s_displayHeight
Definition: ssd1306.c:36
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:71
void(* ssd1306_sendPixels)(uint8_t data)
void ssd1306_spiInit(int8_t cesPin, int8_t dcPin)
Definition: ssd1306_spi.cpp:37
uint8_t s_displayWidth
Definition: ssd1306.c:37