MEM_DEV_WriteAt

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • MEM_DEV_WriteAt

    Hi, I'm usign MEMDEVICES to make a image to rotate in screen. I create 3 MEM_DEV: image_background, image_source, image_destination. Image_background is a LCD copy made before the screen initialization. Image_source is a MEM_DEV created from a SDRAM copy of a image created by BitmapConverter (dta type). Image_destination is the image generated by MEMDEV_ROTATE with angle and magnifier parameters.

    The sequence of my code is something like 2 functions. LoadIcon to read the source image and create background and RotateIcon to rotate the image and draw it to screen:

    void LoadIcon(ICON_ROTATION* icon, GUI_BITMAP *bmp)
    {
    hMemSource[icon->icon_id] = GUI_MEMDEV_CreateFixed(icon->x,icon->y,icon->w,icon->h,GUI_MEMDEV_HASTRANS,GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
    hMemDest[icon->icon_id] = GUI_MEMDEV_CreateFixed(icon->x,icon->y,icon->w,icon->h,GUI_MEMDEV_HASTRANS,GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
    hMemBk[icon->icon_id] = GUI_MEMDEV_CreateFixed(icon->x,icon->y,icon->w,icon->h,GUI_MEMDEV_NOTRANS,GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_888);
    GUI_MEMDEV_Select(hMemBk[icon->icon_id]);
    GUI_MEMDEV_CopyFromLCD(hMemBk[icon->icon_id]);
    statusimg=4;
    GUI_MEMDEV_Select(hMemSource[icon->icon_id]);
    GUI_SetBkColor(GUI_TRANSPARENT);
    GUI_Clear();
    GUI_DrawBitmap(&icones[icon->icon_id],(icon->x+(icon->w/2)-(sprite->XSize/2)),(icon->y+(icon->h/2)-(sprite->YSize/2))); //EMV 0302
    GUI_MEMDEV_Select(0); //retorna para p/ LCD
    }

    void RotateIcon(U8 icon_id, U16 angle, ICON_ROTATION* icon)
    {
    GUI_MEMDEV_Select(hMemDest[icon_id]);
    GUI_MEMDEV_WriteAt(hMemBk[icon_id],icon->x,icon->y);
    GUI_MEMDEV_Rotate(hMemSource[icon_id], hMemDest[icon_id], icon->icon_rotation_center_x, icon->icon_rotation_center_y, (-1000*(angle>initial_rotation_angle)), 1000);
    GUI_MEMDEV_Select(0);
    GUI_MEMDEV_WriteAt(hMemDest[icon_id],icon->x,icon->y);
    }

    The problem is sometimes (very frequently) when GUI_MEMDEV_WriteAt(hMemBk) is executed, a Hard Fault is reached in by code.
    I already verify MemoryUsage by emWin, tested SDRAM timing, and tried another MEMDEV in this project. The only problem is with this feature of rotate a image.
    I believe the issue is because different types of depth color. My LCD is a TFT16bit and the image generated by BitmapConverter is a 8 bit pallete image. I'm right?
    Thanks.
  • Hi,
    After reading one more time emWin User Guide, I've notice the GUI_MEMDEV_CreateAuto function. Is it better for move a pointer image? Is it faster than manage individualy each MEM_DEV (icon, background and LCD)?
    Thanks,
  • Hello Ana,

    In general your code seems to be ok. I did a test with almost the same (see attached) and it worked on my side.
    My LCD is a TFT16bit and the image generated by BitmapConverter is a 8 bit pallete image. I'm right?
    It depends on in which format you have saved the image with the BitmapConverter. But it souldn't matter in which format it is. When drawing it with GUI_DrawBitmap() it will be converted into the format of the destination device.

    Please check the memory again.

    Are all memory devices created properly (hMem != 0)?
    It seems you are creating more than just these three. Depending on their size they require quite some memory. If there is not enough memory the GUI_MEMDEV_Create() function returns with 0.

    How much memory do you have spend emWin (second parameter of GUI_ALLOC_AssignMemory() in GUIConf.c)?

    Regards,
    Sven
    Files
    • MemdevRotate.zip

      (14.26 kB, downloaded 294 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Sven,
    I will check your code.
    Yes, all hMem are allocated as well, such as, they are different from 0. All GUI_MEMDEV_Create() returns a non zero value.
    I allocated 16MB during GUI_Conf.c. My full SDRAM size is 32MB.
    I check memory configuration again, ran a test code of several writes and reads and it is ok.
    I get DataPtr value and read the memory content before to WriteAt and It is ok.
    How could I test it? Using CREATE_Auto is better?
    Thanks.