Example #1
0
/**
  * @brief  Callback function of the performance dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbPerformanceDialog(WM_MESSAGE * pMsg) {
  int NCode;
  int Id;
  WM_HWIN hGraph;

  GUI_RECT Rect;

  switch (pMsg->MsgId) 
  {
    
  case WM_INIT_DIALOG:

    FRAMEWIN_SetTitleVis(pMsg->hWin, 0);
    hGraph = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_CPU);
    hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20);
    GRAPH_SetGridVis(hGraph, 1);
    GRAPH_SetBorder(hGraph, 30, 2, 2, 2); 
    GRAPH_AttachData(hGraph, hData);
    hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_AttachScale(hGraph, hScale);  
    GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW);
    GRAPH_SetGridDistX(hGraph, 25);
    GRAPH_SetGridDistY(hGraph, 25);
    WM_GetClientRect(&Rect);
    WM_CreateWindowAsChild(470, 0, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0); 
    
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
      
    case ID_BUTTON_HIDE: /* Notifications sent by Hide Button */
      switch(NCode) 
      {
      case WM_NOTIFICATION_RELEASED:
        
        if(hPerformance != 0)
        {
          WM_HideWindow(hPerformance);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
static void SweepRobot_PowerStationGraphInit(void)
{
    hGraph = WM_GetDialogItem(hWin_SWRB_POWER_STATION, ID_PS_GRAPH_MAIN);

    hDataVol = GRAPH_DATA_YT_Create(GUI_BLUE, MaxNumDataItems, aVoltageValue, NumDataItems);
    hDataCur = GRAPH_DATA_YT_Create(GUI_DARKGREEN, MaxNumDataItems, aCurrentValue, NumDataItems);
    GRAPH_AttachData(hGraph, hDataVol);
    GRAPH_AttachData(hGraph, hDataCur);
    GRAPH_DATA_YT_SetAlign(hDataVol, GRAPH_ALIGN_LEFT);
    GRAPH_DATA_YT_SetAlign(hDataCur, GRAPH_ALIGN_LEFT);

    hScaleVol = GRAPH_SCALE_Create(320, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);
    hScaleCur = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);
    GRAPH_SCALE_SetTextColor(hScaleVol, GUI_BLUE);
    GRAPH_SCALE_SetTextColor(hScaleCur, GUI_DARKGREEN);
    GRAPH_AttachScale(hGraph, hScaleVol);
    GRAPH_AttachScale(hGraph, hScaleCur);

    GRAPH_DATA_YT_SetOffY(hDataVol, -3100);
    GRAPH_SCALE_SetOff(hScaleVol, -3100);

    GRAPH_SetVSizeY(hGraph, 1000);
}
Example #3
0
/*********************************************************************
*
*       _ShowGraph
*/
static void _ShowGraph(GRAPH_Handle hGraph, GRAPH_DATA_Handle hData[], int DataCount, void (* pfAddData)(GRAPH_DATA_Handle hData, int DataID)) {
  int Data_xSize;
  int NextState;
  int TimeStart;
  int TimeDiff;
  int TimeStep;
  int Count;
  int xSize;
  int i;

  xSize      = LCD_GetXSize();
  Data_xSize = xSize - (DIST_TO_BORDER << 1) - (BORDER_LEFT + BORDER_RIGHT);
  Count      = 0;
  //
  // Attach data objects
  //
  for (i = 0; i < DataCount; i++) {
    GRAPH_AttachData(hGraph, hData[i]);
  }
  //
  // Add values before GRAPH is displayed
  //
  while (Count < Data_xSize) {
    for (i = 0; i < DataCount; i++) {
      pfAddData(hData[i], i);
    }
    Count++;
  }
  //
  // Add values depending on time
  //

  TimeStart = GUIDEMO_GetTime();
  do {
    TimeDiff = GUIDEMO_GetTime() - TimeStart;
    for (i = 0; i < DataCount; i++) {
      pfAddData(hData[i], i);
    }
    NextState = GUIDEMO_CheckCancel();
    TimeStep  = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    }
  } while ((TimeDiff < TIME_RUN) && (NextState == 0));
  for (i = 0; i < DataCount; i++) {
    GRAPH_DetachData(hGraph, hData[i]);
  }
  GUIDEMO_NotifyStartNext();
}
void MainTask_Gyro(void) {
      SysTICK();
      float Buffer[6] = {0};
      uint8_t Xval, Yval = 0x00;


      Demo_GyroConfig();



	SetemWinRunning(1);
		
	GUI_SelectLayer(1); // select foregroung layer
	GUI_SetBkColor(STBLUE);	// select background color as a solid color
	GUI_Clear();	// fill with the background color


        GRAPH_DATA_Handle hData1, hData2, hData3;
        GRAPH_SCALE_Handle hScale;
        WM_HWIN hGraph;
        hGraph = GRAPH_CreateEx(0, 0, 240, 320, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_GRAPH0);
        hData1 = GRAPH_DATA_YT_Create(GUI_GREEN, 240, 0, 0);
        hData2 = GRAPH_DATA_YT_Create(GUI_RED, 240, 0, 0);
        //hData3 = GRAPH_DATA_YT_Create(GUI_BLUE, 240, 0, 0);

        GRAPH_AttachData(hGraph, hData1);
        GRAPH_AttachData(hGraph, hData2);
        //GRAPH_AttachData(hGraph, hData3);

        hScale = GRAPH_SCALE_Create(19, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);

        GRAPH_SCALE_SetFactor(hScale, 0.5);
        GRAPH_SCALE_SetNumDecs(hScale, 0.01);
        GRAPH_SCALE_SetFont(hScale, &GUI_Font16_1);
        GRAPH_SCALE_SetTextColor(hScale, GUI_BLACK);


        GRAPH_AttachScale(hGraph, hScale);
        GRAPH_SetBorder(hGraph, 20, 0, 0, 0);
        GRAPH_SetGridVis(hGraph, 1);


        GRAPH_SetColor(hGraph, GUI_WHITE, GRAPH_CI_BK);
        GRAPH_SetColor(hGraph, GUI_LIGHTGRAY, GRAPH_CI_BORDER);
        GRAPH_SetColor(hGraph, GUI_BLACK, GRAPH_CI_FRAME);
        GRAPH_SetColor(hGraph, GUI_DARKGRAY, GRAPH_CI_GRID);
        
        GRAPH_SetLineStyleH(hGraph, GUI_LS_DOT);
        GRAPH_SetLineStyleV(hGraph, GUI_LS_DOT);
        
        GRAPH_SetGridDistX(hGraph, 50);
        GRAPH_SetGridDistY(hGraph, 20);

        GUI_Exec();

        STM_EVAL_LEDToggle(LED4);
        STM_EVAL_LEDToggle(LED3);

	// the GUI is now rendered 
	// in never ending loop just check if an incon is touched
  


  while(!tamperPushed)
  {             
    if(open){

        /* Read Gyro Angular data */
        Demo_GyroReadAngRate(Buffer);
        /* Update autoreload and capture compare registers value*/
        Xval = ABS((int8_t)(Buffer[0]));
        Yval = ABS((int8_t)(Buffer[1]));

      
              GRAPH_DATA_YT_AddValue(hData1, Xval*2);
              GRAPH_DATA_YT_AddValue(hData2, Yval*2);
              GUI_Exec();
      
              
                open=0;
    }

  }     
       // WM_DeleteWindow(hGraph);
	SetemWinRunning(0);
	GUI_CURSOR_Hide(); 
}
/**
  * @brief  Callback routine of the Benchmark dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  WM_HWIN hGraph;
  int cpu_speed = 0;
  char temp[50];
  WM_CALLBACK  *_cb;

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    /* Initialization of 'CPU' */
    hItem = pMsg->hWin;
    FRAMEWIN_SetFont(hItem, GUI_FONT_13HB_ASCII);
    FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT,  0);

    hItem = TEXT_CreateEx(10, 20, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x123,"");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, 0x00804000);
    TEXT_SetText(hItem, "CPU Usage %:");

    hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetTextColor(hItem, GUI_DARKRED);


    hItem = WM_GetDialogItem(pMsg->hWin, ID_CPU_GRAPH);
    FRAMEWIN_SetBarColor(hItem, 0, GUI_DARKGRAY);
    FRAMEWIN_SetBarColor(hItem, 1, GUI_DARKGRAY);

    hGraph = GRAPH_CreateEx(10, 35, 300, 95, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_GRAPH0);
    hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20);
    GRAPH_SetGridVis(hGraph, 1);
    GRAPH_SetBorder(hGraph, 20, 4, 5, 4);
    GRAPH_AttachData(hGraph, hData);

    hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_AttachScale(hGraph, hScale);
    GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW);
    GRAPH_SetGridDistX(hGraph, 25);
    GRAPH_SetGridDistY(hGraph, 25);

    WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0);

    break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:      /* React only if released */
      switch (Id) {

      case ID_BENCH_CPU:
        Stop_Test = 0;

        WM_HideWindow(pMsg->hWin);

        _cb = WM_GetCallback(WM_HBKWIN);
        WM_SetCallback(WM_HBKWIN, _ClearDesktop);
        cpu_speed = Run_SpeedTest();

        WM_ShowWindow(pMsg->hWin);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU);
        sprintf (temp, "%d  Pixels/s ", cpu_speed);
        TEXT_SetText(hItem, temp);
        WM_SetCallback(WM_HBKWIN, _cb);
        hItem = WM_GetDialogItem(WM_HBKWIN, ID_BUTTON_BKGND);
        WM_InvalidateWindow(hItem);
        WM_InvalidateWindow(WM_HBKWIN);
        WM_Paint(WM_HBKWIN);
        break;
      }
      break;

    case WM_NOTIFICATION_CHILD_DELETED:
      Stop_Test = 1;
      break;
    }
    break;

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Example #6
0
/*********************************************************************
*
*       _cbCallback
*
* Purpose:
*   Callback function of the dialog
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  int NCode, Id, Value, i;
  WM_HWIN hDlg, hItem;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
    _InitPoints();
    /* Add graphs */
    for (i = 0; i < 3; i++) {
      GRAPH_DATA_Handle  hDataXY;
      hDataXY = GRAPH_DATA_XY_Create(_aColor[i], GUI_COUNTOF(_aPoint[i]), _aPoint[i], GUI_COUNTOF(_aPoint[i]));
      GRAPH_DATA_XY_SetLineStyle(hDataXY, _aLStyle[i]);
      GRAPH_AttachData(hItem, hDataXY);
    }
    /* Set graph attributes */
    GRAPH_SetGridDistY(hItem, 25);
    GRAPH_SetGridVis(hItem, 1);
    GRAPH_SetUserDraw(hItem, _UserDraw);
    /* Create and add vertical scale */
    _hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_SCALE_SetOff(_hScaleV, 100);
    GRAPH_SCALE_SetFactor(_hScaleV, 0.04f);
    GRAPH_SCALE_SetTextColor(_hScaleV, GUI_RED);
    GRAPH_AttachScale(hItem, _hScaleV);
    /* Create and add horizontal scale */
    _hScaleH = GRAPH_SCALE_Create(70, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
    GRAPH_SCALE_SetFactor(_hScaleH, 0.02f);
    GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
    GRAPH_AttachScale(hItem, _hScaleH);
    /* Init check boxes */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK2);
    CHECKBOX_SetText(hItem, "L");
    CHECKBOX_SetState(hItem, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK3);
    CHECKBOX_SetText(hItem, "T");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK4);
    CHECKBOX_SetText(hItem, "R");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK5);
    CHECKBOX_SetText(hItem, "B");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK1);
    CHECKBOX_SetText(hItem, "Grid");
    CHECKBOX_SetState(hItem, 1);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK6);
    CHECKBOX_SetText(hItem, "HScroll");
    hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK7);
    CHECKBOX_SetText(hItem, "VScroll");
    /* Init slider widgets */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0);
    SLIDER_SetRange(hItem, 0, 10);
    SLIDER_SetValue(hItem, 5);
    SLIDER_SetNumTicks(hItem, 6);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER1);
    SLIDER_SetRange(hItem, 0, 20);
    SLIDER_SetValue(hItem, 5);
    SLIDER_SetNumTicks(hItem, 6);
    /* Init radio widget */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
    RADIO_SetText(hItem, "3D", 0);
    RADIO_SetText(hItem, "flat", 1);
    RADIO_SetText(hItem, "-", 2);
    /* Init button widget */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
    WM_SetStayOnTop(hItem, 1);
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);      /* Id of widget */
    NCode = pMsg->Data.v;                 /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_CLICKED:
      switch (Id) {
      case GUI_ID_BUTTON0:
        _ToggleFullScreenMode(hDlg);
        break;
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED:
      switch (Id) {
      case GUI_ID_CHECK1:
        /* Toggle grid */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        GRAPH_SetGridVis(hItem, CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK1)));
        break;
      case GUI_ID_CHECK2:
      case GUI_ID_CHECK3:
      case GUI_ID_CHECK4:
      case GUI_ID_CHECK5:
        /* Toggle border */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        GRAPH_SetBorder(hItem, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK2)) * 40, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK3)) * 5, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK4)) * 5, 
                        CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK5)) * 5);
        break;
      case GUI_ID_SLIDER0:
        /* Set horizontal grid spacing */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        Value = SLIDER_GetValue(pMsg->hWinSrc) * 10;
        GRAPH_SetGridDistX(hItem, Value);
        GRAPH_SCALE_SetTickDist(_hScaleH, Value);
        if (Value != 50) {
          GRAPH_SCALE_SetNumDecs(_hScaleH, 1);
        } else {
          GRAPH_SCALE_SetNumDecs(_hScaleH, 0);
        }
        break;
      case GUI_ID_SLIDER1:
        /* Set vertical grid spacing */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        Value = SLIDER_GetValue(pMsg->hWinSrc) * 5;
        GRAPH_SetGridDistY(hItem, Value);
        GRAPH_SCALE_SetTickDist(_hScaleV, Value);
        if (Value != 25) {
          GRAPH_SCALE_SetNumDecs(_hScaleV, 1);
        } else {
          GRAPH_SCALE_SetNumDecs(_hScaleV, 0);
        }
        break;
      case GUI_ID_RADIO0:
        /* Set the widget effect */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        switch (RADIO_GetValue(pMsg->hWinSrc)) {
        case 0:
          WIDGET_SetEffect(hItem, &WIDGET_Effect_3D);
          break;
        case 1:
          WIDGET_SetEffect(hItem, &WIDGET_Effect_Simple);
          break;
        case 2:
          WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
          break;
        }
        break;
      case GUI_ID_CHECK6:
        /* Toggle horizontal scroll bar */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK6))) {
          GRAPH_SetVSizeX(hItem, 500);
        } else {
          GRAPH_SetVSizeX(hItem, 0);
        }
        break;
      case GUI_ID_CHECK7:
        /* Toggle vertical scroll bar */
        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK7))) {
          GRAPH_SetVSizeY(hItem, 300);
        } else {
          GRAPH_SetVSizeY(hItem, 0);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
Example #7
0
static void _cbDialoggraph(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId)
  {
	  case WM_INIT_DIALOG:
	  {
			hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0);

			   GRAPH_DATA_Handle hData;
			   GRAPH_SCALE_Handle hScale;
			   WM_HWIN hGraph;
//			   hGraph = GRAPH_CreateEx(10, 10, 216, 106, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_GRAPH0);
//			   hData = GRAPH_DATA_YT_Create(GUI_DARKGREEN, 200, 5, 0);
//			   GRAPH_AttachData(hGraph, hData);
//			   hScale = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);
//			   GRAPH_AttachScale(hGraph, hScale);

			_InitPoints(_aNumPoints[0]);

			for (int i = 0; i < 3; i++)
			{
//			  _ahDataXY[i] = GRAPH_DATA_XY_Create(GUI_RED, _NumPoints, _aPoint[i], _NumPoints);
			 _ahDataXY[i] = GRAPH_DATA_XY_Create(GUI_RED, 200, 5, 0);
			  GRAPH_DATA_XY_SetLineStyle(_ahDataXY[i], GUI_LS_SOLID);
			  GRAPH_AttachData(hItem, _ahDataXY[i]);
//		      GRAPH_DATA_XY_SetOwnerDraw(_ahDataXY[i], _OwnerDraw);
			}

			// Set graph attributes
			//
			GRAPH_SetGridDistY(hItem, 25);
			GRAPH_SetGridVis(hItem, 1);
			GRAPH_SetUserDraw(hItem, _UserDraw);
			//
			// Create and add vertical scale
			//
			_hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
			GRAPH_SCALE_SetOff(_hScaleV, 100);
			GRAPH_SCALE_SetFactor(_hScaleV, 0.04f);
			GRAPH_SCALE_SetTextColor(_hScaleV, GUI_RED);
			GRAPH_AttachScale(hItem, _hScaleV);
			//
			// Create and add horizontal scale
			//
			_hScaleH = GRAPH_SCALE_Create(70, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
			GRAPH_SCALE_SetFactor(_hScaleH, 0.02f);
			GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
			GRAPH_AttachScale(hItem, _hScaleH);
			GRAPH_SCALE_SetNumDecs(_hScaleV, 0);
			GRAPH_SetVSizeX(hItem, 500);



		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
		EDIT_SetText(hItem, "123");
		// USER START (Optionally insert additional code for further widget initialization)
		// USER END
		break;
	  }
	  case WM_NOTIFY_PARENT:
	  {
		Id    = WM_GetId(pMsg->hWinSrc);
		NCode = pMsg->Data.v;
		switch(Id) {
		case ID_EDIT_1: // Notifications sent by 'Edit'
		  switch(NCode) {
		  case WM_NOTIFICATION_CLICKED:
			// USER START (Optionally insert code for reacting on notification message)
			// USER END
			break;
		  case WM_NOTIFICATION_RELEASED:
			// USER START (Optionally insert code for reacting on notification message)
			// USER END
			break;
		  case WM_NOTIFICATION_VALUE_CHANGED:
			// USER START (Optionally insert code for reacting on notification message)
			// USER END
			break;
		  // USER START (Optionally insert additional code for further notification handling)
		  // USER END
		  }
		  break;
		// USER START (Optionally insert additional code for further Ids)
		// USER END
		}
		break;
	  }
	  // USER START (Optionally insert additional message handling)
	  // USER END
	  default:
	  {
		WM_DefaultProc(pMsg);
		break;
	  }
  }
}
Example #8
0
static void _Show_Sensor_Graph(GRAPH_Handle hGraph, GRAPH_DATA_Handle hData[])
{
  int xSize      = LCD_GetXSize();
  int Data_xSize = xSize - (DIST_TO_BORDER << 1) - (BORDER_LEFT + BORDER_RIGHT);
  int Count      = 0;

  //
  // Attach data objects
  //
  GRAPH_AttachData(hGraph, hData[0]);
  GRAPH_AttachData(hGraph, hData[1]);
  GRAPH_AttachData(hGraph, hData[2]);
  //
  // Add values before GRAPH is displayed
  //
  while (Count < Data_xSize) {
    GRAPH_DATA_YT_AddValue(hData[0], (I16)0);
    GRAPH_DATA_YT_AddValue(hData[1], (I16)0);
    GRAPH_DATA_YT_AddValue(hData[2], (I16)0);
    Count++;
  }

  sensor_all_open();

  // uint32_t lux_senser;
  // get_als_data(&lux_senser);
  int32_t x,y,z;
  uint32_t setp;
  //
  // Add values depending on time
  //
  // int TimeStart, TimeDiff, TimeStep;
  // int NextState, Flag;
  // lighten GS LED
  hal_gpio_output_low(&brd_gpio_table[GPIO_LED_GS]);

  // TimeStart = GUIDEMO_GetTime();
  int Flag = 1;
  do {
    get_acc_data(&x,&y,&z,&setp);
    // TimeDiff = GUIDEMO_GetTime() - TimeStart;
    GRAPH_DATA_YT_AddValue(hData[0], ((I16)x >> 5) + 78);
    GRAPH_DATA_YT_AddValue(hData[1], ((I16)y >> 5) + 78);
    GRAPH_DATA_YT_AddValue(hData[2], ((I16)z >> 5) + 78);

    if (Flag) {
      Flag = 0;
      GUI_Exec();
      GRAPH_DetachScale(hGraph, _hScaleH_sensor);
      GRAPH_DetachScale(hGraph, _hScaleV_sensor);
      WM_ValidateWindow(hGraph);
    }
    /*
    NextState = GUIDEMO_CheckCancel();
    TimeStep  = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    }*/
    GUI_Delay(100);
  } while (key_flag == GUI_DEMO_PAGE_3);

  GRAPH_DetachData(hGraph, hData[0]);
  GRAPH_DetachData(hGraph, hData[1]);
  GRAPH_DetachData(hGraph, hData[2]);

  // GUIDEMO_NotifyStartNext();

  // shutdown GS LED
  hal_gpio_output_high(&brd_gpio_table[GPIO_LED_GS]);
}
Example #9
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) 
{
		
	GUI_Init();
	
	
	WM_SetDesktopColor(GUI_BLUE);	//!< SetDesktopColor
	
	 /* The First window to display the Temperature Curve */
	{
		hWM_HBKWIN_CURVE =
		WM_CreateWindow(0,0,400,240,WM_CF_SHOW | WM_CF_MEMDEV ,0,0);
		
		btn = 		 BUTTON_CreateAsChild(315, 10, 75, 35,hWM_HBKWIN_CURVE, ID_CURVE_BTN_SWTITCH_2_PARA, WM_CF_SHOW);
		btnClear = BUTTON_CreateAsChild(315, 60, 75, 35,hWM_HBKWIN_CURVE, 202, WM_CF_SHOW);
		
		/** PWM Edit **/
		{
			/* Edit to display the PWM1 */
				Edit_PWM1 = EDIT_CreateEx			 (370, 170, 25, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_PWM1,
																				 3);
				EDIT_SetDecMode(Edit_PWM1,0,0,255,0,0);
				EDIT_SetValue(Edit_PWM1,0);
				
				/* Edit to display the PWM2 */
				Edit_PWM2 = EDIT_CreateEx			 (370, 190, 25, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_PWM2,
																				 3);
				EDIT_SetDecMode(Edit_PWM2,0,0,255,0,0);
				EDIT_SetValue(Edit_PWM2,0);
				
					/* Edit to display the PWM3 */
				Edit_PWM3 = EDIT_CreateEx			 (370, 210, 25, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_PWM3,
																				 3);
				EDIT_SetDecMode(Edit_PWM3,0,0,255,0,0);
				EDIT_SetValue(Edit_PWM3,0);
		}


		
		
		// Set Callback function for background window
		WM_SetCallback(hWM_HBKWIN_CURVE, _cbBk);
	}
		
	{
		hWM_HBKWIN_CFG_PID =
		WM_CreateWindow(0,0,400,240,WM_CF_HIDE | WM_CF_MEMDEV ,0,0); //Add the | WM_CF_MEMDEV flah
		
	

		btn1 			= BUTTON_CreateAsChild(320, 30 , 60, 35,hWM_HBKWIN_CFG_PID, ID_CFG_PID_BTN_SWTITCH_2_CURVE, WM_CF_SHOW);
		btnClear1 = BUTTON_CreateAsChild(320, 75, 60, 35,hWM_HBKWIN_CFG_PID, 203, WM_CF_SHOW);
		BUTTON_SetText(btn1,"PID_Set");
		BUTTON_SetText(btnClear1,"Back");
		
		BUTTON_SetText(btn     ,"Running");
		BUTTON_SetText(btnClear,"PID_Set");
	

		WM_SetCallback(hWM_HBKWIN_CFG_PID, _cbBk_CFG_PID);
	}
	

	
	//!< Create a graph widget
	{
		hGraph = GRAPH_CreateEx(8, 10, 300, 220, hWM_HBKWIN_CURVE, WM_CF_SHOW | WM_CF_CONST_OUTLINE | WM_CF_MEMDEV_ON_REDRAW , 0, 100);
		//GRAPH_DATA_YT_MirrorX(hGraph , 1);
		
		//!< Create a YT_data 
		hData  = GRAPH_DATA_YT_Create(GUI_BLUE, 292,0, 0); // Set the	MaxItemNum to 0	
		hData2 = GRAPH_DATA_YT_Create(GUI_RED,292,0,0);
		
		GRAPH_AttachData(hGraph, hData); //!< Attach the data to graph
		GRAPH_AttachData(hGraph, hData2); //!< Attach the data to graph
		
	}
	
	WM_ShowWindow(hWM_HBKWIN_CURVE);
	WM_HideWindow(hWM_HBKWIN_CFG_PID);
/*
	WM_BringToTop(hWM_HBKWIN);
	WM_BringToBottom(hWM_HBKWIN_CFG_PID);
	WM_MoveTo(hWM_HBKWIN_CFG_PID,400,240);
	WM_ResizeWindow(hWM_HBKWIN_CFG_PID,1,1);
*/	
	#ifdef PWM_TEXT		
			/** PWM Text **/
		{
			/* Edit to display the PWM1 */
				Text_PWM1 = TEXT_CreateEx			 (310, 170, 30, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_TXT_PWM1,
																				 "PMW1");				
				/* Edit to display the PWM2 */
				Text_PWM2 = TEXT_CreateEx			 (310, 190, 30, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_TXT_PWM2,
																				 "PWM2");
					/* Edit to display the PWM3 */
				Text_PWM3 = TEXT_CreateEx			 (310, 210, 30, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_TXT_PWM3,
																				 "PWM3");
		}
#endif
		
#ifdef EDIT_AD		
	 {
				/* Edit to display the AD1 */
				Edit_AD1 = EDIT_CreateEx			 (350, 120, 35, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_AD1,
																				 5);
				EDIT_SetDecMode(Edit_AD1,0,0,4095,0,0);
				EDIT_SetValue(Edit_AD1,0);
				
				/* Edit to display the AD2 */
				Edit_AD2 = EDIT_CreateEx			 (350, 140, 35, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_AD2,
																				 5);
				EDIT_SetDecMode(Edit_AD2,0,0,4095,0,0);
				EDIT_SetValue(Edit_AD2,0);
		 

				EDIT_SetFloatMode(
													Edit_AD1,1.0,
													0.0,99.9,1,/*1 bit after dot*/
													0
													);
				EDIT_SetFloatMode(
													Edit_AD2,0.0,
													0.0,99.9,1,/*1 bit after dot*/
													0
													);
	 }
#endif		

	//!< Graph configuration
	{
		hScale = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);
		GRAPH_SCALE_SetTextColor(hScale,GUI_GREEN);
		GRAPH_SCALE_SetFactor(hScale,0.5);
		GRAPH_SCALE_SetNumDecs(hScale,1);
		GRAPH_AttachScale(hGraph, hScale);
		
		GRAPH_SetGridDistX(hGraph,0); // Hide the X Grid
		GRAPH_SetGridDistY(hGraph,20);	
		GRAPH_SetGridVis(hGraph,1);  //!< Display the Grid
		
		GRAPH_SetBorder(hGraph,30,5,5,5);  //!< Set the frame border 
		
		//GRAPH_SetGridFixedX(hGraph,1);
		//GRAPH_SetVSizeX(hGraph,500);  //加入此会导致死掉 程序卡死在获取此指针上面.
		//GRAPH_SetGridFixedY(hGraph,1);
		GRAPH_SetColor(hGraph,GUI_BLUE,GRAPH_CI_BORDER);
		GRAPH_SetColor(hGraph,GUI_WHITE,GRAPH_CI_BK);
		GRAPH_SetColor(hGraph,GUI_WHITE,GRAPH_CI_FRAME);

	}	
	/* Button Configuration */
	{
	
		BUTTON_SetBkColor(btn,BUTTON_CI_UNPRESSED,GUI_LIGHTBLUE);
		BUTTON_SetBkColor(btn,BUTTON_CI_PRESSED,GUI_RED);
			
		BUTTON_SetFocusColor(btn,GUI_YELLOW);	
	}
			
  while(1) 
	{
		GUI_Exec();	

	 	OSTimeDlyHMSM(0,0,0,50);
//#define DRAWPOINT
#ifdef DRAWPOINT
		
		itoa(usValue, buf, 10);
		BUTTON_SetText(btn,buf);

	//	GRAPH_DATA_YT_AddValue(hData,usValue/20);
#endif		
	}
}
Example #10
0
void InitDialog_Lim(WM_MESSAGE * pMsg)
{
	int i,j;
	char buf[8];
	GUI_ConstString _ListBox[] = {"1", "0", "0","E", "", "","R"};
    WM_HWIN hWin = pMsg->hWin,hGraph = 0;
	WM_HWIN hDlg, hItem;
	hDlg = pMsg->hWin;
    //
    //FRAMEWIN
    //
    //FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
    //FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1);
    //FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2);
    //
    //GUI_ID_BUTTON_PARM_SET
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_PARM_SET),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_PRINT
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_PRINT),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_SAVE
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_SAVE),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_HOME
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_HOME),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_CR
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_CR),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_STOP
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_STOP),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_PROGBAR0
    //
    PROGBAR_SetValue(WM_GetDialogItem(hWin,GUI_ID_PROGBAR0),50);
    //
    //GUI_ID_LISTVIEW_RESULT
    //
    //LISTBOX_SetBkColor(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),0,0xffffff);
    LISTVIEW_SetFont(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),&GUI_FontHZ_SongTi_16);
    LISTVIEW_SetAutoScrollH(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),1);
    LISTVIEW_SetAutoScrollV(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),1);
    LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),30,"order",GUI_TA_VCENTER|GUI_TA_LEFT);
    LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),70,"V1",GUI_TA_VCENTER|GUI_TA_LEFT);
    LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),70,"V2",GUI_TA_VCENTER|GUI_TA_LEFT);
	LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),65,"Res",GUI_TA_VCENTER|GUI_TA_LEFT);
    LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),60,"State",GUI_TA_VCENTER|GUI_TA_LEFT);
	LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),70,"Time",GUI_TA_VCENTER|GUI_TA_LEFT);
	LISTVIEW_AddColumn(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),50,"Dir",GUI_TA_VCENTER|GUI_TA_LEFT);

    //LISTVIEW_AddRow(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),_lvTable_100);
    //
    //GUI_ID_BUTTON_START
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_START),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_CHECKBOX_MULT
    //
    CHECKBOX_SetText(WM_GetDialogItem(hWin,GUI_ID_CHECKBOX_MULT),"多曲线显示");
    CHECKBOX_SetFont(WM_GetDialogItem(hWin,GUI_ID_CHECKBOX_MULT),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_DATA
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_DATA),&GUI_FontHZ_SongTi_16);
    //
    //GUI_ID_BUTTON_DELET
    //
    BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON_DELET),&GUI_FontHZ_SongTi_16);




	for(i=0;i< tget_record.act_record_lenth;i++)
	{
	_ListBox[0] = tget_record.sig_record[i].order;
	_ListBox[1] = tget_record.sig_record[i].V1;
	_ListBox[2] = tget_record.sig_record[i].V2;
	_ListBox[3] = tget_record.sig_record[i].result_r_e;
	_ListBox[4] = tget_record.sig_record[i].state;
	_ListBox[5] = tget_record.sig_record[i].time;
	_ListBox[6] = tget_record.sig_record[i].dir;

	LISTVIEW_AddRow(WM_GetDialogItem(hWin,GUI_ID_LISTVIEW_RESULT),_ListBox);
		
	}

	for(i=0;i<TEST_TIMES;i++)
	{
	exist[i] = 0;
	}


	
	#if 0
	hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
	/* Add graphs */
    for (i = 0; i < GUI_COUNTOF(_aColor); i++) {
      _aValue[i] = rand() % 180;
      _ahData[i] = GRAPH_DATA_YT_Create(_aColor[i], 500, 0, 0);
      GRAPH_AttachData(hItem, _ahData[i]);
    }
	 /* Set graph attributes */
    GRAPH_SetGridDistY(hItem, 2);
    GRAPH_SetGridVis(hItem, 1);
    GRAPH_SetGridFixedX(hItem, 1);
    GRAPH_SetUserDraw(hItem, _UserDraw);
    /* Create and add vertical scale */
    _hScaleV = GRAPH_SCALE_Create( 5, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 5);
    GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
    GRAPH_AttachScale(hItem, _hScaleV);
    /* Create and add horizontal scale */
    _hScaleH = GRAPH_SCALE_Create(15, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 5);
    GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
    GRAPH_AttachScale(hItem, _hScaleH);
	#endif 
}
Example #11
0
void OnxxxClicked_Start(WM_MESSAGE * pMsg)
{

	  int lenth;
	  char buf[5];
	
	  GUI_ConstString _ListBox[] = {"1", "0", "0","E", "", "","R"};

	if(!disp_muit && !exist[0])// 如果单曲线显示
	  {

#ifdef DISP_YT
	_ahData[0] = GRAPH_DATA_YT_Create(_aColor[0], 500, 0, 0);//YT
	
#endif

#ifdef DISP_XY

	_ahData[0]  = GRAPH_DATA_XY_Create(_aColor[0],DISP_XY_X_LENTH,0, 0);
     
#endif
	 
    GRAPH_AttachData(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _ahData[0]);//attaches  data object to graph object
    exist[0] = 1;
	GRAPH_SetUserDraw(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _UserDraw); /* Enable user draw */
			
    GRAPH_SetGridVis(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 6);
	GRAPH_SetVSizeY(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 1000);
    _hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 10);
    GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
    GRAPH_AttachScale(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _hScaleV);
	  }

	  if((get_data.e_work_state != START_TEST)&&(get_data.e_work_state != GET_V1))
	  	{
	
	  lenth = LISTVIEW_GetNumRows(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT));
	  
	  if(lenth < TEST_TIMES)
	  {
	  record.test_times++;
	  
	  sprintf(buf,"%d",lenth+1);
	  _ListBox[0]= buf;
	  LISTVIEW_InsertRow(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT),0,_ListBox);
	
	  if(disp_muit)
	  	{
	  	if(!exist[lenth])
	  		{
		_ahData[lenth] = GRAPH_DATA_YT_Create(_aColor[lenth%3], 500, 0, 0);//YT
	 
     	GRAPH_AttachData(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _ahData[lenth]);//attaches  data object to graph object
     	exist[lenth] = 1;
		
			if(lenth == 0)
			{
			GRAPH_SetUserDraw(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _UserDraw); /* Enable user draw */	
    		GRAPH_SetGridVis(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 6);
			GRAPH_SetVSizeY(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 1000);
    		_hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 10);
    		GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
    		GRAPH_AttachScale(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _hScaleV);
			}

	    }
	  }
      
	  BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_CR),"正转");
	  button_cr_state = 1;

	  pars.dir = 1;
	  
	  start_test_init();
	  	}
	}
}
/*********************************************************************
*
*       _cbCallbackWidgets
*
* Purpose:
*   Initializes the widgets of the main dialog box
*/
static void _cbCallbackWidgets(WM_MESSAGE * pMsg) {
  GRAPH_SCALE_Handle hScaleH, hScaleV;
  int i;
  WM_HWIN hDlg, hMenu;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      /* Get handles of widgets */
      for (i = 0; i < NUM_WIDGETS; i++) {
        _ahWin[i] = WM_GetDialogItem(hDlg, _aID[i]);
      }
      /* Init dropdown widget */
      for (i = 0; i < 8; i++) {
        char acBuffer[] = {"Item x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        DROPDOWN_AddString(_ahWin[DROPDOWN0], acBuffer);
      }
      /* Init edit widget */
      EDIT_SetText(_ahWin[EDIT0], "Edit");
      /* Init listbox widget */
      LISTBOX_SetAutoScrollV(_ahWin[LISTBOX0], 1);
      for (i = 0; i < 4; i++) {
        char acBuffer[] = {"Item x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        LISTBOX_AddString(_ahWin[LISTBOX0], acBuffer);
      }
      /* Init listview widget */
      for (i = 0; i < 2; i++) {
        char acBuffer[] = {"Col. x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        LISTVIEW_AddColumn(_ahWin[LISTVIEW0], 60, acBuffer, GUI_TA_CENTER);
      }
      for (i = 0; i < 9; i++) {
        int j;
        LISTVIEW_AddRow(_ahWin[LISTVIEW0], NULL);
        for (j = 0; j < (int)LISTVIEW_GetNumColumns(_ahWin[LISTVIEW0]); j++) {
          char acBuffer[] = {"Rx/Cx"};
          acBuffer[1] = '1' + i;
          acBuffer[4] = '1' + j;
          LISTVIEW_SetItemText(_ahWin[LISTVIEW0], j, i, acBuffer);
        }
      }
      LISTVIEW_SetGridVis(_ahWin[LISTVIEW0], 1);
      SCROLLBAR_CreateAttached(_ahWin[LISTVIEW0], SCROLLBAR_CF_VERTICAL);
      /* Init multiedit widget */
      MULTIEDIT_SetText(_ahWin[MULTIEDIT0], "This text could be modified by the MULTIEDIT widget");
      MULTIEDIT_SetWrapWord(_ahWin[MULTIEDIT0]);
      MULTIEDIT_SetAutoScrollV(_ahWin[MULTIEDIT0], 1);
      /* Init progbar widget */
      WIDGET_SetEffect(_ahWin[PROGBAR0], &WIDGET_Effect_3D);
      /* Init graph widget */
      for (i = 0; i < GUI_COUNTOF(_aColor); i++) {
        _aValue[i] = rand() % 95;
        _ahData[i] = GRAPH_DATA_YT_Create(_aColor[i], 500, 0, 0);
        GRAPH_AttachData(_ahWin[GRAPH0], _ahData[i]);
      }
      GRAPH_SetGridDistY(_ahWin[GRAPH0], 25);
      GRAPH_SetGridVis(_ahWin[GRAPH0], 1);
      GRAPH_SetGridFixedX(_ahWin[GRAPH0], 1);
      GRAPH_SetBorder(_ahWin[GRAPH0], 20, 4, 5, 4);
      /* Create and add vertical scale of graph widget */
      hScaleV = GRAPH_SCALE_Create(18, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
      GRAPH_SCALE_SetTextColor(hScaleV, GUI_RED);
      GRAPH_AttachScale(_ahWin[GRAPH0], hScaleV);
      /* Create and add horizontal scale of graph widget */
      hScaleH = GRAPH_SCALE_Create(46, GUI_TA_HCENTER | GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
      GRAPH_SCALE_SetTextColor(hScaleH, GUI_DARKGREEN);
      GRAPH_AttachScale(_ahWin[GRAPH0], hScaleH);
      /* Init multipage widget */
      MULTIPAGE_AddPage(_ahWin[MULTIPAGE0],
                        GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbDialogPage, WM_UNATTACHED, 0, 0), 
                        "Page 1");
      MULTIPAGE_AddPage(_ahWin[MULTIPAGE0],
                        GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), &_cbDialogPage, WM_UNATTACHED, 0, 0), 
                        "Page 2");
      /* Create and attach menu */
      hMenu = _CreateMenu(hDlg);/**/
      break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Example #13
0
static void _cbDialog(WM_MESSAGE * pMsg)
{
    WM_HWIN hItem;
    int     NCode;
    int     Id;
    char * buffer = rt_malloc(64);
    static GRAPH_DATA_Handle  _ahData[4]; 
    rt_uint8_t major, minor;
    rt_uint32_t  total, used, max_used;
    switch (pMsg->MsgId)
    {
        case WM_TIMER:
            cpu_usage_get(&major, &minor);
            rt_memory_info(&total, &used, &max_used);
            
            sprintf(buffer, "CPU :%d.%2d%%", major, minor);
            TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), buffer);
            PROGBAR_SetValue(WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_0), major);
        
            sprintf(buffer, "Used mem:%d%%", used*100/total);
            TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_1), buffer);
            PROGBAR_SetValue(WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_1), used*100/total);

            GRAPH_DATA_YT_AddValue(_ahData[0], major);
            GRAPH_DATA_YT_AddValue(_ahData[1], used*100/total);
        
            rt_device_t dev;
            enet_phy_data phy_data;
            dev = rt_device_find("e0");
            if(dev)
            {
                dev->control(dev, NIOCTL_GET_PHY_DATA, &phy_data);
                GRAPH_DATA_YT_AddValue(_ahData[2], phy_data.tx_fcnt);
                GRAPH_DATA_YT_AddValue(_ahData[3], phy_data.rx_fcnt);
            }
            WM_RestartTimer(pMsg->Data.v, 20);
            break;
        case WM_INIT_DIALOG:
            WM_CreateTimer(WM_GetClientWindow(pMsg->hWin), 0, 300, 0);
        
            hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_0);
            PROGBAR_SetBarColor(hItem, 1, GUI_GREEN);
            PROGBAR_SetBarColor(hItem, 0, GUI_RED);
        
            hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_1);
            PROGBAR_SetBarColor(hItem, 1, GUI_GREEN);
            PROGBAR_SetBarColor(hItem, 0, GUI_RED);
        
            // GRAPH
            _ahData[0] = GRAPH_DATA_YT_Create(GUI_DARKGREEN, 500, 0, 0);
            _ahData[1] = GRAPH_DATA_YT_Create(GUI_BLUE, 500, 0, 0);
            _ahData[2] = GRAPH_DATA_YT_Create(GUI_YELLOW, 500, 0, 0);
            _ahData[3] = GRAPH_DATA_YT_Create(GUI_BROWN, 500, 0, 0);
        
            WM_HWIN hGRAPH[4];
            int i;  
            hGRAPH[0] = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
            hGRAPH[1] = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_1);
            hGRAPH[2] = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_2);
            hGRAPH[3] = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_3);
            for(i=0;i<GUI_COUNTOF(hGRAPH);i++)
            {
                GRAPH_SetBorder(hGRAPH[i], 1, 1, 1, 1);
                GRAPH_SetGridVis(hGRAPH[i], 1);
                GRAPH_SetGridDistX(hGRAPH[i], 10);
                GRAPH_SetGridDistY(hGRAPH[i], 10); 
                GRAPH_AttachData(hGRAPH[i], _ahData[i]);                
            }
        break;
        default:
            WM_DefaultProc(pMsg);
        break;
    }
    rt_free(buffer);
}