Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
ERM19264_UC1609_LCD_RDL.hpp
Go to the documentation of this file.
1
15#pragma once
16
17// ** INCLUDES **
18#include <lgpio.h>
19#include <cstdio>
20#include <cstdint>
21#include <cstdbool>
23
24
29public:
30 // Contructor 1 Software SPI with explicit SCLK and SDIN
31 ERM19264_UC1609(int16_t lcdwidth, int16_t lcdheight , int8_t rst, int8_t cd, int8_t cs, int8_t sclk, int8_t din);
32 // Constructor 2 Hardware SPI
33 ERM19264_UC1609(int16_t lcdwidth, int16_t lcdheight , int8_t rst, int8_t cd);
34
36
47
48 virtual void drawPixel(int16_t x, int16_t y, uint8_t colour) override;
49
52 void LCDBuffer(int16_t x, int16_t y, uint8_t w, uint8_t h, std::span<uint8_t> data);
53 rdlib::Return_Codes_e LCDSetBufferPtr(uint8_t width, uint8_t height , std::span<uint8_t> data);
54 void LCDBitmap(int16_t x, int16_t y, uint8_t w, uint8_t h, const std::span<const uint8_t> data);
55
56 rdlib::Return_Codes_e LCDbegin(uint8_t AddressSet, uint8_t VbiasPot, int device, int channel, int speed, int flags, int gpioDev ); // HW SPI
57 rdlib::Return_Codes_e LCDbegin(uint8_t AddressSet, uint8_t VbiasPot, int gpioDev ); // SW SPI
58 void LCDinit(void);
59 void LCDEnable(uint8_t on);
60 void LCDFillScreen(uint8_t pixel);
61 void LCDFillPage(uint8_t page_num, uint8_t pixels);
63 void LCDinvert(uint8_t on);
64 void LCDallpixelsOn(uint8_t bits);
65 void LCDscroll(uint8_t bits);
66 void LCDReset(void);
67 void LCDPowerDown(void);
69 bool LCDIssleeping(void);
70
71 uint16_t LCD_HighFreqDelayGet(void);
72 void LCD_HighFreqDelaySet(uint16_t);
73
74 private:
75
76 void sendData(uint8_t data);
77 void sendCommand(uint8_t command, uint8_t value);
78 int8_t GetCommMode(void);
79 void SoftwareSPIShiftOut(uint8_t val);
80
81 // GPIO related
82 int8_t _Display_CS;
83 int8_t _Display_DC;
84 int8_t _Display_RST;
88 int _GpioHandle = 0;
90 // Display
91 int16_t _LCD_WIDTH = 192;
92 int16_t _LCD_HEIGHT = 64;
94 std::span<uint8_t> _LCDbufferScreen ;
95 bool _sleep = true;
96 uint8_t _VbiasPOT= 0x49;
97 uint8_t _AddressCtrl= 0x02;
99 // SPI related
100 int _spiHandle = 0;
101 int _spiDev = 0;
102 int _spiChan = 0;
103 int _spiBaud = 50000;
104 int _spiFlags = 0;
105 int8_t _LCD_mode = 2;
106 uint16_t _LCD_HighFreqDelay = 0;
110 {
111 static constexpr uint16_t INIT_DELAY = 100;
112 static constexpr uint16_t INIT_DELAY2 = 3;
113 static constexpr uint16_t RESET_DELAY = 3;
114 static constexpr uint16_t RESET_DELAY2 = 0;
115 };
116
117 // UC1909 Write registers
118 static constexpr uint8_t UC1609_SYSTEM_RESET = 0xE2 ;
119 static constexpr uint8_t UC1609_POWER_CONTROL = 0x28 ;
120 static constexpr uint8_t UC1609_PC_SET = 0x06 ;
121 static constexpr uint8_t UC1609_ADDRESS_CONTROL = 0x88 ;
122 static constexpr uint8_t UC1609_ADDRESS_SET = 0x02 ;
123 static constexpr uint8_t UC1609_SET_PAGEADD = 0xB0 ;
124 static constexpr uint8_t UC1609_SET_COLADD_LSB = 0x00 ;
125 static constexpr uint8_t UC1609_SET_COLADD_MSB = 0x10 ;
126 static constexpr uint8_t UC1609_TEMP_COMP_REG = 0x27 ;
127 static constexpr uint8_t UC1609_TEMP_COMP_SET = 0x00 ;
128 static constexpr uint8_t UC1609_FRAMERATE_REG = 0xA0 ;
129 static constexpr uint8_t UC1609_FRAMERATE_SET = 0x01 ;
130 static constexpr uint8_t UC1609_BIAS_RATIO = 0xE8 ;
131 static constexpr uint8_t UC1609_BIAS_RATIO_SET = 0x03 ;
132 static constexpr uint8_t UC1609_GN_PM = 0x81 ;
133 static constexpr uint8_t UC1609_DEFAULT_GN_PM = 0x49 ;
134 static constexpr uint8_t UC1609_LCD_CONTROL = 0xC0 ;
135 static constexpr uint8_t UC1609_DISPLAY_ON = 0xAE ;
136 static constexpr uint8_t UC1609_ALL_PIXEL_ON = 0xA4 ;
137 static constexpr uint8_t UC1609_INVERSE_DISPLAY = 0xA6 ;
138 static constexpr uint8_t UC1609_SCROLL = 0x40 ;
139};
Graphics based functions for bicolor display.
class to drive the ERM19264 UC1609 LCD
Definition ERM19264_UC1609_LCD_RDL.hpp:28
void LCDBuffer(int16_t x, int16_t y, uint8_t w, uint8_t h, std::span< uint8_t > data)
Draw a data array to the screen.
Definition ERM19264_UC1609_LCD_RDL.cpp:671
std::span< uint8_t > _LCDbufferScreen
Definition ERM19264_UC1609_LCD_RDL.hpp:94
static constexpr uint8_t UC1609_GN_PM
Definition ERM19264_UC1609_LCD_RDL.hpp:132
int _spiBaud
Definition ERM19264_UC1609_LCD_RDL.hpp:103
uint8_t _VbiasPOT
Definition ERM19264_UC1609_LCD_RDL.hpp:96
void LCDPowerDown(void)
Powerdown procedure for LCD see datasheet P40.
Definition ERM19264_UC1609_LCD_RDL.cpp:277
void LCD_HighFreqDelaySet(uint16_t)
Freq delay used in SW SPI setter, uS delay used in CustomshiftOut method.
Definition ERM19264_UC1609_LCD_RDL.cpp:756
int8_t _Display_RST
Definition ERM19264_UC1609_LCD_RDL.hpp:84
uint16_t LCD_HighFreqDelayGet(void)
Freq delay used in SW SPI getter, uS delay used in CustomshiftOut method.
Definition ERM19264_UC1609_LCD_RDL.cpp:750
void LCDFillPage(uint8_t page_num, uint8_t pixels)
Fill the chosen page at page_num with a datapattern.
Definition ERM19264_UC1609_LCD_RDL.cpp:488
static constexpr uint8_t UC1609_TEMP_COMP_SET
Definition ERM19264_UC1609_LCD_RDL.hpp:127
int _spiHandle
Definition ERM19264_UC1609_LCD_RDL.hpp:100
void LCDReset(void)
Resets LCD in a four wire setup called at start and should also be called in a controlled power down ...
Definition ERM19264_UC1609_LCD_RDL.cpp:343
int _DeviceNumGpioChip
Definition ERM19264_UC1609_LCD_RDL.hpp:87
void sendCommand(uint8_t command, uint8_t value)
Sends a command to the display.
Definition ERM19264_UC1609_LCD_RDL.cpp:332
rdlib::Return_Codes_e LCDupdate(void)
updates the buffer i.e. writes it to the screen
Definition ERM19264_UC1609_LCD_RDL.cpp:630
int8_t GetCommMode(void)
Checks if software SPI is on.
Definition ERM19264_UC1609_LCD_RDL.cpp:582
static constexpr uint8_t UC1609_SET_COLADD_MSB
Definition ERM19264_UC1609_LCD_RDL.hpp:125
void LCDFillScreen(uint8_t pixel)
Fill the screen NOT the buffer with a datapattern.
Definition ERM19264_UC1609_LCD_RDL.cpp:527
int8_t _LCD_PAGE_NUM
Definition ERM19264_UC1609_LCD_RDL.hpp:93
static constexpr uint8_t UC1609_PC_SET
Definition ERM19264_UC1609_LCD_RDL.hpp:120
static constexpr uint8_t UC1609_ADDRESS_SET
Definition ERM19264_UC1609_LCD_RDL.hpp:122
uint16_t _LCD_HighFreqDelay
Definition ERM19264_UC1609_LCD_RDL.hpp:106
static constexpr uint8_t UC1609_ADDRESS_CONTROL
Definition ERM19264_UC1609_LCD_RDL.hpp:121
int8_t _Display_SCLK
Definition ERM19264_UC1609_LCD_RDL.hpp:85
static constexpr uint8_t UC1609_DISPLAY_ON
Definition ERM19264_UC1609_LCD_RDL.hpp:135
void LCDBitmap(int16_t x, int16_t y, uint8_t w, uint8_t h, const std::span< const uint8_t > data)
Draw a bitmap into the screen.
Definition ERM19264_UC1609_LCD_RDL.cpp:543
LCD_rotate_command_e
enum to hold LCD Rotate command constants
Definition ERM19264_UC1609_LCD_RDL.hpp:41
@ UC1609_ROTATION_NORMAL
Definition ERM19264_UC1609_LCD_RDL.hpp:43
@ UC1609_ROTATION_FLIP_TWO
Definition ERM19264_UC1609_LCD_RDL.hpp:42
@ UC1609_ROTATION_FLIP_ONE
Definition ERM19264_UC1609_LCD_RDL.hpp:44
@ UC1609_ROTATION_FLIP_THREE
Definition ERM19264_UC1609_LCD_RDL.hpp:45
int _spiChan
Definition ERM19264_UC1609_LCD_RDL.hpp:102
int8_t _Display_DC
Definition ERM19264_UC1609_LCD_RDL.hpp:83
static constexpr uint8_t UC1609_LCD_CONTROL
Definition ERM19264_UC1609_LCD_RDL.hpp:134
bool LCDIssleeping(void)
LCD Is Sleeping?
Definition ERM19264_UC1609_LCD_RDL.cpp:376
int8_t _Display_CS
Definition ERM19264_UC1609_LCD_RDL.hpp:82
int _spiDev
Definition ERM19264_UC1609_LCD_RDL.hpp:101
static constexpr uint8_t UC1609_SET_PAGEADD
Definition ERM19264_UC1609_LCD_RDL.hpp:123
static constexpr uint8_t UC1609_SYSTEM_RESET
Definition ERM19264_UC1609_LCD_RDL.hpp:118
void LCDinvert(uint8_t on)
invert the display
Definition ERM19264_UC1609_LCD_RDL.cpp:444
void LCDallpixelsOn(uint8_t bits)
turns on all Pixels
Definition ERM19264_UC1609_LCD_RDL.cpp:466
void LCDEnable(uint8_t on)
Turns On Display.
Definition ERM19264_UC1609_LCD_RDL.cpp:355
static constexpr uint8_t UC1609_ALL_PIXEL_ON
Definition ERM19264_UC1609_LCD_RDL.hpp:136
int16_t _LCD_WIDTH
Definition ERM19264_UC1609_LCD_RDL.hpp:91
static constexpr uint8_t UC1609_SCROLL
Definition ERM19264_UC1609_LCD_RDL.hpp:138
rdlib::Return_Codes_e LCDSPIoff(void)
End SPI operations.
Definition ERM19264_UC1609_LCD_RDL.cpp:200
void SoftwareSPIShiftOut(uint8_t val)
used in software SPI mode to shift out data
Definition ERM19264_UC1609_LCD_RDL.cpp:589
uint8_t _AddressCtrl
Definition ERM19264_UC1609_LCD_RDL.hpp:97
rdlib::Return_Codes_e LCDSetBufferPtr(uint8_t width, uint8_t height, std::span< uint8_t > data)
sets the buffer pointer to the users screen data buffer
Definition ERM19264_UC1609_LCD_RDL.cpp:768
static constexpr uint8_t UC1609_INVERSE_DISPLAY
Definition ERM19264_UC1609_LCD_RDL.hpp:137
virtual void drawPixel(int16_t x, int16_t y, uint8_t colour) override
Draws a Pixel to the screen , overrides the graphics library.
Definition ERM19264_UC1609_LCD_RDL.cpp:713
static constexpr uint8_t UC1609_FRAMERATE_REG
Definition ERM19264_UC1609_LCD_RDL.hpp:128
int _spiFlags
Definition ERM19264_UC1609_LCD_RDL.hpp:104
rdlib::Return_Codes_e LCDclearBuffer(void)
clears the buffer memory i.e. does NOT write to the screen
Definition ERM19264_UC1609_LCD_RDL.cpp:651
static constexpr uint8_t UC1609_SET_COLADD_LSB
Definition ERM19264_UC1609_LCD_RDL.hpp:124
static constexpr uint8_t UC1609_POWER_CONTROL
Definition ERM19264_UC1609_LCD_RDL.hpp:119
bool _sleep
Definition ERM19264_UC1609_LCD_RDL.hpp:95
void sendData(uint8_t data)
Send data byte with SPI to UC1609.
Definition ERM19264_UC1609_LCD_RDL.cpp:606
rdlib::Return_Codes_e LCDbegin(uint8_t AddressSet, uint8_t VbiasPot, int device, int channel, int speed, int flags, int gpioDev)
begin Method initialise LCD Sets pinmodes and SPI setup HW SPI
Definition ERM19264_UC1609_LCD_RDL.cpp:71
int8_t _LCD_mode
Definition ERM19264_UC1609_LCD_RDL.hpp:105
int _GpioHandle
Definition ERM19264_UC1609_LCD_RDL.hpp:88
static constexpr uint8_t UC1609_BIAS_RATIO
Definition ERM19264_UC1609_LCD_RDL.hpp:130
static constexpr uint8_t UC1609_FRAMERATE_SET
Definition ERM19264_UC1609_LCD_RDL.hpp:129
static constexpr uint8_t UC1609_BIAS_RATIO_SET
Definition ERM19264_UC1609_LCD_RDL.hpp:131
int16_t _LCD_HEIGHT
Definition ERM19264_UC1609_LCD_RDL.hpp:92
void LCDscroll(uint8_t bits)
Scroll the displayed image up by SL rows.
Definition ERM19264_UC1609_LCD_RDL.cpp:385
static constexpr uint8_t UC1609_DEFAULT_GN_PM
Definition ERM19264_UC1609_LCD_RDL.hpp:133
int8_t _Display_SDATA
Definition ERM19264_UC1609_LCD_RDL.hpp:86
rdlib::Return_Codes_e LCDrotate(LCD_rotate_command_e rotatevalue)
Rotates the display by sending commands to display.
Definition ERM19264_UC1609_LCD_RDL.cpp:411
static constexpr uint8_t UC1609_TEMP_COMP_REG
Definition ERM19264_UC1609_LCD_RDL.hpp:126
void LCDinit(void)
Called from LCDbegin carries out Power on sequence and register init Can be used to reset LCD to defa...
Definition ERM19264_UC1609_LCD_RDL.cpp:290
Graphics class to hold graphic related functions for 1-bit displays.
Definition bicolor_graphics_RDL.hpp:21
int16_t width(void) const
Gets the width of the display (per current _rotation)
Definition bicolor_graphics_RDL.cpp:560
int16_t height(void) const
Gets the height of the display (per current _rotation)
Definition bicolor_graphics_RDL.cpp:566
Return_Codes_e
Definition common_data_RDL.hpp:22
Struct to hold delay values used in driver.
Definition ERM19264_UC1609_LCD_RDL.hpp:110
static constexpr uint16_t RESET_DELAY2
Definition ERM19264_UC1609_LCD_RDL.hpp:114
static constexpr uint16_t INIT_DELAY2
Definition ERM19264_UC1609_LCD_RDL.hpp:112
static constexpr uint16_t INIT_DELAY
Definition ERM19264_UC1609_LCD_RDL.hpp:111
static constexpr uint16_t RESET_DELAY
Definition ERM19264_UC1609_LCD_RDL.hpp:113