Fork of Silabs MemoryLCD library

Dependents:   demoUI whrmDemoUI Host_Software_MAX32664GWEB_HR_EXTENDED Host_Software_MAX32664GWEC_SpO2_HR-_EXTE ... more

C++ library for Sharp Microelectronics 1.28 inch LCD TFT, LS013B7DH03, SPI bus. Forked from Silicon Labs MemoryLCD display driver.

Files at this revision

API Documentation at this revision

Comitter:
stevew817
Date:
Wed Aug 12 13:32:01 2015 +0000
Parent:
9:2441ef131ab8
Child:
11:0f8ae10b308d
Commit message:
Use masking instead of modulo to speed up operation of pixel()

Changed in this revision

BufferedDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
LCDSettings.h Show annotated file Show diff for this revision Revisions of this file
--- a/BufferedDisplay.cpp	Thu Jul 30 09:01:02 2015 +0000
+++ b/BufferedDisplay.cpp	Wed Aug 12 13:32:01 2015 +0000
@@ -82,13 +82,13 @@
 	    /* Since we are dealing with 1-bit pixels, we can avoid having to do bitshift and comparison operations twice.
 	     * Basically, do the comparison with the requested state and current state, and if it changed, do an XOR on the framebuffer pixel and set the line to dirty.
 	     */
-	    bool change = ((_pixelBuffer[((y * DISPLAY_WIDTH) + x) / DISPLAY_BUFFER_TYPE_SIZE] & (1 << (x % DISPLAY_BUFFER_TYPE_SIZE))) != ((colour & 0x01) << (x % DISPLAY_BUFFER_TYPE_SIZE)));
+	    bool change = ((_pixelBuffer[((y * DISPLAY_WIDTH) + x) / DISPLAY_BUFFER_TYPE_SIZE] & (1 << (x & DISPLAY_BUFFER_TYPE_MASK))) != ((colour & 0x01) << (x & DISPLAY_BUFFER_TYPE_MASK)));
 		if(change) {
-			/* Do XOR (no bitshifting required) */
-            _pixelBuffer[((y * DISPLAY_WIDTH) + x) / DISPLAY_BUFFER_TYPE_SIZE] ^= (1 << (x % DISPLAY_BUFFER_TYPE_SIZE));
+			/* Pixel's value and requested value are different, so since it's binary, we can simply do an XOR */
+            _pixelBuffer[((y * DISPLAY_WIDTH) + x) / DISPLAY_BUFFER_TYPE_SIZE] ^= (1 << (x & DISPLAY_BUFFER_TYPE_MASK));
 
             /* notify dirty status of this line */
-            _dirtyRows[y / DISPLAY_BUFFER_TYPE_SIZE] |= (1 << (y % DISPLAY_BUFFER_TYPE_SIZE));
+            _dirtyRows[y / DISPLAY_BUFFER_TYPE_SIZE] |= (1 << (y & DISPLAY_BUFFER_TYPE_MASK));
 		}
 	}
 
--- a/LCDSettings.h	Thu Jul 30 09:01:02 2015 +0000
+++ b/LCDSettings.h	Wed Aug 12 13:32:01 2015 +0000
@@ -10,8 +10,10 @@
 /** Data type for storing buffer the pixel buffer */
 #if	((DISPLAY_WIDTH % 32) == 0)
 #define	DISPLAY_BUFFER_TYPE			uint32_t
+#define DISPLAY_BUFFER_TYPE_MASK    (0x1F)
 #else
 #define DISPLAY_BUFFER_TYPE			uint8_t
+#define DISPLAY_BUFFER_TYPE_MASK    (0x07)
 #endif
 
 #define DISPLAY_BUFFER_TYPE_SIZE	(sizeof(DISPLAY_BUFFER_TYPE) * 8)