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 ??
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;
}