SEPS114A Driver
SEPS114A SPI Driver
class SPIPreInit : public SPI { public: SPIPreInit(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk) { format(8,3); frequency(12000000); }; };
SPIPreInit gSpi(PB_15,NC,PB_13); PinName mosi(sda), PinName miso, PinName clk(scl) Adafruit_SEPS114A_Spi oled(gSpi,PB_14,PB_1,PB_2); PinName DC, PinName RST, PinName CS
You can print russian cyrilic
Adafruit_SEPS114A.h
- Committer:
- Dzhafarkhanov
- Date:
- 2016-05-10
- Revision:
- 1:a37035f55af3
- Parent:
- 0:f7b7f71865d1
File content as of revision 1:a37035f55af3:
//#ifndef _Adafruit_SEPS114A_H_
//#define _Adafruit_SEPS114A_H_
#include "mbed.h"
#include "Adafruit_GFX.h"
#include <vector>
#include <algorithm>
/* some 16bit RGB color definitions */
enum Color{
Black = 0x0000, /* 0, 0, 0 */
Navy = 0x000F, /* 0, 0, 128 */
DarkGreen = 0x03E0, /* 0, 128, 0 */
DarkCyan = 0x03EF, /* 0, 128, 128 */
Maroon = 0x7800, /* 128, 0, 0 */
Purple = 0x780F, /* 128, 0, 128 */
Olive = 0x7BE0, /* 128, 128, 0 */
LightGrey = 0xC618, /* 192, 192, 192 */
DarkGrey = 0x7BEF, /* 128, 128, 128 */
Blue = 0x001F, /* 0, 0, 255 */
Green = 0x07E0, /* 0, 255, 0 */
Cyan = 0x07FF, /* 0, 255, 255 */
Red = 0xF800, /* 255, 0, 0 */
Magenta = 0xF81F, /* 255, 0, 255 */
Yellow = 0xFFE0, /* 255, 255, 0 */
White = 0xFFFF, /* 255, 255, 255 */
Orange = 0xFD20, /* 255, 165, 0 */
GreenYellow = 0xAFE5, /* 173, 255, 47 */
Pink = 0xF81F
};
// A DigitalOut sub-class that provides a constructed default state
class DigitalOut2 : public DigitalOut
{
public:
DigitalOut2(PinName pin, bool active = false) : DigitalOut(pin) { write(active); };
DigitalOut2& operator= (int value) { write(value); return *this; };
DigitalOut2& operator= (DigitalOut2& rhs) { write(rhs.read()); return *this; };
operator int() { return read(); };
};
/** The pure base class for the SSD1351 display driver.
*
*/
class Adafruit_SEPS114A : public Adafruit_GFX
{
public:
Adafruit_SEPS114A(PinName RST, uint8_t rawHeight = 96, uint8_t rawWidth = 96)
: Adafruit_GFX(rawWidth,rawHeight)
, rst(RST,false)
{
};
void begin();
void clearDisplay();
void MemorySize(uint8_t X1, uint8_t X2, uint8_t Y1, uint8_t Y2);
void set_region(int x, int y, int xs, int ys);
uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
// These must be implemented in the derived transport driver
virtual void writeCommand(uint8_t reg_index,uint8_t reg_value) = 0;
virtual void writeData(uint32_t data_value) = 0;
virtual void DDRAM_access() = 0;
virtual void drawPixel(int16_t x, int16_t y, uint16_t color);
void setContrastControl(int brightness);
protected:
DigitalOut2 rst;
};
/** This is the SPI SSD1351 display driver transport class
*
*/
class Adafruit_SEPS114A_Spi : public Adafruit_SEPS114A
{
public:
/** Create a SSD1351 SPI transport display driver instance with the specified DC, RST, and CS pins, as well as the display dimentions
*
* Required parameters
* @param spi - a reference to an initialized SPI object
* @param DC (Data/Command) pin name
* @param RST (Reset) pin name
* @param CS (Chip Select) pin name
*
* Optional parameters
* @param rawHeight - the vertical number of pixels for the display, defaults to 96
* @param rawWidth - the horizonal number of pixels for the display, defaults to 96
*/
Adafruit_SEPS114A_Spi(SPI &spi, PinName DC, PinName RST, PinName CS, uint8_t rawHieght = 96, uint8_t rawWidth = 96)
: Adafruit_SEPS114A(RST, rawHieght, rawWidth)
, cs(CS,true)
, dc(DC,false)
, mspi(spi)
{
begin();
clearDisplay();
};
virtual void writeCommand(uint8_t reg_index,uint8_t reg_value)
{
//Select index addr
cs = 0;
dc = 0;
mspi.write(reg_index);
cs = 1;
//Write data to reg
cs = 0;
dc = 1;
mspi.write(reg_value);
cs = 1;
};
virtual void writeData(uint32_t data_value)
{
cs = 0;
dc = 1;
mspi.write(data_value);
cs = 1;
};
virtual void DDRAM_access()
{
cs = 0;
dc = 0;
mspi.write(0x08);
cs = 1;
};
protected:
DigitalOut2 cs, dc;
SPI &mspi;
};