(TECH) Issues with Lcd.draw_point

Moderators: lily.li, violet, jessie, chao.zhang

Post Reply
User avatar
asf.dominio
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Thu Feb 11, 2016 10:41 pm
Location: Spain

(TECH) Issues with Lcd.draw_point

Post by asf.dominio » Fri Feb 26, 2016 5:23 pm

Dear all,

I have been trying to use ugui library (used in RePhone Kit default application) with Arduino. First thing I need is a function that draws a point, so I wrapped method Lcd.draw_point from library LDisplay, but it doesn't work.

After some research I discovered that drawing code in LDisplay/utility/Display.cpp
is commented out!

Code: Select all

boolean lcd_draw_point(void* user_data)
{
    point_info_struct* data = (point_info_struct*) user_data;
    //vm_graphic_point_t frame_position[1] = {0, 0};
    /*
    vm_graphic_color_argb_t color;
    color.a = 0;
    color.r = ((data->PCulValue >> 16) & 0xff);
    color.g = ((data->PCulValue >> 8) & 0xff);
    color.b = (data->PCulValue & 0xff);
    vm_graphic_set_color(color);
    vm_graphic_draw_point(&g_frame, data->ulX, data->ulY);
    */
    VMUINT16 *pbuf = (VMUINT16 *)g_frame.buffer; 
    pbuf += data->ulY * 240 + data->ulX;
    *pbuf = ((data->PCulValue >> 8) & (0x1F << 11)) | ((data->PCulValue >> 5) & (0x3F << 5)) | ((data->PCulValue >> 3) & 0x1F);
    
    vm_graphic_rotate_frame(&g_rotated_frame, &g_frame, VM_GRAPHIC_ROTATE_180);
    //vm_graphic_blt_frame(g_frame_blt_group, frame_position, (VMINT)1);
    
    return true;
}
I uncommented the central part and commented lines with "pbuf", that I don't now what they do, and now it works (warning: a call to Lcd.draw_updata() is needed after drawing points):

Code: Select all

boolean lcd_draw_point(void* user_data)
{
    point_info_struct* data = (point_info_struct*) user_data;
    //vm_graphic_point_t frame_position[1] = {0, 0};
    
    vm_graphic_color_argb_t color;
    color.a = 0;
    color.r = ((data->PCulValue >> 16) & 0xff);
    color.g = ((data->PCulValue >> 8) & 0xff);
    color.b = (data->PCulValue & 0xff);
    vm_graphic_set_color(color);
    vm_graphic_draw_point(&g_frame, data->ulX, data->ulY);
    /*
    VMUINT16 *pbuf = (VMUINT16 *)g_frame.buffer; 
    pbuf += data->ulY * 240 + data->ulX;
    *pbuf = ((data->PCulValue >> 8) & (0x1F << 11)) | ((data->PCulValue >> 5) & (0x3F << 5)) | ((data->PCulValue >> 3) & 0x1F);
    */
    vm_graphic_rotate_frame(&g_rotated_frame, &g_frame, VM_GRAPHIC_ROTATE_180);
    //vm_graphic_blt_frame(g_frame_blt_group, frame_position, (VMINT)1);
    
    return true;
}
Is it a real bug or I have missed something?


Best regards.
Errepunto

User avatar
chao.zhang
Kindergarten
Kindergarten
Posts: 81
Joined: Thu Jan 22, 2015 9:55 am

Re: (TECH) Issues with Lcd.draw_point

Post by chao.zhang » Thu Mar 03, 2016 10:21 am

asf.dominio wrote:Dear all,

I have been trying to use ugui library (used in RePhone Kit default application) with Arduino. First thing I need is a function that draws a point, so I wrapped method Lcd.draw_point from library LDisplay, but it doesn't work.

After some research I discovered that drawing code in LDisplay/utility/Display.cpp
is commented out!

Code: Select all

boolean lcd_draw_point(void* user_data)
{
    point_info_struct* data = (point_info_struct*) user_data;
    //vm_graphic_point_t frame_position[1] = {0, 0};
    /*
    vm_graphic_color_argb_t color;
    color.a = 0;
    color.r = ((data->PCulValue >> 16) & 0xff);
    color.g = ((data->PCulValue >> 8) & 0xff);
    color.b = (data->PCulValue & 0xff);
    vm_graphic_set_color(color);
    vm_graphic_draw_point(&g_frame, data->ulX, data->ulY);
    */
    VMUINT16 *pbuf = (VMUINT16 *)g_frame.buffer; 
    pbuf += data->ulY * 240 + data->ulX;
    *pbuf = ((data->PCulValue >> 8) & (0x1F << 11)) | ((data->PCulValue >> 5) & (0x3F << 5)) | ((data->PCulValue >> 3) & 0x1F);
    
    vm_graphic_rotate_frame(&g_rotated_frame, &g_frame, VM_GRAPHIC_ROTATE_180);
    //vm_graphic_blt_frame(g_frame_blt_group, frame_position, (VMINT)1);
    
    return true;
}
I uncommented the central part and commented lines with "pbuf", that I don't now what they do, and now it works (warning: a call to Lcd.draw_updata() is needed after drawing points):

Code: Select all

boolean lcd_draw_point(void* user_data)
{
    point_info_struct* data = (point_info_struct*) user_data;
    //vm_graphic_point_t frame_position[1] = {0, 0};
    
    vm_graphic_color_argb_t color;
    color.a = 0;
    color.r = ((data->PCulValue >> 16) & 0xff);
    color.g = ((data->PCulValue >> 8) & 0xff);
    color.b = (data->PCulValue & 0xff);
    vm_graphic_set_color(color);
    vm_graphic_draw_point(&g_frame, data->ulX, data->ulY);
    /*
    VMUINT16 *pbuf = (VMUINT16 *)g_frame.buffer; 
    pbuf += data->ulY * 240 + data->ulX;
    *pbuf = ((data->PCulValue >> 8) & (0x1F << 11)) | ((data->PCulValue >> 5) & (0x3F << 5)) | ((data->PCulValue >> 3) & 0x1F);
    */
    vm_graphic_rotate_frame(&g_rotated_frame, &g_frame, VM_GRAPHIC_ROTATE_180);
    //vm_graphic_blt_frame(g_frame_blt_group, frame_position, (VMINT)1);
    
    return true;
}
Is it a real bug or I have missed something?


Best regards.

Hi, please check my image below. Actually the commented part and the uncommented part, they both work drawing points on the LCD, but we do recommend you using the uncommented phrases as we do cause they works much faster, also if you do so, you need to use the function "lcd_draw_updata(void* user_data)" as well.
Image
Image

Post Reply