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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Muhammad

Pages: [1]
1
Discussion - EVE / 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;
}

Pages: [1]