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.
Revision 6:fe04073fe90c, committed 2015-07-29
- Comitter:
- stevew817
- Date:
- Wed Jul 29 09:03:13 2015 +0000
- Parent:
- 5:26851f9655cf
- Child:
- 7:6cf0aa7bc0fc
- Commit message:
- Update to showBMP() function and buffer type to support display widths that are not a multiple of 32.
Changed in this revision
--- a/BufferedDisplay.cpp Tue Jun 09 14:48:20 2015 +0000
+++ b/BufferedDisplay.cpp Wed Jul 29 09:03:13 2015 +0000
@@ -70,29 +70,30 @@
* Function to move bitmap into frame buffer
* arguments:
* * bitmap: pointer to uint8 array containing horizontal pixel data
- * * bmpWidth: width of the bitmap in pixels (must be byte multiple)
- * * bmpHeight: height of the bitmap in pixels (must be byte multiple)
- * * startX: starting position to apply bitmap in horizontal direction (0 = leftmost) (must be byte multiple)
- * * startY: starting position to apply bitmap in vertical direction (0 = topmost) (must be byte multiple)
+ * * bmpWidth: width of the bitmap in pixels (must be multiple of 8)
+ * * bmpHeight: height of the bitmap in pixels
+ * * startX: starting position to apply bitmap in horizontal direction (0 = leftmost) (must be multiple of 8)
+ * * startY: starting position to apply bitmap in vertical direction (0 = topmost)
*/
void BufferedDisplay::showBMP(const uint8_t* bitmap, const uint32_t bmpWidth, const uint32_t bmpHeight, const uint32_t startX, const uint32_t startY) {
- uint32_t iterBMP = 0, iterFB = startY;
+ uint32_t bitmapLine = 0, y = startY, bytesPerLine = ((bmpWidth >= (DISPLAY_WIDTH - startX)) ? (DISPLAY_WIDTH - startX) : bmpWidth) / 8;
/* Apply constraints */
if((bmpWidth & 0x07) != 0) return;
- if((bmpHeight & 0x07) != 0) return;
if((startX & 0x07) != 0) return;
- if(startX > DISPLAY_WIDTH) return;
- if((startY & 0x07) != 0) return;
+ if(startX >= DISPLAY_WIDTH) return;
+
+ //Superflouous due to for-loop check
+ //if((startY >= DISPLAY_HEIGHT) return;
/* Copy over bytes to the framebuffer */
- for(; iterFB < DISPLAY_HEIGHT; iterFB++) {
- memcpy( (void*) &(_pixelBuffer[((iterFB * DISPLAY_WIDTH) + startX) / DISPLAY_BUFFER_TYPE_SIZE]),
- (const void*) &(bitmap[iterBMP * (bmpWidth / 8)]),
- (DISPLAY_WIDTH - startX) / 8);
+ for(; y < DISPLAY_HEIGHT; y++) {
+ memcpy( (void*) &(((uint8_t*)_pixelBuffer)[((y * DISPLAY_WIDTH) + startX) / 8]),
+ (const void*) &(bitmap[bitmapLine * (bmpWidth / 8)]),
+ bytesPerLine);
- _dirtyRows[iterFB / DISPLAY_BUFFER_TYPE_SIZE] |= (1 << (iterFB % DISPLAY_BUFFER_TYPE_SIZE));
- iterBMP++;
+ _dirtyRows[y / DISPLAY_BUFFER_TYPE_SIZE] |= (1 << (y % DISPLAY_BUFFER_TYPE_SIZE));
+ bitmapLine++;
}
return;
--- a/BufferedDisplay.h Tue Jun 09 14:48:20 2015 +0000 +++ b/BufferedDisplay.h Wed Jul 29 09:03:13 2015 +0000 @@ -61,10 +61,10 @@ * Function to move bitmap into frame buffer * * @param bitmap pointer to uint8 array containing horizontal pixel data - * @param bmpWidth width of the bitmap in pixels (must be byte multiple) - * @param bmpHeight height of the bitmap in pixels (must be byte multiple) - * @param startX starting position to apply bitmap in horizontal direction (0 = leftmost) (must be byte multiple) - * @param startY starting position to apply bitmap in vertical direction (0 = topmost) (must be byte multiple) + * @param bmpWidth width of the bitmap in pixels (must be multiple of 8) + * @param bmpHeight height of the bitmap in pixels + * @param startX starting position to apply bitmap in horizontal direction (0 = leftmost) (must be multiple of 8) + * @param startY starting position to apply bitmap in vertical direction (0 = topmost) */ void showBMP(const uint8_t* bitmap, const uint32_t bmpWidth, const uint32_t bmpHeight, const uint32_t startX, const uint32_t startY);
--- a/LCDSettings.h Tue Jun 09 14:48:20 2015 +0000 +++ b/LCDSettings.h Wed Jul 29 09:03:13 2015 +0000 @@ -8,7 +8,11 @@ #define DISPLAY_HEIGHT (128) /** Data type for storing buffer the pixel buffer */ +#if ((DISPLAY_WIDTH % 32) == 0) #define DISPLAY_BUFFER_TYPE uint32_t +#else +#define DISPLAY_BUFFER_TYPE uint8_t +#endif #define DISPLAY_BUFFER_TYPE_SIZE (sizeof(DISPLAY_BUFFER_TYPE) * 8) #define DISPLAY_BUFFER_ELEMENTS ((DISPLAY_WIDTH*DISPLAY_HEIGHT)/DISPLAY_BUFFER_TYPE_SIZE)