Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
NOKIA_5110_LCD_RDL.hpp
Go to the documentation of this file.
1
10#pragma once
11
12// libraries
13#include <cstdint>
14#include <cstdbool>
15#include <cstdio>
16#include <lgpio.h>
18
19// Classes
20
25{
26
27public:
28
29 // SW SPI
30 NOKIA_5110_RPI(int16_t lcdwidth, int16_t lcdheight, uint8_t LCD_RST, uint8_t LCD_DC, uint8_t LCD_CE, int8_t LCD_DIN, int8_t LCD_CLK);
31 //HW SPI
32 NOKIA_5110_RPI(int16_t lcdwidth, int16_t lcdheight, uint8_t LCD_RST, uint8_t LCD_DC);
34
35 // SW SPI
36 rdlib::Return_Codes_e LCDBegin(bool Inverse, uint8_t Contrast,uint8_t Bias, int gpioDev);
37 // HW SPI
38 rdlib::Return_Codes_e LCDBegin(bool Inverse, uint8_t Contrast,uint8_t Bias, int device, int channel, int speed, int flags, int gpioDev);
39 void LCDenableSleep(void);
40 void LCDdisableSleep(void);
41 bool LCDIsSleeping(void);
42
44 void LCDPowerDown(void);
45
46 virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override;
47
48 void LCDSetContrast(uint8_t con);
49 void LCDdisplayUpdate(void);
50 void LCDdisplayClear(void);
51 void LCDfillScreen(void);
52 void LCDfillScreenPattern(uint8_t);
53 void LCDinvertDisplay(bool inv);
54
55 uint16_t LCDHighFreqDelayGet(void);
56 void LCDHighFreqDelaySet(uint16_t);
57 bool isHardwareSPI(void);
58
59private:
60
61 void LCDWriteData(uint8_t data);
62 void LCDWriteCommand(uint8_t command);
63 void LCDInit(void);
64
65 // LCD Commands & registers list
66 static constexpr uint8_t LCD_FUNCTIONSET = 0x20;
67 static constexpr uint8_t LCD_POWERDOWN = 0x04;
68 static constexpr uint8_t LCD_ENTRYMODE = 0x02;
69 static constexpr uint8_t LCD_EXTENDEDINSTRUCTION = 0x01;
71 static constexpr uint8_t LCD_DISPLAYCONTROL = 0x08;
72 static constexpr uint8_t LCD_DISPLAYBLANK = 0x00;
73 static constexpr uint8_t LCD_DISPLAYNORMAL = 0x04;
74 static constexpr uint8_t LCD_DISPLAYALLON = 0x01;
75 static constexpr uint8_t LCD_DISPLAYINVERTED = 0x05;
77 static constexpr uint8_t LCD_SETYADDR = 0x40;
78 static constexpr uint8_t LCD_SETXADDR = 0x80;
80 static constexpr uint8_t LCD_SETTEMP = 0x04;
81 static constexpr uint8_t LCD_CONTRAST = 0xB0;
82 static constexpr uint8_t LCD_BIAS = 0x13;
84 // SPI
85 bool _LCDHardwareSPI = true;
86 uint16_t _LCDHighFreqDelay = 0;
87 int _spiHandle = 0;
88 int _spiDev = 0;
89 int _spiChan = 0;
90 int _spiBaud = 50000;
91 int _spiFlags = 0;
93 // GPIO
94 int8_t _Display_DC;
95 int8_t _Display_RST;
96 int8_t _Display_CS;
100 int _GpioHandle = 0;
102 // Display
103 uint8_t _contrast;
104 uint8_t _bias;
105 bool _inverse = false;
106 bool _sleep;
107 int16_t _LCD_HEIGHT = 48;
108 int16_t _LCD_WIDTH = 84;
110 uint8_t LCDDisplayBuffer[504];
111}; //end of class
112
113
Graphics based functions for bicolor display.
Class Controls SPI comms and LCD functionality.
Definition NOKIA_5110_LCD_RDL.hpp:25
rdlib::Return_Codes_e LCDBegin(bool Inverse, uint8_t Contrast, uint8_t Bias, int gpioDev)
This sends the commands to the PCD8544 to init LCD.
Definition NOKIA_5110_LCD_RDL.cpp:138
static constexpr uint8_t LCD_FUNCTIONSET
Definition NOKIA_5110_LCD_RDL.hpp:66
int8_t _Display_RST
Definition NOKIA_5110_LCD_RDL.hpp:95
void LCDinvertDisplay(bool inv)
inverts color on display
Definition NOKIA_5110_LCD_RDL.cpp:454
static constexpr uint8_t LCD_EXTENDEDINSTRUCTION
Definition NOKIA_5110_LCD_RDL.hpp:69
rdlib::Return_Codes_e LCDSPIoff(void)
End SPI operations.
Definition NOKIA_5110_LCD_RDL.cpp:224
int _GpioHandle
Definition NOKIA_5110_LCD_RDL.hpp:100
void LCDdisplayUpdate(void)
Writes the buffer to the LCD.
Definition NOKIA_5110_LCD_RDL.cpp:369
uint16_t _LCDHighFreqDelay
Definition NOKIA_5110_LCD_RDL.hpp:86
static constexpr uint8_t LCD_SETTEMP
Definition NOKIA_5110_LCD_RDL.hpp:80
virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override
Set a single pixel in the buffer.
Definition NOKIA_5110_LCD_RDL.cpp:390
int _spiFlags
Definition NOKIA_5110_LCD_RDL.hpp:91
uint8_t LCDDisplayBuffer[504]
Definition NOKIA_5110_LCD_RDL.hpp:110
int8_t _Display_DC
Definition NOKIA_5110_LCD_RDL.hpp:94
void LCDHighFreqDelaySet(uint16_t)
Freq delay used in SW SPI setter, uS delay used in SW SPI method.
Definition NOKIA_5110_LCD_RDL.cpp:516
int8_t _Display_CS
Definition NOKIA_5110_LCD_RDL.hpp:96
static constexpr uint8_t LCD_ENTRYMODE
Definition NOKIA_5110_LCD_RDL.hpp:68
static constexpr uint8_t LCD_DISPLAYCONTROL
Definition NOKIA_5110_LCD_RDL.hpp:71
static constexpr uint8_t LCD_DISPLAYINVERTED
Definition NOKIA_5110_LCD_RDL.hpp:75
uint8_t _contrast
Definition NOKIA_5110_LCD_RDL.hpp:103
bool isHardwareSPI(void)
Checks which SPI mode is on.
Definition NOKIA_5110_LCD_RDL.cpp:503
int8_t _Display_SDATA
Definition NOKIA_5110_LCD_RDL.hpp:98
void LCDfillScreenPattern(uint8_t)
Writes the buffer (with pattern) to the LCD.
Definition NOKIA_5110_LCD_RDL.cpp:443
void LCDenableSleep(void)
Turn on sleep mode.
Definition NOKIA_5110_LCD_RDL.cpp:468
bool _inverse
Definition NOKIA_5110_LCD_RDL.hpp:105
bool _sleep
Definition NOKIA_5110_LCD_RDL.hpp:106
void LCDWriteData(uint8_t data)
Writes a byte to the PCD8544.
Definition NOKIA_5110_LCD_RDL.cpp:316
void LCDWriteCommand(uint8_t command)
Writes a command byte to the PCD8544.
Definition NOKIA_5110_LCD_RDL.cpp:348
static constexpr uint8_t LCD_BIAS
Definition NOKIA_5110_LCD_RDL.hpp:82
int16_t _LCD_HEIGHT
Definition NOKIA_5110_LCD_RDL.hpp:107
uint16_t _LCD_Display_size
Definition NOKIA_5110_LCD_RDL.hpp:109
void LCDInit(void)
Init the LCD command sequence, called from begin.
Definition NOKIA_5110_LCD_RDL.cpp:196
int _DeviceNumGpioChip
Definition NOKIA_5110_LCD_RDL.hpp:99
int16_t _LCD_WIDTH
Definition NOKIA_5110_LCD_RDL.hpp:108
void LCDSetContrast(uint8_t con)
Function to set contrast passed a byte.
Definition NOKIA_5110_LCD_RDL.cpp:359
void LCDfillScreen(void)
Writes the buffer (full of ones(0xFF)) to the LCD.
Definition NOKIA_5110_LCD_RDL.cpp:433
void LCDdisplayClear(void)
Writes the buffer (full of zeros) to the LCD.
Definition NOKIA_5110_LCD_RDL.cpp:424
static constexpr uint8_t LCD_POWERDOWN
Definition NOKIA_5110_LCD_RDL.hpp:67
static constexpr uint8_t LCD_SETXADDR
Definition NOKIA_5110_LCD_RDL.hpp:78
static constexpr uint8_t LCD_CONTRAST
Definition NOKIA_5110_LCD_RDL.hpp:81
static constexpr uint8_t LCD_DISPLAYALLON
Definition NOKIA_5110_LCD_RDL.hpp:74
int _spiDev
Definition NOKIA_5110_LCD_RDL.hpp:88
bool _LCDHardwareSPI
Definition NOKIA_5110_LCD_RDL.hpp:85
uint8_t _bias
Definition NOKIA_5110_LCD_RDL.hpp:104
void LCDPowerDown(void)
Call when powering down LCD.
Definition NOKIA_5110_LCD_RDL.cpp:299
int8_t _Display_SCLK
Definition NOKIA_5110_LCD_RDL.hpp:97
bool LCDIsSleeping(void)
LCDisSleeping.
Definition NOKIA_5110_LCD_RDL.cpp:497
uint16_t LCDHighFreqDelayGet(void)
Freq delay used in SW SPI getter, uS delay used in SW SPI method.
Definition NOKIA_5110_LCD_RDL.cpp:510
int _spiChan
Definition NOKIA_5110_LCD_RDL.hpp:89
static constexpr uint8_t LCD_DISPLAYBLANK
Definition NOKIA_5110_LCD_RDL.hpp:72
static constexpr uint8_t LCD_DISPLAYNORMAL
Definition NOKIA_5110_LCD_RDL.hpp:73
static constexpr uint8_t LCD_SETYADDR
Definition NOKIA_5110_LCD_RDL.hpp:77
void LCDdisableSleep(void)
Turn off sleep mode.
Definition NOKIA_5110_LCD_RDL.cpp:477
int _spiBaud
Definition NOKIA_5110_LCD_RDL.hpp:90
int _spiHandle
Definition NOKIA_5110_LCD_RDL.hpp:87
Graphics class to hold graphic related functions for 1-bit displays.
Definition bicolor_graphics_RDL.hpp:21
Return_Codes_e
Definition common_data_RDL.hpp:22