Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SSD1351 Class Reference
SSD1351 Library for STM32F401RE Nucleo or STMstation P.1 development boards - may work with other targets, but not tested yet. More...
#include <SSD1351.h>
Public Member Functions | |
| SSD1351 (PinName mosi_pin, PinName sclk_pin, PinName dc_pin, PinName cs_pin, PinName rst_pin) | |
| Connect to an SSD1351 on specified pins Connect to: (MOSI, SCLK) <-- Native SPI pins (DC, CS, RST) <-- Any digital pins. | |
| SSD1351 () | |
| Connect to SSD1351 on STMstation P.1, or default pins specified in defines in SSD1351.h Default pins are: MOSI PA_7 SCLK PA_5 CS PA_6 DC PC_5 RST PA_4. | |
| void | enableWrite () |
| Enable writing directly to the VRAM. | |
| void | fillBuf (uint16_t fillcolor) |
| Fill the buffer with a single color. | |
| void | writeBuf () |
| Write the buffer to the VRAM. | |
| void | drawSpritePtr (const uint16_t s[], int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t mask) |
| Draw a sprite from flash memory, into the buffer. | |
| void | fillCMask (uint8_t state) |
| Fill the collision mask with a single value. | |
| void | drawCMask (const uint16_t s[], int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t mask, uint8_t state) |
| Draw a sprite from flash memory, into the collision map. | |
| uint8_t | checkCollision (const uint16_t s[], int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t mask) |
| Check if a sprite (not yet written to collision map) is going to collide with anything. | |
| void | drawChar (char c, int16_t x, int16_t y, uint16_t color, uint8_t zoom) |
| Draw a single character. | |
| void | printText (const char c[], int16_t x, int16_t y, uint16_t color, uint8_t zoom) |
| Draw a single character. | |
| void | setBuf (uint8_t *_buf) |
| Set the display buffer. | |
| void | setCMask (uint8_t *_cmask) |
| Set the collision map. | |
| void | fillRect (int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t color) |
| Draw a filled rectangle to buffer. | |
| void | openRect (int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t color) |
| Draw a open rectangle to buffer. | |
| void | drawHLine (int16_t x, int16_t y, int16_t length, uint16_t color) |
| Draw a horizontal line without position calculations. | |
| void | drawVLine (int16_t x, int16_t y, int16_t length, uint16_t color) |
| Draw a vertical line without position calculations. | |
| void | drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) |
| Draw a line using Bresenham algorithm. | |
| void | openCircle (int16_t x0, int16_t y0, uint16_t radius, uint16_t color) |
| Draw open circle. | |
| void | fillCircle (int16_t x0, int16_t y0, uint16_t radius, uint16_t color) |
| Draw filled circle. | |
Detailed Description
SSD1351 Library for STM32F401RE Nucleo or STMstation P.1 development boards - may work with other targets, but not tested yet.
Standard mbed SPI library is VERY slow, limiting frame rate. Using EricWieser's BurstSPI (which fixes compilation errors on the STM32F4XX improves throughput significantly.
Tested on SSD1351 P/N UG-2828GDEDF11. May work with other SSD1351 panels but this is untested.
Example:
#include "mbed.h" #include "SSD1351.h" uint8_t buffer[128*128*2]; SSD1351 oled; //SSD1351 oled(PA_7,PA_5,PA_6,PC_5,PA_4); int main(){ oled.enableWrite(); oled.setBuf(buffer); oled.fillBuf(0x0000); oled.printText("Hello World!",0,0,0x07E0,1) oled.writeBuf(); }
Definition at line 77 of file SSD1351.h.
Constructor & Destructor Documentation
| SSD1351 | ( | PinName | mosi_pin, |
| PinName | sclk_pin, | ||
| PinName | dc_pin, | ||
| PinName | cs_pin, | ||
| PinName | rst_pin | ||
| ) |
Connect to an SSD1351 on specified pins Connect to: (MOSI, SCLK) <-- Native SPI pins (DC, CS, RST) <-- Any digital pins.
Definition at line 17 of file SSD1351.cpp.
| SSD1351 | ( | ) |
Connect to SSD1351 on STMstation P.1, or default pins specified in defines in SSD1351.h Default pins are: MOSI PA_7 SCLK PA_5 CS PA_6 DC PC_5 RST PA_4.
Definition at line 22 of file SSD1351.cpp.
Member Function Documentation
| uint8_t checkCollision | ( | const uint16_t | s[], |
| int16_t | x, | ||
| int16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | mask | ||
| ) |
Check if a sprite (not yet written to collision map) is going to collide with anything.
- Parameters:
-
s[] Sprite containing unsigned 16-bit 565 RGB values (1D vector) x x-coordinate of sprite y y-coordinate of sprite w Width of sprite h Height of sprite mask This value in the sprite is "skipped" - transparancy value
Definition at line 513 of file SSD1351.cpp.
| void drawChar | ( | char | c, |
| int16_t | x, | ||
| int16_t | y, | ||
| uint16_t | color, | ||
| uint8_t | zoom | ||
| ) |
Draw a single character.
- Parameters:
-
c ASCII character x x-coordinate of character y y-coordinate of character color Unsigned 16-bit 565 RGB zoom Scaling factor
Definition at line 544 of file SSD1351.cpp.
| void drawCMask | ( | const uint16_t | s[], |
| int16_t | x, | ||
| int16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | mask, | ||
| uint8_t | state | ||
| ) |
Draw a sprite from flash memory, into the collision map.
- Parameters:
-
s[] Sprite containing unsigned 16-bit 565 RGB values (1D vector) x x-coordinate of sprite y y-coordinate of sprite w Width of sprite h Height of sprite mask This value in the sprite is "skipped" - transparancy value state Value written to the collision map
Definition at line 483 of file SSD1351.cpp.
| void drawHLine | ( | int16_t | x, |
| int16_t | y, | ||
| int16_t | length, | ||
| uint16_t | color | ||
| ) |
Draw a horizontal line without position calculations.
- Parameters:
-
x x-coordinate y y-coordinate length Length, can be positive or negative color Unsigned 16-bit 565 RGB
Definition at line 252 of file SSD1351.cpp.
| void drawLine | ( | int16_t | x1, |
| int16_t | y1, | ||
| int16_t | x2, | ||
| int16_t | y2, | ||
| uint16_t | color | ||
| ) |
Draw a line using Bresenham algorithm.
- Parameters:
-
x1 Start x-coordinate y1 Start y-coordinate x2 End x-coordinate y2 End y-coordinate color Unsigned 16-bit 565 RGB
Definition at line 320 of file SSD1351.cpp.
| void drawSpritePtr | ( | const uint16_t | s[], |
| int16_t | x, | ||
| int16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | mask | ||
| ) |
Draw a sprite from flash memory, into the buffer.
- Parameters:
-
s[] Sprite containing unsigned 16-bit 565 RGB values (1D vector) x x-coordinate of sprite y y-coordinate of sprite w Width of sprite h Height of sprite mask This value in the sprite is "skipped" - transparancy value
Definition at line 445 of file SSD1351.cpp.
| void drawVLine | ( | int16_t | x, |
| int16_t | y, | ||
| int16_t | length, | ||
| uint16_t | color | ||
| ) |
Draw a vertical line without position calculations.
- Parameters:
-
x x-coordinate y y-coordinate length Length, can be positive or negative color Unsigned 16-bit 565 RGB
Definition at line 286 of file SSD1351.cpp.
| void enableWrite | ( | ) |
Enable writing directly to the VRAM.
This must be called at least once before calling writeBuf().
Definition at line 164 of file SSD1351.cpp.
| void fillBuf | ( | uint16_t | fillcolor ) |
Fill the buffer with a single color.
- Parameters:
-
fillcolor Unsigned 16-bit 565 RGB
Definition at line 178 of file SSD1351.cpp.
| void fillCircle | ( | int16_t | x0, |
| int16_t | y0, | ||
| uint16_t | radius, | ||
| uint16_t | color | ||
| ) |
Draw filled circle.
- Parameters:
-
x0 Center x-coordinate y0 Center y-coordinate radius Circle radius color Unsigned 16-bit 565 RGB
Definition at line 417 of file SSD1351.cpp.
| void fillCMask | ( | uint8_t | state ) |
Fill the collision mask with a single value.
- Parameters:
-
state Fill value
Definition at line 476 of file SSD1351.cpp.
| void fillRect | ( | int16_t | x, |
| int16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color | ||
| ) |
Draw a filled rectangle to buffer.
- Parameters:
-
x x-coordinate y y-coordinate w Width h Height color Unsigned 16-bit 565 RGB
Definition at line 193 of file SSD1351.cpp.
| void openCircle | ( | int16_t | x0, |
| int16_t | y0, | ||
| uint16_t | radius, | ||
| uint16_t | color | ||
| ) |
Draw open circle.
- Parameters:
-
x0 Center x-coordinate y0 Center y-coordinate radius Circle radius color Unsigned 16-bit 565 RGB
Definition at line 368 of file SSD1351.cpp.
| void openRect | ( | int16_t | x, |
| int16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color | ||
| ) |
Draw a open rectangle to buffer.
- Parameters:
-
x x-coordinate y y-coordinate w Width h Height color Unsigned 16-bit 565 RGB
Definition at line 222 of file SSD1351.cpp.
| void printText | ( | const char | c[], |
| int16_t | x, | ||
| int16_t | y, | ||
| uint16_t | color, | ||
| uint8_t | zoom | ||
| ) |
Draw a single character.
- Parameters:
-
c Char array x x-coordinate of character y y-coordinate of character color Unsigned 16-bit 565 RGB zoom Scaling factor
Definition at line 578 of file SSD1351.cpp.
| void setBuf | ( | uint8_t * | _buf ) |
Set the display buffer.
- Parameters:
-
_buf Buffer, must be uint8_t name[32768]
Definition at line 29 of file SSD1351.cpp.
| void setCMask | ( | uint8_t * | _cmask ) |
Set the collision map.
- Parameters:
-
_cmask Collision map, must be uint8_t name[16384]
Definition at line 34 of file SSD1351.cpp.
| void writeBuf | ( | ) |
Write the buffer to the VRAM.
Make sure you call enableWrte() before doing this!
Definition at line 186 of file SSD1351.cpp.
Generated on Fri Jul 15 2022 01:37:24 by
1.7.2