Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
common_data_RDL.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <cstdint>
11#include <chrono>
12#include <thread>
13#include <array>
14#include <lgpio.h>
15#include "utility_data_RDL.hpp"
16
18namespace rdlib {
19
54
57constexpr std::array<const char*, 30> ReturnCodesStrings = {
58 "Success, Function ran without defined Error",
59 "Reserved, Reserved for future use",
60 "WrongFont, Wrong Font selected",
61 "CharScreenBounds, Text Character is out of Screen bounds, Check x and y",
62 "CharFontASCIIRange, Text Character is outside of chosen Fonts ASCII range, Check the selected Fonts ASCII range",
63 "CharArrayNullptr, Text Character Array is an invalid pointer object",
64 "FontDataEmpty, Span to the font data is an empty object",
65 "BitmapDataEmpty, The Bitmap span is an empty object",
66 "BitmapScreenBounds, The Bitmap starting point is outside screen bounds, check x and y",
67 "BitmapLargerThanScreen, The Bitmap is larger than screen, check w and h",
68 "BitmapVerticalSize, A vertical Bitmap's height must be divisible by 8",
69 "BitmapHorizontalSize, A horizontal Bitmap's width must be divisible by 8",
70 "BitmapSize, Size of the Bitmap is incorrect: BitmapSize(vertical)!=(w*(h/8), BitmapSize(horizontal)!=(w/8)*h",
71 "CustomCharLen, Char array is incorrect size",
72 "BufferSize, Size of the Buffer is incorrect: BufferSize(vertical)!=(w*(h/8)",
73 "BufferEmpty, The Buffer span is an empty object",
74 "SPIOpenFailure, Failed to open HW SPI, lgpio",
75 "SPICloseFailure, Failed to close HW SPI, lgpio",
76 "I2CbeginFail, Failed to open I2C, lgpio",
77 "I2CcloseFail, Failed to close I2C, lgpio",
78 "ShapeScreenBounds, Shape is outside screen bounds, check x and y",
79 "MemoryAError, Could not assign memory",
80 "WrongInputPCBType, Wrong input PCB type chosen",
81 "GpioChipDevice, Failed to open or close GPIO chip device, lgpio",
82 "GpioPinClaim, Failed to claim a GPIO for output or input, lgpio",
83 "GpioPinFree, Failed to free a GPIO for output or input, lgpio",
84 "WrongModeChosen, Wrong SPI communication mode chosen by user",
85 "GenericError, Generic error message , for minor errors",
86 "UnknownError, For unknown error events",
87 "InvalidRAMLocation, Invalid RAM location"
88};
89
91uint16_t LibraryVersion(void);
92
93};
94
95// Delay abstractions Macros
97#define delaySecRDL lguSleep
99#define delayMilliSecRDL(x) std::this_thread::sleep_for(std::chrono::milliseconds(x))
101#define delayMicroSecRDL(x) std::this_thread::sleep_for(std::chrono::microseconds(x))
102
103
105
106// lg library GLOBAL ABSTRACTION
107// (this makes porting or changing the library much easier across all devices)
108// GPIO write levels
109#define Display_DC_SetHigh lgGpioWrite(_GpioHandle, _Display_DC, 1)
110#define Display_DC_SetLow lgGpioWrite(_GpioHandle ,_Display_DC, 0)
111#define Display_RST_SetHigh lgGpioWrite(_GpioHandle, _Display_RST, 1)
112#define Display_RST_SetLow lgGpioWrite(_GpioHandle, _Display_RST, 0)
113#define Display_CS_SetHigh lgGpioWrite(_GpioHandle ,_Display_CS, 1)
114#define Display_CS_SetLow lgGpioWrite(_GpioHandle, _Display_CS, 0)
115#define Display_SCLK_SetHigh lgGpioWrite(_GpioHandle, _Display_SCLK, 1)
116#define Display_SCLK_SetLow lgGpioWrite(_GpioHandle, _Display_SCLK, 0)
117#define Display_SDATA_SetHigh lgGpioWrite(_GpioHandle, _Display_SDATA, 1)
118#define Display_SDATA_SetLow lgGpioWrite(_GpioHandle, _Display_SDATA,0)
119#define _XPT_RST_SetHigh lgGpioWrite(_GpioHandle, _RESET_PIN , 1)
120#define _XPT_RST_SetLow lgGpioWrite(_GpioHandle, _RESET_PIN , 0)
121// GPIO read levels
122#define Display_MISO_Read lgGpioRead(_GpioHandle, _Display_MISO)
123#define Display_SDATA_Read lgGpioRead(_GpioHandle, _Display_SDATA) //tm163X
124#define _XPT_IRQ_Read lgGpioRead(_GpioHandle, _IRQ_PIN)
125// GPIO claim output
126#define Display_RST_SetDigitalOutput lgGpioClaimOutput(_GpioHandle, 0, _Display_RST, 0);
127#define Display_DC_SetDigitalOutput lgGpioClaimOutput(_GpioHandle, 0, _Display_DC, 0);
128#define Display_CS_SetDigitalOutput lgGpioClaimOutput(_GpioHandle, 0, _Display_CS, 0);
129#define Display_SCLK_SetDigitalOutput lgGpioClaimOutput(_GpioHandle, 0, _Display_SCLK, 0);
130#define Display_SDATA_SetDigitalOutput lgGpioClaimOutput(_GpioHandle, 0, _Display_SDATA, 0);
131#define _XPT_RST_SetDigitalOutput lgGpioClaimOutput(_GpioHandle, 0,_RESET_PIN, 0);
132// GPIO claim input
133#define Display_SCLK_SetDigitalInput lgGpioClaimInput(_GpioHandle, 0, _Display_SCLK);
134#define Display_SDATA_SetDigitalInput lgGpioClaimInput(_GpioHandle, 0, _Display_SDATA);
135#define Display_MISO_SetDigitalInput lgGpioClaimInput(_GpioHandle, 0,_Display_MISO);
136#define _XPT_IRQ_SetDigitalInput lgGpioClaimInput(_GpioHandle, 0,_IRQ_PIN);
137// GPIO open and close
138#define Display_OPEN_GPIO_CHIP lgGpiochipOpen(_DeviceNumGpioChip)
139#define Display_CLOSE_GPIO_HANDLE lgGpiochipClose(_GpioHandle)
140// GPIO free modes
141#define Display_GPIO_FREE_DC lgGpioFree(_GpioHandle , _Display_DC)
142#define Display_GPIO_FREE_RST lgGpioFree(_GpioHandle , _Display_RST)
143#define Display_GPIO_FREE_CS lgGpioFree(_GpioHandle , _Display_CS)
144#define Display_GPIO_FREE_CLK lgGpioFree(_GpioHandle , _Display_SCLK)
145#define Display_GPIO_FREE_SDATA lgGpioFree(_GpioHandle , _Display_SDATA)
146#define _XPT_GPIO_FREE_IRQ lgGpioFree(_GpioHandle , _IRQ_PIN)
147#define _XPT_GPIO_FREE_RST lgGpioFree(_GpioHandle , _RESET_PIN )
148// SPI
149#define Display_OPEN_SPI lgSpiOpen(_spiDev, _spiChan, _spiBaud, _spiFlags)
150#define Display_CLOSE_SPI lgSpiClose(_spiHandle)
151#define Display_SPI_READ lgSpiRead
152#define Display_SPI_WRITE lgSpiWrite
153#define Display_SPI_TRANSFER lgSpiXfer
154// I2C
155#define Display_RDL_I2C_OPEN lgI2cOpen
156#define Display_RDL_I2C_CLOSE lgI2cClose
157#define Display_RDL_I2C_WRITE lgI2cWriteDevice
158#define Display_RDL_I2C_READ lgI2cReadDevice
159
Name space for common utilities.
Definition common_data_RDL.hpp:18
std::string ReturnCodetoText(Return_Codes_e)
Prints out Enum label and help message for given enum code from Return_Codes_e.
Definition common_data_RDL.cpp:23
uint16_t LibraryVersion(void)
get the library version number
Definition common_data_RDL.cpp:13
Return_Codes_e
Definition common_data_RDL.hpp:22
@ CustomCharLen
Definition common_data_RDL.hpp:36
@ GpioPinFree
Definition common_data_RDL.hpp:48
@ BitmapScreenBounds
Definition common_data_RDL.hpp:31
@ BitmapHorizontalSize
Definition common_data_RDL.hpp:34
@ GpioPinClaim
Definition common_data_RDL.hpp:47
@ MemoryAError
Definition common_data_RDL.hpp:44
@ WrongInputPCBType
Definition common_data_RDL.hpp:45
@ BitmapDataEmpty
Definition common_data_RDL.hpp:30
@ Reserved
Definition common_data_RDL.hpp:24
@ CharScreenBounds
Definition common_data_RDL.hpp:26
@ I2CbeginFail
Definition common_data_RDL.hpp:41
@ BitmapLargerThanScreen
Definition common_data_RDL.hpp:32
@ Success
Definition common_data_RDL.hpp:23
@ SPICloseFailure
Definition common_data_RDL.hpp:40
@ WrongModeChosen
Definition common_data_RDL.hpp:49
@ BufferEmpty
Definition common_data_RDL.hpp:38
@ ShapeScreenBounds
Definition common_data_RDL.hpp:43
@ InvalidRAMLocation
Definition common_data_RDL.hpp:52
@ FontDataEmpty
Definition common_data_RDL.hpp:29
@ GpioChipDevice
Definition common_data_RDL.hpp:46
@ WrongFont
Definition common_data_RDL.hpp:25
@ BufferSize
Definition common_data_RDL.hpp:37
@ BitmapVerticalSize
Definition common_data_RDL.hpp:33
@ BitmapSize
Definition common_data_RDL.hpp:35
@ I2CcloseFail
Definition common_data_RDL.hpp:42
@ GenericError
Definition common_data_RDL.hpp:50
@ CharArrayNullptr
Definition common_data_RDL.hpp:28
@ SPIOpenFailure
Definition common_data_RDL.hpp:39
@ UnknownError
Definition common_data_RDL.hpp:51
@ CharFontASCIIRange
Definition common_data_RDL.hpp:27
constexpr std::array< const char *, 30 > ReturnCodesStrings
Definition common_data_RDL.hpp:57
A file to hold some utilities(config file , logging etc) , included in common_data_RDL.