diff -r 5cf4034ba4e0 -r 55021f3f1929 lib/unigraphic/SSD1322.h --- a/lib/unigraphic/SSD1322.h Fri Sep 23 21:12:43 2016 +0200 +++ b/lib/unigraphic/SSD1322.h Tue Oct 11 00:14:20 2016 +0200 @@ -2,18 +2,32 @@ #define MBED_SSD1322_H #include "mbed.h" - -#include "SPI8.h" - -#include "Protocols.h" #include "GraphicsDisplay.h" +//Display module specs +#define DISPLAY_WIDTH (256) +#define DISPLAY_HEIGHT (64) +#define DISPLAY_BUFFER_TYPE uint8_t +#define DISPLAY_BUFFER_TYPE_SIZE (2) // 2 pixel / byte +#define DISPLAY_BUFFER_ELEMENTS 8192 // 256*64 / 2 (because 2 pixels/byte) + + /** Mirror mode */ -enum mirror_t {X,Y,XY,NONE}; +enum mirror_t {X, Y, XY, NONE}; + +typedef enum { + IDLE, // No operation currently ongoing + CLEARING, // In the process of clearing the display + WRITING, // In the process of sending a display update + WAIT_CLEAR, // Going to clear after CS pin timeout + WAIT_WRITE, // Going to write after CS pin timeout + TRANSFERS_DONE, // Last transfer in progress + DONE, // Done with transmission, waiting for CS pin to become high +} SSD1322_state_t; /** A common base class for monochrome Display */ -class SSD1322 : public GraphicsDisplay +class SSD1322: public GraphicsDisplay { public: @@ -22,15 +36,13 @@ /** Create a monochrome SSD1322 SPI interface * @param name The name used by the parent class to access the interface */ - SSD1322(proto_t displayproto, - int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, - const char* name, - const unsigned int lcdsize_x=128, const unsigned int lcdsize_y=64); + SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, + const char* name); /** Destructor * will free framebuffer */ - virtual ~SSD1322(); + virtual ~SSD1322() {}; @@ -129,12 +141,12 @@ /** get display X size in pixels (native, orientation independent) * @returns X size in pixels */ - int sizeX(); + int sizeX() {return screensize_X;}; /** get display Y size in pixels (native, orientation independent) * @returns Y size in pixels */ - int sizeY(); + int sizeY() {return screensize_Y;}; //////////////////////////////////////////////////////////////////////////////// // not implemented yet @@ -151,13 +163,10 @@ void clrbuff(const unsigned char value=0x00); unsigned long buffaddr(unsigned int i); void fills(const unsigned char value=0xFF); - void ll_fill(const unsigned char value=0xFF, const unsigned char w=0x78, const unsigned char=0x80); + void set_row_address(unsigned char start_row=0x00, unsigned char end_row=0x3F); void set_column_address(unsigned char start_col=0x00, unsigned char end_col=0x3F); - void start_loop(float tick); - void stop_loop(void); - virtual void copy_to_lcd(unsigned char from_col, unsigned char to_col, unsigned char from_row, unsigned char to_row); @@ -188,41 +197,22 @@ * */ void wr_data8(unsigned char data); - - /** Send 16bit command to display controller - * - * @param cmd: halfword to send - * - */ - void wr_cmd16(unsigned short cmd); - - /** Send same 16bit pixeldata to display controller multiple times - * - * @param data: halfword to send - * @param count: how many - * - */ - virtual void wr_gram(unsigned short data, unsigned int count); - - /** Send array of pixeldata shorts to display controller - * - * @param data: unsigned short pixeldata array - * @param lenght: lenght (in shorts) - * - */ - virtual void wr_grambuf(unsigned short* data, unsigned int lenght); - + /** HW reset sequence (without display init commands) */ void hw_reset(); int contrast; - void loop_event(void); protected: - Protocols* proto; - unsigned char *buffer; + mbed::SPI _spi; + DigitalOut _CS; + DigitalOut _RST; + DigitalOut _DC; + volatile DISPLAY_BUFFER_TYPE _pixelBuffer[DISPLAY_BUFFER_ELEMENTS]; // one full frame buffer + DISPLAY_BUFFER_TYPE _trBuffer[DISPLAY_BUFFER_ELEMENTS]; // for sending + const int screensize_X; const int screensize_Y; const int _PAGES; @@ -231,8 +221,6 @@ const int _IC_Y_COMS; const int _IC_PAGES; - Ticker bah; - int loop_pos; // pixel location int cur_x; int cur_y; @@ -242,6 +230,9 @@ int win_y1; int win_y2; int orientation; + + SSD1322_state_t _state; + }; #endif