Guillermo Stedile / RA8875

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Wed Jan 28 12:21:11 2015 +0000
Parent:
89:04575562c961
Child:
91:ca5f829e6d27
Commit message:
persist screen width/height in the private data so that it does not have the burn the cycles to query the hardware on every need.

Changed in this revision

RA8875.cpp Show annotated file Show diff for this revision Revisions of this file
RA8875.h Show annotated file Show diff for this revision Revisions of this file
--- a/RA8875.cpp	Sun Jan 25 00:15:02 2015 +0000
+++ b/RA8875.cpp	Wed Jan 28 12:21:11 2015 +0000
@@ -125,6 +125,7 @@
     wait_ms(1);
 
     // Horizontal Settings
+    screenwidth = width;
     WriteCommand(0x14, width/8 - 1);            //HDWR//Horizontal Display Width Setting Bit[6:0]
     WriteCommand(0x15, 0x02);                   //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0]
     WriteCommand(0x16, 0x03);                   //HNDR//Horizontal Non-Display Period Bit[4:0]
@@ -132,6 +133,7 @@
     WriteCommand(0x18, 0x03);                   //HPWR//HSYNC Polarity ,The period width of HSYNC.
 
     // Vertical Settings
+    screenheight = height;
     WriteCommand(0x19, (height-1)&0xFF);        //VDHR0 //Vertical Display Height Bit [7:0]
     WriteCommand(0x1a, (height-1)>>8);          //VDHR1 //Vertical Display Height Bit [8]
     WriteCommand(0x1b, 0x0F);                   //VNDR0 //Vertical Non-Display Period Bit [7:0]
@@ -575,13 +577,21 @@
 
 dim_t RA8875::width(void)
 {
-    return (ReadCommand(0x14) + 1) * 8;
+    if (portraitmode)
+        return screenheight;
+    else
+        return screenwidth;
+//    return (ReadCommand(0x14) + 1) * 8;
 }
 
 
 dim_t RA8875::height(void)
 {
-    return (ReadCommand(0x19) | (ReadCommand(0x1A) << 8)) + 1;
+    if (portraitmode)
+        return screenwidth;
+    else
+        return screenheight;
+//    return (ReadCommand(0x19) | (ReadCommand(0x1A) << 8)) + 1;
 }
 
 
@@ -682,18 +692,22 @@
         case RA8875::normal:
             //fncr1Val |= 0x10;
             //dpcrVal |= 0x00;
+            portraitmode = false;
             break;
         case RA8875::rotate_90:
             fncr1Val |= 0x10;
             dpcrVal |= 0x08;
+            portraitmode = true;
             break;
         case RA8875::rotate_180:
             //fncr1Val |= 0x00;
             dpcrVal |= 0x0C;
+            portraitmode = false;
             break;
         case RA8875::rotate_270:
             fncr1Val |= 0x10;
             dpcrVal |= 0x04;
+            portraitmode = true;
             break;
         default:
             return bad_parameter;
--- a/RA8875.h	Sun Jan 25 00:15:02 2015 +0000
+++ b/RA8875.h	Wed Jan 28 12:21:11 2015 +0000
@@ -1974,8 +1974,13 @@
     unsigned long spireadfreq;      ///< saved read freq
     DigitalOut cs;                  ///< chip select pin, assumed active low
     DigitalOut res;                 ///< reset pin, assumed active low
+    
+    dim_t screenwidth;              ///< configured screen width
+    dim_t screenheight;             ///< configured screen height
+    bool portraitmode;              ///< set true when in portrait mode (w,h are reversed)
+    
     const unsigned char * font;     ///< reference to an external font somewhere in memory
-    loc_t cursor_x, cursor_y;    ///< used for external fonts only
+    loc_t cursor_x, cursor_y;       ///< used for external fonts only
     
     #ifdef PERF_METRICS
     typedef enum