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

Author Topic: Problem with drawing button using CMD_BUTTON  (Read 11067 times)

Muhammad

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problem with drawing button using CMD_BUTTON
« on: April 22, 2021, 09:01:38 AM »

Hello all,

This is my API to draw a button.
As per the picture on the attachement , the button is rendered as expected but the background is not correct !!
In this example I cleared the screen to red, and then sent the CMD_BUTTON, so any idea about whats behind the button ??
Code: [Select]
int16_t bt81x_draw_button (uint16_t u16_Xpos,
                           uint16_t u16_Ypos,
                           uint16_t u16_width,
                           uint16_t u16_height,
                           uint16_t u16_font,
                           uint16_t u16_opt,
                           const char * pachr_name)
{
  int16_t s16_ret;
  uint8_t u8_name_len;
  uint16_t u16_cmd_offset = 0;
  uint8_t u8_byte_idx = 0;
  uint32_t u32_word;
  do
  {
     s16_ret = wait_for_coproc_engine(&u16_cmd_offset);
    _ERROR_BREAK(s16_ret);
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, CMD_DLSTART);
    _ERROR_BREAK(s16_ret);                                                                                 
    inc_offset(&u16_cmd_offset, 4);
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, CMD_BUTTON);
    _ERROR_BREAK(s16_ret);
    inc_offset(&u16_cmd_offset, 4);
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, ((uint32_t)(u16_Ypos << 16) | (uint32_t)(u16_Xpos)));
    _ERROR_BREAK(s16_ret);
    inc_offset(&u16_cmd_offset, 4); 
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, ((uint32_t)(u16_height << 16) | (uint32_t)(u16_width)));
    _ERROR_BREAK(s16_ret);
    inc_offset(&u16_cmd_offset, 4);
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, ((uint32_t)(u16_opt << 16) | (uint32_t)(u16_font)));
    _ERROR_BREAK(s16_ret);
    inc_offset(&u16_cmd_offset, 4);
    u8_name_len = strlen(pachr_name);
    for(uint8_t u8_word_idx = 0; u8_word_idx < (u8_name_len/4); u8_word_idx++, u8_byte_idx += 4)
    {
      u32_word = (uint32_t)(pachr_name[u8_byte_idx+3] << 24) | (uint32_t)(pachr_name[u8_byte_idx+2] << 16)
                    | (uint32_t)(pachr_name[u8_byte_idx+1] << 8) | (uint32_t)(pachr_name[u8_byte_idx]);
      s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, u32_word);
      _ERROR_BREAK(s16_ret);
      inc_offset(&u16_cmd_offset, 4);
    }
    _ERROR_BREAK(s16_ret);
    u32_word = 0;
    for(uint8_t u8_remaining = 0; u8_remaining < (u8_name_len%4); u8_remaining++,u8_byte_idx++)
    {
      u32_word |= (uint32_t)pachr_name[u8_byte_idx] << (u8_remaining * 8);
    }
    if(u8_name_len%4)
    {
      s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, u32_word);
      _ERROR_BREAK(s16_ret);
      inc_offset(&u16_cmd_offset, 4);
    }
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, (DISPLAY << 24));
    _ERROR_BREAK(s16_ret);
    inc_offset(&u16_cmd_offset, 4);
    s16_ret = bt81x_write_32bit_reg(RAM_CMD + u16_cmd_offset, CMD_SWAP);
    _ERROR_BREAK(s16_ret);
    inc_offset(&u16_cmd_offset, 4);
    s16_ret = bt81x_write_32bit_reg(REG_CMD_WRITE, u16_cmd_offset);
  }while(0);
  return s16_ret;
}
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: Problem with drawing button using CMD_BUTTON
« Reply #1 on: April 22, 2021, 01:52:42 PM »

Hello,

Thank you for your question.

I suspect the issue lies with the display list you are writing to EVE, for example your button routine includes a DL_START and SWAP/DISPLAY commands, but you mention that you are also setting the background to red. In general a Co-processor list should be structured as follows, with only one set DL_START and DISPLAY/SWAP commands:

Code: [Select]
[Await REG_CMD_READ == REG_CMD_WRITE and read value of these registers]
CMD_DL_START // Tells co-pro to begin writing DL at RAM_DL+0
CLEAR_COLOR_RGB // Co-processor writes this instruction to the DL
CLEAR(1,1,1) // Co-processor writes this instruction to the DL
Color_RGB(0,0,255)
Point_Size(20)
Begin(Points)
Vertex2F(0,0)
End()
DISPLAY // Co-processor writes this instruction to the DL
CMD_SWAP // Co-processor writes REG_DL_SWAP
[update REG_CMD_WRITE to point to end of new commands]
[Await REG_CMD_READ == REG_CMD_WRITE]

Could you provide the whole co-processor list that you are writing to the BT81X? (I assume you are writing other commands to EVE outwith the bt81x_draw_button routine, please correct me if I am wrong)

Best Regards,
BRT Community
Logged

Muhammad

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with drawing button using CMD_BUTTON
« Reply #2 on: April 22, 2021, 02:21:27 PM »

You are right, I thought I can draw each list independently !
But now thats a problem.
Assume I have a frame already drawn and then I wanted to add a new object to the existing frame,
Is that possible ?
Or I have to redraw the whole frame from scratch ??!!
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: Problem with drawing button using CMD_BUTTON
« Reply #3 on: April 22, 2021, 03:13:17 PM »

Hello,

Essentially for any screen update required a new display list must be issued to EVE and the swap command executed.

However there is an append() function which can be used to append new display list commands to an existing display list, please see the following:
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/AN_340_FT800_Optimising-screen-updates-with-Macro-and-Append.pdf

The following application note may interest you as it creates a graph on the display and utilises Append() functionality:
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/Modules/EVE/AN_356-FT800-Interfacing-I2C-Sensor-to-VM800P.pdf

In practice if the Library you have implemented utilises SPI burst writes to EVE then there is a negligible performance hit for re-writing a whole display list.

Best Regards,
BRT Community
Logged

Muhammad

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with drawing button using CMD_BUTTON
« Reply #4 on: April 22, 2021, 03:19:44 PM »

The update on the fly is a very important feature.
In my application for example , there are multiple RTOS threads that updates their own corresponding fields on the screen.
Each thread is not aware of anything but its own section of the screen.
So if that feature is not enabled, it means the threads need to redraw the whole frame!!!
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: Problem with drawing button using CMD_BUTTON
« Reply #5 on: April 22, 2021, 04:19:22 PM »

Hello,

In this case I would suggest having in a single thread in your system that deals with updating the EVE display list
Whilst your other threads can update and pass any applicable variable changes into the EVE thread, which will redraw the screen periodically.

Best Regards,
BRT community
Logged