SSD1351 Controllers

This section covers GLCD devices that use the SSD1351 graphics controller. The SSD1351 is a single-chip controller/driver for 262K-color, graphic type OLED-LCD.

The GCBASIC constants shown below control the configuration of the SSD1351 controller.    GCBASIC supports SPI, hardware and software SPI, connectivity. This is shown in the tables below.

GCBASIC supports 65K-color mode operations.

To use the SSD1351 driver simply include the following in your user code. This will initialise the driver.

        #include <glcd.h>
        #define GLCD_TYPE GLCD_TYPE_SSD1351

        'Pin mappings for SPI - this GLCD driver supports Hardware SPI and Software SPI
        #define GLCD_DC       portb.0           ' Data command line
        #define GLCD_CS       portb.2           ' Chip select line
        #define GLCD_RESET    portb.1           ' Reset line
        #define GLCD_DO       portb.3           ' Data out | MOSI
        #define GLCD_SCK      portb.5           ' Clock Line

        #define SSD1351_HardwareSPI    ' remove/comment out if you want to use software SPI.  If you are using PPS to setup the SPI - ensure that PPS SPI is disabled to use software SPI.

The GCBASIC constants for control display characteristics are shown in the table below.

Constants Controls Options

GLCD_TYPE

GLCD_TYPE_SSD1351

 

GLCD_DC

Specifies the output pin that is connected to Data/Command IO pin on the GLCD.

Required

GLCD_CS

Specifies the output pin that is connected to Chip Select (CS) on the GLCD.

Required

GLCD_Reset

Specifies the output pin that is connected to Reset pin on the GLCD.

Required

GLCD_DO

Specifies the output pin that is connected to Data Out (GLCD in) pin on the GLCD.

Required

GLCD_SCK

Specifies the output pin that is connected to Clock (CLK) pin on the GLCD.

Required

SSD1351_HardwareSPI

Specifies that hardware SPI will be used

SPI ports MUST be defined that match the SPI module for each specific microcontroller

#define SSD1351_HardwareSPI

HWSPIMode

Specifies the speed of the SPI communications for Hardware SPI only.

Optional defaults to MASTERFAST.

Options are MASTERSLOW,
MASTER,
MASTERFAST, or
MASTERULTRAFAST for specific AVRs only.

The GCBASIC constants for control display characteristics are shown in the table below.

Constants Controls Default

GLCD_WIDTH

The width parameter of the GLCD

128
This cannot be changed

GLCD_HEIGHT

The height parameter of the GLCD

128
This cannot be changed

GLCDFontWidth

Specifies the font width of the GCBASIC font set.

6 or 5 for the OLED font set.

The GCBASIC commands supported for this GLCD are shown in the table below.   Always review the appropiate library for the latest full set of supported commands.

Command Purpose Example

GLCDCLS

Clear screen of GLCD

GLCDCLS

GLCDPrint

Print string of characters on GLCD using GCB font set

GLCDPrint( Xposition, Yposition, Stringvariable )

GLCDDrawChar

Print character on GLCD using GCB font set

GLCDDrawChar( Xposition, Yposition, CharCode )

GLCDDrawString

Print characters on GLCD using GCB font set

GLCDDrawString( Xposition, Yposition, Stringvariable )

Box

Draw a box on the GLCD to a specific size

Box ( Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour as 0 or 1] )

FilledBox

Draw a box on the GLCD to a specific size that is filled with the foreground colour.

FilledBox (Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour 0 or 1] )

Line

Draw a line on the GLCD to a specific length that is filled with the specific attribute.

Line ( Xposition1, Yposition1, Xposition2, Yposition2, [Optional In LineColour 0 or 1] )

PSet

Set a pixel on the GLCD at a specific position that is set with the specific attribute.

PSet(Xposition, Yposition, Pixel Colour 0 or 1)

Any color can be defined using a valid hexidecimal word value between 0x0000 to 0xFFFF.

   SSD1351_BLACK   'hexidecimal value 0x0000
   SSD1351_BLUE    'hexidecimal value 0xF800
   SSD1351_RED     'hexidecimal value 0x001F
   SSD1351_GREEN   'hexidecimal value 0x07E0
   SSD1351_CYAN    'hexidecimal value 0xFFE0
   SSD1351_MAGENTA 'hexidecimal value 0xF81F
   SSD1351_YELLOW  'hexidecimal value 0x07FF
   SSD1351_WHITE   'hexidecimal value 0xFFFF

Example:

    #chip mega328p, 16
    #option explicit

    #include <glcd.h>
    #define GLCD_TYPE GLCD_TYPE_SSD1351

    'Pin mappings for SPI - this GLCD driver supports Hardware SPI and Software SPI
    #define GLCD_DC       portb.0           ' Data command line
    #define GLCD_CS       portb.2           ' Chip select line
    #define GLCD_RESET    portb.1           ' Reset line
    #define GLCD_DO       portb.3           ' Data out | MOSI
    #define GLCD_SCK      portb.5           ' Clock Line

    #define SSD1351_HardwareSPI    ' remove/comment out if you want to use software SPI.

    'GLCD selected OLED font set.
    #define GLCD_OLED_FONT
    GLCDfntDefaultsize = 1

    GLCDCLS
    GLCDPrintStringLN ("GCBASIC")
    GLCDPrintStringLN ("")
    GLCDPrintStringLN ("Test of the SSD1351")
    GLCDPrintStringLN ("")
    GLCDPrintStringLN ("October 2021")
    end

For more help, see GLCDCLS, GLCDDrawChar, GLCDPrint, GLCDReadByte, GLCDWriteByte or Pset

Supported in <GLCD.H>