BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Pages: [1] 2

Author Topic: ASTC Custom Font from Flash  (Read 15594 times)

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
ASTC Custom Font from Flash
« on: November 16, 2022, 04:42:30 PM »

Hi,

I have a question. I'm currently working on Chinese Simplified Custom Font that store in the built-in Flash as ASTC (EVE4) with the format.

Quote
Font Conversion completed!

Generated Folder: FZShuSong_36_Extend
Format:           COMPRESSED_RGBA_ASTC_10x5_KHR
Compressed:       thorough
Layout Width:     64
Layout Height:    8
Pixel Width:      40
Pixel Height:     40
Number of characters in xfont file:      65408
Number of characters in user input file: 292
   Success: 287
   Fail:    5
   Fail code point: 0x5f00, 0x8a00, 0x9000, 0x9700, 0x9600
There are non-graphic characters filtered out.
FZShuSong_36_ASTC.xfont and FZShuSong_36_ASTC.glyph are generated successfully.

----------------------------------------------------------------------

Flash Size for Custom Font
Quote
19.FZShuSong_30_ASTC.glyph                  : 3925440 : 1263360
20.FZShuSong_30_ASTC.xfont                  : 5188800 : 8832   
21.FZShuSong_36_ASTC.glyph                  : 5197632 : 2021376
22.FZShuSong_36_ASTC.xfont                  : 7219008 : 8832 

I use ASTC Speed Veryfast

The problem I got now is I can't display more than 7 characters (UTF-8) using Gpu_CoCmd_Text.

Font Setup
Quote
             
#define LANG_CN_XFONT_30_ASTC_ADDRESS  5188800
#define LANG_CN_XFONT_30_ASTC_SIZE     8832

#define LANG_CN_XFONT_36_ASTC_ADDRESS  7219008
#define LANG_CN_XFONT_36_ASTC_SIZE     8832

//Load font 30
Gpu_CoCmd_FlashRead(phost, RAM_G + 1000000, LANG_CN_XFONT_30_ASTC_ADDRESS, LANG_CN_XFONT_30_ASTC_SIZE);
Gpu_Hal_WaitCmdfifo_empty(phost);

//Load font 36
Gpu_CoCmd_FlashRead(phost, RAM_G + 1000000 + LANG_CN_XFONT_30_ASTC_SIZE, LANG_CN_XFONT_36_ASTC_ADDRESS, LANG_CN_XFONT_36_ASTC_SIZE);
Gpu_Hal_WaitCmdfifo_empty(phost);

Gpu_CoCmd_SetFont2(phost, FONT_S_HANDLE, RAM_G + 1000000, 0);
Gpu_CoCmd_SetFont2(phost, FONT_M_HANDLE, RAM_G + 1000000 + LANG_CN_XFONT_30_ASTC_SIZE, 0);


Quote
Gpu_CoCmd_SetBitmap(phost, RAM_G + 1000000, COMPRESSED_RGBA_ASTC_8x8_KHR, 32, 40);
Gpu_CoCmd_SetBitmap(phost, RAM_G + 1000000 + LANG_CN_XFONT_30_ASTC_SIZE, COMPRESSED_RGBA_ASTC_10x5_KHR, 40, 40);
Gpu_CoCmd_Text(phost, 30, 133/2, FONT_M_HANDLE, OPT_CENTERY, "设置流速");
Gpu_CoCmd_Text(phost, 230, 133/2, FONT_M_HANDLE, OPT_CENTERY, "= 10 ml/min");


Gpu_CoCmd_Text(phost, 30, 133/2 + 133, FONT_M_HANDLE, OPT_CENTERY, "实际流速");
Gpu_CoCmd_Text(phost, 230, 133/2 + 133, FONT_M_HANDLE, OPT_CENTERY, "= 10 ml/min");

Gpu_CoCmd_Text(phost, 30, 133/2 + 266, FONT_M_HANDLE, OPT_CENTERY, "输注量");
Gpu_CoCmd_Text(phost, 230, 133/2 + 266, FONT_M_HANDLE, OPT_CENTERY, "= 0 ml");


Gpu_CoCmd_Text(phost, 550, 133/2 + 133, FONT_M_HANDLE, OPT_CENTERY, "T = 33.8 °C");

// From now on, Text can't take any more.
//Gpu_CoCmd_Text(phost, 550, 133/2 + 266, FONT_M_HANDLE, OPT_CENTERY, "P = 130");
//Gpu_CoCmd_Text(phost, 512, 100, FONT_M_HANDLE, OPT_CENTER, "检查温度探测器窗口是否堵塞");

As I said, after the line T = 33.8 °C. the Cmd can't handle more input string.
The display is going crazy if I try to use display more text. I'm not sure what is the limit of the CMD_Text.
I want to use the ASTC and store in Flash because the table is big.
I'm not sure where I did wrong or how to solve this problem.

Also in some case, if the string of UTF-8 too long, the cmd is also not work and display go crazy again. Is it because UTF-8 take 3 bytes per char? and the Cmd can't handle it?

I'm using RVT70HSBNWC00-B - Riverdi (7" Display with 1024x600px resolution)
« Last Edit: November 16, 2022, 05:22:49 PM by vdc »
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #1 on: November 17, 2022, 12:47:44 PM »

Hello,

Thank you for your question.

The CMD_TEXT command is structured in such a way that the input string can technically be infinitely long, however this is limited by the size of RAM_DL (4K), as such longer CMD_TEXT strings can take up quite significant amounts of RAM_DL especially with such unicode characters that use 3 bytes for encoding.

For example, the following command would use 24 bytes of RAM_DL:

Code: [Select]
Gpu_CoCmd_Text(phost, 30, 133/2, FONT_M_HANDLE, OPT_CENTERY, "设置流速");
Is the display list you have provided the entire display list you are testing, or is this just a snippet of your display list?

Could you also provide a link for the font file you have used in the conversion so i can test this?

Best Regards,
BRT Community
Logged

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #2 on: November 17, 2022, 03:09:24 PM »

Here is my sample code. I don't think I use up RAM_DL.
Although my complete program will be more but even with this simple code, it still doesn't work.
I also tried with NotoSansCJK-Regular.ttf font and it does the same thing.

I have attached converted chars that using EAB 2.6.1. I'm not sure how the xfont look up for the character in glyph from flash but everytime I tried with 'H', the display go white. Is there any limitation of ASTC font table from Flash? I know the limit of UTF-8 is 127 if using RAM_G for glyph, but I'm not sure for directly from Flash.

I'm using Code Composer Studio 10.4.0 and also make sure that UTF-8 is enable for text file encoding. (Preferences --> Workspace --> Text file encoding (UTF-8).

Quote
// Font Map
// 19.FZShuSong_30_ASTC.glyph                  : 3925440 : 1263360
// 20.FZShuSong_30_ASTC.xfont                  : 5188800 : 8832   
// 21.FZShuSong_36_ASTC.glyph                  : 5197632 : 2021376
// 22.FZShuSong_36_ASTC.xfont                  : 7219008 : 8832   

#define FONT_S_HANDLE  (1)   // Small Font
#define FONT_M_HANDLE  (2)   // Medium Font


int main(void)
{
   DisplayConfiguration();   // Setup Display, SPI at 16Mhz, 1024x600
    Gpu_CoCmd_FlashHelper_SwitchFullMode(phost);   // Switch Built-In flash to FULL MODE
   
   // Load XFont from Flash
   //Load font 30
   Gpu_CoCmd_FlashRead(phost, RAM_G + 1000000, 5188800, 8832);
   Gpu_Hal_WaitCmdfifo_empty(phost);

   //Load font 36
   Gpu_CoCmd_FlashRead(phost, RAM_G + 1000000 + 8832, 7219008, 8832);
   Gpu_Hal_WaitCmdfifo_empty(phost);
   
   while(1){
      // Screen PreCode
      Gpu_CoCmd_Dlstart(phost);
      App_WrCoCmd_Buffer(phost, CLEAR_COLOR_RGB(0, 0, 0));
      App_WrCoCmd_Buffer(phost,CLEAR(1,1,1));


      // Set Font Handle
      Gpu_CoCmd_SetFont2(phost, FONT_S_HANDLE, RAM_G + 1000000, 0);
      Gpu_CoCmd_SetFont2(phost, FONT_M_HANDLE, RAM_G + 1000000 + LANG_CN_XFONT_30_ASTC_SIZE, 0);

      App_WrCoCmd_Buffer(phost, COLOR_RGB(0xFF,0xCA,0x18));

      // Reset Font BitMap (to make sure the bitmap is at correct xfont in case previous SetBitMap for image in use)
      Gpu_CoCmd_SetBitmap(phost, RAM_G + 1000000, COMPRESSED_RGBA_ASTC_8x8_KHR, 32, 40);
      Gpu_CoCmd_SetBitmap(phost, RAM_G + 1000000 + LANG_CN_XFONT_30_ASTC_SIZE, COMPRESSED_RGBA_ASTC_10x5_KHR, 40, 40);


      Gpu_CoCmd_Text(phost, 30, 133/2, FONT_M_HANDLE, OPT_CENTERY, "设置流速");
      Gpu_CoCmd_Text(phost, 230, 133/2, FONT_M_HANDLE, OPT_CENTERY, "= 10 ml/min");


      Gpu_CoCmd_Text(phost, 30, 133/2 + 133, FONT_M_HANDLE, OPT_CENTERY, "实际流速");
      Gpu_CoCmd_Text(phost, 230, 133/2 + 133, FONT_M_HANDLE, OPT_CENTERY, "= 10 ml/min");

      Gpu_CoCmd_Text(phost, 30, 133/2 + 266, FONT_M_HANDLE, OPT_CENTERY, "输注量");
      Gpu_CoCmd_Text(phost, 230, 133/2 + 266, FONT_M_HANDLE, OPT_CENTERY, "= 0 ml");


      Gpu_CoCmd_Text(phost, 550, 133/2 + 133, FONT_M_HANDLE, OPT_CENTERY, "T = 33.8 °C");

      //Gpu_CoCmd_Text(phost, 550, 133/2 + 266, FONT_M_HANDLE, OPT_CENTERY, "P = 130 mmHg");

      //Gpu_CoCmd_FillWidth(phost, 50);
      // Gpu_CoCmd_Text(phost, 10, 100, FONT_M_HANDLE, 0, "值停力功加务动储修入\n关其匹升卡却器一上下\n不与中\n主和品分到制\n前传位低");


      // Screen PostCode
      App_WrCoCmd_Buffer(phost, DISPLAY());
      Gpu_CoCmd_Swap(phost);
      App_Flush_Co_Buffer(phost); //Download the commands into fifo
      while(EVE_busy()); // Gpu_Hal_WaitCmdfifo_empty(phost); //Wait till coprocessor completes the operation   

      // Delay(100ms)
   }

   return 0;
}


p/s: I'm try to get the BRT_AN_042 from https://brtchip.com/software-examples/eve-examples/ but the links doesn't work anymore. Is there any where I can download this file?
Thanks,
« Last Edit: November 17, 2022, 03:25:39 PM by vdc »
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #3 on: November 20, 2022, 08:47:17 PM »

This is likely to be a bandwidth issue between the BT817 and the SPI-Flash.
I converted NotoSansSC-Regular.otf with your table and EAB outputs 48x48 pixel for the glyhs for a size of 36.

So the first thing you can try is to use much smaller fonts, like 24.
Just to test this.
24 is converted here to 24x32 pixel and is using ASTC 8x8 on setting "auto".

If that works with more characters this is a bandwidth issue.

 
Next you can setup the font-cache for the larger font, see CMD_FONTCACHE.
This way a subset of glyphs is fetched from RAM_G.
CMD_FONTCACHEQUERY helps tuning the memory for the cache.

ASTC 10x5 is 2.56 bits per pixel.
So 40 * 40 * 2.56 is 4096.
A glyph needs to be 32 byte aligned but 4096 is divisible by 32.
For 20 chars fontcache we need 4096 * 20 = 81920 bytes.
Note that the start of the cache needs to be 64-byte aligned.

ASTC 8x8 uses 2 bits per pixel:
40 * 40 * 2 = 3200.
20 * 3200 = 64000 bytes

EAB 2.6.1 converts NotoSansSC-Regular.otf to ASTC 8x8 for me when set to "Auto".
Generated Folder: NotoSansSC-Regular_36_Extend
Format:           COMPRESSED_RGBA_ASTC_8x8_KHR
Compressed:       thorough
Layout Width:     80
Layout Height:    8
Pixel Width:      40
Pixel Height:     64
Number of characters in xfont file:      65408
Number of characters in user input file: 292
   Success: 287
   Fail:    5
   Fail code point: 0x5f00, 0x8a00, 0x9000, 0x9600, 0x9700
NotoSansSC-Regular_36_ASTC.xfont and NotoSansSC-Regular_36_ASTC.glyph are generated successfully.

40 * 64 * 2 = 5120
20 * 5120 = 102400 bytes


The "Fail: 5" is interesting as EAB 2.5.1 did not have any fails.

Hmm, when I manually set it to 10x5 I get this:
Generated Folder: NotoSansSC-Regular_36_Extend
Format:           COMPRESSED_RGBA_ASTC_10x5_KHR
Compressed:       thorough
Layout Width:     64
Layout Height:    8
Pixel Width:      40
Pixel Height:     40
Number of characters in xfont file:      65408
Number of characters in user input file: 292
   Success: 287
   Fail:    5
   Fail code point: 0x5f00, 0x8a00, 0x9000, 0x9600, 0x9700

So the same amount of characters for the same map but somehow the glyphs are smaller?
How? Why?

Ok, setting it to 10x8 for 1.6 bits per pixel the result is 40x40 pixel for the glyphs.
40 * 40 * 1.6 = 2560 (2560 % 32 = 0)
20 * 2560 = 51200 bytes


And one last thing.
Setup REG_AH_HCYCLE_MAX to for example HCYCLE + 500, the reset value is zero.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #4 on: November 21, 2022, 01:52:20 PM »

Hello,

Thank you for your full display list, I concur it is unlikely in this case that you are running out of RAM_DL.

IT may be as Rudolph mentions a bandwidth issue between the SPI flash and EVE, you can test this quickly by converting a smaller font size to see if you get the same behaviour. If this is the case, there are a couple of settings I can suggest which should help mitigate the behaviour.

Please let me know how you get on.

Best Regards,
BRT Community
Logged

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #5 on: November 21, 2022, 02:51:23 PM »

Hi Rudolph,

Thank you for the response. I tried with font 24, it getting better but if the string a long enough (ex. "堵住位于一次性使用输血通用管路上的排气阀。") , the display still going crazy.

Since I use 1024x600 display. I do need bigger font to fit and easy to read for user. Unless there is upscale for text font. I will try with difference methods as you mentions and see how it works.

Thanks,
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #6 on: November 22, 2022, 01:20:57 PM »

Hello,

Could you let me know what display settings you are using along with the system clock settings?
Also have you enabled REG_ADAPTIVE_FRAMERATE?

Best Regards,
BRT Community
Logged

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #7 on: November 22, 2022, 01:59:39 PM »

Here is my setup.

I'm using Riverdi 7" EVE4 Display (RVT70HSBNWC00-B)

https://riverdi.com/download/RVT70HSBNWC00-B/DS_RVT70HSBNWC00-B_Rev.1.5.pdf

I'm using TM4C1294NCPDT MCU and run at 120Mhz

Quote
//=====================================
// Setup Display
//=====================================
void BT81X_Setup(void){

    //UARTprintf("**** START BT816 SETUP ****\r\n");
    Gpu_HalInit_t halinit;    /* Not used in this port, but OK to place here */

    // Set Channel 1: Only 1 display connected
    halinit.TotalChannelNum = 1;

    /* API to initialize the SPI interface using SSI3 */
    Gpu_Hal_Init(&halinit);  // Enable SPI3 Here
    host.hal_config.channel_no = 0; //mpsse channel number

#ifdef TM4C_PLATFORM
    host.hal_config.spi_clockrate_khz = 12000; //in KHz = 12Mhz
#endif

    Gpu_Hal_Open(&host);

    phost = &host;

    BootupConfig(&host);
    UARTprintf("**** BOOTUP CONFIG DONE ****\r\n");

    //
    // This use to load images and fonts before use
    // Load background Init Image. Also this will set the default value for TTM_DATA ttm
    //
    RI_Init_appl();

    /* Close all the opened handles */
    Gpu_Hal_Close(phost);
    Gpu_Hal_DeInit();

}


Quote
bool_t Gpu_Hal_Init (Gpu_HalInit_t *halinit)
{

#ifdef TM4C_PLATFORM
    // Init SPI Display
    // set up SPI at 16 Mhz for BT817 Init
    SSI3_Init(16000000);   // SPI Clockrate at 16Mhz
    UARTprintf("**** SSI3 - DISPLAY CLOCK AT 16Mhz ****\r\n");
#endif

  return TRUE;
}


Quote
/* Default is IPS 1024 x 600 */
#define DispWidth     1024L
#define DispHeight    600L

#define DispHCycle    1344L
#define DispHOffset   160L
#define DispHSync0    0L
#define DispHSync1    70L

#define DispVCycle    635L
#define DispVOffset   23L
#define DispVSync0    0
#define DispVSync1    10L

#define DispPCLK      1
#define DispSwizzle   0
#define DispPCLKPol   1
#define DispCSpread   0
#define DispDither    0
#define DispPLCLKFREQ  0xD12
#define DispPCLK2x     0

void BootupConfig(Gpu_Hal_Context_t *host)
{
    // Do a power cycle for safer side. Turn ON/OFF PD
    Gpu_Hal_Powercycle(host,TRUE);
    UARTprintf("**** GPU POWERCYCLE ****\r\n");


    /* Switch PLL output to 48MHz */
#ifdef BT81X_ENABLE
    Gpu_PowerModeSwitch(host, GPU_SLEEP_M); //access address 0 to wake up the chip
    UARTprintf("**** GPU SLEEP ****\r\n");
    Gpu_Hal_Sleep(300);

    Gpu_HostCommand(host,GPU_INTERNAL_OSC);  //FT_GPU_c
    Gpu_Hal_Sleep(100);
    UARTprintf("**** GPU INTERNAL OSC ****\r\n");
#endif

    Gpu_HostCommand(host, GPU_ACTIVE_M);     // Active the display
    Gpu_Hal_Sleep(300);     //wait for 300 ms
    UARTprintf("**** GPU ACTIVE ****\r\n");

    Gpu_81X_SelectSysCLK(host, GPU_SYSCLK_72M); //change system frequency
    UARTprintf("**** GPU SYSCLK 72Mhz ****\r\n");

    Gpu_Hal_Wr32(host, REG_FREQUENCY, 72000000); // Configure the display system clock to 72Mhz

    // Read register ID to check if the chip ID series is correct
    {
        uint8_t ui8Chipid;
        uint32_t ui32ID;
        do{
            ui8Chipid = Gpu_Hal_Rd8(host, REG_ID);
            Gpu_Hal_Sleep(100);
            UARTprintf("**** CHIP ID: 0x%x ****\r\n", ui8Chipid);

            ui32ID = Gpu_Hal_Rd32(host, 0xC0000);
            UARTprintf("**** ID: 0x%08x ****\r\n", ui32ID);
        }  while (ui8Chipid != 0x7C); // 0x7C
    }

    // read REG_CPURESET to confirm 0 is returned
    {
        uint8_t ui8EnStatus;
        /* Read REG_CPURESET to check if engines are ready.
         Bit 0 for coprocessor engine,
         Bit 1 for touch engine,
         Bit 2 for audio engine.
         */
        ui8EnStatus = Gpu_Hal_Rd8(host,REG_CPURESET);
        while(ui8EnStatus != 0x00){
            ui8EnStatus = Gpu_Hal_Rd8(host,REG_CPURESET);
            Gpu_Hal_Sleep(100);
        }
    }

    Gpu_Hal_Wr16(host, REG_PWM_HZ, 4000);
    Gpu_Hal_Wr8(host, REG_PWM_DUTY, 128);

    uint16_t ui16PWMHz = Gpu_Hal_Rd16(phost, REG_PWM_HZ);
    UARTprintf("**** pwmHz: %d  ****\r\n", ui16PWMHz);
   
    // Configuration display registers  for WVGA 800x480 resolution
#ifdef EVE_4
    Gpu_Hal_Wr16(host, REG_PCLK_FREQ, DispPLCLKFREQ);
    Gpu_Hal_Wr8(host, REG_PCLK_2X, DispPCLK2x);
#endif

    // Configuration of LCD display
    Gpu_Hal_Wr16(host, REG_HSIZE, DispWidth);   // DispWidth
    Gpu_Hal_Wr16(host, REG_VSIZE, DispHeight);   // DispHeight
    Gpu_Hal_Wr16(host, REG_HCYCLE, DispHCycle);  // DispHCycle
    Gpu_Hal_Wr16(host, REG_HOFFSET, DispHOffset); // DispHOffset
    Gpu_Hal_Wr16(host, REG_HSYNC0, DispHSync0);  // DispHSync0
    Gpu_Hal_Wr16(host, REG_HSYNC1, DispHSync1);  // DispHSync1
    Gpu_Hal_Wr16(host, REG_VCYCLE, DispVCycle);  // DispVCycle
    Gpu_Hal_Wr16(host, REG_VOFFSET, DispVOffset); // DispVOffset
    Gpu_Hal_Wr16(host, REG_VSYNC0, DispVSync0);  // DispVSync0
    Gpu_Hal_Wr16(host, REG_VSYNC1, DispVSync1);  // DispVSync1

    Gpu_Hal_Wr8(host, REG_SWIZZLE, DispSwizzle); // DispSwizzle
    Gpu_Hal_Wr8(host, REG_PCLK_POL, DispPCLKPol); // DispPCLKPol

    Gpu_Hal_Wr16(host, REG_CSPREAD, DispCSpread); // DispCSpread
    Gpu_Hal_Wr16(host, REG_DITHER, DispDither); // DispDither

   
    /* Enable backlight of display panel */
    Gpu_Hal_Wr8(host, REG_GPIO_DIR, 0xff);
    Gpu_Hal_Wr8(host, REG_GPIO, 0xff);


    Gpu_ClearScreen(host);
    // after this display is visible on the LCD
    Gpu_Hal_Wr8(host, REG_PCLK, DispPCLK); //Configure the PCLK divisor to 2, i.e. PCLK = System CLK/2

    host->cmd_fifo_wp = Gpu_Hal_Rd16(host,REG_CMD_WRITE); // Update coprocessor fifo write pointer. should be 0 here
}

I do not use the REG_ADAPTIVE_FRAMERATE and CMD_FONTCACHE because I'm not sure how to properly enable it.

Any suggest?

Thank you all so much.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #8 on: November 22, 2022, 02:44:24 PM »

Hello,

You can find an example of how to utilise CMD_FONTCACHE at the following:
https://github.com/BRTSG-FOSS/EveApps/blob/825eaeb620274d29082388f448a263525d5fa886/SampleApp/Font/Src/Font.c

As for Adaptive frame rate, you can write the register during your initialization sequence, during your 'configuration of LCD' block, but the LCD must support this feature if it is to be beneficial.

Best Regards,
BRT community
Logged

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #9 on: November 23, 2022, 01:06:01 PM »

When using the CMD_FONTCACHE. How to calculate the Cache I need for the screen? It is not really clear in the example.

Quote
    const uint32_t startOfCache = 800 * 1024;
    const uint32_t cacheSize = 160 * 1024;

Is this based on how many characters that I want to display on screen.

For example if I want to display 100 UTF-8 characters (take 300 bytes).

Quote
void cmd_fontcache( uint32_t font, int32_t ptr, uint32_t num );

startOfCache (ptr) will be the address from the RAM_G with 64-byte aligned.
cacheSize (num) will be the size of characters I wan to this display in 4 byte aligned. Here will be 100 * 1024.

Is this correct?

Thanks.
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #10 on: November 23, 2022, 03:40:57 PM »

startOfCache (ptr) will be the address from the RAM_G with 64-byte aligned.
cacheSize (num) will be the size of characters I wan to this display in 4 byte aligned. Here will be 100 * 1024.

Is this correct?

No, not exactly, see what I wrote.
The size of one glyph is the amount of pixels multiplied with the bits per pixel from the compression.
And each glyph needs to be stored 32 byte aligned.

ASTC 8x8 uses 2 bits per pixel:
40 * 40 * 2 = 3200

ASTC 10x8 uses 1.6 bits per pixel:
40 * 40 * 1.6 = 2560 (2560 % 32 = 0)

ASTC 10x6 uses 2.13 bits per pixel:
40 * 40 * 2.13 = 3408 -> 3424 (3408 % 32 = 16)

But that is just a theory for the moment, I am not entirely sure that the 40x40 pixels the font
converter outputs is really the size of the glyph.
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #11 on: November 23, 2022, 04:10:10 PM »

You can find an example of how to utilise CMD_FONTCACHE at the following:
https://github.com/BRTSG-FOSS/EveApps/blob/825eaeb620274d29082388f448a263525d5fa886/SampleApp/Font/Src/Font.c

As a side note, I wish we had more than 32 bitmap-handles and could setup/query more than one font cache. ;)

Quote
As for Adaptive frame rate, you can write the register during your initialization sequence, during your 'configuration of LCD' block, but the LCD must support this feature if it is to be beneficial.

REG_ADAPTIVE_FRAMERATE has a reset value of 0x1 so it is enabled by default.
It does not seem to do anything though, at least not in regards of saving the pixel engine from crashing when there is not enough time per line.

REG_AH_HCYCLE_MAX has a reset value of 0x0 so adaptive HSYNC is disabled by default.
Hence my recommendation:
"Setup REG_AH_HCYCLE_MAX to for example HCYCLE + 500, the reset value is zero."
Logged

david

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #12 on: November 23, 2022, 04:27:58 PM »

Just a comment about "It does not seem to do anything though, at least not in regards of saving the pixel engine from crashing when there is not enough time per line.":
I tried enabling and disabling REG_ADAPTIVE_FRAMERATE on a project which needs to display a lot of text. It uses also a custom font in the flash.
I analyzed it with an oscyloscope and could see the differences. If you enable it (= using the reset value) you can see the Display clock pin having breaks/pauses in between the usual frequency which you setup.
I was also able to view the influence of that setting right on the display: In a displaylist which is using the processing limits (so again a lot of text loaded from flash) my display started to flicker a lot when I enable REG_ADAPTIVE_FRAMERATE. If I disable it it just stops showing the most right part of the display because it cannot handle it in time.

And I aggree that having multiple font caches for different fonts / sizes would be great. The font cache of BT817 is a huge advantage compared to the BT815 in my opinion.
« Last Edit: November 23, 2022, 04:29:31 PM by david »
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #13 on: November 23, 2022, 04:49:30 PM »

Hello,

The only stipulation is that the cache size should be sized to hold all the bitmaps used in two consecutive frames. i.e. it should be large enough to hold all of the .glyphs used in two consecutive pages in your application, essentiality you can play around with the cache size to find what suits your needs best.

p/s: I'm try to get the BRT_AN_042 from https://brtchip.com/software-examples/eve-examples/ but the links doesn't work anymore. Is there any where I can download this file?
Thanks,

Sorry i hadn't realised i did not reply to this, there has been an update to the font convertor in EAB as such we are currently re-working BRT_AN_042 to take this into account, it should be back online shortly


But that is just a theory for the moment, I am not entirely sure that the 40x40 pixels the font
converter outputs is really the size of the glyph.

The font convertor will take into account all character sizes in the input character set but doesn't not alter the glyph size for each individual character. For example, some characters may extend below the normal font baseline, and some may extend above the average character height, this is taken into account when setting the overall glyph width and height for all characters, so each glyph may be 40*40 but the given character within this glyph may not utilise the full 40*40 pixel size.

As a side note, I wish we had more than 32 bitmap-handles and could setup/query more than one font cache. ;)

I believe this is being looked at for future EVE revisions.

Best Regards,
BRT Community

Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: ASTC Custom Font from Flash
« Reply #14 on: November 23, 2022, 07:07:49 PM »

Just a comment about "It does not seem to do anything though, at least not in regards of saving the pixel engine from crashing when there is not enough time per line.":
I tried enabling and disabling REG_ADAPTIVE_FRAMERATE on a project which needs to display a lot of text. It uses also a custom font in the flash.
I analyzed it with an oscyloscope and could see the differences. If you enable it (= using the reset value) you can see the Display clock pin having breaks/pauses in between the usual frequency which you setup.
I was also able to view the influence of that setting right on the display: In a displaylist which is using the processing limits (so again a lot of text loaded from flash) my display started to flicker a lot when I enable REG_ADAPTIVE_FRAMERATE. If I disable it it just stops showing the most right part of the display because it cannot handle it in time.

And I aggree that having multiple font caches for different fonts / sizes would be great. The font cache of BT817 is a huge advantage compared to the BT815 in my opinion.

Nice, thank you for adding more data!
What I failed to mention is that I used to read REG_FRAMES to measure the effect and while it is called adaptive framerate there was no drop in framerate when deliberately trying to stress out EVE with complicated lines.
But missing clocks on the pixel clock should have that effect and now I doubt that my measurement was correct.

Logged
Pages: [1] 2