SSD1331 Controllers

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

The GCBASIC constants shown below control the configuration of the SSD1331 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 SSD1331 driver simply include the following in your user code. This will initialise the driver.

        #include <glcd.h>
        #include <UNO_mega328p.h >

        #define GLCD_TYPE GLCD_TYPE_SSD1331

        '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 SSD1331_HardwareSPI    ' remove/comment out if you want to use software SPI.

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

Constants Controls Options

GLCD_TYPE

GLCD_TYPE_SSD1331

 

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

SSD1331_HardwareSPI

Specifies that hardware SPI will be used

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

#define SSD1331_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

96
This cannot be changed

GLCD_HEIGHT

The height parameter of the GLCD

48
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.

   SSD1331_BLACK   'hexidecimal value 0x0000
   SSD1331_BLUE    'hexidecimal value 0xF800
   SSD1331_RED     'hexidecimal value 0x001F
   SSD1331_GREEN   'hexidecimal value 0x07E0
   SSD1331_CYAN    'hexidecimal value 0xFFE0
   SSD1331_MAGENTA 'hexidecimal value 0xF81F
   SSD1331_YELLOW  'hexidecimal value 0x07FF
   SSD1331_WHITE   'hexidecimal value 0xFFFF

Example:

    #chip mega328p, 16
    #option explicit

    #include <glcd.h>
    #include <UNO_mega328p.h >

    #define GLCD_TYPE GLCD_TYPE_SSD1331

    '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 SSD1331_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 SSD1331")
    GLCDPrintStringLN ("")
    GLCDPrintStringLN ("Anobium 2021")
    end

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

Supported in <GLCD.H>