cancel
Showing results for 
Search instead for 
Did you mean: 

How to draw a dynamic picture at runtime?

DMeix.1
Associate II

I’m using STM32CubeIDE 1.2.1 and TouchGFX 4.13.0 with STM32F746G-DISC0 kit.

I would like to calculate an image at runtime and then display it. Is there a manual or something similar? I have tried the AnimationStorage, unfortunately getAnimationStorage() always returns a Zero.

12 REPLIES 12
Martin KJELDSEN
Chief III

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/dynamic-bitmaps/

(add: Animation storage must be configured when TouchGFX is set up)

/Martin

DMeix.1
Associate II

Thanks for the help, but I still have some questions about the article:

For the bitmap caching I have to use the function touchgfx_generic_init, which parameters do I need here for the board (cacheStartAddr, <STM32F7HAL>, ...) how exactly does the function call look like?

Does this call have to be in the TouchGFXConfiguration.cpp?

Which includes do I Need?

Hello,

Here is the description of the function available in TouchGFXInit.hpp file

/**
 * @fn template <class HALType> HAL& touchgfx_generic_init(DMA_Interface& dma, LCD& display, TouchController& tc, int16_t width, int16_t height, uint16_t* bitmapCache, uint32_t bitmapCacheSize, uint32_t numberOfDynamicBitmaps = 0)
 *
 * @brief TouchGFX generic initialize.
 *
 *        TouchGFX generic initialize.
 *
 * @tparam HALType The class type of the HAL subclass used for this port.
 * @param [in] dma               Reference to the DMA implementation object to use. Can be of type
 *                               NoDMA to disable the use of DMA for rendering.
 * @param [in] display           Reference to the LCD renderer implementation (subclass of LCD).
 *                               Could be either LCD16bpp for RGB565 UIs, or LCD1bpp for
 *                               monochrome UIs or LCD24bpp for 24bit displays using RGB888 UIs.
 * @param [in] tc                Reference to the touch controller driver (or NoTouchController to
 *                               disable touch input).
 * @param width                  The \a native display width of the actual display, in pixels.
 *                               This value is irrespective of whether the concrete UI should be
 *                               portrait or landscape mode. It must match what the display itself
 *                               is configured as.
 * @param height                 The \a native display height of the actual display, in pixels.
 *                               This value is irrespective of whether the concrete UI should be
 *                               portrait or landscape mode. It must match what the display itself
 *                               is configured as.
 * @param [in] bitmapCache       Optional pointer to starting address of a memory region in which
 *                               to place the bitmap cache. Usually in external RAM. Pass 0 if
 *                               bitmap caching is not used.
 * @param bitmapCacheSize        Size of bitmap cache in bytes. Pass 0 if bitmap cache is not used.
 * @param numberOfDynamicBitmaps Number of dynamic bitmaps.
 *
 * @return A reference to the allocated (and initialized) HAL object.
 */

"Does this call have to be in the TouchGFXConfiguration.cpp?"

Yes

"Which includes do I Need?"

No additional include necessary I believe

/Alexandre

DMeix.1
Associate II

thank you,

it works, i had to adjust the parameters of the call: Bitmap::registerBitmapDatabase in the file TouchGFXConfiguration.cpp in the function touchgfx_init()

DMeix.1
Associate II

Unfortunately there are still some questions left, if I execute the configuration accordingly, it works with one image, if I want to create two images (2 x bmpId_i = Bitmap::dynamicBitmapCreate(400, 200, Bitmap::RGB565);) the STM freezes. Works if I use Bitmap::cache(BitmapId id) for the images...

Where exactly can I get more information about caching bitmaps? At: https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/caching-bitmaps/ I can't find this information.

Martin KJELDSEN
Chief III

Anything you do inside TouchGFXConfiguration.cpp will be overridden when you re-generate code from CubeMX. We removed the dynamic bitmap cache configuartion from the Generator because we were getting a lot of settings that smelled too much like application configuration.

You have to write your custom code inside TouchGFXHAL.cpp - initialize() function.

Here's soem more information: https://support.touchgfx.com/docs/development/ui-development/scenarios/loading-images-at-runtime/

/Martin

DMeix.1
Associate II

I understand that I better not make any changes in the generated data. But how should I get to TouchGFXHAL.cpp? Can I read something like that somewhere or do I have to go through the structure completely? I can't find any point in the given links.

And what exactly do I have to call in the initialize()? Bitmap::registerBitmapDatabase? touchgfx_generic_init?...

Martin KJELDSEN
Chief III

TouchGFXHAL.cpp is a file generated for you by the TouchGFX Generator (in CubeMX). The structure is explained in the HAL Development documentation:

https://support.touchgfx.com/docs/development/touchgfx-hal-development/touchgfx-generator

There's a point at the bottom about modifying the code after generation.

/Martin

DMeix.1
Associate II

Thank you, I'll work through it.