cancel
Showing results for 
Search instead for 
Did you mean: 

Examples of usage of copyFBRegionToMemory()

scottSD
Senior III

Does anyone know if there is there an example somewhere of usage of the method copyFBRegionToMemory()?

The documentation says that the buffer can be a dynamic bitmap and I am having issues getting my code to compile.

19 REPLIES 19

I was looking at the article which allocated the buffer in external RAM and wasn't sure at the time where to allocate it for the card I was using.

Regardless, I have it working now. I am curious as to why you are making the buffer so large. Shouldn't it be bbp/8?

It does look like some cushion is needed. Through some empirical testing, I determined that I can use bbp/8 and add an extra 52 bytes to avoid the BITMAP_INVALID:

uint8_t cache[w*h*(bpp/8) + 52];

And it appears that this cushion is the same regardless of the bmp size. And the cushion is needed for each dynamic bmp.

I assume this extra space is for storing info about the dynamic bmp?

Thanks for your help, Martin. I appreciate it.

I was able to allocate space for the bmpCache on an STM32F746G-Discovery board using the method in the link:

https://touchgfx.zendesk.com/hc/en-us/articles/207460605

The amount of the "cushion" used for it was also 52.

I have been doing this using TouchGFX by itself and clicking its "Run Target" button.

However, I would like to use STM32CubeIDE (v1.0.2) so I can debug. I followed your video and was able to successfully create a project.

But this copying of the framebuffer does not appear to work.

The SDRAM board configuration should be setup the same when using STM32CubeIDE , shouldn't it?

I realized what I did wrong in the STM32CubeIDE version of the TouchGFX code.

I had selected 24Bit color depth in the TouchGFX version, but in the STM32CubeIDE version it was set to 16 Bit. When calling dynamicBitmapCreate(), I had hard-coded to use RGB888 type instead of checking the bit depth.

   if (HAL::lcd().bitDepth() == 16)
   {
       bmpId = Bitmap::dynamicBitmapCreate(bmpW, bmpH, Bitmap::RGB565);
       touchgfx_printf("RGB565\n");
   }
   else
   {
       bmpId = Bitmap::dynamicBitmapCreate(bmpW, bmpH, Bitmap::RGB888);
       touchgfx_printf("RGB888\n");
   }

Works now. 😉

That's great, @scottSD​. Good job. And ooooops, on my side, major typo on the calculation of the buffer size. It's divided by 8, of course : ) I forget what the "cushion" should be. It could be related to alignment.

/Martin

Martin,

I have a question concerning this. It is not related to copyFBRegionToMemory() but only to dynamicBitmapCreate(). I am asking it here instead of creating a new post.

I am digging into dynamicBitmapCreate() because I am planning on using a dynamic bmp for setting the background and foreground images of the Image Progress widget.

The dynamicBitmapCreate() works on the target (STM32F746G -Disco) but returns BMP_INVALID when running the simulator on the TouchGFX Designer.

For the Simulator, is there a different place to set the bmpCache other than touchgfx_init() in BoardConfiguration.cpp?

Hi Scott,

simulator/main.cpp:

uint32_t dynamicBitmapBuffer[1000];
 
...
int main(int argc, char** argv)
{
  ...
  HAL& hal = touchgfx_generic_init<HALSDL2>(dma, lcd, tc, SIM_WIDTH, SIM_HEIGHT, 
  (uint16_t*)dynamicBitmapBuffer, sizeof(dynamicBitmapBuffer), 10);
..

Martin, That's it!

Thanks, it is much appreciated!

I think one of your posts above stated SIM_WIDTH and SIM_HEIGHT, but I didn't realize there was additional buffering needed for dynamic bmps for the simulator as well. This helps out and I am beginning to understand.

No problem!

Yeah, the interface is the same - It's easy because we just have to allocate some memory for it and we don't really have to worry about where, when using the simulator 🙂

/Martin

I just realized something that is kind of annoying, but good for anyone to know.

If you edit the CubeMX code for any settings, it will overwrite your BoardConfiguration.cpp file as well as main.cpp (non-simulator) and lose your dynamic bmp cache. :astonished_face: .

I knew I should have committed it to SVN before that......:sad_but_relieved_face:

CubEMX will overwrite anything that isn't inside a "USER CODE SECTION", yeah :( You may even be able to create your own if you have certain places you would like to insert code.

/Martin