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