SSD1351 library for the STM32F401RE. Uses BurstSPI and a couple of tweaks to improve throughput.
Library for the SSD1351 128 x 128 OLED display, specifically for the STM32F401RE Nucleo/STMstation development boards.
See API documentation for more details and code.
Diff: SSD1351.h
- Revision:
- 0:5115e0080bd5
- Child:
- 1:ae4fe66e9c0e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SSD1351.h Sat Jun 17 09:01:26 2017 +0000 @@ -0,0 +1,75 @@ +#ifndef SSD1351_h +#define SSD1351_h + +#include "mbed.h" +#include "BurstSPI.h" + +#define SSD1351_CMD_SETCOLUMN 0x15 +#define SSD1351_CMD_SETROW 0x75 +#define SSD1351_CMD_WRITERAM 0x5C +#define SSD1351_CMD_READRAM 0x5D +#define SSD1351_CMD_SETREMAP 0xA0 +#define SSD1351_CMD_STARTLINE 0xA1 +#define SSD1351_CMD_DISPLAYOFFSET 0xA2 +#define SSD1351_CMD_DISPLAYALLOFF 0xA4 +#define SSD1351_CMD_DISPLAYALLON 0xA5 +#define SSD1351_CMD_NORMALDISPLAY 0xA6 +#define SSD1351_CMD_INVERTDISPLAY 0xA7 +#define SSD1351_CMD_FUNCTIONSELECT 0xAB +#define SSD1351_CMD_DISPLAYOFF 0xAE +#define SSD1351_CMD_DISPLAYON 0xAF +#define SSD1351_CMD_PRECHARGE 0xB1 +#define SSD1351_CMD_DISPLAYENHANCE 0xB2 +#define SSD1351_CMD_CLOCKDIV 0xB3 +#define SSD1351_CMD_SETVSL 0xB4 +#define SSD1351_CMD_SETGPIO 0xB5 +#define SSD1351_CMD_PRECHARGE2 0xB6 +#define SSD1351_CMD_SETGRAY 0xB8 +#define SSD1351_CMD_USELUT 0xB9 +#define SSD1351_CMD_PRECHARGELEVEL 0xBB +#define SSD1351_CMD_VCOMH 0xBE +#define SSD1351_CMD_CONTRASTABC 0xC1 +#define SSD1351_CMD_CONTRASTMASTER 0xC7 +#define SSD1351_CMD_MUXRATIO 0xCA +#define SSD1351_CMD_COMMANDLOCK 0xFD +#define SSD1351_CMD_HORIZSCROLL 0x96 +#define SSD1351_CMD_STOPSCROLL 0x9E +#define SSD1351_CMD_STARTSCROLL 0x9F + +class SSD1351{ + public: + SSD1351(PinName mosi_pin, PinName sclk_pin, PinName dc_pin, PinName cs_pin, PinName rst_pin); + + void begin(); + //void fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t fillcolor); + + void enableWrite(); + void fillBuf(uint16_t fillcolor); + void writeBuf(); + void drawSpritePtr(const uint16_t s[] ,int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t mask); + void fillCMask(uint8_t state); + void drawCMask(const uint16_t s[], int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t mask, uint8_t state); + uint8_t checkCollision(const uint16_t s[], int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t mask); + void drawChar(char c, int16_t x, int16_t y, uint16_t color, uint8_t zoom); + void printText(const char c[], int16_t x, int16_t y, uint16_t color, uint8_t zoom); + void setBuf(uint8_t* _buf); + void setCMask(uint8_t* _cmask); + + void fillRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t color); + void openRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t color); + void drawHLine(int16_t x, int16_t y, int16_t length, uint16_t color); + void drawVLine(int16_t x, int16_t y, int16_t length, uint16_t color); + void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); + void openCircle(int16_t x0, int16_t y0, uint16_t radius, uint16_t color); + void fillCircle(int16_t x0, int16_t y0, uint16_t radius, uint16_t color); + + private: + void spiwrite(uint8_t c); + void writeCommand(uint8_t c); + void writeData(uint8_t c); + DigitalOut cs, dc, rst; + BurstSPI spi; + uint8_t *buf, *collisionmask; +}; + +#endif \ No newline at end of file