Xuyi Wang / SSD1963
Revision:
1:74bac5f988d8
Parent:
0:94df05e3330d
Child:
2:d8a9ebd28f0a
--- a/SSD1963.h	Sat Oct 03 12:32:04 2020 +0000
+++ b/SSD1963.h	Sun Oct 04 13:19:05 2020 +0000
@@ -82,25 +82,6 @@
 #define GRAY4               RGB565CONVERT(96,   96,     96)
 #define GRAY5               RGB565CONVERT(64,   64,     64)
 #define GRAY6               RGB565CONVERT(32,   32,     32)
-
-// PB0 PB1 PB2 PB6 PB7
-// RST nCS nRD nWR nRS
-  // - LCD_CS -----------------------------------------------------------------
-  #define CS_HIGH    {GPIOB->BSRRL = GPIO_BSRR_BS_1;}
-  #define CS_LOW     {GPIOB->BSRRH = GPIO_BSRR_BS_1;}
-  // - LCD_RS -----------------------------------------------------------------
-  #define RS_HIGH    {GPIOB->BSRRL = GPIO_BSRR_BS_7;}
-  #define RS_LOW     {GPIOB->BSRRH = GPIO_BSRR_BS_7;}
-  // - LCD_WR -----------------------------------------------------------------
-  #define WR_HIGH    {GPIOB->BSRRL = GPIO_BSRR_BS_6;}
-  #define WR_LOW     {GPIOB->BSRRH = GPIO_BSRR_BS_6;}
-  #define WR_STROBE  {WR_LOW; WR_HIGH;}
-  // - LCD_RD -----------------------------------------------------------------
-  #define RD_HIGH    {GPIOB->BSRRL = GPIO_BSRR_BS_2;}
-  #define RD_LOW     {GPIOB->BSRRH = GPIO_BSRR_BS_2;}
-  // - LCD_RST ----------------------------------------------------------------
-  #define RST_HIGH   {GPIOB->BSRRL = GPIO_BSRR_BS_0;}
-  #define RST_LOW    {GPIOB->BSRRH = GPIO_BSRR_BS_0;}
   
 /*
 // Section : SSD1963 Command --------------------------------------------------
@@ -233,11 +214,12 @@
 // End : SSD1963 Command ------------------------------------------------------
 
 #define swap(a, b) { int16_t t = a; a = b; b = t; }
+#define LOW 0
+#define HIGH 1
 
 class SSD1963 {
   public:
-    SSD1963();
-    void init(void);
+    SSD1963(PinName CS, PinName RESET, PinName RS, PinName WR, BusInOut* DATA_PORT, PinName RD);
     void begin(void);
     void reset(void);
     
@@ -266,7 +248,7 @@
     //virtual size_t write(uint8_t);
     
     uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
-    //uint8_t readID(void);
+    uint8_t readID(void);
 
     //void setRotation(uint8_t x);
     //uint8_t getRotation();
@@ -301,6 +283,10 @@
     //void write8(uint8_t d);
     
   private:
+    DigitalOut  _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset;
+    DigitalOut  _lcd_pin_wr;
+    BusInOut*     _lcd_port;
+    DigitalOut  _lcd_pin_rd;
     //void init(void);
     //void flood(uint16_t color, uint32_t len);
     
@@ -310,6 +296,17 @@
     //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;