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 |
|---|---|---|
|
|
|
|
|
|
Specifies the output pin that is connected to Data/Command IO pin on the GLCD. |
Required |
|
|
Specifies the output pin that is connected to Chip Select (CS) on the GLCD. |
Required |
|
|
Specifies the output pin that is connected to Reset pin on the GLCD. |
Required |
|
|
Specifies the output pin that is connected to Data Out (GLCD in) pin on the GLCD. |
Required |
|
|
Specifies the output pin that is connected to Clock (CLK) pin on the GLCD. |
Required |
|
|
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, |
The GCBASIC constants for control display characteristics are shown in the table below.
| Constants | Controls | Default |
|---|---|---|
|
|
The width parameter of the GLCD |
|
|
|
The height parameter of the GLCD |
|
|
|
Specifies the font width of the GCBASIC 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 |
|---|---|---|
|
|
Clear screen of GLCD |
|
|
|
Print string of characters on GLCD using GCB font set |
|
|
|
Print character on GLCD using GCB font set |
|
|
|
Print characters on GLCD using GCB font set |
|
|
|
Draw a box on the GLCD to a specific size |
|
|
|
Draw a box on the GLCD to a specific size that is filled with the foreground colour. |
|
|
|
Draw a line on the GLCD to a specific length that is filled with the specific attribute. |
|
|
|
Set a pixel on the GLCD at a specific position that is set with the specific attribute. |
Any color can be defined using a valid hexidecimal word value between 0x0000 to 0xFFFF. |
Colour RGB
TFT_BLACK 0x0000
TFT_NAVY 0x000F
TFT_DARKGREEN 0x03E0
TFT_DARKCYAN 0x03EF
TFT_MAROON 0x7800
TFT_PURPLE 0x780F
TFT_OLIVE 0x7BE0
TFT_LIGHTGREY 0xC618
TFT_DARKGREY 0x7BEF
TFT_BLUE 0x001F
TFT_GREEN 0x07E0
TFT_CYAN 0x77FF
TFT_RED 0xF800
TFT_MAGENTA 0xF81F
TFT_YELLOW 0xFFE0
TFT_WHITE 0xFFFF
TFT_ORANGE 0xFD20
TFT_GREENYELLOW 0xAFE5
TFT_PINK 0xF81FExample:
#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")
endFor more help, see GLCDCLS, GLCDDrawChar, GLCDPrint, GLCDReadByte, GLCDWriteByte or Pset
Supported in <GLCD.H>

