找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4240|回复: 2
收起左侧

SimpleGUI一套针对单色显示屏的开源GUI接口源程序+说明文档

[复制链接]
ID:68814 发表于 2019-9-17 19:33 | 显示全部楼层 |阅读模式
222.png


有详细说明文档。详见附件。

111.png

单片机源程序如下:
  1. /*************************************************************************/
  2. /** Copyright.                                                                                                                        **/
  3. /** FileName: DemoProc.c                                                                                                **/
  4. /** Author: Polarix                                                                                                                **/
  5. /** Description: User operation interface.                                                                **/
  6. /*************************************************************************/
  7. //=======================================================================//
  8. //= Include files.                                                                                                            =//
  9. //=======================================================================//
  10. #include "DemoProc.h"

  11. #ifdef _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_
  12. #include "SDKInterface.h"
  13. #include "SGUI_FlashData.h"
  14. #else
  15. #include "OLED.h"
  16. #include "DemoActions.h"
  17. #endif

  18. //=======================================================================//
  19. //= Static variable declaration.                                                                            =//
  20. //=======================================================================//
  21. SGUI_SCR_DEV                                g_stDeviceInterface;
  22. HMI_SCREEN_OBJECT*                        g_arrpstScreenObjs[] =
  23.                                                         {
  24.                                                                 &g_stHMIDemo_ScrollingText,
  25.                                                                 &g_stHMIDemo_List,
  26.                                                                 &g_stHMIDemo_TextNotice,
  27.                                                                 &g_stHMIDemo_RTCNotice,
  28.                                                                 &g_stHMIDemo_VariableBox,
  29.                                                                 &g_stHMI_DemoRealtimeGraph,
  30.                                                         };
  31. HMI_ENGINE_OBJECT                        g_stDemoEngine;

  32. //=======================================================================//
  33. //= Static function declare.                                                                            =//
  34. //=======================================================================//
  35. static void                                        KeyPressEventProc(void);
  36. static void                                        RTCEventProc(void);
  37. static void                                        SysTickTimerEventProc(void);

  38. //=======================================================================//
  39. //= Function define.                                                                                            =//
  40. //=======================================================================//

  41. /*****************************************************************************/
  42. /** Function Name:        SimpleGUI_DemoProcess                                                                   **/
  43. /** Purpose:                Simple GUI HMI engine and interface demo process.       **/
  44. /** Parameters:                None.                                                                                                        **/
  45. /** Return:                        HMI_ENGINE_RESULT.                                                                                **/
  46. /** Notice:                        This function demonstrates how to use the interface and **/
  47. /**                 HMI engine of Simple GUI.                               **/
  48. /*****************************************************************************/
  49. HMI_ENGINE_RESULT InitializeEngine(void)
  50. {
  51.         /*----------------------------------*/
  52.         /* Variable Declaration                                */
  53.         /*----------------------------------*/
  54.         HMI_ENGINE_RESULT           eProcessResult;
  55.         int                                                        iIndex;

  56.         /*----------------------------------*/
  57.         /* Initialize                                                */
  58.         /*----------------------------------*/
  59.         eProcessResult =                        HMI_RET_NORMAL;

  60.         /*----------------------------------*/
  61.         /* Process                                                        */
  62.         /*----------------------------------*/
  63.         /* Clear structure. */
  64.         SGUI_SystemIF_MemorySet(&g_stDeviceInterface, 0x00, sizeof(SGUI_SCR_DEV));
  65.         SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT));
  66. #ifdef _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_
  67.         /* Initialize display size. */
  68.         g_stDeviceInterface.stSize.Width = 128;
  69.         g_stDeviceInterface.stSize.Height = 64;
  70.         /* Initialize interface object. */
  71.         g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel;
  72.         g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel;
  73.         g_stDeviceInterface.fnClearScreen = SGUI_SDK_ClearDisplay;
  74.         g_stDeviceInterface.fnRefreshScreen = SGUI_SDK_RefreshDisplay;
  75. #else
  76.         /* Initialize display size. */
  77.         g_stDeviceInterface.stSize.Width = 128;
  78.         g_stDeviceInterface.stSize.Height = 64;
  79.         /* Initialize interface object. */
  80.         g_stDeviceInterface.stActions.fnSetPixel = OLED_SetPixel;
  81.         g_stDeviceInterface.stActions.fnGetPixel = OLED_GetPixel;
  82.         g_stDeviceInterface.stActions.fnClearScreen = OLED_ClearDisplay;
  83.         g_stDeviceInterface.stActions.fnRefreshScreen = OLED_RefreshScreen;
  84. #endif

  85.         do
  86.         {
  87.                 /* Prepare HMI engine object. */
  88.                 g_stDemoEngine.ScreenCount = sizeof(g_arrpstScreenObjs)/sizeof(*g_arrpstScreenObjs);
  89.                 g_stDemoEngine.ScreenObjPtr = g_arrpstScreenObjs;
  90.                 g_stDemoEngine.Interface = &g_stDeviceInterface;

  91.                 /* Initialize all screen object. */
  92.                 if(NULL != g_stDemoEngine.ScreenObjPtr)
  93.                 {
  94.                         for(iIndex=0; iIndex<g_stDemoEngine.ScreenCount; iIndex++)
  95.                         {
  96.                                 if( (NULL != g_stDemoEngine.ScreenObjPtr[iIndex])
  97.                                         && (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions)
  98.                                         && (g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize)
  99.                                         )
  100.                                 {
  101.                                         g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&g_stDeviceInterface);
  102.                                         g_stDemoEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL;
  103.                                 }
  104.                         }
  105.                 }
  106.                 else
  107.                 {

  108.                 }
  109.                 /* Active engine object. */
  110.                 eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_SCROLLING_TEXT);
  111.                 if(HMI_PROCESS_FAILED(eProcessResult))
  112.                 {
  113.                         /* Active engine failed. */
  114.                         break;
  115.                 }
  116.                 /* Start engine process. */
  117.                 eProcessResult = HMI_StartEngine(NULL);
  118.                 if(HMI_PROCESS_FAILED(eProcessResult))
  119.                 {
  120.                         /* Start engine failed. */
  121.                         break;
  122.                 }
  123.         }while(0);


  124.         return eProcessResult;
  125. }

  126. int DemoMainProcess(void)
  127. {
  128.         /*----------------------------------*/
  129.         /* Initialize                                                */
  130.         /*----------------------------------*/
  131.     // Initialize Engine.
  132.     InitializeEngine();

  133.     /*----------------------------------*/
  134.         /* Process                                                        */
  135.         /*----------------------------------*/
  136.     while(1)
  137.     {
  138.         // Check and process heart-beat timer event.
  139.         if(true == SGUI_SDK_GetEventSyncFlag(ENV_FLAG_IDX_SDK_TIM_EVENT))
  140.         {
  141.                 SysTickTimerEventProc();
  142.             SGUI_SDK_SetEvnetSyncFlag(ENV_FLAG_IDX_SDK_TIM_EVENT, false);
  143.         }
  144.         // Check and process key press event.
  145.         if(true == SGUI_SDK_GetEventSyncFlag(ENV_FLAG_IDX_SDK_KEY_EVENT))
  146.         {
  147.             KeyPressEventProc();
  148.             SGUI_SDK_SetEvnetSyncFlag(ENV_FLAG_IDX_SDK_KEY_EVENT, false);
  149.         }
  150.         // Check and process RTC event.
  151.         if(true == SGUI_SDK_GetEventSyncFlag(ENV_FLAG_IDX_SDK_RTC_EVENT))
  152.         {
  153.             RTCEventProc();
  154.             SGUI_SDK_SetEvnetSyncFlag(ENV_FLAG_IDX_SDK_RTC_EVENT, false);
  155.         }
  156.     }

  157.         return 0;
  158. }

  159. void KeyPressEventProc(void)
  160. {
  161.         /*----------------------------------*/
  162.         /* Variable Declaration                                */
  163.         /*----------------------------------*/
  164.         KEY_PRESS_EVENT                stEvent;

  165.         /*----------------------------------*/
  166.         /* Initialize                                                */
  167.         /*----------------------------------*/
  168.         HMI_EVENT_INIT(stEvent);

  169.         /*----------------------------------*/
  170.         /* Process                                                        */
  171.         /*----------------------------------*/
  172.         stEvent.Head.iType = EVENT_TYPE_ACTION;
  173.         stEvent.Head.iID = EVENT_ID_KEY_PRESS;
  174.         stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData();
  175.         // Post key press event.
  176.         HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent));
  177. }

  178. void SysTickTimerEventProc(void)
  179. {
  180.     /*----------------------------------*/
  181.     /* Variable Declaration                                */
  182.     /*----------------------------------*/
  183.     DATA_EVENT                                stEvent;

  184.     /*----------------------------------*/
  185.     /* Initialize                                                */
  186.     /*----------------------------------*/
  187.     HMI_EVENT_INIT(stEvent);

  188.     /*----------------------------------*/
  189.     /* Process                                                        */
  190.     /*----------------------------------*/
  191.     stEvent.Head.iType =        EVENT_TYPE_DATA;
  192.     stEvent.Head.iID =                EVENT_ID_TIMER;
  193. ……………………

  194. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
simplegui.7z (2.42 MB, 下载次数: 112)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:388210 发表于 2020-4-20 15:35 | 显示全部楼层
不放到gitee上吗?
回复

使用道具 举报

ID:68189 发表于 2024-2-22 14:12 | 显示全部楼层
玩不转它的VirtualSDK.有编译好的虚拟窗口吗,或者它的编译环境文件。下载不了
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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