Wednesday, April 25th 2018, 12:30am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

himsha

Beginner

Date of registration: Feb 21st 2018

Posts: 12

1

Tuesday, March 6th 2018, 2:16pm

plot graph from (0,0)

I had created graph as below code shown and able to update graph but graph update is always from right to left. I want from (0, 0) please share some piece of code




hGraph = GRAPH_CreateEx ( 0, 0, LCD_X_SIZE-200, LCD_Y_SIZE-75, 0, WM_CF_SHOW, 0, GUI_ID_GRAPH0 );
GRAPH_SetBorder ( hGraph, 50, 0, 0, 50 );
GRAPH_SetGridVis ( hGraph, 1 );
GRAPH_SetColor ( hGraph, GUI_LIGHTGRAY, GRAPH_CI_GRID );
GRAPH_SetColor ( hGraph, GUI_WHITE, GRAPH_CI_BK );
GRAPH_SetColor ( hGraph, GUI_LIGHTGRAY, GRAPH_CI_BORDER );

/* Create a curve for graph */
hData = GRAPH_DATA_YT_Create (GUI_RED, 700, 0, 20);
// hData = GRAPH_DATA_XY_Create (GUI_RED, 700, 0, 20);
// GRAPH_DATA_XY_SetLineStyle (hData, GUI_LS_SOLID);
GRAPH_DATA_XY_SetPenSize( hData, 10 );
/* Attach curve to graph */
GRAPH_AttachData (hGraph, hData);


/* Create and add vertical scale */
hScale = GRAPH_SCALE_Create ( 45, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 50 );
GRAPH_SCALE_SetOff ( hScale, 0 );
GRAPH_SCALE_SetFactor ( hScale, MachineCapacity/(400) );
GRAPH_SCALE_SetTextColor ( hScale, GUI_GRAY );
GRAPH_AttachScale ( hGraph, hScale );

/* Create and add horizontal scale */
hScale = GRAPH_SCALE_Create ( LCD_Y_SIZE-35, GUI_TA_HORIZONTAL, GRAPH_SCALE_CF_HORIZONTAL, 50 );
GRAPH_SCALE_SetOff ( hScale, -3 );
GRAPH_SCALE_SetFactor ( hScale, 0.02f );
GRAPH_SCALE_SetTextColor ( hScale, GUI_GRAY );
GRAPH_AttachScale ( hGraph, hScale );

WIDGET_SetEffect ( hGraph, &WIDGET_Effect_Simple );
GRAPH_SetUserDraw ( hGraph, _UserDraw );

while (1){

if (secFlag==SET){
GRAPH_DATA_YT_AddValue (hData, fValue);
secFlag = RESET;
}
GUI_Delay (100);

}