cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic create bitmap

DJin.3
Associate

I want to create bitmap dynamically. I called bmpId = Bitmap::dynamicBitmapCreate(800, 480, Bitmap::RGB565); I found bmpId is 0xffff.

and then call Bitmap::cacheGetAddress(bmpId);

system will dead loop in Bitmap::cacheGetAddress(bmpId);

4 REPLIES 4
Martin KJELDSEN
Chief III

Hi @DJin.3​,

You haven't defined a bitmap cache in touchgfx_generic_init() - Without it, you'll get 0xFFFF as your BitmapID (Could not allocate).

/Martin

Martin KJELDSEN
Chief III
uint32_t cache[/*size in words*/];
    
void touchgfx_init()
{
    HAL& hal = touchgfx_generic_init<STM32F7HAL>(dma, display, tc, 480, 272, (uint16_t*)cache, sizeof(cache), 1 /*nr of images*/);
...
}

Thanks for your reply.

But in my code

/* SRE 25/07/2019 Add define to enable or disable TouchScreen */

/* Touchscreen will impact overall performances as it's scanned by Corelib every X frame hal.setTouchSampleRate(X) */

/* Update init to pass parameter related to dynamic Bitmap */

#ifdef NOTOUCH

HAL& hal = touchgfx_generic_init<STA1095HAL_EVB>(dma, display, tcnotouch, dispWidth, dispHeight, bitmapCache , bitmapcache_size , nbcachedbitmap);

    printf("touchgfx HAL Init TouchScreen Disabled \r\n");

#else

  HAL& hal = touchgfx_generic_init<STA1095HAL_EVB>(dma, display, tc, dispWidth, dispHeight, bitmapCache, bitmapcache_size, nbcachedbitmap);

//uint8_t* canvasBuffer = NULL;

hal.setTouchSampleRate(2);

   hal.setFingerSize(1);

printf("touchgfx HAL Init TouchScreen Enabled : Sample rate every 2 frames \r\n");

#endif

It already declare the cache.

Is the cache large enough? I can't really tell from your code - Neither in your init of touchgfx nor where you try to allocate a new dynamic bitmap (it depends on the size and the type).

/Martin