diff --git a/radio/src/bitmaps/Horus/asterisk.png b/radio/src/bitmaps/Horus/asterisk.png index 00c24413d..1e12a2492 100644 Binary files a/radio/src/bitmaps/Horus/asterisk.png and b/radio/src/bitmaps/Horus/asterisk.png differ diff --git a/radio/src/bmp.cpp b/radio/src/bmp.cpp index 05bd94a22..7dc7edc54 100644 --- a/radio/src/bmp.cpp +++ b/radio/src/bmp.cpp @@ -330,7 +330,7 @@ const char * bmpLoad(uint8_t * bmp, const char * filename, uint16_t width, uint1 switch (depth) { case 32: for (int i=h-1; i>=0; i--) { - uint8_t * dst = ((uint8_t *)dest) + i*w*3; + uint8_t * dst = ((uint8_t *)dest) + i*w*2; for (unsigned int j=0; j>24) & 0xff, (pixel>>16) & 0xff, (pixel>>8) & 0xff); dst += 2; - *dst++ = 0x0F; } } break; + case 1: break; @@ -355,13 +355,13 @@ const char * bmpLoad(uint8_t * bmp, const char * filename, uint16_t width, uint1 f_close(&bmpFile); return SDCARD_ERROR(result); } - uint8_t * dst = ((uint8_t *)dest) + i*w*3; + uint8_t * dst = ((uint8_t *)dest) + i*w*2; for (uint32_t j=0; j> ((j & 1) ? 0 : 4)) & 0x0F; uint8_t val = palette[index]; *((uint16_t *)dst) = RGB(val, val, val); dst += 2; - *dst++ = 0x0F; + // *dst++ = 0x0F; } } break; diff --git a/radio/src/gui/Horus/lcd.cpp b/radio/src/gui/Horus/lcd.cpp index 09a6a4a09..a9c675251 100644 --- a/radio/src/gui/Horus/lcd.cpp +++ b/radio/src/gui/Horus/lcd.cpp @@ -400,14 +400,13 @@ void lcdDrawSolidFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlag #endif #if !defined(BOOT) -void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) +void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att) { for (scoord_t i=y; i> 1) + ((pat & 1) << 7); + lcdDrawHorizontalLine(x, i, w, SOLID, att); } } #endif @@ -847,15 +846,23 @@ void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlag display_t color = lcdColorTable[COLOR_IDX(att)]; uint8_t opacity = 0x0F - (att >> 24); - while (w--) { - if (pat & 1) { + if (pat == SOLID) { + while (w--) { lcdDrawTransparentPixel(p, opacity, color); - pat = (pat >> 1) | 0x80; + p++; } - else { - pat = pat >> 1; + } + else { + while (w--) { + if (pat & 1) { + lcdDrawTransparentPixel(p, opacity, color); + pat = (pat >> 1) | 0x80; + } + else { + pat = pat >> 1; + } + p++; } - p++; } } @@ -883,6 +890,13 @@ void lcdDrawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat, LcdFlags } } +#if defined(SIMU) +inline void lcdDrawBitmapDMA(coord_t x, coord_t y, coord_t width, coord_t height, const uint8_t * img) +{ + lcdDrawBitmap(x, y, img-4, 0, 0, -1); +} +#endif + #if !defined(BOOT) void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * bmp, coord_t offset, coord_t width, int scale) { @@ -898,16 +912,15 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * bmp, coord_t offset, co } if (scale == 0) { - scale = -1; + lcdDrawBitmapDMA(x, y, width, height, bmp+4); } - - if (scale < 0) { + else if (scale < 0) { for (coord_t i=0, row=0; row> 11; - uint16_t blue = 0x001F & color; - uint16_t green = (0x07E0 & color) >> 5; + uint8_t red = (0xF800 & color) >> 11; + uint8_t blue = 0x001F & color; + uint8_t green = (0x07E0 & color) >> 5; - /* configure DMA2D */ - DMA2D_InitTypeDef DMA2D_InitStruct; DMA2D_DeInit(); + + DMA2D_InitTypeDef DMA2D_InitStruct; DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; DMA2D_InitStruct.DMA2D_OutputGreen = green; @@ -450,18 +450,84 @@ void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, u while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET); } +void lcdDrawBitmapDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t * bitmap) +{ + uint32_t addr = CurrentFrameBuffer + 2*(LCD_W*y + x); + + DMA2D_DeInit(); + + DMA2D_InitTypeDef DMA2D_InitStruct; + DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = addr; + DMA2D_InitStruct.DMA2D_OutputGreen = 0; + DMA2D_InitStruct.DMA2D_OutputBlue = 0; + DMA2D_InitStruct.DMA2D_OutputRed = 0; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0; + DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_W - w); + DMA2D_InitStruct.DMA2D_NumberOfLine = h; + DMA2D_InitStruct.DMA2D_PixelPerLine = w; + DMA2D_Init(&DMA2D_InitStruct); + + DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct; + DMA2D_FG_StructInit(&DMA2D_FG_InitStruct); + DMA2D_FG_InitStruct.DMA2D_FGMA = CONVERT_PTR_UINT(bitmap); + DMA2D_FG_InitStruct.DMA2D_FGO = 0; + DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0; + DMA2D_FGConfig(&DMA2D_FG_InitStruct); + + /* Start Transfer */ + DMA2D_StartTransfer(); + + /* Wait for CTC Flag activation */ + while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET); +} + +void DMAcopy(void * src, void * dest, int len) +{ + DMA2D_DeInit(); + + DMA2D_InitTypeDef DMA2D_InitStruct; + DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = CONVERT_PTR_UINT(dest); + DMA2D_InitStruct.DMA2D_OutputGreen = 0; + DMA2D_InitStruct.DMA2D_OutputBlue = 0; + DMA2D_InitStruct.DMA2D_OutputRed = 0; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0; + DMA2D_InitStruct.DMA2D_OutputOffset = 0; + DMA2D_InitStruct.DMA2D_NumberOfLine = LCD_H; + DMA2D_InitStruct.DMA2D_PixelPerLine = LCD_W; + DMA2D_Init(&DMA2D_InitStruct); + + DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct; + DMA2D_FG_StructInit(&DMA2D_FG_InitStruct); + DMA2D_FG_InitStruct.DMA2D_FGMA = CONVERT_PTR_UINT(src); + DMA2D_FG_InitStruct.DMA2D_FGO = 0; + DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0; + DMA2D_FGConfig(&DMA2D_FG_InitStruct); + + /* Start Transfer */ + DMA2D_StartTransfer(); + + /* Wait for CTC Flag activation */ + while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET); +} + void lcdStoreBackupBuffer() { - for (uint16_t * src = (uint16_t *)CurrentFrameBuffer, * dest = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; src < (uint16_t *)(CurrentFrameBuffer+DISPLAY_BUFFER_SIZE); src++, dest++) { - *dest = *src; - } + uint16_t * src = (uint16_t *)CurrentFrameBuffer, * dest = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; + DMAcopy(src, dest, DISPLAY_BUFFER_SIZE); } void lcdRestoreBackupBuffer() { - for (uint16_t * dest = (uint16_t *)CurrentFrameBuffer, * src = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; dest < (uint16_t *)(CurrentFrameBuffer+DISPLAY_BUFFER_SIZE); src++, dest++) { - *dest = *src; - } + uint16_t * dest = (uint16_t *)CurrentFrameBuffer, * src = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; + DMAcopy(src, dest, DISPLAY_BUFFER_SIZE); } void lcdRefresh() diff --git a/radio/util/img2lbm.py b/radio/util/img2lbm.py index 7d8a152c2..e02ac7a25 100755 --- a/radio/util/img2lbm.py +++ b/radio/util/img2lbm.py @@ -51,7 +51,8 @@ elif what == "5/6/5/8": for x in range(width): pixel = image.pixel(x, y) val = ((Qt.qRed(pixel) >> 3) << 11) + ((Qt.qGreen(pixel) >> 2) << 5) + ((Qt.qBlue(pixel) >> 3) << 0) - f.write("%d,%d,%d," % (val%256, val/256, Qt.qAlpha(pixel) >> 4)) + # f.write("%d,%d,%d," % (val%256, val/256, Qt.qAlpha(pixel) >> 4)) + f.write("%d,%d," % (val%256, val/256)) f.write("\n") elif what == "4bits": colors = []