OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2666|回复: 2

实正是没办法了,关于emwin中GRAPH_DATA_YT_SetAlign设置RIGHT或LEFT结果奇怪的问题

[复制链接]

1

主题

2

帖子

0

精华

新手入门

积分
12
金钱
12
注册时间
2017-6-12
在线时间
3 小时
发表于 2017-6-12 08:20:01 | 显示全部楼层 |阅读模式
1金钱
我用原子哥的基础不带UCOS的例程写了一个显示曲线的程序,在调用GRAPH_DATA_YT_SetAlign后如果设置成RIGHT的话曲线刷新很慢,但如果设置成LEFT的话,曲线刷新变快,
如果数据达到GRAPH_DATA_YT_Create中设置MaxNumItems的最大的时候,刷新也会变慢

这是曲线的程序


#include <stdlib.h>
#include <string.h>

#include "DIALOG.h"
#include "GRAPH.h"
#include "adc.h"
#include "led.h"









static GRAPH_SCALE_Handle _hScaleV;   // Handle of vertical scale
static GRAPH_SCALE_Handle _hScaleH; // Handle of horizontal scale


GRAPH_DATA_Handle ahdata;

static int _Stop = 1;

static GUI_COLOR _aColor[] = {GUI_RED, GUI_GREEN, GUI_LIGHTBLUE}; // Array of colors for the GRAPH_DATA objects

//
// Dialog ressource
//
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    { FRAMEWIN_CreateIndirect, "Graph widget demo",  0                ,   0,   0, 800, 480, FRAMEWIN_CF_MOVEABLE },
    { GRAPH_CreateIndirect,     0,                   GUI_ID_GRAPH0    ,   12,   10, 700, 430 },

    /**********************BUTTON---STOP***************/
    { BUTTON_CreateIndirect, "START",                GUI_ID_BUTTON2, 722, 50, 65, 50, 0, 0x0, 0 },
    { BUTTON_CreateIndirect, "STOP",                 GUI_ID_BUTTON1, 722, 150,  65, 50, 0, 0x0, 0 },
    { BUTTON_CreateIndirect, "Screen",            GUI_ID_BUTTON0   , 722, 250,   65, 50 },
    /******????******************************/

    { BUTTON_CreateIndirect, 0,            GUI_ID_BUTTON3   , 50,440,  52,  20 },
    { BUTTON_CreateIndirect, 0,            GUI_ID_BUTTON4   , 170, 440,  52,  20 },
    { BUTTON_CreateIndirect, 0,            GUI_ID_BUTTON5   , 290, 440,  52,  20 },
    { BUTTON_CreateIndirect, 0,            GUI_ID_BUTTON6  , 410, 440,  52,  20 },
    { BUTTON_CreateIndirect, 0,            GUI_ID_BUTTON7   , 530, 440,  52,  20 },
    { BUTTON_CreateIndirect, 0,            GUI_ID_BUTTON8   , 650, 440,  52,  20 },


    /*******GUON ??****************/
    { CHECKBOX_CreateIndirect,  0,          GUI_ID_CHECK6 , 725, 350,  300, 0 ,0,0},

};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/
/*********************************************************************
*
*       _AddValues
*
* Function description
*   This routine calculates new random values in dependence of the previous added values
*   and adds them to the GRAPH_DATA objects
*/


/*********************************************************************
*
*       _UserDraw
*
* Function description
*   This routine is called by the GRAPH object before anything is drawn
*   and after the last drawing operation.
*/


/*********************************************************************
*
*       _ForEach
*
* Function description
*   This routine hides/shows all windows except the button, graph and scroll bar widgets
*/
static void _ForEach(WM_HWIN hWin, void * pData) {
  int Id;
  int FullScreenMode;

  FullScreenMode = *(int *)pData;
  Id = WM_GetId(hWin);
  if ((Id == GUI_ID_GRAPH0) || (Id == GUI_ID_BUTTON0) || (Id == GUI_ID_VSCROLL) || (Id == GUI_ID_HSCROLL)) {
    return;
  }
  if (FullScreenMode) {
    WM_HideWindow(hWin);
  } else {
    WM_ShowWindow(hWin);
  }
}

/*********************************************************************
*
*       _ToggleFullScreenMode
*
* Function description
*   This routine switches between full screen mode and normal mode by hiding or showing the
*   widgets of the dialog, enlarging/shrinking the graph widget and modifying some other
*   attributes of the dialog widgets.
*/
static void _ToggleFullScreenMode(WM_HWIN hDlg) {
  static int FullScreenMode;
  static GUI_RECT Rect;
  static unsigned ScalePos;
  WM_HWIN hGraph;
  WM_HWIN hButton;
  WM_HWIN hClient;
  GUI_RECT RectInside;
  int xPos, yPos;

  hGraph  = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
  hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
  FullScreenMode ^= 1;
  if (FullScreenMode) {
    //
    // Enter the full screen mode
    //
    hClient = WM_GetClientWindow(hDlg);
    BUTTON_SetText(hButton, "Back");
    WM_MoveWindow(hButton, 0, 11);
    FRAMEWIN_SetTitleVis(hDlg, 0);
    WM_GetInsideRectEx(hClient, &RectInside);
    WM_GetWindowRectEx(hGraph, &Rect);
    WM_ForEachDesc(hClient, _ForEach, &FullScreenMode); // Hide all descendants
    xPos = WM_GetWindowOrgX(hClient);
    yPos = WM_GetWindowOrgY(hClient);
    WM_SetWindowPos(hGraph, xPos, yPos, RectInside.x1, RectInside.y1);
    ScalePos = GRAPH_SCALE_SetPos(_hScaleH, RectInside.y1 - 20);
  } else {
    //
    // Return to normal mode
    //
    BUTTON_SetText(hButton, "Screen");
    WM_MoveWindow(hButton, 0, -11);
    WM_ForEachDesc(WM_GetClientWindow(hDlg), _ForEach, &FullScreenMode); // Show all descendants
    WM_SetWindowPos(hGraph, Rect.x0, Rect.y0, Rect.x1 - Rect.x0 + 1, Rect.y1 - Rect.y0 + 1);
    FRAMEWIN_SetTitleVis(hDlg, 1);
    GRAPH_SCALE_SetPos(_hScaleH, ScalePos);

  }
}

/*********************************************************************
*
*       _cbCallback
*
* Function description
*   Callback function of the dialog
*/
static void _cbCallback(WM_MESSAGE * pMsg) {

  int      NCode;
  int      Id;

  WM_HWIN  hDlg;
  WM_HWIN  hItem;

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

    GRAPH_SetGridDistY(hItem, 25);
    GRAPH_SetGridVis(hItem, 1);
    GRAPH_SetGridFixedX(hItem, 1);
    //
    // Create and add vertical scale
    //
    _hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
    GRAPH_AttachScale(hItem, _hScaleV);
    //
    // Create and add horizontal scale
    //
    _hScaleH = GRAPH_SCALE_Create(400, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
    GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
    GRAPH_AttachScale(hItem, _hScaleH);
       
         
  ahdata=GRAPH_DATA_YT_Create(GUI_RED,1000,0,0);
        GRAPH_AttachData(hItem, ahdata);
       
        GRAPH_DATA_YT_MirrorX(ahdata, 1);
         GRAPH_DATA_YT_SetAlign(ahdata, GRAPH_ALIGN_LEFT);
        GRAPH_SetVSizeX(hItem, 1000);

       
       



   hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK6);
    CHECKBOX_SetText(hItem, "HScroll");
    CHECKBOX_SetState(hItem, 1);





// hObj =   BUTTON_Create(725,370,  52,  20 ,GUI_ID_BUTTON3 ,WM_CF_SHOW);



  hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON3);
  BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
  BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_RED);
  BUTTON_SetText(hItem, "LED1");

  hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON4);
  BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
  BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_RED);
  BUTTON_SetText(hItem, "LED1");

  hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON5);
  BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
  BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_RED);
  BUTTON_SetText(hItem, "LED1");

  hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON6);
  BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
  BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_RED);
  BUTTON_SetText(hItem, "LED1");

  hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON7);
  BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
  BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_RED);
  BUTTON_SetText(hItem, "LED1");

  hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON8);
  BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
  BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_RED);
  BUTTON_SetText(hItem, "LED1");






// BUTTON_SetBkColor(hObj, BUTTON_CI_UNPRESSED,GUI_RED);




/************GUI_RECT rClient;
GUI_GetClientRect(&rClient);
GUI_DispStringInRect("Text", &rClient, GUI_TA_HCENTER | GUI_TA_VCENTER);*/




    break;
    /************************************************************************/
    /************************************************************************
    ***********************************************************************/
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);      // Id of widget
    NCode = pMsg->Data.v;



/***************************************BUTTON********************************/
/***************************************BUTTON********************************/
/***************************************BUTTON********************************/
/***************************************BUTTON********************************/
/***************************************BUTTON********************************/

    switch(Id)
    {
    case GUI_ID_BUTTON1: // Notifications sent by 'Button'
      switch(NCode)
      {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
                         _Stop = 1;
        break;
     }
         break;
    case GUI_ID_BUTTON2: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:

        break;
      case WM_NOTIFICATION_RELEASED:
                         _Stop = 0;
        break;
                 }
         break;
      }

/***************************************BUTTON----OVER********************************/
/***************************************BUTTON----OVER********************************/
/***************************************BUTTON----OVER********************************/
/***************************************BUTTON----OVER********************************/
/***************************************BUTTON----OVER********************************/


    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_CHECK6:

        hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
        if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK6))) {
          GRAPH_SetVSizeX(hItem, 2500);
        } else {
          GRAPH_SetVSizeX(hItem, 0);
        }
        break;
        }
        break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
//u16 i;
//u16 adcx;
//float temp;

//void disp()
//{

//    adcx=Get_Adc_Average(ADC_Channel_1,2);
//                temp=(float)adcx*(3.3/4096);
//                adcx=temp*100;
//               
//       
//    GRAPH_DATA_YT_AddValue(ahdata,adcx);
//       
//}

extern u16 flag;
u16 ss;
void inTask(void) {
  WM_HWIN hDlg;
  WM_HWIN hGraph;

  hGraph = 0;
        LED1 = 0;
  GUI_Init();
// GUI_CURSOR_Show();
  WM_SetDesktopColor(GUI_GRAY);
  #if GUI_SUPPORT_MEMDEV
    WM_SetCreateFlags(WM_CF_MEMDEV);
  #endif
  hDlg = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbCallback, 0, 0, 0);
  LED1 = ~LED1;
  while (1) {
       
                GRAPH_DATA_YT_AddValue(ahdata,flag);
               
                LED1 = ~LED1;
                       
//   
     GUI_Delay(1);
     LED0 = ~LED0;
               
               
//   
//    if (!_Stop) {
//      if (!hGraph) {
       // hGraph = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
//      }
//    }
//    GUI_Exec();
               
               
// disp();
               
               

  }
}

/*************************** End of file ****************************/








这是定时器读取AD的值的程序
void TIM4_Int_Init(u16 arr,u16 psc)
{
        TIM_TimeBaseInitTypeDef        TIM_TimeBaseInitStructure;
        NVIC_InitTypeDef NVIC_InitStructure;
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4,ENABLE);//&#191;a&#198;&#244;TIM3ê±&#214;ó

        TIM_TimeBaseInitStructure.TIM_Prescaler=psc;   //·&#214;&#198;μ&#214;μ
        TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up;           //&#188;&#198;êy&#196;£ê&#189;
        TIM_TimeBaseInitStructure.TIM_Period=arr;                   //×&#212;&#182;ˉ&#214;&#216;×°êy&#214;μ
        TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;  //éè&#214;&#195;ê±&#214;ó·&#214;&#184;&#238;
        TIM_TimeBaseInit(TIM4,&TIM_TimeBaseInitStructure);
        TIM_ITConfig(TIM4,TIM_IT_Update,ENABLE);//&#212;êDí&#184;üD&#194;&#214;D&#182;&#207;

        NVIC_InitStructure.NVIC_IRQChannel=TIM4_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority=3;
        NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        TIM_Cmd(TIM4,ENABLE);                  //ê1&#196;üTIM3
}



u16 i;
u16 adcx;
float temp;
u16  flag;
u8 a;

void TIM4_IRQHandler(void)
{
        if(TIM_GetITStatus(TIM4,TIM_IT_Update)!=RESET)
        {       
          adcx=Get_Adc_Average(ADC_Channel_1,2);
                temp=(float)adcx*(3.3/4096);
                flag=temp*100;
               
   // GRAPH_DATA_YT_AddValue(ahdata,adcx);
               
//        if(a)
//                flag--;
//        else
//                flag++;
//  if(flag >= 450)
//                 a = 1;
//         if(flag <= 1)
//                 a = 0;
        }
        TIM_ClearITPendingBit(TIM4,TIM_IT_Update);
}





各位大神们帮我看看吧,这个程序搞了一个多星期了,最后卡到这里来了
实正是没办法了

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165309
金钱
165309
注册时间
2010-12-1
在线时间
2108 小时
发表于 2017-6-12 21:04:25 | 显示全部楼层
回复

使用道具 举报

1

主题

9

帖子

0

精华

初级会员

Rank: 2

积分
148
金钱
148
注册时间
2016-9-27
在线时间
22 小时
发表于 2017-6-13 21:25:51 | 显示全部楼层
ahdata=GRAPH_DATA_YT_Create(GUI_RED,1000,0,0);
        
        
        GRAPH_DATA_YT_MirrorX(ahdata, 1);
         GRAPH_DATA_YT_SetAlign(ahdata, GRAPH_ALIGN_LEFT);

GRAPH_AttachData(hItem, ahdata);//将数据对象附加到现有图形小工具

        GRAPH_SetVSizeX(hItem, 1000);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-11-23 07:12

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表