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
Display All
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
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.40 *
- * Compiled Jun 22 2017, 10:13:26 *
- * (c) 2017 Segger Microcontroller GmbH & Co. KG *
- * *
- **********************************************************************
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- #include "GUI_App.h"
- #include "GUI.h"
- #include "DIALOG.h"
- #include "stm32746g_discovery.h"
- #include "stm32746g_discovery_ts.h"
- #include "stm32f7xx_hal.h"
- #include "DIALOG.h"
- #include "stdlib.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
- #define ID_GRAPH_0 (GUI_ID_USER + 0x01)
- #define ID_SLIDER_0 (GUI_ID_USER + 0x02)
- ADC_HandleTypeDef hadc1;
- static void MX_ADC1_Init(void);
- static void MX_GPIO_Init(void);
- int frameXSize=480;
- int frameYSize=205;
- uint16_t c;
- uint16_t sliderV=10;
- GUI_RECT Rect = {0, 0, 30, 205};
- char acText[] = "Temperature";
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { WINDOW_CreateIndirect, "Window",ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
- { GRAPH_CreateIndirect, "Graph",ID_GRAPH_0, 25, 86, 200, 100, 0, 0x0, 0 },
- };
- static GRAPH_DATA_Handle _hDataYT0;
- static SLIDER_Handle hSli;
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Window'
- //
- hItem = pMsg->hWin;
- hSli=SLIDER_CreateEx(25,200,200,25,hItem,WM_CF_SHOW,0,0);
- WINDOW_SetBkColor(hItem, GUI_DARKGREEN);
- hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
- _hDataYT0 = GRAPH_DATA_YT_Create(GUI_RED, 200, NULL, 0);
- GRAPH_SetGridVis(hItem, 1);
- SLIDER_SetNumTicks(hSli,50);
- SLIDER_SetRange(hSli,0,90);
- SLIDER_SetFocusColor(hSli,GUI_DARKGREEN);
- GRAPH_AttachData(hItem,_hDataYT0);
- while(1)
- {
- sliderV=SLIDER_GetValue(hSli);
- HAL_ADC_Start(&hadc1);
- c=HAL_ADC_GetValue(&hadc1);
- GRAPH_DATA_YT_AddValue(_hDataYT0,c*0.025);
- GUI_Delay(sliderV+10);
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateWindow
- */
- WM_HWIN CreateWindow(void);
- WM_HWIN CreateWindow(void) {
- WM_HWIN hWin;
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- return hWin;
- }
- // USER START (Optionally insert additional public code)
- // USER END
- /*************************** End of file ****************************/
- static void MX_ADC1_Init(void)
- {
- ADC_ChannelConfTypeDef sConfig;
- hadc1.Instance = ADC1;
- hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
- hadc1.Init.Resolution = ADC_RESOLUTION_12B;
- hadc1.Init.ScanConvMode = DISABLE;
- hadc1.Init.ContinuousConvMode = ENABLE;
- hadc1.Init.DiscontinuousConvMode = DISABLE;
- hadc1.Init.NbrOfDiscConversion = 1;
- hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
- hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
- hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
- hadc1.Init.NbrOfConversion = 1;
- hadc1.Init.DMAContinuousRequests = DISABLE;
- hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
- if (HAL_ADC_Init(&hadc1) != HAL_OK)
- {
- _Error_Handler(__FILE__, __LINE__);
- }
- sConfig.Channel = ADC_CHANNEL_0;
- sConfig.Rank = ADC_REGULAR_RANK_1;
- sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
- if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
- {
- _Error_Handler(__FILE__, __LINE__);
- }
- }
- static void MX_GPIO_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct;
- // GPIO Ports Clock Enable
- __HAL_RCC_GPIOE_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOG_CLK_ENABLE();
- __HAL_RCC_GPIOJ_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOK_CLK_ENABLE();
- __HAL_RCC_GPIOF_CLK_ENABLE();
- __HAL_RCC_GPIOI_CLK_ENABLE();
- __HAL_RCC_GPIOH_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- //Configure GPIO pin Output Level
- HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);
- //Configure GPIO pin Output Level
- HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
- //Configure GPIO pin : LCD_BL_CTRL_Pin
- GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);
- //Configure GPIO pin : LCD_DISP_Pin
- GPIO_InitStruct.Pin = LCD_DISP_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(LCD_DISP_GPIO_Port, &GPIO_InitStruct);
- //Configure GPIO pin : LCD_INT_Pin
- GPIO_InitStruct.Pin = LCD_INT_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
- }