Test for STM32F4
Fork of RGB_OLED_SSD1331 by
Diff: include/SSD1331.h
- Revision:
- 2:e033aab5daad
- Parent:
- 1:b55525d2db34
- Child:
- 3:af00512c9694
--- a/include/SSD1331.h Tue Nov 10 23:16:37 2015 +0000 +++ b/include/SSD1331.h Thu Nov 12 22:31:58 2015 +0000 @@ -62,6 +62,7 @@ #include "DigitalOut.h" #include "PinNames.h" #include "SGL.h" +#include "Stream.h" namespace mbed { @@ -136,6 +137,27 @@ COLOR_PURPLE = RGB(160, 32,240), // purple }; +/* some RGB color definitions */ +#define Black 0x0000 /* 0, 0, 0 */ +#define Navy 0x000F /* 0, 0, 128 */ +#define DarkGreen 0x03E0 /* 0, 128, 0 */ +#define DarkCyan 0x03EF /* 0, 128, 128 */ +#define Maroon 0x7800 /* 128, 0, 0 */ +#define Purple 0x780F /* 128, 0, 128 */ +#define Olive 0x7BE0 /* 128, 128, 0 */ +#define LightGrey 0xC618 /* 192, 192, 192 */ +#define DarkGrey 0x7BEF /* 128, 128, 128 */ +#define Blue 0x001F /* 0, 0, 255 */ +#define Green 0x07E0 /* 0, 255, 0 */ +#define Cyan 0x07FF /* 0, 255, 255 */ +#define Red 0xF800 /* 255, 0, 0 */ +#define Magenta 0xF81F /* 255, 0, 255 */ +#define Yellow 0xFFE0 /* 255, 255, 0 */ +#define White 0xFFFF /* 255, 255, 255 */ +#define Orange 0xFD20 /* 255, 165, 0 */ +#define GreenYellow 0xAFE5 /* 173, 255, 47 */ +#define Pink 0xF81F + enum DisplayMode{ //reset the above effect and turn the data to ON at the corresponding gray level. NormalDisplay = 0xA4, @@ -160,9 +182,9 @@ }; -class SSD1331 : public virtual SGL { +class SSD1331 : public mbed::Stream, public virtual SGL { public: - SSD1331(PinName cs, PinName dc, PinName mosi, PinName sck); + SSD1331(PinName cs, PinName rst, PinName dc, PinName mosi, PinName miso, PinName sclk); void init(void); virtual void drawPixel(uint16_t x, uint16_t y, uint16_t color); virtual void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); @@ -174,13 +196,25 @@ void enableScolling(bool enable); void setDisplayMode(DisplayMode mode); void setDisplayPower(DisplayPower power); -private: - void _sendCmd(uint8_t cmd); + void Draw_Dot(uint8_t x, uint8_t y,unsigned int Color); + + void RegWriteM(unsigned char *Command, int count); +protected: + // Stream implementation functions + virtual int _putc( int c ); + virtual int _getc(); private: - mbed::DigitalOut* _cs; - mbed::DigitalOut* _dc; - mbed::SPI* _spiPort; + void sendCmd(unsigned char cmd); + void sendCmd(unsigned char cmd, unsigned char arg1); + void sendCmd(unsigned char cmd, unsigned char arg1, unsigned char arg2); + void sendCmd(unsigned char *cmd, int count); + void sendData(uint16_t data); + +private: + mbed::DigitalOut _cs; + mbed::DigitalOut _dc; + mbed::SPI _spiPort; }; #endif \ No newline at end of file