Graph Data Control with Checkbox Widget

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Graph Data Control with Checkbox Widget

      New

      Hello
      I have a graph field and a graph data.
      I want attach it to graph with a checkbox if it is true [GRAPH_AttachData(hItem,_hDataYT0);]
      and if it is no true detach it [GRAPH_DetachData(hItem,_hDataYT0);]
      and do it with a button.

      But I could not control it with check box and button.. It is complicated a bit.
      Here is my code block. I made it with emWin GUIBuilder.

      In this project ADC is activated and my board is stm32f746g_disco

      C Source Code: WindowDLG.c

      1. /*********************************************************************
      2. * *
      3. * SEGGER Microcontroller GmbH & Co. KG *
      4. * Solutions for real time microcontroller applications *
      5. * *
      6. **********************************************************************
      7. * *
      8. * C-file generated by: *
      9. * *
      10. * GUI_Builder for emWin version 5.40 *
      11. * Compiled Jun 22 2017, 10:13:26 *
      12. * (c) 2017 Segger Microcontroller GmbH & Co. KG *
      13. * *
      14. **********************************************************************
      15. * *
      16. * Internet: www.segger.com Support: support@segger.com *
      17. * *
      18. **********************************************************************
      19. */
      20. // USER START (Optionally insert additional includes)
      21. #include "GUI_App.h"
      22. #include "GUI.h"
      23. #include "DIALOG.h"
      24. #include "stm32746g_discovery.h"
      25. #include "stm32746g_discovery_ts.h"
      26. #include "stm32f7xx_hal.h"
      27. #include "DIALOG.h"
      28. #include "stdlib.h"
      29. /*********************************************************************
      30. *
      31. * Defines
      32. *
      33. **********************************************************************
      34. */
      35. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      36. #define ID_GRAPH_0 (GUI_ID_USER + 0x01)
      37. #define ID_SLIDER_0 (GUI_ID_USER + 0x02)
      38. ADC_HandleTypeDef hadc1;
      39. static void MX_ADC1_Init(void);
      40. static void MX_GPIO_Init(void);
      41. int frameXSize=480;
      42. int frameYSize=205;
      43. uint16_t c;
      44. uint16_t sliderV=10;
      45. GUI_RECT Rect = {0, 0, 30, 205};
      46. char acText[] = "Temperature";
      47. /*********************************************************************
      48. *
      49. * Static data
      50. *
      51. **********************************************************************
      52. */
      53. /*********************************************************************
      54. *
      55. * _aDialogCreate
      56. */
      57. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      58. { WINDOW_CreateIndirect, "Window",ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
      59. { GRAPH_CreateIndirect, "Graph",ID_GRAPH_0, 25, 86, 200, 100, 0, 0x0, 0 },
      60. };
      61. static GRAPH_DATA_Handle _hDataYT0;
      62. static SLIDER_Handle hSli;
      63. /*********************************************************************
      64. *
      65. * Static code
      66. *
      67. **********************************************************************
      68. */
      69. /*********************************************************************
      70. *
      71. * _cbDialog
      72. */
      73. static void _cbDialog(WM_MESSAGE * pMsg) {
      74. WM_HWIN hItem;
      75. switch (pMsg->MsgId) {
      76. case WM_INIT_DIALOG:
      77. //
      78. // Initialization of 'Window'
      79. //
      80. hItem = pMsg->hWin;
      81. hSli=SLIDER_CreateEx(25,200,200,25,hItem,WM_CF_SHOW,0,0);
      82. WINDOW_SetBkColor(hItem, GUI_DARKGREEN);
      83. hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
      84. _hDataYT0 = GRAPH_DATA_YT_Create(GUI_RED, 200, NULL, 0);
      85. GRAPH_SetGridVis(hItem, 1);
      86. SLIDER_SetNumTicks(hSli,50);
      87. SLIDER_SetRange(hSli,0,90);
      88. SLIDER_SetFocusColor(hSli,GUI_DARKGREEN);
      89. GRAPH_AttachData(hItem,_hDataYT0);
      90. while(1)
      91. {
      92. sliderV=SLIDER_GetValue(hSli);
      93. HAL_ADC_Start(&hadc1);
      94. c=HAL_ADC_GetValue(&hadc1);
      95. GRAPH_DATA_YT_AddValue(_hDataYT0,c*0.025);
      96. GUI_Delay(sliderV+10);
      97. }
      98. break;
      99. default:
      100. WM_DefaultProc(pMsg);
      101. break;
      102. }
      103. }
      104. /*********************************************************************
      105. *
      106. * Public code
      107. *
      108. **********************************************************************
      109. */
      110. /*********************************************************************
      111. *
      112. * CreateWindow
      113. */
      114. WM_HWIN CreateWindow(void);
      115. WM_HWIN CreateWindow(void) {
      116. WM_HWIN hWin;
      117. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      118. return hWin;
      119. }
      120. // USER START (Optionally insert additional public code)
      121. // USER END
      122. /*************************** End of file ****************************/
      123. static void MX_ADC1_Init(void)
      124. {
      125. ADC_ChannelConfTypeDef sConfig;
      126. hadc1.Instance = ADC1;
      127. hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
      128. hadc1.Init.Resolution = ADC_RESOLUTION_12B;
      129. hadc1.Init.ScanConvMode = DISABLE;
      130. hadc1.Init.ContinuousConvMode = ENABLE;
      131. hadc1.Init.DiscontinuousConvMode = DISABLE;
      132. hadc1.Init.NbrOfDiscConversion = 1;
      133. hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
      134. hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
      135. hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
      136. hadc1.Init.NbrOfConversion = 1;
      137. hadc1.Init.DMAContinuousRequests = DISABLE;
      138. hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
      139. if (HAL_ADC_Init(&hadc1) != HAL_OK)
      140. {
      141. _Error_Handler(__FILE__, __LINE__);
      142. }
      143. sConfig.Channel = ADC_CHANNEL_0;
      144. sConfig.Rank = ADC_REGULAR_RANK_1;
      145. sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
      146. if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
      147. {
      148. _Error_Handler(__FILE__, __LINE__);
      149. }
      150. }
      151. static void MX_GPIO_Init(void)
      152. {
      153. GPIO_InitTypeDef GPIO_InitStruct;
      154. // GPIO Ports Clock Enable
      155. __HAL_RCC_GPIOE_CLK_ENABLE();
      156. __HAL_RCC_GPIOB_CLK_ENABLE();
      157. __HAL_RCC_GPIOA_CLK_ENABLE();
      158. __HAL_RCC_GPIOG_CLK_ENABLE();
      159. __HAL_RCC_GPIOJ_CLK_ENABLE();
      160. __HAL_RCC_GPIOD_CLK_ENABLE();
      161. __HAL_RCC_GPIOK_CLK_ENABLE();
      162. __HAL_RCC_GPIOF_CLK_ENABLE();
      163. __HAL_RCC_GPIOI_CLK_ENABLE();
      164. __HAL_RCC_GPIOH_CLK_ENABLE();
      165. __HAL_RCC_GPIOC_CLK_ENABLE();
      166. //Configure GPIO pin Output Level
      167. HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);
      168. //Configure GPIO pin Output Level
      169. HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
      170. //Configure GPIO pin : LCD_BL_CTRL_Pin
      171. GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
      172. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
      173. GPIO_InitStruct.Pull = GPIO_NOPULL;
      174. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
      175. HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);
      176. //Configure GPIO pin : LCD_DISP_Pin
      177. GPIO_InitStruct.Pin = LCD_DISP_Pin;
      178. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
      179. GPIO_InitStruct.Pull = GPIO_NOPULL;
      180. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
      181. HAL_GPIO_Init(LCD_DISP_GPIO_Port, &GPIO_InitStruct);
      182. //Configure GPIO pin : LCD_INT_Pin
      183. GPIO_InitStruct.Pin = LCD_INT_Pin;
      184. GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
      185. GPIO_InitStruct.Pull = GPIO_NOPULL;
      186. HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
      187. }
      Display All