/*********************************************************************
*
*       _cbBkWin
*/
static void _cbBkWin(WM_MESSAGE* pMsg) {
  switch(pMsg->MsgId) {
  case WM_PAINT:
    GUI_SetBkColor(GUI_BLACK);
    GUI_Clear();
    GUI_SetColor(0x0060FF);
    GUI_DispStringAt("PaintCount (Early):", 0, 0);
    GUI_DispDecAt(_PaintCount1, 120, 0, 5);
    GUI_SetColor(0x00FFC0);
    GUI_DispStringAt("PaintCount (Late):", 0, 12);
    GUI_DispDecAt(_PaintCount2, 120, 12, 5);
    break;
  case WM_NOTIFY_PARENT:
    if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
      if (pMsg->hWinSrc == _hBut1) {
        WM_InvalidateWindow(_hWin1);
        WM_InvalidateWindow(_hWin2);
      } else if (pMsg->hWinSrc == _hBut2) {
        _PaintCount1 = 0;
        _PaintCount2 = 0;
        WM_InvalidateWindow(pMsg->hWin);
      }
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
Пример #2
0
void TIM4_IRQHandler(void)
{
  RCC_ClocksTypeDef RCC_Clocks;
  RCC_GetClocksFreq(&RCC_Clocks);

  /* Clear TIM4 Capture compare interrupt pending bit */
  TIM_ClearITPendingBit(TIM4, TIM_IT_CC2);

  /* Get the Input Capture value */
  IC2Value = TIM_GetCapture2(TIM4);
	IC1Value = TIM_GetCapture1(TIM4);
  if (IC2Value != 0)
  {
        /* Duty cycle computation */
        DutyCycle = (IC1Value* 100+1 ) / IC2Value;//

        /* Frequency computation 
           TIM4 counter clock = (RCC_Clocks.HCLK_Frequency)/2 */

        Frequency = (1780000)/2 / IC2Value;//RCC_Clocks.HCLK_Frequency
     
	   GUI_DispDecAt(Frequency,0,0,6);
	   GUI_DispDecAt(DutyCycle,40,0,3);
  }
  else
  {
        DutyCycle = 0;
        Frequency = 0;
  }
//  Stop_Tim4IT();
}
/*******************************************************************
*
*       _Label

  Labels the x & y-axis
*/
static void _Label(void) {
  int x, y;
  GUI_SetBkColor(GUI_RED);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("MEMDEV_DrawGraph - Sample", 160, 5);
  GUI_SetPenSize(1);
  GUI_ClearRect(0, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 1));
  GUI_DrawRect(18, (LCD_YSIZE - 21) - YSIZE, (LCD_XSIZE - 1), (LCD_YSIZE - 20));
  GUI_SetFont(&GUI_Font6x8);
  for (x = 0; x < (LCD_XSIZE - 20); x += 40) {
    int xPos = x + 18;
    GUI_DrawVLine(xPos, (LCD_YSIZE - 20), (LCD_YSIZE - 14));
    GUI_DispDecAt(x / 40, xPos - 2, (LCD_YSIZE - 9), 1);
  }
  for (y = 0; y < YSIZE / 2; y += 20) {
    int yPos = (LCD_YSIZE - 20) - YSIZE / 2 + y;
    GUI_DrawHLine(yPos, 13, 18);
    if (y) {
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(-y / 20, 2);
      yPos = (LCD_YSIZE - 20) - YSIZE / 2 - y;
      GUI_DrawHLine(yPos, 13, 18);
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(y / 20, 2);
    } else {
      GUI_DispCharAt('0', 7, yPos - 4);
    }
  }
}
Пример #4
0
static void _Label(void) {
  int x, y;
  GUI_SetPenSize(1);
  GUI_ClearRect(0, (LCD_GetYSize() - 21) - _YSize, (LCD_GetXSize() - 1), (LCD_GetYSize() - 1));
  GUI_DrawRect(18, (LCD_GetYSize() - 21) - _YSize, (LCD_GetXSize() - 1), (LCD_GetYSize() - 20));
  GUI_SetFont(&GUI_Font6x8);
  for (x = 0; x < (LCD_GetXSize() - 20); x += 40) {
    int xPos = x + 18;
    GUI_DrawVLine(xPos, (LCD_GetYSize() - 20), (LCD_GetYSize() - 14));
    GUI_DispDecAt(x / 40, xPos - 2, (LCD_GetYSize() - 9), 1);
  }
  for (y = 0; y < _YSize / 2; y += 20) {
    int yPos = (LCD_GetYSize() - 20) - _YSize / 2 + y;
    GUI_DrawHLine(yPos, 13, 18);
    if (y) {
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(-y / 20, 2);
      yPos = (LCD_GetYSize() - 20) - _YSize / 2 - y;
      GUI_DrawHLine(yPos, 13, 18);
      GUI_GotoXY(1, yPos - 4);
      GUI_DispSDec(y / 20, 2);
    } else {
      GUI_DispCharAt('0', 7, yPos - 4);
    }
  }
}
Пример #5
0
/*********************************************************************
*
*       _LabelGraph
*/
static void _LabelGraph(void) {
  GUI_RECT Rect;
  int      x;
  int      y;
  int      xSize;
  int      ySize;

  WM_GetClientRect(&Rect);
  xSize = Rect.x1;
  ySize = Rect.y1;
  GUI_SetBkColor(_ColorBackGround);
  GUI_Clear();
  GUI_SetColor(_ColorLabel);
  GUI_SetPenSize(1);
  GUI_ClearRect(0, (ySize - 21) - ySize, (xSize - 1), (ySize - 1));
  GUI_DrawRect(25, 0, xSize, ySize - 20);
  GUI_SetFont(&GUI_Font6x8);
  for (x = 0; x < (xSize - 20); x += 40) {
    int xPos = x + 25;
    GUI_DrawVLine(xPos, (ySize - 20), (ySize - 14));
    GUI_DispDecAt(x / 40, xPos - 2, (ySize - 9), 1);
  }
  for (y = 0; y < ySize - 20; y += 20) {
    int yPos = ySize - 20 - y;
    GUI_DrawHLine(yPos, 20, 25);
    GUI_GotoXY(1, yPos - 4);
    GUI_DispDecSpace(_TempMin + y, 3);
  }
}
/*******************************************************************
*
*       MainTask
*/
void MainTask(void) {
  int xPos;
  int yPos;
  int xSize;
  int i;
  
  i = 0;
  GUI_Init();
  //
  // Check if recommended memory for the sample is available
  //
  if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
    GUI_ErrorOut("Not enough memory available."); 
    return;
  }
  xPos = LCD_GetXSize() / 2;
  yPos = LCD_GetYSize() / 3;
  GUI_SetTextMode(GUI_TM_REV);
  GUI_SetFont(GUI_FONT_20F_ASCII);
  GUI_DispStringHCenterAt("Hello world!", xPos, yPos);
  GUI_SetFont(GUI_FONT_D24X32);
  xSize = GUI_GetStringDistX("0000");
  xPos -= xSize / 2;
  yPos += 24 + 10;
  while (1) {
    GUI_DispDecAt( i++, xPos, yPos, 4);
    if (i > 9999) {
      i = 0;
    }
  }
}
Пример #7
0
void MainTask(void) {
  int i=0;
/*
 ToDo:  Make sure hardware is initilized first!!
*/
  GUI_Init();
  GUI_DispString("Hello world!");
  while(1) {
    GUI_DispDecAt( i++, 20,20,4);
    if (i>9999) i=0;
  }
}
Пример #8
0
int main(void)
{
    uint32_t i;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("flexbus lcd test\r\n");
    GUI_Init();
    GUI_DispString("ucGUI");
    GUI_DispString(GUI_GetVersionString());
    GUI_DispString("\r\nHello world!");
    while(1) 
    {
        GUI_DispDecAt( i++, 20,20,4);
        if (i>9999)
        {
            i=0;
        }
    }
}
Пример #9
0
/*******************************************************************
*
*       MainTask
*/
void MainTask(void) {
  int xPos, yPos, xSize;
  int i = 0;

  GUI_Init();
  xPos = LCD_GetXSize() / 2;
  yPos = LCD_GetYSize() / 3;
  GUI_SetTextMode(GUI_TM_REV);
  GUI_SetFont(GUI_FONT_20F_ASCII);
  GUI_DispStringHCenterAt("Hello world!", xPos, yPos);
  GUI_SetFont(GUI_FONT_D24X32);
  xSize = GUI_GetStringDistX("0000");
  xPos -= xSize / 2;
  yPos += 24 + 10;
  while (1) {
    GUI_DispDecAt( i++, xPos, yPos, 4);
    if (i > 9999) {
      i = 0;
    }
  }
}
Пример #10
0
/** Use emWin to prerender all the necessary numbers
  * from 00-59 to a separate buffer. This will later
  * be used to speed up the process of drawing them 
  * to the display */
static void prerenderNumbers(void)
{
  int i;
  
  /* Tell emWin to draw to the prerender number buffer */
  activateNumberBuffer();
  
  /* Change the width of the window to match the buffer size */
  setNumberBufferScreenSize();
  
  /* Drawing each number 8 px wide and 16 px high */
  GUI_SetFont(&GUI_Font8x16);
  
  /* Draw all the numbers to the buffer */
  for ( i=0; i<60; i++ ) {
    GUI_DispDecAt(i, i*16, 0, 2);
  }
  
  /* Set the display width back to normal */
  setFrameBufferScreenSize();
  
  /* Tell emWin to draw to the normal frame buffer */
  FB_activateFirstBuffer(); 
}
Пример #11
0
/**************************************************************************************
* FunctionName   : _FillCalendar()
* Description    : 日历填写
* EntryParameter : None
* ReturnValue    : None
**************************************************************************************/
void _FillCalendar(CLD_DAY *pDay, int year, U8 month, U8 day, U8 wekday)
{
	const U8 cstmonth[][4] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEQ", "OCT", "NOV", "DEC" };
	const U8 monthDay[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//非闰年
	const U8 monthDayLY[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//闰年
	int tmpWek;
	U8 i = 0;

	GUI_SetFont(&GUI_Font32_ASCII);
	GUI_SetColor(GUI_BLACK);                                      // 设置蓝色
	GUI_DispStringHCenterAt(cstmonth[month - 1], 120, 5);                      // 显示月份
	GUI_GotoXY(170, 5);
	GUI_DispDecSpace(year, 5); //显示年份 最大可显示9999
	tmpWek = wekday - (day % 7) + 1;                       // 获取本月第一天是星期几?
	if (tmpWek <= 0)
		tmpWek = 7 + wekday - (day % 7) + 1;

	for (i = 0; i < tmpWek; i++)        // 存储上月的
	{
		if (month == 1)
		{
			if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
				pDay[i].Date = monthDayLY[12 - 1] - tmpWek + i + 1;
			else pDay[i].Date = monthDay[12 - 1] - tmpWek + i + 1;
		}
		else
		{
			if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
				pDay[i].Date = monthDayLY[month - 2] - tmpWek + i + 1;
			else pDay[i].Date = monthDay[month - 2] - tmpWek + i + 1;
		}
		pDay[i].Color = GUI_GRAY;
	}

	if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
	{
		for (i = 0; i < monthDayLY[month - 1]; i++)
		{
			pDay[i + tmpWek].Date = i + 1;                               // 存储本月的
			pDay[i + tmpWek].Color = (day == i + 1) ? GUI_GREEN : GUI_BLACK;
		}
	}
	else
	{
		for (i = 0; i < monthDay[month - 1]; i++)
		{
			pDay[i + tmpWek].Date = i + 1;                               // 存储本月的
			pDay[i + tmpWek].Color = (day == i + 1) ? GUI_GREEN : GUI_BLACK;
		}
	}

	if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0)//闰年
	{
		for (i = 0; i < 42 - tmpWek - monthDayLY[month - 1]; i++)
		{
			if (month == 0x12)
			{
				pDay[i + tmpWek + monthDayLY[1 - 1]].Date = i + 1;
			}
			else
			{
				pDay[i + tmpWek + monthDayLY[month - 1]].Date = i + 1;    // 存储下月的
			}
			pDay[i + tmpWek + monthDayLY[month - 1]].Color = GUI_GRAY;
		}
	}
	else
	{
		for (i = 0; i < 42 - tmpWek - monthDay[month - 1]; i++)
		{
			if (month == 0x12)
			{
				pDay[i + tmpWek + monthDay[1 - 1]].Date = i + 1;
			}
			else
			{
				pDay[i + tmpWek + monthDay[month - 1]].Date = i + 1;    // 存储下月的
			}
			pDay[i + tmpWek + monthDay[month - 1]].Color = GUI_GRAY;
		}
	}

	for (i = 0; i < 42; i++)
	{
		GUI_SetFont(&GUI_Font24_ASCII);
		GUI_SetColor(pDay[i].Color);
		GUI_SetTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER);
		GUI_DispDecAt(pDay[i].Date, pDay[i].X, pDay[i].Y, ((pDay[i].Date > 10) ? 2 : 1));
	}
}
Пример #12
0
 /**********************************************************
  *                 _Paint
  *
  */
static void _Paint(SLIDER_Obj* pObj, WM_HWIN hObj)
{
   GUI_RECT r, rFocus, rSlider, rSlot;
   GUI_COLOR  SlotColor, SliderColor;
   int x0, xSize,  Range, NumTicks,hasFocus;
   WIDGET__GetClientRect(&pObj->Widget, &rFocus);
   GUI__ReduceRect(&r, &rFocus, 1);
   NumTicks  = pObj->NumTicks;
   xSize  = r.x1 - r.x0 + 1 - pObj->Width;
   x0     = r.x0 + pObj->Width / 2;
   Range  = pObj->Max - pObj->Min;
   
   if(Range == 0)
   {
      Range  = 1;
   }
   
   
   if(pObj->Widget.State & WIDGET_STATE_FOCUS)
   {
      LCD_SetColor(pObj->aBkColor[1]);
      SlotColor  = pObj->aColor[1];
      SliderColor  = pObj->aColor[3];
      
      hasFocus  = 1;
   }
   else
   {
      LCD_SetColor(pObj->aBkColor[0]);
      SlotColor  = pObj->aColor[0];
      SliderColor  = pObj->aColor[2];
      hasFocus  = 0;
   }
   
   GUI_Clear();
   GUI_FillRectEx(&rFocus);
   
   rSlider     = r;
   rSlider.y0  = 5;
   rSlider.x0  = x0 + (U32)xSize * (U32)(pObj->v - pObj->Min) / Range - pObj->Width / 2;
   rSlider.x1  = rSlider.x0 + pObj->Width;    
   
   LCD_SetColor(SlotColor);
   rSlot.x0  = x0;
   rSlot.x1  = x0 + xSize;
   rSlot.y0  = (rSlider.y0 + rSlider.y1) / 2 - 1;
   rSlot.y1  = rSlot.y0 + 3; 
   GUI_FillRectEx(&rSlot);
   
   if(hasFocus)
   {
      LCD_SetColor(GUI_WHITE);
      GUI_DrawRect(rSlot.x0-1, rSlot.y0-1, rSlot.x1+1,rSlot.y1+1);   
   }
    
   LCD_SetColor(SliderColor);   
   GUI_FillCircle(rSlider.x0+pObj->Width/2,(rSlider.y0+rSlider.y1)/2 , pObj->Width/2);  
   
   
   if(NumTicks > 0)
   {
      LCD_SetColor(GUI_BLACK);
      GUI_SetFont(GUI_FONT_16B_1);
      GUI_SetTextMode(GUI_TM_TRANS);
      GUI_DispDecAt(pObj->v, rSlider.x0+pObj->Width/2-3,(rSlider.y0+rSlider.y1)/2-8, 1);
   }
}
Пример #13
0
/*
*********************************************************************************************************
*	函 数 名: DispCh1Wave
*	功能说明: 显示通道1波形
*	形    参:无
*	返 回 值: 无
*********************************************************************************************************
*/
 void DispCh1Wave(void)
{
	int16_t i,j = 0;		/* 有符号数 */
	uint16_t *px;
	uint16_t *py;
	int16_t iTemp;
    uint16_t VccMax,VccMin;
	uint16_t Average;

      for(i=0;i<1024;i++)
	{ 
		
		g_DSO.Ch1Buf[j++]=g_DSO.buffer[i]>>16;		//ADC2
		g_DSO.Ch1Buf[j++]=g_DSO.buffer[i] & 0xFFFF;	//ADC1
	}

	if (g_DSO.BufUsed == 0)
	{
		g_DSO.BufUsed = 1;
	}
	else
	{
		g_DSO.BufUsed = 0;
	}

	if (g_DSO.BufUsed == 0)
	{
		px = g_DSO.xCh1Buf1;
		py = g_DSO.yCh1Buf1;
	}
	else
	{
		px = g_DSO.xCh1Buf2;
		py = g_DSO.yCh1Buf2;
	}

	  GUI_SetColor(GUI_MAGENTA);
	
	 /* 下面的代码用于实现 最大值和最小值得差值  */
	 VccMax=g_DSO.Ch1Buf[0];
	 VccMin=g_DSO.Ch1Buf[0];
	 for(i=1;i<1024;i++)
	 {
	    if(VccMax<g_DSO.Ch1Buf[i])VccMax=g_DSO.Ch1Buf[i];
		if(VccMin>g_DSO.Ch1Buf[i])VccMin=g_DSO.Ch1Buf[i];
	 }
	  VccMax=VccMax-VccMin;
      GUI_GotoXY(323-55,104);
	  GUI_DispFloatFix((VccMax* 1.406)/1050,5,2);
	 
	 /* CH1通道, 输入0V时,ADC采样值 = 1900 ,1024个点求到的平均值 */
	 /* 增益1:1的时候 1.406对应的AD值是2951 -1901 = 1050  */
	  for(i=1;i<21;i++)
	 {
	    Average +=g_DSO.Ch1Buf[i];
	 } 
	 Average = Average / 20;
	 GUI_GotoXY(323-55,40);
	 GUI_DispFloatFix(((Average-1900) * 1.406)/1050,5,2);
	 

	 GUI_DispDecAt(g_DSO.Ch1Buf[0], 323-55, 72, 4);
	/* 下面的代码用于实现波形的刷新  */
	for (i = 0; i < 300; i++)
	{
		px[i] = 15 + i;
		iTemp = g_DSO.Ch1VOffset + (int16_t)((1900 - g_DSO.Ch1Buf[i + 1]) * 10)/g_DSO.Ch1Attenuation ;
		if (iTemp > 200)
		{
			iTemp = 200;
		}
		else if (iTemp < 0)
		{
			iTemp = 0;
		}
		py[i] = iTemp;
	}

	/* 下面的代码采取清除上帧波形,然后再重新描绘新波形,避免整屏刷新的闪烁感 */
	/* 清除上帧波形 */
	if (g_DSO.BufUsed == 0)
	{
		GUI_SetColor(GUI_BLUE);
	    GUI_DrawGraph((signed short *)g_DSO.yCh1Buf2, 250, 14,20);

	}
	else
	{
		GUI_SetColor(GUI_BLUE);
	    GUI_DrawGraph((signed short *)g_DSO.yCh1Buf1, 250, 14,20);
	}

	/* 显示更新的波形 */
	GUI_SetColor(GUI_YELLOW);
	GUI_DrawGraph((I16 *)py, 250, 14,20);
}