Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.29 KB | None | 0 0
  1. //<File !Start!>
  2. // FILE: [test.ino]
  3. // Created by GUIslice Builder version: [0.13.b014]
  4. //
  5. // GUIslice Builder Generated File
  6. //
  7. // For the latest guides, updates and support view:
  8. // https://github.com/ImpulseAdventure/GUIslice
  9. //
  10. //<File !End!>
  11. //
  12. // ARDUINO NOTES:
  13. // - GUIslice_config.h must be edited to match the pinout connections
  14. //   between the Arduino CPU and the display controller (see ADAGFX_PIN_*).
  15. //
  16.  
  17. // ------------------------------------------------
  18. // Headers to include
  19. // ------------------------------------------------
  20. #include "GUIslice.h"
  21. #include "GUIslice_drv.h"
  22.  
  23. // Include any extended elements
  24. //<Includes !Start!>
  25. //<Includes !End!>
  26.  
  27. // ------------------------------------------------
  28. // Headers and Defines for fonts
  29. // Note that font files are located within the Adafruit-GFX library folder:
  30. // ------------------------------------------------
  31. //<Fonts !Start!>
  32. //<Fonts !End!>
  33.  
  34. // ------------------------------------------------
  35. // Defines for resources
  36. // ------------------------------------------------
  37. //<Resources !Start!>
  38. //<Resources !End!>
  39.  
  40. // ------------------------------------------------
  41. // Enumerations for pages, elements, fonts, images
  42. // ------------------------------------------------
  43. //<Enum !Start!>
  44. enum {E_PG_MAIN};
  45. enum {E_COUNTER,E_ELEM_TEXT1,E_ELEM_TEXT2};
  46. // Must use separate enum for fonts with MAX_FONT at end to use gslc_FontSet.
  47. enum {E_FONT_TXT10,E_FONT_TXT15,MAX_FONT};
  48. //<Enum !End!>
  49.  
  50. // ------------------------------------------------
  51. // Instantiate the GUI
  52. // ------------------------------------------------
  53.  
  54. // ------------------------------------------------
  55. // Define the maximum number of elements and pages
  56. // ------------------------------------------------
  57. //<ElementDefines !Start!>
  58. #define MAX_PAGE                1
  59.  
  60. #define MAX_ELEM_PG_MAIN 3 // # Elems total on page
  61. #define MAX_ELEM_PG_MAIN_RAM MAX_ELEM_PG_MAIN // # Elems in RAM
  62. //<ElementDefines !End!>
  63.  
  64. // ------------------------------------------------
  65. // Create element storage
  66. // ------------------------------------------------
  67. gslc_tsGui                      m_gui;
  68. gslc_tsDriver                   m_drv;
  69. gslc_tsFont                     m_asFont[MAX_FONT];
  70. gslc_tsPage                     m_asPage[MAX_PAGE];
  71.  
  72. //<GUI_Extra_Elements !Start!>
  73. gslc_tsElem                     m_asPage1Elem[MAX_ELEM_PG_MAIN_RAM];
  74. gslc_tsElemRef                  m_asPage1ElemRef[MAX_ELEM_PG_MAIN];
  75.  
  76. #define MAX_STR                 100
  77.  
  78. //<GUI_Extra_Elements !End!>
  79.  
  80. // ------------------------------------------------
  81. // Program Globals
  82. // ------------------------------------------------
  83.  
  84. // Save some element references for direct access
  85. //<Save_References !Start!>
  86. gslc_tsElemRef*  counter_txt       = NULL;
  87. //<Save_References !End!>
  88.  
  89. // Define debug message function
  90. static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); else Serial.write(ch); return 0; }
  91.  
  92. // ------------------------------------------------
  93. // Callback Methods
  94. // ------------------------------------------------
  95. //<Button Callback !Start!>
  96. //<Button Callback !End!>
  97. //<Checkbox Callback !Start!>
  98. //<Checkbox Callback !End!>
  99. //<Keypad Callback !Start!>
  100. //<Keypad Callback !End!>
  101. //<Spinner Callback !Start!>
  102. //<Spinner Callback !End!>
  103. //<Listbox Callback !Start!>
  104. //<Listbox Callback !End!>
  105. //<Draw Callback !Start!>
  106. //<Draw Callback !End!>
  107. //<Slider Callback !Start!>
  108. //<Slider Callback !End!>
  109. //<Tick Callback !Start!>
  110. //<Tick Callback !End!>
  111.  
  112. // ------------------------------------------------
  113. // Create page elements
  114. // ------------------------------------------------
  115. bool InitGUI()
  116. {
  117.   gslc_tsElemRef* pElemRef = NULL;
  118.  
  119. //<InitGUI !Start!>
  120.   gslc_PageAdd(&m_gui,E_PG_MAIN,m_asPage1Elem,MAX_ELEM_PG_MAIN_RAM,m_asPage1ElemRef,MAX_ELEM_PG_MAIN);
  121.  
  122.   // NOTE: The current page defaults to the first page added. Here we explicitly
  123.   //       ensure that the main page is the correct page no matter the add order.
  124.   gslc_SetPageCur(&m_gui,E_PG_MAIN);
  125.  
  126.   // Set Background to a flat color
  127.   gslc_SetBkgndColor(&m_gui,GSLC_COL_BLACK);
  128.  
  129.   // -----------------------------------
  130.   // PAGE: E_PG_MAIN
  131.  
  132.  
  133.   // Create E_ELEM_TEXT1 text label
  134.   pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT1,E_PG_MAIN,(gslc_tsRect){125,10,220,26},
  135.     (char*)"Simple Counter",0,E_FONT_TXT15);
  136.  
  137.   // Create E_ELEM_TEXT2 text label
  138.   pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT2,E_PG_MAIN,(gslc_tsRect){10,63,168,18},
  139.     (char*)"Current count:",0,E_FONT_TXT10);
  140.   gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLUE_LT1);
  141.  
  142.   // Create E_COUNTER runtime modifiable text
  143.   static char m_sDisplayText3[13] = "0";
  144.   pElemRef = gslc_ElemCreateTxt(&m_gui,E_COUNTER,E_PG_MAIN,(gslc_tsRect){163,63,132,18},
  145.     (char*)m_sDisplayText3,13,E_FONT_TXT10);
  146.   counter_txt = pElemRef;
  147. //<InitGUI !End!>
  148.  
  149.   return true;
  150. }
  151.  
  152. void setup()
  153. {
  154.   // ------------------------------------------------
  155.   // Initialize
  156.   // ------------------------------------------------
  157.   Serial.begin(9600);
  158.   // Wait for USB Serial
  159.   //delay(1000);  // NOTE: Some devices require a delay after Serial.begin() before serial port can be used
  160.  
  161.   gslc_InitDebug(&DebugOut);
  162.  
  163.   if (!gslc_Init(&m_gui,&m_drv,m_asPage,MAX_PAGE,m_asFont,MAX_FONT)) { return; }
  164.  
  165.   // ------------------------------------------------
  166.   // Load Fonts
  167.   // ------------------------------------------------
  168. //<Load_Fonts !Start!>
  169.     if (!gslc_FontSet(&m_gui,E_FONT_TXT10,GSLC_FONTREF_PTR,NULL,2)) { return; }
  170.     if (!gslc_FontSet(&m_gui,E_FONT_TXT15,GSLC_FONTREF_PTR,NULL,3)) { return; }
  171. //<Load_Fonts !End!>
  172.  
  173.   // ------------------------------------------------
  174.   // Create graphic elements
  175.   // ------------------------------------------------
  176.   InitGUI();
  177.  
  178. //<Startup !Start!>
  179. //<Startup !End!>
  180.  
  181. }
  182.  
  183. // -----------------------------------
  184. // Main event loop
  185. // -----------------------------------
  186. void loop()
  187. {
  188.  
  189.   // ------------------------------------------------
  190.   // Update GUI Elements
  191.   // ------------------------------------------------
  192.  
  193.   //TODO - Add update code for any text, gauges, or sliders
  194.  
  195.   // ------------------------------------------------
  196.   // Periodically call GUIslice update function
  197.   // ------------------------------------------------
  198.   gslc_Update(&m_gui);
  199.    
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement