硬汉嵌入式论坛

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

[ThreadX全家桶] 初步研究发现ThreadX GUIX不适合像emWin那样研究API用法,因为实现个简单的hello world都有难度

[复制链接]

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115787
QQ
发表于 2020-6-20 09:09:03 | 显示全部楼层 |阅读模式
初步研究,我尝试用emWin的开发方式来学习GUIX,发现行不通,很多地方没有整明白。

以他们官方的介绍为例,一个简单的helloworld搞这么多代码,而且这个代码比较老,有些函数在GUIX 6.0上面已经没有了。

不能用这种方式来研究,那用什么方式研究,自然是GUIX Studio,发现这个Studio是一条龙服务的那种,本身GUIX就没有打算让用户去研究API的用法。

本质就想让用户研究Studio的用法即可:

https://docs.microsoft.com/en-us/azure/rtos/guix/guix-example

  1. /* This is a small demonstration of the high-performance GUIX embedded UI run-time environment. This demonstration consists of a simple "Hello World" prompt on top of the root window. */

  2. /* Include necessary system files.

  3. #include "tx_api.h"
  4. #include "gx_api.h"

  5. /* Define constants for the GUIX Win32 demo. */

  6. /* Define the display dimentions specific to this implemenation. */
  7. #define DEMO_DISPLAY_WIDTH              320
  8. #define DEMO_DISPLAY_HEIGHT             240

  9. /* Define the number of pixels on the canvas */
  10. #define DEFAULT_CANVAS_PIXELS     (DEMO_DISPLAY_WIDTH * DEMO_DISPLAY_HEIGHT)

  11. /* Define the ThreadX demo thread control block. */
  12. TX_THREAD        demo_thread;

  13. /* Define the stack for the demo thread. */
  14. ULONG            demo_thread_stack[4096 / sizeof(ULONG)];

  15. /* Define the GUIX resources for this demo. */

  16. /* GUIX display represents the physical display device */
  17. GX_DISPLAY       demo_display;

  18. /* GUIX canvas is the frame buffer on top of GUIX displayl. */
  19. GX_CANVAS        default_canvas;

  20. /* The root window is a special GUIX background window, right on top of the canvas. */
  21. GX_WINDOW_ROOT   demo_root_window;

  22. /* GUIX Prompt displays a string. */
  23. GX_PROMPT        demo_prompt;

  24. /* Memory for the frame buffer. */
  25. GX_COLOR default_canvas_memory[DEFAULT_CANVAS_PIXELS];

  26. /* Define GUIX strings ID for the demo. */
  27. enum demo_string_ids
  28. {
  29.     SID_HELLO_WORLD = 1,
  30.     SID_MAX
  31. };

  32. /* Define GUIX string for the demo. */
  33. CHAR *demo_strings[] = {
  34.     NULL,
  35.     "Hello World"
  36. };

  37. /* User-defined color ID */
  38. #define GX_COLOR_ID_BLACK      GX_FIRST_USER_COLOR
  39. #define GX_COLOR_ID_WHITE       (GX_FIRST_USER_COLOR + 1)

  40. /* User-defined color table. */
  41. static GX_COLOR demo_color_table[] =
  42. {
  43.     /* First, bring in GUIX default color table. These colors are used by GUIX internals. */
  44.     GX_SYSTEM_DEFAULT_COLORS_DECLARE,

  45.     /* In this demo, two color entries are added to the color table. */
  46.     GX_COLOR_BLACK,
  47.     GX_COLOR_WHITE
  48. };

  49. /* Define prototypes. */

  50. VOID  demo_thread_entry(ULONG thread_input);

  51. int main(void)
  52. {
  53.     /* Enter ThreadX. */
  54.     tx_kernel_enter();
  55.    
  56.     return (0);
  57. }

  58. VOID tx_application_define(void *first_unused_memory)
  59. {
  60.     /* Create the main demo thread. */
  61.     tx_thread_create(&demo_thread, "GUIX Demo Thread", demo_thread_entry, 0,
  62.                     demo_thread_stack, sizeof(demo_thread_stack),
  63.                     1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
  64. }

  65. VOID demo_thread_entry(ULONG thread_input)
  66. {

  67. GX_RECTANGLE    root_window_size;
  68. GX_RECTANGLE    prompt_position;

  69.    /* Initialize GUIX. */
  70.    gx_system_initialize();

  71.    /* Install the demo string table. */
  72.    gx_system_string_table_set(demo_strings, SID_MAX);

  73.    /* Install the demo color table. */
  74.    gx_system_color_table_set(demo_color_table, sizeof(demo_color_table) /
  75.                          sizeof(GX_COLOR));

  76.    /* Create the demo display and associated driver. */
  77.    gx_display_create(&demo_display, "demo display",
  78.                  win32_graphics_driver_setup_16bpp,
  79.                  DEMO_DISPLAY_WIDTH, DEMO_DISPLAY_HEIGHT);

  80.    /* Create the default canvas. */
  81.    gx_canvas_create(&default_canvas, "demo canvas",&demo_display,
  82.                    GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE,
  83.                    DEMO_DISPLAY_WIDTH,DEMO_DISPLAY_HEIGHT,
  84.                    default_canvas_memory, sizeof(default_canvas_memory));

  85.    /*Define the size of the root window. */
  86.    gx_utility_rectangle_define(&root_window_size, 0, 0,
  87.                               DEMO_DISPLAY_WIDTH - 1, DEMO_DISPLAY_HEIGHT - 1);

  88.    /* Create a background root window and attach to the canvas. */
  89.    gx_window_root_create(&demo_root_window, "demo root window", &default_canvas,
  90.                         GX_STYLE_BORDER_NONE, GX_ID_NONE, &root_window_size);

  91.    /* Set the root window to be black. */
  92.    gx_widget_background_set(&demo_root_window, GX_COLOR_ID_BLACK,
  93.                            GX_COLOR_ID_BLACK);

  94.    /* Create a text prompt on the root window. Set the text color to white, and the background to black. */

  95.    /* Define the size and the position of the prompt. */
  96.    gx_utility_rectangle_define(&prompt_position, 100, 90, 220, 130);

  97.    /* Create the prompt on top of the root window using the string defined by string ID SID_HELLO_WORLD. */
  98.    gx_prompt_create(&demo_prompt, NULL, &demo_root_window, SID_HELLO_WORLD,
  99.                    GX_STYLE_NONE, GX_ID_NONE, &prompt_position);

  100.    /* Set the text color to be white, and the background color to be black. */
  101.    gx_prompt_text_color_set(&demo_prompt, GX_COLOR_ID_WHITE, GX_COLOR_ID_WHITE);
  102.    gx_widget_background_set(&demo_prompt, GX_COLOR_ID_BLACK,GX_COLOR_ID_BLACK);

  103.    /* Show the root window. */
  104.    gx_widget_show(&demo_root_window);

  105.    /* let GUIX run! */
  106.    gx_system_start();
  107. }
复制代码





回复

使用道具 举报

2

主题

180

回帖

186

积分

初级会员

积分
186
发表于 2020-6-20 11:38:15 | 显示全部楼层
有工具多好很多东西会用和了解底层运行机制就行了,真要研究就直接看底层太耗时间,现在在做的无线协议栈就几千个API真要弄起来也麻烦,只能开着API手册和demo慢慢撸
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115787
QQ
 楼主| 发表于 2020-6-20 21:17:21 | 显示全部楼层
qq57379550 发表于 2020-6-20 11:38
有工具多好很多东西会用和了解底层运行机制就行了,真要研究就直接看底层太耗时间,现在在做的无线协议栈就 ...

是的,研究下常用的几个API,心理踏实些。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-19 02:59 , Processed in 0.195615 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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