Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SSD1331_OLED Class Reference

Class to control SSD1331 OLED basic functionality. More...

#include <SSD1331_OLED_RDL.hpp>

Inheritance diagram for SSD1331_OLED:
Inheritance graph
[legend]

Classes

struct  Constrast_values_t
 Set contrast color values in normal mode. More...
 
struct  Dim_Constrast_values_t
 Set contrast color values in dim mode. More...
 

Public Types

enum  scroll_time_interval_e : uint8_t { SCROLL_FRAME_6 , SCROLL_FRAME_10 , SCROLL_FRAME_100 , SCROLL_FRAME_200 }
 Set the Set time interval between each scroll. More...
 
enum  scroll_control_e : uint8_t { SCROLL_ACTIVATE , SCROLL_DEACTIVE }
 Set the Scroll mode on or off according to the setting done by OLEDScrollSetup() More...
 
enum  color_order_e : uint8_t { COLORORDER_RGB = 0x72 , COLORORDER_BGR = 0x76 }
 Set the pixel color order RGB mapping. More...
 
enum  display_mode_e : uint8_t { DISPLAY_INVERSE , DISPLAY_NORMAL , DISPLAY_ALL_ON , DISPLAY_ALL_OFF }
 Set the display mode. More...
 
- Public Types inherited from color16_graphics
enum  pixel_color565_e : uint16_t {
  RDLC_BLACK = 0x0000 , RDLC_BLUE = 0x001F , RDLC_RED = 0xF800 , RDLC_GREEN = 0x07E0 ,
  RDLC_CYAN = 0x07FF , RDLC_MAGENTA = 0xF81F , RDLC_YELLOW = 0xFFE0 , RDLC_WHITE = 0xFFFF ,
  RDLC_TAN = 0xED01 , RDLC_GREY = 0x9CD1 , RDLC_BROWN = 0x6201 , RDLC_DGREEN = 0x01C0 ,
  RDLC_ORANGE = 0xFC00 , RDLC_NAVY = 0x000F , RDLC_DCYAN = 0x03EF , RDLC_MAROON = 0x7800 ,
  RDLC_PURPLE = 0x780F , RDLC_OLIVE = 0x7BE0 , RDLC_LGREY = 0xC618 , RDLC_DGREY = 0x7BEF ,
  RDLC_GYELLOW = 0xAFE5 , RDLC_PINK = 0xFC18 , RDLC_LBLUE = 0x7E5F , RDLC_BEIGE = 0xB5D2
}
 16-bit color definitions (RGB565 format). More...
 
enum  display_rotate_e : uint8_t { Degrees_0 = 0 , Degrees_90 , Degrees_180 , Degrees_270 }
 
- Public Types inherited from Print
enum  BaseNum : uint8_t { RDL_DEC = 10 , RDL_HEX = 16 , RDL_OCT = 8 , RDL_BIN = 2 }
 

Public Member Functions

 SSD1331_OLED (color_order_e, const Constrast_values_t &contrast, const Dim_Constrast_values_t &dimContrast)
 Constructor for class SSD1331_OLED.
 
virtual void setAddrWindow (uint16_t, uint16_t, uint16_t, uint16_t) override
 SPI displays set an address window rectangle for blitting pixels.
 
void OLEDSetupGPIO (int8_t, int8_t, int8_t, int8_t, int8_t)
 sets up OLED GPIO for software SPI
 
void OLEDSetupGPIO (int8_t, int8_t)
 sets up OLED GPIO for Hardware SPi
 
void OLEDInitScreenSize (uint16_t w, uint16_t h)
 initialise the variables that define the size of the screen
 
rdlib::Return_Codes_e OLEDInitSPI (uint16_t CommDelay, int gpioDev)
 intialise PCBtype and SPI, Software SPI
 
rdlib::Return_Codes_e OLEDInitSPI (int device, int channel, int speed, int flags, int gpioDev)
 intialise SPI, Hardware SPI
 
rdlib::Return_Codes_e OLEDResetPin (void)
 Method for Hardware Reset pin control.
 
uint16_t HighFreqDelayGet (void)
 Freq delay used in SW SPI getter, uS delay used in SW SPI method.
 
void HighFreqDelaySet (uint16_t)
 Freq delay used in SW SPI setter, uS delay used in SW SPI method.
 
rdlib::Return_Codes_e OLEDPowerDown (void)
 Call when powering down OLED.
 
void OLEDsetRotation (display_rotate_e r)
 : change rotation of display.
 
void OLEDchangeDisplayMode (display_mode_e)
 change the display mode
 
void OLEDDimDisplay (void)
 enable dim mode
 
void OLEDenableDisplay (void)
 enable display mode
 
void OLEDsleepDisplay (void)
 enable sleep mode
 
void OLEDClearWindowCmd (uint8_t c1, uint8_t r1, uint8_t c2, uint8_t r2)
 Clears a specific rectangular window on the OLED display.
 
void OLEDCopyWindowCmd (uint8_t c1, uint8_t r1, uint8_t c2, uint8_t r2, uint8_t c3, uint8_t r3)
 Copies a specific rectangular window to a new position on the OLED display.
 
void OLEDDimWindowCmd (uint8_t c1, uint8_t r1, uint8_t c2, uint8_t r2)
 Dims a specific rectangular window on the OLED display.
 
void OLEDDrawLineCmd (uint8_t c1, uint8_t r1, uint8_t c2, uint8_t r2, uint16_t color)
 Draws a line between two points on the OLED display.
 
void OLEDDrawRectCmd (uint8_t c1, uint8_t r1, uint8_t c2, uint8_t r2, uint16_t color, bool fill)
 Draws a rectangle on the OLED display, with optional filling. This function issues a command to draw a rectangle with the specified coordinates and color. The rectangle can be either outlined or filled. The function also accounts for screen rotation when determining coordinates.
 
void OLEDScroll (scroll_control_e)
 : This method is used to turn scroll on or off
 
void OLEDScrollSetup (uint8_t, uint8_t, uint8_t, uint8_t, scroll_time_interval_e)
 This method setups up horizontal and vertical scrolling register _CMD_CONT_SCROLL_SET.
 
- Public Member Functions inherited from color16_graphics
 color16_graphics ()
 Construct a new graphics class object.
 
void fillScreen (uint16_t color)
 Fills the whole screen with a given color.
 
void setCursor (int16_t x, int16_t y)
 Set the Cursor Position on screen.
 
void drawPixel (uint16_t, uint16_t, uint16_t)
 Draw a pixel to screen.
 
rdlib::Return_Codes_e drawDotGrid (int16_t x, int16_t y, int16_t w, int16_t h, uint8_t DotGridGap, uint16_t color)
 Draws a grid of dots on the screen starting from the given coordinates. This function draws a grid of pixels with a specified gap between them. It checks that the provided coordinates and dimensions are within the screen bounds and adjusts them if necessary. It also validates The grid of dots gap value and defaults it to 2 if invalid.
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 draws a line from (x0,y0) to (x1,y1).
 
rdlib::Return_Codes_e drawFastVLine (uint16_t x, uint16_t y, uint16_t h, uint16_t color)
 Draws a vertical line starting at (x,y) with height h.
 
rdlib::Return_Codes_e drawFastHLine (uint16_t x, uint16_t y, uint16_t w, uint16_t color)
 Draws a horizontal line starting at (x,y) with width w.
 
void drawLineAngle (int16_t x, int16_t y, int angle, uint8_t start, uint8_t length, int offset, uint16_t color)
 Draws a line using an angle and length as parameters. This function draws a line starting from (x, y), extending in the direction specified by angle, with a given length. The function also allows applying an offset to the angle before computing the line’s end coordinates.
 
void drawRectWH (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
 draws rectangle at (x,y) where h is height and w is width of the rectangle.
 
rdlib::Return_Codes_e fillRectangle (uint16_t, uint16_t, uint16_t, uint16_t, uint16_t)
 fills a rectangle starting from coordinates (x,y) with width of w and height of h.
 
void fillRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
 fills a rectangle at (x,y) where h is height and w is width of the rectangle.
 
void drawRoundRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r, uint16_t color)
 draws a rectangle with rounded edges
 
void fillRoundRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r, uint16_t color)
 Fills a rectangle with rounded edges.
 
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 draws a circle where (x0,y0) are center coordinates an r is circle radius.
 
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 fills a circle where (x0,y0) are center coordinates an r is circle radius.
 
void drawEllipse (int16_t cx, int16_t cy, int16_t semiMajorAxis, int16_t semiMinorAxis, bool fill, uint16_t color)
 Draw an ellipse on the display. This function uses the midpoint ellipse algorithm to efficiently draw an ellipse centered at (cx, cy) with the given semi-major (horizontal) and semi-minor (vertical) axes.
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 draws a triangle of coordinates (x0,y0), (x1,y1) and (x2,y2).
 
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Fills a triangle of coordinates (x0,y0), (x1,y1) and (x2,y2).
 
void drawQuadrilateral (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint16_t color)
 Draws a quadrilateral (four-sided polygon) by connecting four points with lines. This function draws a quadrilateral by drawing four lines between the given vertices. The lines are drawn in the order: (x0, y0) to (x1, y1), (x1, y1) to (x2, y2), (x2, y2) to (x3, y3), and finally (x3, y3) back to (x0, y0).
 
void fillQuadrilateral (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint16_t color, bool useTriangleSplit=true)
 Fills a quadrilateral with the specified color using triangles. This function fills a quadrilateral by dividing it into triangles and filling them individually. The quadrilateral is filled by calling the fillTriangle function three times with appropriate vertex coordinates. The useTriangleSplit parameter determines whether the quadrilateral is divided into two triangles or if only one triangle is used.
 
rdlib::Return_Codes_e drawPolygon (int16_t x, int16_t y, uint8_t sides, int16_t diameter, float rotation, bool fill, uint16_t color)
 Draws a polygon with a specified number of sides, diameter, rotation, and color. This function draws a regular polygon by connecting points equally spaced around a circle, with each point having a distance defined by the diameter. The polygon is rotated by the given angle (in degrees) before being drawn. The number of sides is enforced to be at least 3.
 
void drawSimpleArc (int16_t cx, int16_t cy, int16_t radius, float startAngle, float endAngle, uint16_t color)
 Draw a simple arc of one pixel on the display( no offsets , thickness or maximum arc calculations) This function draws an arc between two angles (start and end) on a circle with a given radius.
 
void drawArc (uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float startAngle, float endAngle, uint16_t color)
 Draw an arc on the TFT display. This function draws an arc between two angles (start and end) on a circle with a given radius.
 
float getArcAngleMax () const
 Get the current maximum angle of the arc.
 
void setArcAngleMax (float arcAngleMax)
 Set a new maximum angle for the arc.
 
int getArcAngleOffset () const
 Get the current angle offset.
 
void setArcAngleOffset (int arcAngleOffset)
 Set a new angle offset.
 
virtual size_t write (uint8_t) override
 write method used in the print class when user calls print
 
rdlib::Return_Codes_e writeChar (int16_t x, int16_t y, char value)
 Write 1 character on Display.
 
rdlib::Return_Codes_e writeCharString (int16_t x, int16_t y, char *text)
 Write Text character array on display.
 
void setTextWrap (bool w)
 turn on or off screen wrap of the text (fonts 1-6)
 
void setTextColor (uint16_t c, uint16_t bg)
 Set text color foreground and background.
 
void setTextColor (uint16_t c)
 Set text color foreground.
 
rdlib::Return_Codes_e drawIcon (uint16_t x, uint16_t y, uint16_t w, uint16_t color, uint16_t bgcolor, const std::span< const uint8_t > data)
 Draws an custom Icon of X by 8 size to screen , where X = 0 to 127.
 
rdlib::Return_Codes_e drawBitmap (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint16_t bgcolor, const std::span< const uint8_t > data)
 : Draws an bi-color bitmap to screen
 
rdlib::Return_Codes_e drawBitmap24 (uint16_t x, uint16_t y, const std::span< const uint8_t > data, uint16_t w, uint16_t h)
 Draws an 24 bit color bitmap to screen from a data array.
 
rdlib::Return_Codes_e drawBitmap16 (uint16_t x, uint16_t y, const std::span< const uint8_t > data, uint16_t w, uint16_t h)
 : Draws an 16 bit color bitmap to screen from a data array
 
rdlib::Return_Codes_e drawSprite (uint16_t x, uint16_t y, const std::span< const uint8_t > data, uint16_t w, uint16_t h, uint16_t backgroundColor)
 : Draws an 16 bit color sprite bitmap to screen with transparent background
 
int16_t Color565 (int16_t, int16_t, int16_t)
 : Convert: 24-bit color to 565 16-bit color
 
int getDisplaySPIBlockSize () const
 Gets the maximum SPI transaction block size.
 
void setDisplaySPIBlockSize (int size)
 Sets the maximum SPI transaction block size.
 
- Public Member Functions inherited from display_Fonts
 display_Fonts ()
 init the OLED font class object constructor
 
rdlib::Return_Codes_e setFont (display_Font_name_e)
 SetFont.
 
void setInvertFont (bool invertStatus)
 setInvertFont
 
bool getInvertFont (void)
 getInvertFont
 
- Public Member Functions inherited from Print
int getWriteError ()
 gets the error flag status, zero no error
 
void clearWriteError ()
 clears the error flag by setting it to zero
 
virtual size_t write (const uint8_t *buffer, size_t size)
 define in the sub class
 
size_t write (const char *str)
 Writes a string to the output.
 
size_t write (const char *buffer, size_t size)
 Writes a buffer of a specified size to the output.
 
virtual int availableForWrite ()
 define in the sub class
 
size_t print (const char[])
 print an array
 
size_t print (char)
 print an character
 
size_t print (int, int=RDL_DEC)
 print an integer of base number system
 
size_t print (unsigned int, int=RDL_DEC)
 print an unsigned integer of base number system
 
size_t print (long, int=RDL_DEC)
 print an long integer of base number system
 
size_t print (unsigned long, int=RDL_DEC)
 print an unsigned long integer of base number system
 
size_t print (double, int=2)
 print an double
 
size_t print (const std::string &)
 print an C++ string object
 
size_t println (const char[])
 Prints a character array followed by a newline.
 
size_t println (char)
 print an character followed by new line
 
size_t println (int, int=RDL_DEC)
 print an integer of base number system followed by new line
 
size_t println (unsigned int, int=RDL_DEC)
 print an unsigned integer of base number system followed by new line
 
size_t println (long, int=RDL_DEC)
 print an long integer of base number system followed by new line
 
size_t println (unsigned long, int=RDL_DEC)
 print an unsigned long integer of base number system followed by new line
 
size_t println (double, int=2)
 print an double
 
size_t println (void)
 Goto to new line.
 
size_t println (const std::string &s)
 print an C++ string object followed by new line
 
template<typename T >
size_t print (const std::vector< T > &v, int format=defaultFormat< T >())
 Print a vector of any type.
 
template<typename T >
size_t println (const std::vector< T > &vec, int format=defaultFormat< T >())
 Print a vector of elements followed by a newline.
 
template<typename T , size_t N>
size_t print (const std::array< T, N > &arr, int format=defaultFormat< T >())
 Print a std::array of any type.
 
template<typename T , size_t N>
size_t println (const std::array< T, N > &arr, int format=defaultFormat< T >())
 Print a std::array of elements followed by a newline.
 

Private Member Functions

void OLEDConfigueDimMode (void)
 Command sequence for configure Dim mode contrast.
 
void OLEDConfigueContrast (void)
 Command sequence for configure contrast.
 
rdlib::Return_Codes_e OLEDDataCommandPin (void)
 : Method for Data or Command pin setup
 
rdlib::Return_Codes_e OLEDClock_Data_ChipSelect_Pins (void)
 : Method for Clock, data and chip select pin setup routine for software SPI.
 
rdlib::Return_Codes_e OLEDSSD1331Initialize (void)
 init routine for SSD1331 controller
 
void cmdBegin (void)
 Command Initialization sequence for SSD1331 display.
 
void WriteColor16 (uint16_t colorWrite)
 Writes a 16-bit RGB565 color to the SSD1331 OLED display. This function extracts the red, green, and blue components from the 16-bit RGB565 color value and sends them as 6-bit values to the display. RRRRR GGGGGG BBBBB.
 

Private Attributes

uint16_t _widthStartOLED = 96
 
uint16_t _heightStartOLED = 64
 
color_order_e _colorOrder = COLORORDER_RGB
 
display_rotate_e _displayRotate = Degrees_0
 
Constrast_values_t ContrastValues = { 0x7D, 0x7D, 0x7D }
 
Dim_Constrast_values_t DimContrastValues { 0x1E, 0x1E, 0x1E }
 
int _spiDev = 0
 
int _spiChan = 0
 
int _spiBaud = 50000
 
int _spiFlags = 0
 

Static Private Attributes

static constexpr uint8_t _CMD_DRAWLINE = 0x21
 
static constexpr uint8_t _CMD_DRAWRECT = 0x22
 
static constexpr uint8_t _CMD_COPY_WINDOW = 0x23
 
static constexpr uint8_t _CMD_DIM_WINDOW = 0x24
 
static constexpr uint8_t _CMD_CLEAR_WINDOW = 0x25
 
static constexpr uint8_t _CMD_FILL = 0x26
 
static constexpr uint8_t _CMD_DISABLE_FILL = 0x00
 
static constexpr uint8_t _CMD_ENABLE_FILL = 0x01
 
static constexpr uint8_t _CMD_CONT_SCROLL_SET =0x27
 
static constexpr uint8_t _CMD_DEACTIVE_SCROLL = 0x2E
 
static constexpr uint8_t _CMD_ACTIVE_SCROLL = 0x2F
 
static constexpr uint8_t _CMD_SETCOLUMN = 0x15
 
static constexpr uint8_t _CMD_SETROW = 0x75
 
static constexpr uint8_t _CMD_CONTRASTA = 0x81
 
static constexpr uint8_t _CMD_CONTRASTB = 0x82
 
static constexpr uint8_t _CMD_CONTRASTC = 0x83
 
static constexpr uint8_t _CMD_MASTERCURRENT = 0x87
 
static constexpr uint8_t _CMD_PRECHARGEA = 0x8A
 
static constexpr uint8_t _CMD_PRECHARGEB = 0x8B
 
static constexpr uint8_t _CMD_PRECHARGEC = 0x8C
 
static constexpr uint8_t _CMD_SETREMAP = 0xA0
 
static constexpr uint8_t _CMD_STARTLINE = 0xA1
 
static constexpr uint8_t _CMD_DISPLAYOFFSET = 0xA2
 
static constexpr uint8_t _CMD_NORMALDISPLAY = 0xA4
 
static constexpr uint8_t _CMD_DISPLAYALLON = 0xA5
 
static constexpr uint8_t _CMD_DISPLAYALLOFF = 0xA6
 
static constexpr uint8_t _CMD_INVERTDISPLAY = 0xA7
 
static constexpr uint8_t _CMD_SETMULTIPLEX = 0xA8
 
static constexpr uint8_t _CMD_DIM_MODE_SET =0xAB
 
static constexpr uint8_t _CMD_DIM_MODE_ON = 0xAC
 
static constexpr uint8_t _CMD_SETMASTER = 0xAD
 
static constexpr uint8_t _CMD_DISPLAYOFF = 0xAE
 
static constexpr uint8_t _CMD_DISPLAYON = 0xAF
 
static constexpr uint8_t _CMD_POWERMODE = 0xB0
 
static constexpr uint8_t _CMD_PRECHARGE = 0xB1
 
static constexpr uint8_t _CMD_CLOCKDIV = 0xB3
 
static constexpr uint8_t _CMD_SET_GRAYSCALE = 0xB8
 
static constexpr uint8_t _CMD_ENABLE_GRAYSCALE =0xB9
 
static constexpr uint8_t _CMD_PRECHARGE_VOLT = 0xBB
 
static constexpr uint8_t _CMD_V_VOLTAGE = 0xBE
 

Additional Inherited Members

- Protected Member Functions inherited from color16_graphics
void pushColor (uint16_t color)
 pushColor
 
void writeCommand (uint8_t)
 : Write an SPI command to
 
void writeData (uint8_t)
 Write an SPI data byte to device.
 
void spiWrite (uint8_t)
 Write byte to SPI.
 
void spiWriteDataBuffer (uint8_t *spidata, int len)
 Write a buffer to SPI, both Software and hardware SPI supported.
 
- Protected Member Functions inherited from Print
void setWriteError (int err=0)
 
- Protected Attributes inherited from color16_graphics
bool _textwrap = true
 
uint16_t _textcolor = 0xFFFF
 
uint16_t _textbgcolor = 0x0000
 
int16_t _cursorX = 0
 
int16_t _cursorY = 0
 
uint16_t _width
 
uint16_t _height
 
uint8_t _XStart = 0
 
uint8_t _YStart = 0
 
float _arcAngleMax = 360.0f
 
int _arcAngleOffset = 0
 
int8_t _Display_DC
 
int8_t _Display_RST
 
int8_t _Display_CS
 
int8_t _Display_SCLK
 
int8_t _Display_SDATA
 
int8_t _Display_MISO
 
int _DeviceNumGpioChip = 0
 
int _GpioHandle = 0
 
bool _hardwareSPI =true
 
uint16_t _HighFreqDelay = 0
 
int _spiHandle = 0
 
- Protected Attributes inherited from display_Fonts
std::span< const uint8_t > _FontSelect = pFontDefault
 
uint8_t _Font_X_Size = 0x08
 
uint8_t _Font_Y_Size = 0x08
 
uint8_t _FontOffset = 0x20
 
uint8_t _FontNumChars = 0x5F
 

Detailed Description

Class to control SSD1331 OLED basic functionality.

Member Enumeration Documentation

◆ color_order_e

Set the pixel color order RGB mapping.

This command bit a[2](0x04) is made for flexible layout of segment signals in OLED module to match filter design. If user color is inverted: try the other setting.

Enumerator
COLORORDER_RGB 

A[2]=0, normal order SA,SB,SC (e.g. RGB)

COLORORDER_BGR 

A[2]=1, reverse order SC,SB,SA (e.g. BGR)

◆ display_mode_e

Set the display mode.

Enumerator
DISPLAY_INVERSE 

The gray level of display data are swapped such that “GS0” <-> “GS63”, “GS1” <-> “GS62”,

DISPLAY_NORMAL 

Reset the other effects and turn the data to ON at the corresponding gray level.

DISPLAY_ALL_ON 

Forces the entire display to be at “GS63” regardless of the contents of the display data RAM.

DISPLAY_ALL_OFF 

Forces the entire display to be at gray level “GS0” regardless of the contents of the display data RAM

◆ scroll_control_e

Set the Scroll mode on or off according to the setting done by OLEDScrollSetup()

Enumerator
SCROLL_ACTIVATE 

This command activates the scrolling function

SCROLL_DEACTIVE 

This command deactivates the scrolling action

◆ scroll_time_interval_e

Set the Set time interval between each scroll.

Enumerator
SCROLL_FRAME_6 

6 frames

SCROLL_FRAME_10 

10 frames

SCROLL_FRAME_100 

100 frames

SCROLL_FRAME_200 

200 frames

Constructor & Destructor Documentation

◆ SSD1331_OLED()

SSD1331_OLED::SSD1331_OLED ( color_order_e  colororder,
const Constrast_values_t contrast,
const Dim_Constrast_values_t dimContrast 
)

Constructor for class SSD1331_OLED.

Parameters
colororderThe enum value from color_order_e RGB or BGR color mode
contrastStruct containing 3 color values for normal mode contrast
dimContrastStruct containing 3 color values for dim mode contrast

Member Function Documentation

◆ HighFreqDelayGet()

uint16_t SSD1331_OLED::HighFreqDelayGet ( void  )

Freq delay used in SW SPI getter, uS delay used in SW SPI method.

Returns
The GPIO communications delay in uS

◆ HighFreqDelaySet()

void SSD1331_OLED::HighFreqDelaySet ( uint16_t  CommDelay)

Freq delay used in SW SPI setter, uS delay used in SW SPI method.

Parameters
CommDelayThe GPIO communications delay in uS

◆ OLEDchangeDisplayMode()

void SSD1331_OLED::OLEDchangeDisplayMode ( display_mode_e  mode)

change the display mode

Parameters
modeenum containing the display modes available

◆ OLEDClearWindowCmd()

void SSD1331_OLED::OLEDClearWindowCmd ( uint8_t  column1,
uint8_t  row1,
uint8_t  column2,
uint8_t  row2 
)

Clears a specific rectangular window on the OLED display.

Parameters
column1Starting column (X coordinate) of the window
row1Starting row (Y coordinate) of the window
column2Ending column (X coordinate) of the window
row2Ending row (Y coordinate) of the window
Note
The coordinates must be within the display bounds
Uses the SSD1331 _CMD_CLEAR_WINDOW command.
A small delay is added (delayMicroSecRDL(500)) to allow processing time.

◆ OLEDClock_Data_ChipSelect_Pins()

rdlib::Return_Codes_e SSD1331_OLED::OLEDClock_Data_ChipSelect_Pins ( void  )
private

: Method for Clock, data and chip select pin setup routine for software SPI.

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioPinClaim

◆ OLEDCopyWindowCmd()

void SSD1331_OLED::OLEDCopyWindowCmd ( uint8_t  column1,
uint8_t  row1,
uint8_t  column2,
uint8_t  row2,
uint8_t  column3,
uint8_t  row3 
)

Copies a specific rectangular window to a new position on the OLED display.

Parameters
column1Starting column (X coordinate) of the source window (Range: 0-95).
row1Starting row (Y coordinate) of the source window (Range: 0-63).
column2Ending column (X coordinate) of the source window (Range: 0-95).
row2Ending row (Y coordinate) of the source window (Range: 0-63).
column3Destination column (X coordinate) where the copied window will be placed (Range: 0-95).
row3Destination row (Y coordinate) where the copied window will be placed (Range: 0-63).
Note
The coordinates must be within the display bounds (96x64 pixels).
Uses the SSD1331 _CMD_COPY_WINDOW command.
A small delay is added (delayMicroSecRDL(500)) to allow processing time.

◆ OLEDDataCommandPin()

rdlib::Return_Codes_e SSD1331_OLED::OLEDDataCommandPin ( void  )
private

: Method for Data or Command pin setup

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioPinClaim

◆ OLEDDimWindowCmd()

void SSD1331_OLED::OLEDDimWindowCmd ( uint8_t  column1,
uint8_t  row1,
uint8_t  column2,
uint8_t  row2 
)

Dims a specific rectangular window on the OLED display.

Parameters
column1Starting column (X coordinate) of the window to be dimmed
row1Starting row (Y coordinate) of the window to be dimmed
column2Ending column (X coordinate) of the window to be dimmed
row2Ending row (Y coordinate) of the window to be dimmed
Note
The coordinates must be within the display bounds .
Uses the SSD1331 _CMD_DIM_WINDOW command.
A small delay is added (delayMicroSecRDL(500)) to allow processing time.

◆ OLEDDrawLineCmd()

void SSD1331_OLED::OLEDDrawLineCmd ( uint8_t  c1,
uint8_t  r1,
uint8_t  c2,
uint8_t  r2,
uint16_t  color 
)

Draws a line between two points on the OLED display.

Parameters
c1Starting column (X coordinate) of the line (Range: 0-95).
r1Starting row (Y coordinate) of the line (Range: 0-63).
c2Ending column (X coordinate) of the line (Range: 0-95).
r2Ending row (Y coordinate) of the line (Range: 0-63).
color16-bit RGB565 color value for the line.
Note
this uses built-in OLED command NOT the graphics library.

◆ OLEDDrawRectCmd()

void SSD1331_OLED::OLEDDrawRectCmd ( uint8_t  c1,
uint8_t  r1,
uint8_t  c2,
uint8_t  r2,
uint16_t  color,
bool  fill 
)

Draws a rectangle on the OLED display, with optional filling. This function issues a command to draw a rectangle with the specified coordinates and color. The rectangle can be either outlined or filled. The function also accounts for screen rotation when determining coordinates.

Parameters
c1Starting column (X coordinate) of the rectangle.
r1Starting row (Y coordinate) of the rectangle.
c2Ending column (X coordinate) of the rectangle.
r2Ending row (Y coordinate) of the rectangle.
colorThe 16-bit RGB565 color value for the rectangle.
fillIf true, the rectangle will be filled with the specified color. If false, only the border will be drawn.
Note
this uses built-in OLED command NOT the graphics library.

◆ OLEDInitScreenSize()

void SSD1331_OLED::OLEDInitScreenSize ( uint16_t  width_OLED,
uint16_t  height_OLED 
)

initialise the variables that define the size of the screen

Parameters
width_OLEDwidth in pixels
height_OLEDheight in pixels

◆ OLEDInitSPI() [1/2]

rdlib::Return_Codes_e SSD1331_OLED::OLEDInitSPI ( int  device,
int  channel,
int  speed,
int  flags,
int  gpioDev 
)

intialise SPI, Hardware SPI

Parameters
deviceA SPI device, >= 0.
channelA SPI channel, >= 0.
speedThe speed of serial communication in bits per second.
flagsThe flags may be used to modify the default behaviour. Set to 0(mode 0) for this device.
gpioDevThe device number of a gpiochip.
Returns
  1. rdlib::Success = success
  2. upstream failure from OLEDSSD1331Initialize()
Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ OLEDInitSPI() [2/2]

rdlib::Return_Codes_e SSD1331_OLED::OLEDInitSPI ( uint16_t  CommDelay,
int  gpioDev 
)

intialise PCBtype and SPI, Software SPI

Parameters
CommDelayuS GPIO delay used in software SPI
gpioDevThe device number of a gpiochip.
Returns
  1. rdlib::Success = success
  2. upstream failure from OLEDSSD1331Initialize()
Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ OLEDPowerDown()

rdlib::Return_Codes_e SSD1331_OLED::OLEDPowerDown ( void  )

Call when powering down OLED.

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioChipDevice
  3. rdlib::GpioPinFree
  4. rdlib::SPIOpenClose

    Turns off Display, sets GPIO low and frees them,closes GPIO device, closes SPI handle.

◆ OLEDResetPin()

rdlib::Return_Codes_e SSD1331_OLED::OLEDResetPin ( void  )

Method for Hardware Reset pin control.

Returns
a rdlib::Return_Codes_e code
  1. rdlib::Success
  2. rdlib::GpioPinClaim

< Reset delay in mS

◆ OLEDScroll()

void SSD1331_OLED::OLEDScroll ( scroll_control_e  scrollActivate)

: This method is used to turn scroll on or off

Parameters
scrollActivateDeactive or active scroll called after OLEDScrollSetup()

◆ OLEDScrollSetup()

void SSD1331_OLED::OLEDScrollSetup ( uint8_t  horOffset,
uint8_t  startRowAddr,
uint8_t  numOfRows,
uint8_t  verOffset,
scroll_time_interval_e  scrollTimeInterval 
)

This method setups up horizontal and vertical scrolling register _CMD_CONT_SCROLL_SET.

Parameters
horOffsetSet num of col as h scroll Range: 0-95 ( no h scroll = 0)
startRowAddrDefine start row address 0-63
numOfRowsSet number of rows to be horizontal scrolled (startRowAddr + numOfRows) <= 64
verOffsetSet num of col as v scroll Range: 0-63 ( no v scroll = 0)
scrollTimeIntervalSet time interval between each scroll, enum

◆ OLEDsetRotation()

void SSD1331_OLED::OLEDsetRotation ( display_rotate_e  mode)

: change rotation of display.

Parameters
modeOLED_rotate_e enum 0 = Normal 1= 90 rotate 2 = 180 rotate 3 = 270 rotate

◆ OLEDSetupGPIO() [1/2]

void SSD1331_OLED::OLEDSetupGPIO ( int8_t  rst,
int8_t  dc 
)

sets up OLED GPIO for Hardware SPi

Parameters
rstreset GPIO
dcdata or command GPIO.
Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ OLEDSetupGPIO() [2/2]

void SSD1331_OLED::OLEDSetupGPIO ( int8_t  rst,
int8_t  dc,
int8_t  cs,
int8_t  sclk,
int8_t  din 
)

sets up OLED GPIO for software SPI

Parameters
rstreset GPIO
dcdata or command GPIO.
cschip select GPIO
sclkData clock GPIO
dinData to OLED GPIO
Note
overloaded 2 off, 1 for HW SPI , 1 for SW SPI

◆ OLEDSSD1331Initialize()

rdlib::Return_Codes_e SSD1331_OLED::OLEDSSD1331Initialize ( void  )
private

◆ setAddrWindow()

void SSD1331_OLED::setAddrWindow ( uint16_t  x,
uint16_t  y,
uint16_t  w,
uint16_t  h 
)
overridevirtual

SPI displays set an address window rectangle for blitting pixels.

Parameters
xTop left corner x coordinate
yTop left corner y coordinate
wWidth of window
hHeight of window
Note
virtual function overloads graphics library

Implements color16_graphics.

◆ WriteColor16()

void SSD1331_OLED::WriteColor16 ( uint16_t  colorWrite)
private

Writes a 16-bit RGB565 color to the SSD1331 OLED display. This function extracts the red, green, and blue components from the 16-bit RGB565 color value and sends them as 6-bit values to the display. RRRRR GGGGGG BBBBB.

Parameters
colorWrite16-bit RGB565 color value to be written to the display.

Member Data Documentation

◆ _CMD_ACTIVE_SCROLL

constexpr uint8_t SSD1331_OLED::_CMD_ACTIVE_SCROLL = 0x2F
staticconstexprprivate

Activate scrolling

◆ _CMD_CLEAR_WINDOW

constexpr uint8_t SSD1331_OLED::_CMD_CLEAR_WINDOW = 0x25
staticconstexprprivate

Clear a window

◆ _CMD_CLOCKDIV

constexpr uint8_t SSD1331_OLED::_CMD_CLOCKDIV = 0xB3
staticconstexprprivate

Set clk divide ratio/oscillator freq

◆ _CMD_CONT_SCROLL_SET

constexpr uint8_t SSD1331_OLED::_CMD_CONT_SCROLL_SET =0x27
staticconstexprprivate

Continuous Horizontal & Vertical Scrolling Setup

◆ _CMD_CONTRASTA

constexpr uint8_t SSD1331_OLED::_CMD_CONTRASTA = 0x81
staticconstexprprivate

Set contrast for colour A

◆ _CMD_CONTRASTB

constexpr uint8_t SSD1331_OLED::_CMD_CONTRASTB = 0x82
staticconstexprprivate

Set contrast for colour B

◆ _CMD_CONTRASTC

constexpr uint8_t SSD1331_OLED::_CMD_CONTRASTC = 0x83
staticconstexprprivate

Set contrast for colour C

◆ _CMD_COPY_WINDOW

constexpr uint8_t SSD1331_OLED::_CMD_COPY_WINDOW = 0x23
staticconstexprprivate

Copy a window

◆ _CMD_DEACTIVE_SCROLL

constexpr uint8_t SSD1331_OLED::_CMD_DEACTIVE_SCROLL = 0x2E
staticconstexprprivate

Deactivate scrolling

◆ _CMD_DIM_MODE_ON

constexpr uint8_t SSD1331_OLED::_CMD_DIM_MODE_ON = 0xAC
staticconstexprprivate

Enable Dim mode

◆ _CMD_DIM_MODE_SET

constexpr uint8_t SSD1331_OLED::_CMD_DIM_MODE_SET =0xAB
staticconstexprprivate

Configure settings for dim mode

◆ _CMD_DIM_WINDOW

constexpr uint8_t SSD1331_OLED::_CMD_DIM_WINDOW = 0x24
staticconstexprprivate

Dim a window

◆ _CMD_DISABLE_FILL

constexpr uint8_t SSD1331_OLED::_CMD_DISABLE_FILL = 0x00
staticconstexprprivate

used with _CMD_FILL to not fill rect

◆ _CMD_DISPLAYALLOFF

constexpr uint8_t SSD1331_OLED::_CMD_DISPLAYALLOFF = 0xA6
staticconstexprprivate

Set entire display OFF

◆ _CMD_DISPLAYALLON

constexpr uint8_t SSD1331_OLED::_CMD_DISPLAYALLON = 0xA5
staticconstexprprivate

Set entire display ON

◆ _CMD_DISPLAYOFF

constexpr uint8_t SSD1331_OLED::_CMD_DISPLAYOFF = 0xAE
staticconstexprprivate

Display OFF (sleep mode)

◆ _CMD_DISPLAYOFFSET

constexpr uint8_t SSD1331_OLED::_CMD_DISPLAYOFFSET = 0xA2
staticconstexprprivate

Set display offset

◆ _CMD_DISPLAYON

constexpr uint8_t SSD1331_OLED::_CMD_DISPLAYON = 0xAF
staticconstexprprivate

Normal Brightness Display ON

◆ _CMD_DRAWLINE

constexpr uint8_t SSD1331_OLED::_CMD_DRAWLINE = 0x21
staticconstexprprivate

Draw line Command

◆ _CMD_DRAWRECT

constexpr uint8_t SSD1331_OLED::_CMD_DRAWRECT = 0x22
staticconstexprprivate

Draw rectangle command

◆ _CMD_ENABLE_FILL

constexpr uint8_t SSD1331_OLED::_CMD_ENABLE_FILL = 0x01
staticconstexprprivate

used with _CMD_FILL to fill rect

◆ _CMD_ENABLE_GRAYSCALE

constexpr uint8_t SSD1331_OLED::_CMD_ENABLE_GRAYSCALE =0xB9
staticconstexprprivate

Reloads preset linear gray scale table

◆ _CMD_FILL

constexpr uint8_t SSD1331_OLED::_CMD_FILL = 0x26
staticconstexprprivate

Fill enable/disable used with Draw rect

◆ _CMD_INVERTDISPLAY

constexpr uint8_t SSD1331_OLED::_CMD_INVERTDISPLAY = 0xA7
staticconstexprprivate

Invert display

◆ _CMD_MASTERCURRENT

constexpr uint8_t SSD1331_OLED::_CMD_MASTERCURRENT = 0x87
staticconstexprprivate

Master current control

◆ _CMD_NORMALDISPLAY

constexpr uint8_t SSD1331_OLED::_CMD_NORMALDISPLAY = 0xA4
staticconstexprprivate

Set display to normal mode

◆ _CMD_POWERMODE

constexpr uint8_t SSD1331_OLED::_CMD_POWERMODE = 0xB0
staticconstexprprivate

Power save mode

◆ _CMD_PRECHARGE

constexpr uint8_t SSD1331_OLED::_CMD_PRECHARGE = 0xB1
staticconstexprprivate

Phase 1 and 2 period adjustment

◆ _CMD_PRECHARGE_VOLT

constexpr uint8_t SSD1331_OLED::_CMD_PRECHARGE_VOLT = 0xBB
staticconstexprprivate

Set pre-charge voltage

◆ _CMD_PRECHARGEA

constexpr uint8_t SSD1331_OLED::_CMD_PRECHARGEA = 0x8A
staticconstexprprivate

Set second pre-charge speed for colour A

◆ _CMD_PRECHARGEB

constexpr uint8_t SSD1331_OLED::_CMD_PRECHARGEB = 0x8B
staticconstexprprivate

Set second pre-charge speed for colour B

◆ _CMD_PRECHARGEC

constexpr uint8_t SSD1331_OLED::_CMD_PRECHARGEC = 0x8C
staticconstexprprivate

Set second pre-charge speed for colour C

◆ _CMD_SET_GRAYSCALE

constexpr uint8_t SSD1331_OLED::_CMD_SET_GRAYSCALE = 0xB8
staticconstexprprivate

Sets the gray scale table

◆ _CMD_SETCOLUMN

constexpr uint8_t SSD1331_OLED::_CMD_SETCOLUMN = 0x15
staticconstexprprivate

Set column address

◆ _CMD_SETMASTER

constexpr uint8_t SSD1331_OLED::_CMD_SETMASTER = 0xAD
staticconstexprprivate

Set master configuration

◆ _CMD_SETMULTIPLEX

constexpr uint8_t SSD1331_OLED::_CMD_SETMULTIPLEX = 0xA8
staticconstexprprivate

Set multiplex ratio

◆ _CMD_SETREMAP

constexpr uint8_t SSD1331_OLED::_CMD_SETREMAP = 0xA0
staticconstexprprivate

Set re-map & data format

◆ _CMD_SETROW

constexpr uint8_t SSD1331_OLED::_CMD_SETROW = 0x75
staticconstexprprivate

Set row address

◆ _CMD_STARTLINE

constexpr uint8_t SSD1331_OLED::_CMD_STARTLINE = 0xA1
staticconstexprprivate

Set display start line

◆ _CMD_V_VOLTAGE

constexpr uint8_t SSD1331_OLED::_CMD_V_VOLTAGE = 0xBE
staticconstexprprivate

Set Vcomh voltage

◆ _colorOrder

color_order_e SSD1331_OLED::_colorOrder = COLORORDER_RGB
private

Enum to hold color order

◆ _displayRotate

display_rotate_e SSD1331_OLED::_displayRotate = Degrees_0
private

Enum to hold rotation

◆ _heightStartOLED

uint16_t SSD1331_OLED::_heightStartOLED = 64
private

never change after first init

◆ _spiBaud

int SSD1331_OLED::_spiBaud = 50000
private

The speed of serial communication in bits per second.

◆ _spiChan

int SSD1331_OLED::_spiChan = 0
private

A SPI channel, >= 0.

◆ _spiDev

int SSD1331_OLED::_spiDev = 0
private

A SPI device, >= 0.

◆ _spiFlags

int SSD1331_OLED::_spiFlags = 0
private

The flags 2 LSB defines SPI mode, mode 0 for this device.

◆ _widthStartOLED

uint16_t SSD1331_OLED::_widthStartOLED = 96
private

never change after first init

◆ ContrastValues

Constrast_values_t SSD1331_OLED::ContrastValues = { 0x7D, 0x7D, 0x7D }
private

struct to hold normal mode contrast colors ABC

◆ DimContrastValues

Dim_Constrast_values_t SSD1331_OLED::DimContrastValues { 0x1E, 0x1E, 0x1E }
private

struct to hold dim mode contrast colors ABC


The documentation for this class was generated from the following files: