Esempio n. 1
0
/*********************************************************************
*
*       _DrawBkCircle
*/
static void _DrawBkCircle(int DrawLogo) {
  static GUI_MEMDEV_Handle   hMemStretch;
  GUI_MEMDEV_Handle          hMemGradient;
  GUI_MEMDEV_Handle          hMemCircle;
  GUI_MEMDEV_Handle          hMemOld;
  int                        CircleWidth;
  int                        ySizeV;
  int                        xSize;
  int                        ySize;
  int                        i;
  U32                      * pData;

  xSize  = LCD_GetXSize();
  ySize  = LCD_GetYSize();
  ySizeV = LCD_GetVYSize();
  if (ySizeV > ySize) {
    GUI_SetBkColor(BK_COLOR_1);
    GUI_ClearRect(0, 0, xSize, ySizeV);
  }
  if (hMemStretch == 0) {
    CircleWidth  = (CIRCLE_RADIUS << 1) + 1;
    hMemCircle   = GUI_MEMDEV_CreateFixed(0, 0, CircleWidth, CircleWidth,   GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
    hMemStretch  = GUI_MEMDEV_CreateEx   (0, 0, xSize,       ySize,         GUI_MEMDEV_NOTRANS);
    hMemGradient = GUI_MEMDEV_CreateFixed(0, 0, 1,           CIRCLE_RADIUS, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
    //
    // Initialize background
    //
    hMemOld = GUI_MEMDEV_Select(hMemCircle);
    GUI_SetBkColor(BK_COLOR_1);
    GUI_Clear();
    //
    // Create Gradient
    //
    GUI_MEMDEV_Select(hMemGradient);
    GUI_DrawGradientV(0, 0, 0, CIRCLE_RADIUS, BK_COLOR_0, BK_COLOR_1);
    //
    // Get color and draw circles
    //
    pData = (U32 *)GUI_MEMDEV_GetDataPtr(hMemGradient);
    GUI_MEMDEV_Select(hMemCircle);
    for (i = 0; i < CIRCLE_RADIUS; i++, pData++) {
      GUI_SetColor(*pData);
      GUI_DrawCircle(CIRCLE_RADIUS, CIRCLE_RADIUS, i);
    }
    //
    // Stretch and display
    //
    GUI_MEMDEV_Select(hMemStretch);
    GUI_MEMDEV_DrawPerspectiveX(hMemCircle, 0, 0, ySize, ySize, xSize, 0);
    GUI_MEMDEV_Delete(hMemCircle);
    GUI_MEMDEV_Delete(hMemGradient);
    GUI_MEMDEV_Select(hMemOld);
  }
  GUI_MEMDEV_Write(hMemStretch);
  if (DrawLogo) {
    GUI_DrawBitmap(&bmSTLogo70x35, LOGO_DIST_BORDER, LOGO_DIST_BORDER);
  }
}
Esempio n. 2
0
/********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  GUI_MEMDEV_Handle hMem;
  GUI_Init();

  _Explain();     /* Explain the sample */

  GUI_SetFont(&GUI_Font16B_ASCII);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Screen output:", 5, 59);
  _Draw();        /* Draw "Preview" on the screen */

  /* Create and select a memory device with 1bpp color conversion (B/W) */
  hMem = GUI_MEMDEV_CreateFixed(0, 75, 320, 64, 0, 
                                GUI_MEMDEV_APILIST_1, /* Used API list */
                                GUI_COLOR_CONV_1);    /* Black/white color conversion */
  GUI_MEMDEV_Select(hMem);
  _Draw();                  /* Call the same routine as before for drawing into memory device */
  GUI_MEMDEV_Select(0);     /* Switch back from memory device to the display */

  GUI_SetFont(&GUI_Font16B_ASCII);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Printer output:", 5, 154);
  _SendToPrinter(hMem, 170);

  /* Cleanup, end-of sample */
  GUI_MEMDEV_Delete(hMem);
  while(1) {
    GUI_Exec();
  }
}
Esempio n. 3
0
__s32  GUI_LongStringStop(__hdle hString)
{
    __string_show_info_t    *show_info;

    if(!hString)
    {
        ORANGE_WRN("input parameter error!\n");

        return ORANGE_FAIL;
    }

    show_info  = (__string_show_info_t *)hString;
	if(show_info->hmem )
	{	
        __here__;
        if(show_info->hlayer)
        {
            GUI_LyrWinSel(show_info->hlayer);
            __here__;
    		GUI_MEMDEV_Delete(show_info->hmem );
            __here__;
        }
		show_info->hmem = NULL;
	}

    /*all can see*/
	if(show_info->show_size.width < show_info->region.width)
	{
		return ORANGE_OK;
	}

    LONGSTR_LOCK();
    /*等待move结束之后,然后返回*/
    show_info->status = LONGSTRING_STOP;
    LONGSTR_UNLOCK();

    return ORANGE_OK;
}
Esempio n. 4
0
/**
  * @brief  Update the text area display
  * @param  None
  * @retval None
  */
void USER_LCD_LOG_UpdateDisplay (void)
{
  #ifndef __USER_USE_SOLID_BK_
  GUI_MEMDEV_Handle tempMem;    
  void *pbk;
  void *ptemp; 
  #endif
  uint8_t cnt = 0 ;
  uint16_t length = 0 ;
  uint16_t ptr = 0, index = 0;
  if((USER_LCD_CacheBuffer_yptr_bottom  < (USER_YWINDOW_SIZE -1)) && 
     (USER_LCD_CacheBuffer_yptr_bottom  >= USER_LCD_CacheBuffer_yptr_top))
  {
    if(u8_enable_display)
    {
      USER_LCD_LOG_DisplayStringAtLine ((USER_YWINDOW_MIN + Y0/GUI_GetFontSizeY()+ USER_LCD_CacheBuffer_yptr_bottom),
                           (char *)(USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].line),
                             USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].color);
    }
  }
  else
  {
    if(USER_LCD_CacheBuffer_yptr_bottom < USER_LCD_CacheBuffer_yptr_top)
    {
      /* Virtual length for rolling */
      length = USER_LCD_CACHE_DEPTH + USER_LCD_CacheBuffer_yptr_bottom ;
    }
    else
    {
      length = USER_LCD_CacheBuffer_yptr_bottom;
    }
    
    ptr = length - USER_YWINDOW_SIZE + 1;

    GUI_SetFont(&USER_LCD_LOG_TEXT_FONT);
    #ifdef __USER_USE_SOLID_BK_ 
    for  (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++)
      {        
        index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ;
        if(u8_enable_display)
        {
          USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), 
                               (char *)(USER_LCD_CacheBuffer[index].line),
                                 USER_LCD_CacheBuffer[index].color); 
        }                       
      }
    #else 
    tempMem=GUI_MEMDEV_Create(GUI_MEMDEV_GetXPos(backgroundDisplayMem),GUI_MEMDEV_GetYPos(backgroundDisplayMem),GUI_MEMDEV_GetXSize(backgroundDisplayMem),GUI_MEMDEV_GetYSize(backgroundDisplayMem));
    if(tempMem)
    {
      pbk=GUI_MEMDEV_GetDataPtr(backgroundDisplayMem);
      ptemp=GUI_MEMDEV_GetDataPtr(tempMem);
    
      memcpy((uint8_t *)ptemp,(uint8_t *)pbk,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem));

      GUI_MEMDEV_Select(backgroundDisplayMem);
      
      for  (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++)
      {        
        index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ;
        if(u8_enable_display)
        {
          USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), 
                               (char *)(USER_LCD_CacheBuffer[index].line),
                                 USER_LCD_CacheBuffer[index].color); 
        }                       
      }
      
      GUI_MEMDEV_CopyToLCD(backgroundDisplayMem);
      GUI_MEMDEV_Select(0);
      
      memcpy((uint8_t *)pbk,(uint8_t *)ptemp,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem));
      GUI_MEMDEV_Delete(tempMem);
      tempMem=0;
    }
    #endif
      
  }
  
}
Esempio n. 5
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

    LBF_Board_Init();

    Red_Led_ON();

/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

    // UNCOMMENT IF YOU WELL BE USING ...:
  
    /* ... La BlueFrog as USB Mass Storage (Full Speed)             */
    /*     (based on ST-provided stack part of STM32 Cube offering  */
    // Delay_ms(1000);
    // LBF_LaunchUSB_MassStorage();
 
    /* ... the FAT File System (FatFS)                              */
    /*     (based on ChanN's FatFS included in STM32 Cube offering) */
    // LBF_FatFS_Init();

    /* ... the STemWin Graphical Library                            */
    /*     (based on Segger's emWin included in STM32 Cube offering)*/
    LBF_emWin_Init();


    Red_Led_OFF();



/* ================================================================ */
/*   Application Code Below                                         */
/* ================================================================ */

/* ==  User Declarations ========================================== */

uint16_t fconfig[11];  // configuration file to control some OLED parameters
GUI_MEMDEV_Handle hMemDevice;  //handle to a memory device


/* ==  Body              ========================================== */

   fconfig[0]=0xFFFF;  // to use default settings
   LBF_OLED_Init(fconfig);  
        //sets up OLED register and powers on OLED VDDH(13V) 


   OLED_Fill(0, 0, 160, 128, CYAN);

   Red_Led_ON();


  /*** Start Demo *******************************************************/

  /* Different options posible */ 
  /* Use Display Cache or Use Memory Device or use Banded Memory Device */
  /* With 32K SRAM only the latter allows to cover full screen */


  // =============================================================
  // == Using the dislay cache  ==================================

  // Usage of display cache can be enabled through parameters of function 
  // GUIDRV_FlexColor_SetFunc() called in LCDConf_FlexColor_LBF.c
  // found in library LBF_STemWin

  // !!! ISSUE !!!
  // XSIZE_PHYS x YSIZE_PHYS (defined in above files) need to be set to 160x128 
  // to hold full display. However at 16bpp that represents about 40BK
  // but available SRAM is only 32KB...
  // Work-Around: define a smaller display cache (XSIZE_PHYS, YSIZE_PHYS)
  // -- but will not allow to address full screen

  // Not much interest vs use of "Memory Device", below, anyway
/*
  GUI_SetFont(&GUI_Font20_1);
  GUI_SetTextMode(GUI_TM_TRANS);  // write with transparent background
  GUI_DispStringAt("Hello from La BlueFrog !", LCD_GetXSize()/8, LCD_GetYSize()/2);  
  Green_Led_ON();
*/


  // =============================================================
  // == Using a "Memory Device"  (refer to emWin documentation) 

  // Work with a centered 128x64 window    
  // (cannot cover full screen for same memory limitation as above)
  #define X_FULL_SCREEN  160
  #define Y_FULL_SCREEN  128
  #define MD_X_LEFT  (X_FULL_SCREEN -128)/2
  #define MD_X_RIGHT  160-MD_X_LEFT
  #define MD_Y_TOP   (Y_FULL_SCREEN -64)/2
  #define MD_Y_BOT    128-MD_Y_TOP


  // Create Memory Device (top left & bottom right coordinates) on Layer 0:
  GUI_SelectLayer(0);
  hMemDevice = GUI_MEMDEV_Create(MD_X_LEFT, MD_Y_TOP,  (MD_X_RIGHT-MD_X_LEFT+1), (MD_Y_BOT-MD_Y_TOP+1) );
      // Caution: 
      // Memory allocated by GUI_X_Config in GUIConf_LBF.c must be sufficient to fit MemDevice buffer
      // plus other needs of emWin
      // Else GUI_MEMDEV_Create will fail (returns 0) and operations will be done directly to screen

  // Activate it: 
  GUI_MEMDEV_Select(hMemDevice);

  // Draw Stuff   (refer to emWin documentation)
  GUI_DrawGradientRoundedH( MD_X_LEFT, MD_Y_TOP,  MD_X_RIGHT, MD_Y_BOT, 
                            10, // rounded corner radius
                            0xFF0000, 0xFFFF00); // red to yellow
  GUI_SetPenSize(6);
  GUI_DrawLine(MD_X_LEFT, MD_Y_TOP, MD_X_RIGHT, MD_Y_BOT);
  GUI_DrawLine(MD_X_LEFT, MD_Y_BOT, MD_X_RIGHT, MD_Y_TOP);

  GUI_SetFont(&GUI_Font13_1);
  GUI_SetColor(GUI_BLACK);
  GUI_SetTextMode(GUI_TM_TRANS);  // write with transparent background
  GUI_DispStringAt("Hello !\n", MD_X_LEFT+10, MD_Y_TOP+10 );  

  // Copy to display
  GUI_MEMDEV_CopyToLCD(hMemDevice);

  // Free memory
  GUI_MEMDEV_Delete(hMemDevice);


  // =============================================================
  // == Using a "Banded Memory Device"  (refer to emWin documentation) 
  // == (Banding, aka tiling, allows to cover full screen by processing
  // ==  a number of bands successively)

  //TODO
  // use function: GUI_MEMDEV_Draw (GUI_RECT * pRect, GUI_CALLBACK_VOID_P * pfDraw, 
  //                 void* pData, int NumLines, int Flags);



while(1);

 
}
Esempio n. 6
0
static int StaticCtrlProc (__gui_msg_t *msg)
{
    __u32	            	dwStyle;
    static_data_t*			pData;

    dwStyle = GUI_WinGetStyle(msg->h_deswin);

    switch(msg->id)
    {
        case GUI_MSG_CREATE:
            pData = (static_data_t*) orange_malloc(sizeof(static_data_t));
            if (pData == NULL) 
            {
                return ORANGE_FAIL;
            }

            pData->status       = 0;
            pData->hmem         = 0;
            pData->str_move     = 0;
            pData->data         = (__u32)GUI_WinGetAttr(msg->h_deswin);
            GUI_CtrlWinSetAddData(msg->h_deswin,(__u32)pData);
            return 0;
       
        case GUI_MSG_DESTROY:
            pData = (static_data_t*)GUI_CtrlWinGetAddData(msg->h_deswin);
            if(pData->str_move)
            {
                GUI_LongStringDelete(pData->str_move);
            }
            orange_mfree ((void *)GUI_CtrlWinGetAddData(msg->h_deswin));
            return 0;
        
        case GUI_MSG_ENABLE:
            if (msg->dwAddData1 && (dwStyle & WS_DISABLED))
            {
                dwStyle &= ~WS_DISABLED;

                GUI_WinSetStyle(msg->h_deswin,dwStyle);
            }
            else if (!msg->dwAddData1 && !(dwStyle & WS_DISABLED))
            {
                dwStyle |= WS_DISABLED;

                GUI_WinSetStyle(msg->h_deswin,dwStyle);
            }
            else
            {
                return 0;
            }
            return 0;
            
        case GUI_MSG_SET_UNFOCUS:
            if((STATIC_DRAWSTATUS(msg->h_deswin) & STATICST_FOCUS))
            {
                STATIC_DRAWSTATUS(msg->h_deswin) &= (~STATICST_FOCUS);
                

    			GUI_InvalidateRect (msg->h_deswin, NULL, ORANGE_TRUE);
            }
            return 0;

        case GUI_MSG_SET_FOCUS:          
            if(!(STATIC_DRAWSTATUS(msg->h_deswin) & STATICST_FOCUS))
            {
                STATIC_DRAWSTATUS(msg->h_deswin) |= STATICST_FOCUS;

    			GUI_InvalidateRect (msg->h_deswin, NULL, ORANGE_TRUE);
            }
            return 0;
        
        case GUI_MSG_KEY:
			switch(msg->dwAddData1)
			{
				/*case GUI_MSG_KEY_RISE:
				{
					{
						__gui_notify_msg_t      notify_msg;

		                notify_msg.hWnd     = msg->h_deswin;
		                notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                notify_msg.msgcode  = STN_CLICKED;
		                notify_msg.dwAddData= last_key;
		                    
		                GUI_NotifyParent (&notify_msg);
		            }
				}
                return 0;*/
                
				case GUI_MSG_KEY_DOWN:
				{
					if(msg->dwAddData2 == KEY_UP_ACTION)
					{
						{
							__gui_notify_msg_t      notify_msg;

		                	notify_msg.hWnd     = msg->h_deswin;
		                	notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                	notify_msg.msgcode  = STN_CLICKED;
		                	notify_msg.dwAddData= last_key;
		                    
		                GUI_NotifyParent (&notify_msg);
		            	}
					}

					if(msg->dwAddData2 == KEY_DOWN_ACTION)
					{
						{
							__gui_notify_msg_t      notify_msg;

		                	notify_msg.hWnd     = msg->h_deswin;
		                	notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                	notify_msg.msgcode  = STN_PUSHED;
		                	notify_msg.dwAddData= GUI_MSG_KEY_DOWN;
		                    
		                	GUI_NotifyParent (&notify_msg);
		            	}
					}
		            
				}
                return 0;
                
				case GUI_MSG_KEY_ENTER:
				{
					if(msg->dwAddData2 == KEY_UP_ACTION)
					{
						{
							__gui_notify_msg_t      notify_msg;

		                	notify_msg.hWnd     = msg->h_deswin;
		                	notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                	notify_msg.msgcode  = STN_CLICKED;
		                	notify_msg.dwAddData= last_key;
		                    
		                GUI_NotifyParent (&notify_msg);
		            	}
					}

					if(msg->dwAddData2 == KEY_DOWN_ACTION)
					{
						{
							__gui_notify_msg_t      notify_msg;
	
		                	notify_msg.hWnd     = msg->h_deswin;
		                	notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                	notify_msg.msgcode  = STN_PUSHED;
		                	notify_msg.dwAddData= GUI_MSG_KEY_ENTER;
		                    
		                	GUI_NotifyParent (&notify_msg);
		            	}
					}
		            
				}

                return 0;
                
				case GUI_MSG_KEY_RIGHT:
				case GUI_MSG_KEY_LEFT:
				case GUI_MSG_KEY_UP:
				default:
                {
					if(msg->dwAddData2 == KEY_UP_ACTION)
					{
						{
							__gui_notify_msg_t      notify_msg;

		                	notify_msg.hWnd     = msg->h_deswin;
		                	notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                	notify_msg.msgcode  = STN_CLICKED;
		                	notify_msg.dwAddData= last_key;
		                    
		                GUI_NotifyParent (&notify_msg);
		            	}
					}

					if(msg->dwAddData2 == KEY_DOWN_ACTION)
					{
						{
							__gui_notify_msg_t      notify_msg;
	
		                	notify_msg.hWnd     = msg->h_deswin;
		                	notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
		                	notify_msg.msgcode  = STN_PUSHED;
		                	notify_msg.dwAddData= msg->dwAddData1;
		                    
		                	GUI_NotifyParent (&notify_msg);
		            	}
					}
					
                }
				break;
					
			}

            /*if(msg->dwAddData1 != GUI_MSG_KEY_RISE)
            {
                last_key = msg->dwAddData1;
            }
            else
            {
                last_key = 0xffffffff;
            }*/
            last_key = msg->dwAddData1;
            
        return 0;
        
        case GUI_MSG_TOUCH:
			{
				switch(msg->dwAddData1)
				{
					case GUI_MSG_TOUCH_DOWN:
					{
						{
							__gui_notify_msg_t      notify_msg;

			                notify_msg.hWnd     = msg->h_deswin;
			                notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
			                notify_msg.msgcode  = STN_PUSHED;
			                notify_msg.dwAddData= 0;
			                    
			                GUI_NotifyParent (&notify_msg);
						}		            
					}
					break;
					
					case GUI_MSG_TOUCH_UP:
					{
						{
							__gui_notify_msg_t      notify_msg;

			                notify_msg.hWnd     = msg->h_deswin;
			                notify_msg.id       = GUI_WinGetItemId(msg->h_deswin);
			                notify_msg.msgcode  = STN_CLICKED;
			                notify_msg.dwAddData= 0;
			                    
			                GUI_NotifyParent (&notify_msg);
				         }
					}
					break;	
				}
			}
            
        return 0;

        case GUI_MSG_WIN_WAKEUP:
        case GUI_MSG_PAINT:
        {
			__gui_rect_t 	rcrect;
            RECT            fbrect;
			//void         	*pBMP;
            static_data_t   *static_data;
			static_para_t  	*user_data;
			//__u32			 color;

            //static_data = (static_para_t *)GUI_CtrlWinGetAddData(msg->h_deswin);

			user_data   = (static_para_t *)(((static_data_t *)GUI_CtrlWinGetAddData(msg->h_deswin))->data);
            static_data = (static_data_t *)GUI_CtrlWinGetAddData(msg->h_deswin);

            GUI_LyrWinSel(GUI_LyrP2H(GUI_WinGetLyrWin(msg->h_deswin)));
            
            GUI_WinGetClientFBRect(msg->h_deswin,&fbrect);
            if(!static_data->hmem && (GUI_WinGetStyle(msg->h_deswin) & WS_MEMDEV))
            {
            	#if GUI_CORE_MEMDEV_EN		//avoid complier error, by Derek
                static_data->hmem = GUI_MEMDEV_Create(fbrect.x,fbrect.y,fbrect.width,fbrect.height);
				#endif
            }
			SysRectToGuiRect(&fbrect,&rcrect);

			if(static_data->hmem)
			{
				#if GUI_CORE_MEMDEV_EN		//avoid complier error, by Derek
            	GUI_MEMDEV_Select(static_data->hmem);           // start memory device
            	#endif
        	}
				
        	if (STATIC_DRAWSTATUS(msg->h_deswin) & STATICST_FOCUS)
            {	
                GUI_RECT        rect;
                
                GUI_SetBkColor(user_data->bk_color);
            	GUI_ClearRect(rcrect.left,rcrect.top,
                 			rcrect.right,rcrect.bottom);

                if(user_data->focus_bmp)
                {
                    GUI_BMP_Draw(user_data->focus_bmp, rcrect.left + user_data->bmp_pos.x, 
    					rcrect.top + user_data->bmp_pos.y);
                }
				
				if(user_data->alpha_en)
                {
                    GUI_OpenAlphaBlend();
                }
                
				GUI_CharSetToEncode(user_data->draw_code);
				GUI_SetFont(user_data->draw_font);

				GUI_SetDrawMode(GUI_DRAWMODE_TRANS);
			    GUI_SetColor(user_data->ftxt_color);

                rect.x0 = rcrect.left;
                rect.y0 = rcrect.top;
                rect.x1 = rcrect.right;
                rect.y1 = rcrect.bottom;
                if(!user_data->txt_align)
                {
    			    GUI_DispStringAt(user_data->text,
    			                     rcrect.left + user_data->text_pos.x, 
    					            rcrect.top + user_data->text_pos.y);
                }
                else
                {
                    GUI_DispStringInRect(user_data->text,&rect,user_data->txt_align);
                }
            }
            else
            {
                GUI_RECT        rect;
                
                GUI_SetBkColor(user_data->bk_color);
				
            	GUI_ClearRect(rcrect.left,rcrect.top,
                 			rcrect.right,rcrect.bottom);

                if(user_data->unfocus_bmp)
                {
                    GUI_BMP_Draw(user_data->unfocus_bmp, rcrect.left + user_data->bmp_pos.x, 
    					rcrect.top + user_data->bmp_pos.y);
                }
				
				if(user_data->alpha_en)
                {
                    GUI_OpenAlphaBlend();
                }
                
				GUI_CharSetToEncode(user_data->draw_code);
				GUI_SetFont(user_data->draw_font);

				GUI_SetDrawMode(GUI_DRAWMODE_TRANS);
			    GUI_SetColor(user_data->uftxt_color);

                rect.x0 = rcrect.left;
                rect.y0 = rcrect.top;
                rect.x1 = rcrect.right;
                rect.y1 = rcrect.bottom;
                
			    if(!user_data->txt_align)
                {
    			    GUI_DispStringAt(user_data->text,
    			                     rcrect.left + user_data->text_pos.x, 
    					            rcrect.top + user_data->text_pos.y);
                }
                else
                {
                    GUI_DispStringInRect(user_data->text,&rect,user_data->txt_align);
                }
            }
            if(static_data->hmem)
            {
            	#if GUI_CORE_MEMDEV_EN		//avoid complier error, by Derek
	            GUI_MEMDEV_CopyToLCD( static_data->hmem );          // copy from memory device to fb
		        GUI_MEMDEV_Select( NULL );                    // stop memory device
		        GUI_MEMDEV_Delete(static_data->hmem);
				#endif
	            static_data->hmem = NULL;
        	}

            if(user_data->alpha_en)
            {
                GUI_CloseAlphaBlend();
            }

            GUI_LyrWinFlushFB(GUI_WinGetLyrWin(msg->h_deswin));
        }
        return 0;

        default:
        break;
    }
    
    return GUI_CtrlWinDefaultProc (msg);
}
Esempio n. 7
0
/*********************************************************************
*
*       _DemoBarGraph
*/
static void _DemoBarGraph(void) {
  GUI_MEMDEV_Handle hMem;
  int               ayOrg[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 };
  int               ayCur[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 };
  int               aAdd[GUI_COUNTOF(ayOrg)];
  int               NextState;
  int               TimeStart;
  int               xPosGraph;
  int               yPosGraph;
  int               AddBlend;
  int               NumItems;
  int               TimeDiff;
  int               TimeStep;
  int               Blend;
  int               xSize;
  int               ySize;
  int               i;

  //
  // Initialize values; 
  //
  AddBlend  = 1;
  Blend     = 64;
  NumItems  = GUI_COUNTOF(ayOrg);
  xSize     = LCD_GetXSize();
  ySize     = LCD_GetYSize();
  xPosGraph = (xSize - GRAPH_WIDTH)  / 2;
  yPosGraph = (ySize - GRAPH_HEIGHT) / 2;
  //
  // Create MEMDEV
  //
  hMem = GUI_MEMDEV_Create(xPosGraph, yPosGraph, GRAPH_WIDTH + 7 + 1, GRAPH_HEIGHT + 1);
  if (hMem == 0) {
    return;
  }
  GUI_MEMDEV_CopyFromLCD(hMem);
  for (i = 0; i < NumItems; i++) {
    aAdd[i] = (i & 1) * 2 - 1;
  }
  _DrawLabel(0, xPosGraph, yPosGraph);
  TimeStart = GUIDEMO_GetTime();
  do {
    TimeDiff = GUIDEMO_GetTime() - TimeStart;
    _DrawDiagramAt(hMem, xPosGraph, yPosGraph, ayCur, Blend);
    Blend += AddBlend;
    if ((Blend >= 164) || (Blend <= 8)) {
      AddBlend = -AddBlend;
    }
    for (i = 0; i < NumItems; i++) {
      *(ayCur + i) += *(aAdd + i);
      if ((*(ayCur + i) > (*(ayOrg + i) + 10)) || (*(ayCur + i) < (*(ayOrg + i) - 10))) {
        *(aAdd + i) = -*(aAdd + i);
      }
    }
    TimeStep = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    } else {
      GUI_Exec();
    }
    NextState = GUIDEMO_CheckCancel();
  } while ((TimeDiff < SHOW_TIME) && (NextState == 0));
  GUI_MEMDEV_Delete(hMem);
}
Esempio n. 8
0
static void _spinbox_ctrl_paint(__gui_msg_t * msg)
{
	char					str[128];
	__gui_rect_t			rcrect;
	RECT					fbrect;
	spinbox_data_t	 		*spinbox_data;
	spinbox_para_t			*user_data; 		
	
	user_data	= (spinbox_para_t *)(((spinbox_data_t *)GUI_CtrlWinGetAddData(msg->h_deswin))->data);
	spinbox_data = (spinbox_data_t *)GUI_CtrlWinGetAddData(msg->h_deswin);
	
	GUI_LyrWinSel((H_LYR)GUI_WinGetLyrWin(msg->h_deswin));
	GUI_WinGetClientFBRect(msg->h_deswin,&fbrect);
	if(!spinbox_data->hmem)
	{
		#if GUI_CORE_MEMDEV_EN		//avoid complier error, by Derek
		spinbox_data->hmem = GUI_MEMDEV_Create(fbrect.x,fbrect.y,fbrect.width,fbrect.height);
		GUI_MEMDEV_Select(spinbox_data->hmem);
		#endif
	}			 
	
	SysRectToGuiRect(&fbrect,&rcrect);
	
	GUI_OpenAlphaBlend();
	if (SPINBOX_DRAWSTATUS(msg->h_deswin) & BST_PUSHED)
	{	
		GUI_SetBkColor(user_data->bk_color);
		GUI_ClearRect(rcrect.left, rcrect.top, rcrect.right, rcrect.bottom);
		
		GUI_CharSetToEncode(user_data->draw_code);
		
		GUI_SetFont(user_data->draw_font);
	
		GUI_SetDrawMode(GUI_DRAWMODE_TRANS);						
		if(SPINBOX_DRAWFLAG(msg->h_deswin) & BST_LEFT)
		{
			GUI_BMP_Draw(user_data->ufup_bmp, rcrect.left + user_data->upbmp_pos.x, 
						 rcrect.top + user_data->upbmp_pos.y);
			GUI_BMP_Draw(user_data->fdn_bmp, rcrect.left + user_data->dnbmp_pos.x, 
						 rcrect.top + user_data->dnbmp_pos.y); 
		}
		else
		{	
			GUI_BMP_Draw(user_data->fup_bmp, rcrect.left + user_data->upbmp_pos.x, 
						 rcrect.top + user_data->upbmp_pos.y);					
			GUI_BMP_Draw(user_data->ufdn_bmp, rcrect.left + user_data->dnbmp_pos.x, 
				 		 rcrect.top + user_data->dnbmp_pos.y);	
		}
		
		GUI_SetColor(user_data->ftxt_color);
		eLIBs_uint2str_dec(user_data->cur_value, str);
		GUI_DispStringHCenterAt(str, rcrect.left + user_data->text_pos.x, rcrect.top + user_data->text_pos.y);		
	}
	else
	{			
		GUI_SetBkColor(user_data->bk_color);
		GUI_ClearRect(rcrect.left, rcrect.top, rcrect.right, rcrect.bottom);
	
		GUI_CharSetToEncode(user_data->draw_code);
		
		GUI_SetFont(user_data->draw_font);
	
		GUI_SetDrawMode(GUI_DRAWMODE_TRANS);
		GUI_BMP_Draw(user_data->ufup_bmp, rcrect.left + user_data->upbmp_pos.x, 
					  rcrect.top + user_data->upbmp_pos.y);
		GUI_BMP_Draw(user_data->ufdn_bmp, rcrect.left + user_data->dnbmp_pos.x, 
					  rcrect.top + user_data->dnbmp_pos.y);	
					  
		GUI_SetColor(user_data->uftxt_color);	
		eLIBs_uint2str_dec(user_data->cur_value, str);
		GUI_DispStringHCenterAt(str, rcrect.left + user_data->text_pos.x,rcrect.top + user_data->text_pos.y);					  						
	}
	GUI_LyrWinFlushFB((H_LYR)GUI_WinGetLyrWin(msg->h_deswin));
	GUI_CloseAlphaBlend();	
	
	if(spinbox_data->hmem)
	{
		#if GUI_CORE_MEMDEV_EN		//avoid complier error, by Derek
		GUI_MEMDEV_CopyToLCD( spinbox_data->hmem ); 
		GUI_MEMDEV_Select( NULL );			
		GUI_MEMDEV_Delete(spinbox_data->hmem);
		#endif
		spinbox_data->hmem = NULL;
	}	

}