Display_Lib_RPI 2.4.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);
43 void LCDPowerDown(void);
44 uint16_t LCDHighFreqDelayGet(void);
45 void LCDHighFreqDelaySet(uint16_t);
46 bool isHardwareSPI(void);
47
48 rdlib::Return_Codes_e LCDSetBufferPtr(std::span<uint8_t> buffer);
50 rdlib::Return_Codes_e LCDclearBuffer(uint8_t pattern = 0x00);
51 void LCDfillScreen(uint8_t pattern = 0x00);
52 virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override;
53
54 void LCDSetContrast(uint8_t con);
55 void LCDinvertDisplay(bool inv);
56
57private:
58
59 void LCDBuffer(std::span<uint8_t> data);
60 void LCDWriteData(uint8_t data);
61 void LCDWriteCommand(uint8_t command);
62 void LCDInit(void);
63
64 // LCD Commands & registers list
65 static constexpr uint8_t LCD_FUNCTIONSET = 0x20;
66 static constexpr uint8_t LCD_POWERDOWN = 0x04;
67 static constexpr uint8_t LCD_ENTRYMODE = 0x02;
68 static constexpr uint8_t LCD_EXTENDEDINSTRUCTION = 0x01;
70 static constexpr uint8_t LCD_DISPLAYCONTROL = 0x08;
71 static constexpr uint8_t LCD_DISPLAYBLANK = 0x00;
72 static constexpr uint8_t LCD_DISPLAYNORMAL = 0x04;
73 static constexpr uint8_t LCD_DISPLAYALLON = 0x01;
74 static constexpr uint8_t LCD_DISPLAYINVERTED = 0x05;
76 static constexpr uint8_t LCD_SETYADDR = 0x40;
77 static constexpr uint8_t LCD_SETXADDR = 0x80;
79 static constexpr uint8_t LCD_SETTEMP = 0x04;
80 static constexpr uint8_t LCD_CONTRAST = 0xB0;
81 static constexpr uint8_t LCD_BIAS = 0x13;
83 // SPI
84 bool _LCDHardwareSPI = true;
85 uint16_t _LCDHighFreqDelay = 0;
86 int _spiHandle = 0;
87 int _spiDev = 0;
88 int _spiChan = 0;
89 int _spiBaud = 50000;
90 int _spiFlags = 0;
92 // GPIO
93 int8_t _Display_DC;
94 int8_t _Display_RST;
95 int8_t _Display_CS;
99 int _GpioHandle = 0;
101 // Display
102 uint8_t _contrast;
103 uint8_t _bias;
104 bool _inverse = false;
105 bool _sleep;
106 int16_t _LCD_HEIGHT = 48;
107 int16_t _LCD_WIDTH = 84;
109 std::span<uint8_t> _LCDbuffer;
110}; //end of class
111
112
Graphics based functions for bicolor display.
Class Controls SPI comms and LCD functionality.
Definition NOKIA_5110_LCD_RDL.hpp:25
rdlib::Return_Codes_e LCDSetBufferPtr(std::span< uint8_t > buffer)
sets the buffer pointer to the users screen data buffer
Definition NOKIA_5110_LCD_RDL.cpp:496
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
std::span< uint8_t > _LCDbuffer
Definition NOKIA_5110_LCD_RDL.hpp:109
static constexpr uint8_t LCD_FUNCTIONSET
Definition NOKIA_5110_LCD_RDL.hpp:65
void LCDBuffer(std::span< uint8_t > data)
Draw an array to the screen.
Definition NOKIA_5110_LCD_RDL.cpp:556
int8_t _Display_RST
Definition NOKIA_5110_LCD_RDL.hpp:94
void LCDinvertDisplay(bool inv)
inverts color on display
Definition NOKIA_5110_LCD_RDL.cpp:424
static constexpr uint8_t LCD_EXTENDEDINSTRUCTION
Definition NOKIA_5110_LCD_RDL.hpp:68
rdlib::Return_Codes_e LCDSPIoff(void)
End SPI operations.
Definition NOKIA_5110_LCD_RDL.cpp:224
int _GpioHandle
Definition NOKIA_5110_LCD_RDL.hpp:99
uint16_t _LCDHighFreqDelay
Definition NOKIA_5110_LCD_RDL.hpp:85
static constexpr uint8_t LCD_SETTEMP
Definition NOKIA_5110_LCD_RDL.hpp:79
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:371
rdlib::Return_Codes_e LCDclearBuffer(uint8_t pattern=0x00)
clears the buffer of the active screen pointed to by Active Buffer
Definition NOKIA_5110_LCD_RDL.cpp:539
int _spiFlags
Definition NOKIA_5110_LCD_RDL.hpp:90
int8_t _Display_DC
Definition NOKIA_5110_LCD_RDL.hpp:93
void LCDHighFreqDelaySet(uint16_t)
Freq delay used in SW SPI setter, uS delay used in SW SPI method.
Definition NOKIA_5110_LCD_RDL.cpp:486
int8_t _Display_CS
Definition NOKIA_5110_LCD_RDL.hpp:95
static constexpr uint8_t LCD_ENTRYMODE
Definition NOKIA_5110_LCD_RDL.hpp:67
static constexpr uint8_t LCD_DISPLAYCONTROL
Definition NOKIA_5110_LCD_RDL.hpp:70
static constexpr uint8_t LCD_DISPLAYINVERTED
Definition NOKIA_5110_LCD_RDL.hpp:74
uint8_t _contrast
Definition NOKIA_5110_LCD_RDL.hpp:102
bool isHardwareSPI(void)
Checks which SPI mode is on.
Definition NOKIA_5110_LCD_RDL.cpp:473
int8_t _Display_SDATA
Definition NOKIA_5110_LCD_RDL.hpp:97
void LCDenableSleep(void)
Turn on sleep mode.
Definition NOKIA_5110_LCD_RDL.cpp:438
bool _inverse
Definition NOKIA_5110_LCD_RDL.hpp:104
void LCDfillScreen(uint8_t pattern=0x00)
Writes the buffer (with pattern) to the LCD.
Definition NOKIA_5110_LCD_RDL.cpp:406
rdlib::Return_Codes_e LCDupdate(void)
updates the LCD i.e. writes the shared buffer to the active screen pointed to by Active Buffer
Definition NOKIA_5110_LCD_RDL.cpp:520
bool _sleep
Definition NOKIA_5110_LCD_RDL.hpp:105
void LCDWriteData(uint8_t data)
Writes a byte to the PCD8544.
Definition NOKIA_5110_LCD_RDL.cpp:315
void LCDWriteCommand(uint8_t command)
Writes a command byte to the PCD8544.
Definition NOKIA_5110_LCD_RDL.cpp:347
static constexpr uint8_t LCD_BIAS
Definition NOKIA_5110_LCD_RDL.hpp:81
int16_t _LCD_HEIGHT
Definition NOKIA_5110_LCD_RDL.hpp:106
uint16_t _LCD_Display_size
Definition NOKIA_5110_LCD_RDL.hpp:108
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:98
int16_t _LCD_WIDTH
Definition NOKIA_5110_LCD_RDL.hpp:107
void LCDSetContrast(uint8_t con)
Function to set contrast passed a byte.
Definition NOKIA_5110_LCD_RDL.cpp:358
static constexpr uint8_t LCD_POWERDOWN
Definition NOKIA_5110_LCD_RDL.hpp:66
static constexpr uint8_t LCD_SETXADDR
Definition NOKIA_5110_LCD_RDL.hpp:77
static constexpr uint8_t LCD_CONTRAST
Definition NOKIA_5110_LCD_RDL.hpp:80
static constexpr uint8_t LCD_DISPLAYALLON
Definition NOKIA_5110_LCD_RDL.hpp:73
int _spiDev
Definition NOKIA_5110_LCD_RDL.hpp:87
bool _LCDHardwareSPI
Definition NOKIA_5110_LCD_RDL.hpp:84
uint8_t _bias
Definition NOKIA_5110_LCD_RDL.hpp:103
void LCDPowerDown(void)
Call when powering down LCD.
Definition NOKIA_5110_LCD_RDL.cpp:298
int8_t _Display_SCLK
Definition NOKIA_5110_LCD_RDL.hpp:96
bool LCDIsSleeping(void)
LCDisSleeping.
Definition NOKIA_5110_LCD_RDL.cpp:467
uint16_t LCDHighFreqDelayGet(void)
Freq delay used in SW SPI getter, uS delay used in SW SPI method.
Definition NOKIA_5110_LCD_RDL.cpp:480
int _spiChan
Definition NOKIA_5110_LCD_RDL.hpp:88
static constexpr uint8_t LCD_DISPLAYBLANK
Definition NOKIA_5110_LCD_RDL.hpp:71
static constexpr uint8_t LCD_DISPLAYNORMAL
Definition NOKIA_5110_LCD_RDL.hpp:72
static constexpr uint8_t LCD_SETYADDR
Definition NOKIA_5110_LCD_RDL.hpp:76
void LCDdisableSleep(void)
Turn off sleep mode.
Definition NOKIA_5110_LCD_RDL.cpp:447
int _spiBaud
Definition NOKIA_5110_LCD_RDL.hpp:89
int _spiHandle
Definition NOKIA_5110_LCD_RDL.hpp:86
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