Hi,
I am new to EmWin and am using it on an STM32 Discovery platform. I want to find a way of plotting two graphs and a knob. So far I have managed to plot the graphs and update their values based on code available on this forums. However, I can not see the knob when I try to plot it. I am attaching the relevant code below.
/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2015 SEGGER Microcontroller Systeme GmbH *
* *
* Internet: segger.com Support: support@segger.com *
* *
**********************************************************************
***** emWin - Graphical user interface for embedded applications *****
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File : BASIC_HelloWorld.c
Purpose : Simple demo drawing "Hello world"
----------------------------------------------------------------------
*/
#include "GUI.h"
#include "download.c"
#include "DIALOG.h"
#include "KNOB.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_GRAPH_0 (GUI_ID_USER + 0x01)
#define ID_EDIT_0 (GUI_ID_USER + 0x02)
#define ID_GRAPH_1 (GUI_ID_USER + 0x03)
#define ID_KNOB (GUI_ID_USER + 0x04)
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 500, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "Graph", ID_GRAPH_0, 20, 20, 440, 200, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "Graph", ID_GRAPH_1, 20, 240, 440, 200, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_0, 600, 200, 150, 50, 0, 0x0, 0},
{ KNOB_CreateIndirect, "Knob", ID_KNOB, 300, 300, 150, 150, 0, 0x0, 0}
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetADValue
*/
static I16 _GetADValue(void) {
return (rand() % 100 + 1) + 50;
}
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
static GRAPH_DATA_Handle hData;
static GRAPH_DATA_Handle hData_1;
WM_HWIN hItem;
WM_HWIN hItem_1;
I16 Value;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hData = GRAPH_DATA_YT_Create(GUI_ORANGE, 440, NULL, 0);
hData_1 = GRAPH_DATA_YT_Create(GUI_GREEN, 440, NULL, 0);
hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
GRAPH_AttachData(hItem, hData);
WM_CreateTimer(pMsg->hWin, 0, 25, 0);
hItem_1 = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_1);
GRAPH_AttachData(hItem_1, hData_1);
WM_CreateTimer(pMsg->hWin, 0, 25, 0);
break;
case WM_TIMER:
Value = _GetADValue();
GRAPH_DATA_YT_AddValue(hData, Value);
WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
Value = _GetADValue()*2;
GRAPH_DATA_YT_AddValue(hData_1, Value);
WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_Init();
GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
while (1) {
GUI_Delay(100);
}
}
/*************************** End of file ****************************/
I am new to EmWin and am using it on an STM32 Discovery platform. I want to find a way of plotting two graphs and a knob. So far I have managed to plot the graphs and update their values based on code available on this forums. However, I can not see the knob when I try to plot it. I am attaching the relevant code below.
/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2015 SEGGER Microcontroller Systeme GmbH *
* *
* Internet: segger.com Support: support@segger.com *
* *
**********************************************************************
***** emWin - Graphical user interface for embedded applications *****
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File : BASIC_HelloWorld.c
Purpose : Simple demo drawing "Hello world"
----------------------------------------------------------------------
*/
#include "GUI.h"
#include "download.c"
#include "DIALOG.h"
#include "KNOB.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_GRAPH_0 (GUI_ID_USER + 0x01)
#define ID_EDIT_0 (GUI_ID_USER + 0x02)
#define ID_GRAPH_1 (GUI_ID_USER + 0x03)
#define ID_KNOB (GUI_ID_USER + 0x04)
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 500, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "Graph", ID_GRAPH_0, 20, 20, 440, 200, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "Graph", ID_GRAPH_1, 20, 240, 440, 200, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_0, 600, 200, 150, 50, 0, 0x0, 0},
{ KNOB_CreateIndirect, "Knob", ID_KNOB, 300, 300, 150, 150, 0, 0x0, 0}
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetADValue
*/
static I16 _GetADValue(void) {
return (rand() % 100 + 1) + 50;
}
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
static GRAPH_DATA_Handle hData;
static GRAPH_DATA_Handle hData_1;
WM_HWIN hItem;
WM_HWIN hItem_1;
I16 Value;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hData = GRAPH_DATA_YT_Create(GUI_ORANGE, 440, NULL, 0);
hData_1 = GRAPH_DATA_YT_Create(GUI_GREEN, 440, NULL, 0);
hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
GRAPH_AttachData(hItem, hData);
WM_CreateTimer(pMsg->hWin, 0, 25, 0);
hItem_1 = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_1);
GRAPH_AttachData(hItem_1, hData_1);
WM_CreateTimer(pMsg->hWin, 0, 25, 0);
break;
case WM_TIMER:
Value = _GetADValue();
GRAPH_DATA_YT_AddValue(hData, Value);
WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
Value = _GetADValue()*2;
GRAPH_DATA_YT_AddValue(hData_1, Value);
WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_Init();
GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
while (1) {
GUI_Delay(100);
}
}
/*************************** End of file ****************************/