Xuyi Wang / SSD1963
Revision:
2:d8a9ebd28f0a
Parent:
1:74bac5f988d8
Child:
3:31ca3cd96572
diff -r 74bac5f988d8 -r d8a9ebd28f0a SSD1963.h
--- a/SSD1963.h	Sun Oct 04 13:19:05 2020 +0000
+++ b/SSD1963.h	Thu Oct 08 06:50:37 2020 +0000
@@ -18,7 +18,7 @@
  *****************************************************************************/
 #ifndef __SSD1963_H_
 #define __SSD1963_H_
-//#include "mbed.h"
+#include "lcd_base.h"
 
     /*********************************************************************
     * Overview: Image orientation (can be 0, 90, 180, 270 degrees).
@@ -27,13 +27,13 @@
     /*********************************************************************
     * Overview: Panel Data Width (R,G,B) in (6,6,6)
     *********************************************************************/
-    #define DISP_DATA_WIDTH                 18
+    #define DISP_DATA_WIDTH             18
     /*********************************************************************
     * Overview: Horizontal and vertical display resolution
     *                  (from the glass datasheet).
     *********************************************************************/
-    #define DISP_HOR_RESOLUTION 800
-    #define DISP_VER_RESOLUTION 480
+    #define DISP_HOR_RESOLUTION 480
+    #define DISP_VER_RESOLUTION 272
     /*********************************************************************
     * Overview: Horizontal synchronization timing in pixels
     *                  (from the glass datasheet).
@@ -103,7 +103,7 @@
 //#define SRAM_WRITE        0x22  // W/R SRAM Write
 #define SRAM_WRITE        0x2C
 */
-/*
+
 #define Com_NOP                 0x00   // brief No opeation
 #define Com_Reset               0x01   // brief Software reset
 #define Com_GetPowerMode        0x0A   // brief Get power mode
@@ -210,111 +210,58 @@
 
 #define Com_SetPixelInterface   0xF0
 #define Com_GetPixelInterface   0xF1
-*/
+
 // End : SSD1963 Command ------------------------------------------------------
 
 #define swap(a, b) { int16_t t = a; a = b; b = t; }
 #define LOW 0
 #define HIGH 1
 
-class SSD1963 {
+class SSD1963 : public LCD {
   public:
     SSD1963(PinName CS, PinName RESET, PinName RS, PinName WR, BusInOut* DATA_PORT, PinName RD);
     void begin(void);
     void reset(void);
-    
-    //void drawPixel(uint16_t x, uint16_t y, uint16_t color);
-    void fillScreen(uint16_t color);
-    //void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
-    //void drawVerticalLine(uint16_t x, uint16_t y, uint16_t length, uint16_t color);
-    //void drawHorizontalLine(uint16_t x, uint16_t y, uint16_t length, uint16_t color);
-    //void drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
-    //void fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
-    //void drawRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);
-    //void fillRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);
-    //void drawRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color);
-    //void fillRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color);
-    //void drawCircle(uint16_t x0, uint16_t y0, uint16_t r,   uint16_t color);
-    //void fillCircle(uint16_t x0, uint16_t y0, uint16_t r,   uint16_t color);
+                
+    uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
+
+  protected:
+     /** Assigns a chunk of the display memory to receive data.
+     *
+     * When data is sent to the display after this function completes, the opertion will
+     * start from the begining of the assigned address (pixel position) and the pointer
+     * will be automatically incremented so that the next data write operation will continue
+     * with the next pixel from the memory block.  If more data is written than available
+     * pixels, at the end of the block the pointer will jump back to its beginning and
+     * commence again, until the next address change command is sent to the display.
+     *
+     * \param x1 The X coordinate of the pixel at the beginning of the block.
+     * \param y1 The Y coordinate of the pixel at the beginning of the block.
+     * \param x2 The X coordinate of the pixel at the end of the block.
+     * \param y2 The Y coordinate of the pixel at the end of the block.
+     * \remarks Addressing commands are controller-specific and this function needs to be
+     *          implemented separately for each available controller.
+     */
+    virtual void SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 );
+
+    /** Sets the color of the pixel at the address pointer of the controller.
+     *
+     * This function is to be provided by each implementation separately in
+     * order to account for different color depth used by the controller.
+     * \param color The color of the pixel.
+     * \param mode The depth (palette) of the color.
+     */
+    virtual void SetPixelColor( unsigned int color, colordepth_t mode = RGB24 );
     
-    //void setCursor(uint16_t x, uint16_t y);
-    //void setTextColor(uint16_t c);
-    //void setTextColor(uint16_t c, uint16_t bg);
-    //void setTextSize(uint8_t s);
-    //void setTextWrap(bool w);
-    //void drawChar(uint16_t x, uint16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
-    //void drawBitmap(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color);
-    
-    //virtual size_t write(uint8_t);
-    
-    uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
-    uint8_t readID(void);
-
-    //void setRotation(uint8_t x);
-    //uint8_t getRotation();
-    // These methods are public in order for BMP examples to work:
-    //void setAddrWindow(int x1, int y1, int x2, int y2);
-    //void pushColors(uint16_t *data, uint8_t len, bool first);
-    
-    // - Low Level ------------------------------------------------------------
-    void writeData(uint16_t data);
-    void writeCommand(uint16_t cmd);
+    virtual void WriteData(unsigned short data);
+    virtual void WriteCmd(unsigned short cmd);
     uint16_t readData(void);
     void writeRegister(uint16_t addr, uint16_t data);
-
-    //void writeData8(uint8_t d);
-    //void writeData16(uint16_t d);
-    //void writeCommand(uint8_t c);
-    //uint8_t readData8(void);
-    //uint16_t readData16(void);
-    //void writeRegister(uint8_t addr, uint8_t data);
-    //void writeRegisterPair(uint8_t aH, uint8_t aL, uint16_t d);
-    
-    //uint16_t width();
-    //uint16_t height();
-    
-    static const uint16_t TFTWIDTH  = 800;
-    static const uint16_t TFTHEIGHT = 480;
-    
-    //void writeData_unsafe(uint16_t d);
-    //void setWriteDir(void);
-    //void setReadDir(void);
-    
-    //void write8(uint8_t d);
-    
+        
   private:
-    DigitalOut  _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset;
     DigitalOut  _lcd_pin_wr;
-    BusInOut*     _lcd_port;
+    BusInOut*   _lcd_port;
     DigitalOut  _lcd_pin_rd;
-    //void init(void);
-    //void flood(uint16_t color, uint32_t len);
-    
-    //void drawCircleHelper(uint16_t x0, uint16_t y0, uint16_t r, uint8_t corner, uint16_t color);
-    //void fillCircleHelper(uint16_t x0, uint16_t y0, uint16_t r, uint8_t corner, uint16_t delta, uint16_t color);
-    
-    //uint8_t read8(void);
-
-  protected:
-    /** Activates the display for command/data transfer.
-     *
-     * Usually achieved by pulling the CS pin of the display low.
-     */
-    void Activate( void );
-    
-    /** Deactivates the display after data has been transmitted.
-     *
-     * Usually achieved by pulling the CS pin of the display high.
-     */
-    void Deactivate( void );
-    //uint16_t _width, _height;
-    //uint8_t  textsize;
-    //uint16_t cursor_x, cursor_y;
-    //uint16_t textcolor;
-    //uint16_t textbgcolor;
-    //uint8_t  rotation;
-    //uint8_t  driver;
-    //bool wrap;
 };
 
 #endif