custom palette

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

  • custom palette

    Hello everybody!

    Is there anyone that can provide an example of using a custom palette?

    My settings are the following:

    #define COLOR_CONVERSION_0 GUICC_8666
    #define DISPLAY_DRIVER_0 GUIDRV_LIN_8

    in order to set my palette I have modified the following function

    int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)
    ....
    ....
    case LCD_X_SETLUTENTRY:
    #ifdef MY_PALETTE
    HAL_LTDC_ConfigCLUT(&hltdc, (uint32_t *)(my_palette.pPalEntries), my_palette.NumEntries, LayerIndex);
    #else
    HAL_LTDC_ConfigCLUT(&hltdc, (uint32_t *)&(((LCD_X_SETLUTENTRY_INFO *)pData)->Color), 1, LayerIndex);
    #endif
    break;
    ....

    where my_palette is a GUI_PHYSPALETTE defined as LCD_PHYSPALETTE that is

    typedef struct{
    int NumEntries;
    const LCD_COLOR * pPalEntries;
    } LCD_PHYSPALETTE;

    The problem is that if I use the palette that is produced by BitMap converter when setting 8666 color format,
    namely 6 scales for every color, 16 gray levels (that should be the default palette for GUICC_8666), then everything look ok, if I try use a different palette, for instance the palette produced by Bitmap Converter when setting 256 shades of gray then the result is not ok; for instance the white background is not white, it is gray, same for the black, a different gray level but still a gray, not the black.

    Is it because it is not correct to modify the switch-case in LCD_X_DisplayDriver? Do I have to add some code in the LCD_X_Config as well? Is there a emWin sample where custom palette is used?

    I am using STemWin v524b.

    Thanks,
    Ezio
  • Hello Ezio,

    You can do everything which is documented in the emWin user manual. This includes adapting the function LCD_X_DisplayDriver(). Unfortunately I can not tell you if adding code to the function LCD_X_Config() is required as well. This depends on your hardware. Please find attached a sample file for custom palettes. This should also be part of your emWin shipment.

    Best regards,
    Adrian
    Files