Ejemplo n.º 1
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]);
}
Ejemplo n.º 2
0
static void _Graph_Sensor_Demo()
{
  const WIDGET_EFFECT * pEffectOld;
  GRAPH_Handle          hGraph;
  GRAPH_DATA_Handle     hData[3];
  // GRAPH_DATA_Handle     hData;
  int                   xSize, ySize, i;
  int                   Graph_xSize, Graph_ySize, Data_ySize;
  int                   Graph_xPos, Graph_yPos;

  // set back screen black
  // GUI_SetColor(GUI_BLACK);
  // GUIDEMO_DrawBk(1);

  xSize      = LCD_GetXSize();
  ySize      = LCD_GetYSize();  // 256
  pEffectOld = WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple);
  // Return a poninter to the previous callback routine
  // Set Callback function for background window
  // The given window will be invalidated. This makes sure the window will be redrawn
  WM_SetCallback(WM_HBKWIN, _cbBk_test);
  //
  // Determine size of GRAPH
  //
  Graph_xSize = xSize - (DIST_TO_BORDER << 1);            // xsize = Screen size subtracting twice the distance to the border of the screen
  Graph_ySize = ySize - INFO_SIZE_Y - (DIST_TO_WIN << 1); // ysize = Screen size subtracting the window sizes and twice the distance to the windows
  if (Graph_ySize > MAX_GRAPH_SIZE_Y) {  // 181
    Graph_ySize = MAX_GRAPH_SIZE_Y;  // 140
    if (Graph_xSize > (Graph_ySize * 20) / 11) {
      Graph_xSize = (Graph_ySize * 20) / 11;
    }
  }
  //
  // Create and configure GRAPH_WIDGET
  //
  Graph_xPos = (xSize - Graph_xSize) >> 1;
  Graph_yPos = (ySize - Graph_ySize) >> 1;
  if (Graph_yPos < INFO_SIZE_Y + DIST_TO_WIN) {
    Graph_yPos = INFO_SIZE_Y + DIST_TO_WIN;
  }
  // create a graph widget
  hGraph = GRAPH_CreateEx(Graph_xPos, Graph_yPos, Graph_xSize, Graph_ySize, WM_HBKWIN, WM_CF_SHOW | WM_CF_CONST_OUTLINE, 0, 0);
  GRAPH_SetBorder(hGraph, BORDER_LEFT, BORDER_TOP, BORDER_RIGHT, BORDER_BOTTOM);  // set width of border
  WM_SetHasTrans (hGraph);  // enbale tansparency for the given window
  GRAPH_SetColor (hGraph, COLOR_BK,     GRAPH_CI_BK);  // Sets the desired color of the given GRAPH widget
  GRAPH_SetColor (hGraph, COLOR_BORDER, GRAPH_CI_BORDER);
  GRAPH_SetColor (hGraph, COLOR_FRAME,  GRAPH_CI_FRAME);
  GRAPH_SetColor (hGraph, COLOR_GRID,   GRAPH_CI_GRID);
  //
  // Adjust grid
  //
  GRAPH_SetGridVis  (hGraph, 1);  // set grid visible
  GRAPH_SetGridDistX(hGraph, GRID_DIST_X);  // set horizontal grid spacing
  GRAPH_SetGridDistY(hGraph, GRID_DIST_Y);  // set vertical grid spacing
  WM_BringToBottom  (hGraph);  // Places hGraph underneath its siblings
  //
  // Create and configure GRAPH_DATA_YT object
  //

  for (i = 0; i < 3; i++) {
    // Create a point valude which include a X-axis value on the Y-axis
    hData[i] = GRAPH_DATA_YT_Create(_aColorData_sensor[i], xSize - (DIST_TO_BORDER << 1) - BORDER_LEFT, 0, 0);
  }

  // hData = GRAPH_DATA_YT_Create(_aColorData_sensor[0], xSize - (DIST_TO_BORDER << 1) - BORDER_LEFT, 0, 0);
  Data_ySize = Graph_ySize - BORDER_BOTTOM;  // 131
  //
  // Create and configure GRAPH_SCALE objects
  //
  _hScaleH_sensor = GRAPH_SCALE_Create(BORDER_BOTTOM >> 1, GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, TICK_DIST_H);
  _hScaleV_sensor = GRAPH_SCALE_Create(BORDER_LEFT   >> 1, GUI_TA_HCENTER, GRAPH_SCALE_CF_VERTICAL,   TICK_DIST_V);
  GRAPH_SCALE_SetPos(_hScaleH_sensor, Graph_ySize - 4);  // Sets the vertical position for showing the scale object with in the GRAPH widget
  GRAPH_SCALE_SetOff(_hScaleH_sensor, -5);  // Sets an horizontal offset used to 'shift' the scale object in positive or negative direction

  // show sensor graph
  GUIDEMO_ShowInfo("sensor demo");
  GRAPH_AttachScale(hGraph, _hScaleH_sensor);
  GRAPH_AttachScale(hGraph, _hScaleV_sensor);
  // _Data_Sensor_Adjust = (Data_ySize * 100) >> GRAPH_DIV;
  // (Data_ySize * 21) >> GRAPH_DIV
  GRAPH_SetGridOffY (hGraph, 6);  // Add an offset used to show the horizontal grid lines
  // (((Data_ySize - BORDER_BOTTOM) * 260) >> GRAPH_DIV)
  GRAPH_SCALE_SetOff(_hScaleV_sensor, 75);

  _Show_Sensor_Graph(hGraph, hData);

  //
  // Clean up
  //
  GRAPH_DetachScale(hGraph, _hScaleH_sensor);
  GRAPH_DetachScale(hGraph, _hScaleV_sensor);
  GRAPH_SCALE_Delete(_hScaleH_sensor);
  GRAPH_SCALE_Delete(_hScaleV_sensor);

  for (i = 0; i < 3; i++) {
    GRAPH_DATA_YT_Delete(hData[i]);
  }
  // GRAPH_DATA_YT_Delete(hData);
  WM_DeleteWindow(hGraph);
  WIDGET_SetDefaultEffect(pEffectOld);

}
Ejemplo n.º 3
0
/*********************************************************************
*
*       _GraphDemo
*/
static void _GraphDemo(void) {
  const WIDGET_EFFECT * pEffectOld;
  GRAPH_DATA_Handle     hData[MAX_NUM_DATA_OBJ];
  GRAPH_Handle          hGraph;
  unsigned              i;
  int                   Graph_xSize;
  int                   Graph_ySize;
  int                   Graph_xPos;
  int                   Graph_yPos;
  int                   Data_ySize;
  int                   xSize;
  int                   ySize;

  xSize      = LCD_GetXSize();
  ySize      = LCD_GetYSize();
  pEffectOld = WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple);
  //
  // Set Callback function for background window
  //
  WM_SetCallback(WM_HBKWIN, _cbBk);
  //
  // Determine size of GRAPH
  //
  Graph_xSize = xSize - (DIST_TO_BORDER << 1);            // xsize = Screen size subtracting twice the distance to the border of the screen
  Graph_ySize = ySize - INFO_SIZE_Y - (DIST_TO_WIN << 1); // ysize = Screen size subtracting the window sizes and twice the distance to the windows
  if (Graph_ySize > MAX_GRAPH_SIZE_Y) {
    Graph_ySize = MAX_GRAPH_SIZE_Y;
    if (Graph_xSize > (Graph_ySize * 20) / 11) {
      Graph_xSize = (Graph_ySize * 20) / 11;
    }
  }
  //
  // Create and configure GRAPH_WIDGET
  //
  Graph_xPos = (xSize - Graph_xSize) / 2;
  Graph_yPos = (ySize - Graph_ySize) / 2;
  if (Graph_yPos < INFO_SIZE_Y + DIST_TO_WIN) {
    Graph_yPos = INFO_SIZE_Y + DIST_TO_WIN;
  }
  hGraph = GRAPH_CreateEx(Graph_xPos, Graph_yPos, Graph_xSize, Graph_ySize, WM_HBKWIN, WM_CF_SHOW | WM_CF_CONST_OUTLINE, 0, 0);
  GRAPH_SetBorder(hGraph, BORDER_LEFT, BORDER_TOP, BORDER_RIGHT, BORDER_BOTTOM);
  WM_SetHasTrans (hGraph);
  GRAPH_SetColor (hGraph, COLOR_BK,     GRAPH_CI_BK);
  GRAPH_SetColor (hGraph, COLOR_BORDER, GRAPH_CI_BORDER);
  GRAPH_SetColor (hGraph, COLOR_FRAME,  GRAPH_CI_FRAME);
  GRAPH_SetColor (hGraph, COLOR_GRID,   GRAPH_CI_GRID);
  //
  // Adjust grid
  //
  GRAPH_SetGridVis  (hGraph, 1);
  GRAPH_SetGridDistX(hGraph, GRID_DIST_X);
  GRAPH_SetGridDistY(hGraph, GRID_DIST_Y);
  WM_BringToBottom  (hGraph);
  //
  // Create and configure GRAPH_DATA_YT object
  //
  for (i = 0; i < MAX_NUM_DATA_OBJ; i++) {
    hData[i] = GRAPH_DATA_YT_Create(_aColorData[i], xSize - (DIST_TO_BORDER << 1) - BORDER_LEFT, 0, 0);
  }
  Data_ySize = Graph_ySize - BORDER_BOTTOM;
  //
  // Create and configure GRAPH_SCALE objects
  //
  _hScaleH = GRAPH_SCALE_Create(BORDER_BOTTOM >> 1, GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, TICK_DIST_H);
  _hScaleV = GRAPH_SCALE_Create(BORDER_LEFT   >> 1, GUI_TA_HCENTER, GRAPH_SCALE_CF_VERTICAL,   TICK_DIST_V);
  GRAPH_AttachScale(hGraph, _hScaleH);
  GRAPH_AttachScale(hGraph, _hScaleV);
  GRAPH_SCALE_SetPos(_hScaleH, Graph_ySize - SCALE_H_HEIGHT);
  GRAPH_SCALE_SetOff(_hScaleH, -5);
  //
  // Show some graphs
  //
  for (i = 0; i < GUI_COUNTOF(_aWave); i++) {
    GUIDEMO_ShowInfo(_aWave[i].pName);
    _DataAdjust = GUIDEMO_ShiftRight(Data_ySize * _aWave[i].DataVOff, GRAPH_DIV);
    GRAPH_SetGridOffY (hGraph, GUIDEMO_ShiftRight(Data_ySize * _aWave[i].GridVOff, GRAPH_DIV));
    GRAPH_SCALE_SetOff(_hScaleV, GUIDEMO_ShiftRight((Data_ySize - BORDER_BOTTOM) * _aWave[i].ScaleVOff, GRAPH_DIV));
    _ShowGraph(hGraph, hData, _aWave[i].NumWaves, _aWave[i].pfAddData);
  }
  //
  // Clean up
  //
  GRAPH_DetachScale(hGraph, _hScaleH);
  GRAPH_DetachScale(hGraph, _hScaleV);
  GRAPH_SCALE_Delete(_hScaleH);
  GRAPH_SCALE_Delete(_hScaleV);
  for (i = 0; i < MAX_NUM_DATA_OBJ; i++) {
    GRAPH_DATA_YT_Delete(hData[i]);
  }
  WM_DeleteWindow(hGraph);
  WIDGET_SetDefaultEffect(pEffectOld);
}