Joseph Realmuto and I have just updated the SSD1306 and the SH1106 GLCD library to improve performance and to support microcontrollers with limited memory.
The SSD1306 and the SH1106 are single-chip CMOS OLED/PLED drivers with controllers for organic / polymer light emitting diode dot-matrix graphic display system. It consists of 128 segments and 64 commons. These IC's are designed for Common Cathode type OLED panel.
The Great Cow BASIC support is for SPI (SDD1306 only) and I2C hardware & software connectivity. These libraries supports 128 * 64 pixels or 128 * 32 pixels. The default is 128 * 64 pixels.
Problem we needed to address... low memory microcontroller devices. The existing driver requires a buffer of 128 bytes and therefore this excluded many, many microcontroller devices.
The solution was to implement two new methods to use these display. These are additive to the existing GLCD methods.
For High memory microcontrollers we now support
1. Full GLCD Mode: 1024 byte buffer, Random Access, full capabilities [default GLCD mode of operation]
2. Low GLCD Mode: 128 byte buffer, Write only, page control, constrained capabilities
3. Text only
For Low memory microcontroller we now support
1. Low GLCD Mode: 128 byte buffer, Write only, page control, constrained capabilities
2. Text only [default GLCD mode of operation]
Usage
*Full GLCD Mode*: As this is the existing usage method - no changes.
*Low GLCD Mode*: You must specify a define and enable the new GLCD transaction methods. For High memory microcontrollers you must also specify an additional define.
*Text only*. The default for low memory devices, so, no define is required. For High memory microcontrollers you must also specify a define.
For example usage of the Full GLCD Mode. See the manual.... nothing changed!
Example Text Mode: I will explain the Text Mode first as this sets the scene with respect to the page numbering scheme of the GLCD devices.
Assuming you have a low memory device. Initialise the GLCD as normal. The default operation is text mode only so you can only use character commands such as GLCDPRINT
GLCDPrint 1, 0, "Meter"
GLCDPrint 1, 8, "Meter"
The Y position stated in the GLCD commands will be mapped to the GLCD page. Pages are numbered 0 to 7. So, a Y position between 0-7 is mapped to page 0 or row 0 of the GLCD device.a Y position between 8-15 is mapped to page 1 or row 1 of the GLCD device. Essentially, page number = INT(Y position / 8 ).
You have control the X of the text position as normally.
To enable this text mode on a high memory device add the following to your user program.
only.
#define GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY
Example Low GLCD Mode
Assuming you have a low memory device. Initialise the GLCD as normal. The default operation is text mode only so you can only use character commands such as GLCDPRINT. To enable Low GLCD Mode add the following to your program.
#define GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE
To use Low Memory GLCD use all the normal GLCD (except ReadPixelStatus) but you need to enable the GLCD Transactions.
As follows:
GLCD_Open_PageTransaction 0,7
GLCDPrint 1, 0, "Great Cow BASIC"
GLCDPrint 1, 8, "Meter"
Line 0, 0, 127, 63
Line 127, 0, 0, 63
GLCD_Close_PageTransaction
GLCD_Open_PageTransaction and GLCD_Close_PageTransaction as required to update the device. The two parameters on GLCD_Open_PageTransaction are the device pages you wish to update. Calling 0, 7 will update the complete screen. There are excellent use cases for not updating every device page.
Everything between GLCD_Open_PageTransaction and GLCD_Close_PageTransaction should be GLCD related. Consider commands between GLCD_Open_PageTransaction and GLCD_Close_PageTransaction as a single page update. Including WAITs is not advised - just include GLCD commands.
To enable this text mode on a high memory device add the following to your user program.
only.
#define GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY
#define GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE
RAM required
*Full GLCD Mode*: No changes. Still requires 1024 bytes of memory.
*Low GLCD Mode*: Requires a 128 byte buffer and the use of the GLCD transaction methods.
*Text only*: Require RAM only to support basic character operations. No buffer is used.
Performance
We have improved the overall performance of the drivers. The Low GLCD mode is comparable to the Full GLCD mode and we still think we can improve further. Joseph has performance statistics - these are available.
Enjoy, Another cool capability from the Great Cow BASIC team.
Информация по комментариям в разработке