硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3723|回复: 0
收起左侧

[ThreadX全家桶] 备份下ThreadX GUIX的圆盘多指针设计方案

[复制链接]

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117568
QQ
发表于 2021-8-5 09:26:08 | 显示全部楼层 |阅读模式

此贴10楼:

https://forum.anfulai.cn/forum.php?mod=viewthread&tid=106310


circular gauge 目前只支持一个指针,可以通过重写circular gauge draw实现多指针。
示例:
INT second_needle_angle = 60;

VOID custom_circular_gauge_draw(GX_CIRCULAR_GAUGE *gauge)
{
    GX_CIRCULAR_GAUGE_INFO *info;
    INT xcor;
    INT ycor;
    INT needle_xpos;
    INT needle_ypos;
    GX_PIXELMAP *needle;
    GX_PIXELMAP needle_rotated;

    /* Call default circular draw. */
    gx_circular_gauge_draw(gauge);

    /* Pick up pointer to the gauge information structure.  */
    info = &gauge->gx_circular_gauge_info;

    /* Retrieve the map for the second needle. */
    gx_context_pixelmap_get(GX_PIXELMAP_ID_NEEDLE, &needle);

    if (needle)
    {
        xcor = (INT)(info->gx_circular_gauge_info_needle_xcor);
        ycor = (INT)(info->gx_circular_gauge_info_needle_ycor);

        needle_xpos = info->gx_circular_gauge_info_needle_xpos;
        needle_ypos = info->gx_circular_gauge_info_needle_ypos;

        /* Rotate the second needle pixelmap. */
        if (gx_utility_pixelmap_rotate(needle, second_needle_angle, &needle_rotated, &xcor, &ycor) == GX_SUCCESS)
        {
            /* Calculate start position of needle pixelmap.  */
            needle_xpos = gauge->gx_widget_size.gx_rectangle_left + info->gx_circular_gauge_info_needle_xpos;
            needle_xpos -= xcor;

            needle_ypos = gauge->gx_widget_size.gx_rectangle_top + info->gx_circular_gauge_info_needle_ypos;
            needle_ypos -= ycor;

            /* Draw needle .  */
            _gx_canvas_pixelmap_draw((GX_VALUE)needle_xpos, (GX_VALUE)needle_ypos, &needle_rotated);

            /* Free rotate needle pixelmap memory.  */
            if (memory_free)
            {
                if (needle_rotated.gx_pixelmap_aux_data)
                {
                    memory_free((VOID*)needle_rotated.gx_pixelmap_aux_data);
                }
                memory_free((VOID*)needle_rotated.gx_pixelmap_data);
            }
        }
    }
}

这段代码可以放在tutorials/demo_guix_circular_gauge里使用,需要把表盘的draw函数设为custom_circular_gauge_draw。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-15 16:08 , Processed in 0.035496 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表