KSM edits to RA8875

Dependents:   Liz_Test_Code

Revision:
111:efe436c43aba
Parent:
110:39f22e0c8de4
Child:
114:dbfb996bfbf3
--- a/RA8875.h	Sat Mar 19 20:49:14 2016 +0000
+++ b/RA8875.h	Mon Apr 25 01:43:59 2016 +0000
@@ -157,7 +157,6 @@
 /// @endcode
 ///
 /// @todo Add Scroll support for text.
-/// @todo Improve sync between internal and external font support - cursor, window, scroll.
 /// @todo Add Hardware reset signal - but testing to date indicates it is not needed.
 /// @todo Add high level objects - x-y graph, meter, others... but these will
 ///     probably be best served in another class, since they may not
@@ -1208,15 +1207,50 @@
     ///
     virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y);
     
-    /// Set the window, which controls where items are written to the screen.
+    /// Set the window, constraining where items are written to the screen.
+    ///
+    /// After setting the window, text and graphics are constrained to this
+    /// window. Text will wrap from the right edge back to the left and down
+    /// one row and from the bottom to the top. Graphics drawing will be clipped
+    /// at the edge of the window.
+    ///
+    /// @note If the initial text write is outside the window, it will be shown
+    /// where the cursor position it. Once the write hits the right edge of
+    /// the defined window, it will then wrap back to the left edge. Once it
+    /// hits the bottom, it wraps to the top of the window. For this reason,
+    /// it is common to set the text cursor to the window.
     ///
-    /// When something hits the window width, it wraps back to the left side
-    /// and down a row. If the initial write is outside the window, it will
-    /// be captured into the window when it crosses a boundary.
+    /// @code
+    ///     rect_t r = {10,10, 90,90};
+    ///     lcd.window(r);
+    ///     lcd.SetTextCursor(r.p1.x, r.p1.y);
+    ///     lcd.puts("012345678901234567890123456789012345678901234567890");
+    ///     lcd.window(); restore to full screen
+    /// @endcode
+    ///
+    /// @param[in] r is the rect_t used to set the window.
+    /// @returns success/failure code. See @ref RetCode_t.
+    ///
+    virtual RetCode_t window(rect_t r);
+    
+    /// Set the window, constraining where items are written to the screen.
+    ///
+    /// After setting the window, text and graphics are constrained to this
+    /// window. Text will wrap from the right edge back to the left and down
+    /// one row and from the bottom to the top. Graphics drawing will be clipped
+    /// at the edge of the window.
+    ///
+    /// @note If the initial text write is outside the window, it will be shown
+    /// where the cursor position it. Once the write hits the right edge of
+    /// the defined window, it will then wrap back to the left edge. Once it
+    /// hits the bottom, it wraps to the top of the window. For this reason,
+    /// it is common to set the text cursor to the window.
     ///
     /// @code
     ///     lcd.window(10,10, 80,80);
+    ///     lcd.SetTextCursor(10,10);
     ///     lcd.puts("012345678901234567890123456789012345678901234567890");
+    ///     lcd.window(); restore to full screen
     /// @endcode
     ///
     /// @param[in] x is the left edge in pixels.
@@ -1225,7 +1259,7 @@
     /// @param[in] height is the window height in pixels.
     /// @returns success/failure code. See @ref RetCode_t.
     ///
-    virtual RetCode_t window(loc_t x, loc_t y, dim_t width, dim_t height);
+    virtual RetCode_t window(loc_t x = 0, loc_t y = 0, dim_t width = (dim_t)-1, dim_t height = (dim_t)-1);
     
     /// Clear either the specified layer, or the active layer.
     ///
@@ -2194,6 +2228,7 @@
     uint8_t screenbpp;              ///< configured bits per pixel
     dim_t screenwidth;              ///< configured screen width
     dim_t screenheight;             ///< configured screen height
+    rect_t windowrect;              ///< window commands are held here for speed of access 
     bool portraitmode;              ///< set true when in portrait mode (w,h are reversed)
     
     const unsigned char * font;     ///< reference to an external font somewhere in memory