Beispiel #1
0
__s32  GUI_LongStringStart(__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 == 0)
    {
        GUI_LyrWinSel(show_info->hlayer);
    	show_info->hmem = 
    		GUI_MEMDEV_Create( show_info->region.x, show_info->region.y, show_info->region.width, show_info->region.height);
    	if(!show_info->hmem)
    	{	
    		ORANGE_WRN("create show info mem device fail\n");
            
    		return  ORANGE_FAIL;
    	}
    }

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

    LONGSTR_LOCK();
    show_info->status = LONGSTRING_MOVE;
    LONGSTR_UNLOCK();
    
    if(run_sem)
	{
		int   sem_value; 
    
        sem_getvalue (&run_sem, &sem_value); 
        if (sem_value <= 0) 
        {
            sem_post(&run_sem); 
        }
	}

    return ORANGE_OK;
}
/*---------------------------------------------------------------------------*
 * Routine: _PFMainDialog
 *---------------------------------------------------------------------------*
 * Description:
 *      Callback function used by emWin to process events.
 * Inputs:
 *      WM_MESSAGE *pMsg -- message structure for current dialog.
 *---------------------------------------------------------------------------*/
static void _PFMainDialog(WM_MESSAGE *pMsg)
{
    int Id, NCode;
    WM_HWIN hItem;
    GUI_PID_STATE *p_touchState;
    T_ImageMessage message;

    switch (pMsg->MsgId){
    case WM_INIT_DIALOG:
        Id    = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        LAFSetup(pMsg->hWin, ID_WINDOW, PFMainLayout);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_REVERSE_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &REVERSE_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &REVERSE_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &REVERSE_BUTTON);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_PAUSE_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &PLAY_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &PLAY_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &PLAY_BUTTON);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_FORWARD_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &FORWARD_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &FORWARD_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &FORWARD_BUTTON);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_SETTINGS_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &SETTINGS_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &SETTINGS_BUTTON);
        BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &SETTINGS_BUTTON);

        G_OverlayTimer = WM_CreateTimer(pMsg->hWin, ID_OVERLAY_TIMER, OVERLAY_TIMEOUT_MS, 0);
        G_UpdateTimer = WM_CreateTimer(pMsg->hWin, ID_UPDATE_TIMER, UPDATE_TIME_MS, 0);
        G_PictureChangeTimer = WM_CreateTimer(pMsg->hWin, ID_PICTURECHANGE_TIMER, 0, 0);

        if (!G_Current) {
            G_Current = GUI_MEMDEV_Create(0, 0,
                    UEZ_LCD_DISPLAY_WIDTH, UEZ_LCD_DISPLAY_HEIGHT);
            GUI_MEMDEV_Select(G_Current);
            GUI_BMP_Draw(G_CurrentImage, 0, 0);
            GUI_MEMDEV_Select(0);
        }

        WM_SetHasTrans(pMsg->hWin);

        message = IMAGE_INITILIZE;
        UEZQueueSend(G_ImageLoadQueue,
                (void*)&message,
                50);
        break;
    case WM_NOTIFY_PARENT:
        Id = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        if( !LAFHandleEvent(PFMainLayout, pMsg, NCode, Id)){
            //Handle special cases here
        }
        break;
    case WM_TIMER:
        NCode = pMsg->Data.v;
        if (G_Active) {
            if (NCode == G_OverlayTimer) {
                IHideButtonsAndText(pMsg);
                //Grab all the touches
                WM_SetCapture(pMsg->hWin, 0);
            } else if (NCode == G_PictureChangeTimer) {
                //put up new picture
                if(G_AutoPlayOn) {
                    IHandleForward(pMsg, WM_NOTIFICATION_RELEASED, ID_FORWARD_BUTTON);
                    WM_RestartTimer(G_PictureChangeTimer, 5000);
                }
            } else if (NCode == G_UpdateTimer) {
                IUpdateFields(pMsg);
                WM_RestartTimer(G_UpdateTimer, UPDATE_TIME_MS);
            }
        }
        break;
    case WM_TOUCH:
        p_touchState = (GUI_PID_STATE *)(pMsg->Data.p);
        if (!p_touchState->Pressed) {
            WM_RestartTimer(G_OverlayTimer, OVERLAY_TIMEOUT_MS);
            //Show all the hidden text on buttons
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_TEXT);
            WM_ShowWindow(hItem);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_SETTINGS_BUTTON);
            WM_ShowWindow(hItem);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_REVERSE_BUTTON);
            WM_ShowWindow(hItem);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_PAUSE_BUTTON);
            WM_ShowWindow(hItem);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_FORWARD_BUTTON);
            WM_ShowWindow(hItem);
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMEDATE_TEXT);
            WM_ShowWindow(hItem);
            WM_ReleaseCapture();
            IUpdateFields(pMsg);
        }
        break;
    case WM_POST_PAINT:
        GUI_BMP_Draw(G_CurrentImage, 0, 0);
        break;
    case WM_APP_GAINED_FOCUS:
        G_Active = ETrue;
        WM_SetCapture(pMsg->hWin, 0);
        IHideButtonsAndText(pMsg);
        IUpdateFields(pMsg);
        break;
    case WM_APP_LOST_FOCUS:
        G_Active = EFalse;
        IHideButtonsAndText(pMsg);
        WM_ReleaseCapture();
        G_AutoPlayOn = EFalse;
        break;
    default:
      WM_DefaultProc(pMsg);
    break;
  }
}
Beispiel #3
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
      
  }
  
}
Beispiel #4
0
void TH_GUI (void const *argument) {
	static volatile uint16_t i=0;
	static uint16_t Triggered_Sample=0;	
	osEvent evt;
	GUI_MEMDEV_Handle hMem0;
	GUI_SelectLayer(0);
	hMem0 = GUI_MEMDEV_Create(0,0,480,272);
	
	if(!GUI_CURSOR_GetState())
		GUI_CURSOR_Select(&GUI_CursorCrossM);
	
	GUI_CURSOR_Show();
  while (1) {
																															Anal_CH1_Set(/*Main loop start*/);
																															Anal_CH2_Set(/*Wait start*/);
		evt = osSignalWait(DMA_ConvCpltSig,(uint32_t)2);
		if( evt.status == osEventTimeout)
				Error_Handler();
																															Anal_CH2_Reset(/*Wait finish*/);
		//osSignalSet(tid_Touch,GUI_TouchStateReqSig);
		
																															Anal_CH3_Set(/*Copy start*/);
		for(i=0;i<ADC_BUFFER_LENGTH;i++)	// <- Temporary. Take the full advantage of DMA !
		values_BUF[i]=255-values[i];
																															Anal_CH3_Reset(/*Copy finish*/);
		
		HAL_ADC_Start_DMA(&g_AdcHandle, values, ADC_BUFFER_LENGTH);
		osSignalClear(tid_TH_GUI, DMA_ConvCpltSig);
																															Anal_CH4_Set(/*Wait start*/);		
		osSignalWait(GUI_TouchGetSig,(uint32_t)0);
		GUI_CURSOR_SetPosition(g_Touched.pState->x,g_Touched.pState->y);
																															Anal_CH4_Reset(/*Wait finish*/);
		
		Trigger_Point = g_Touched.MSG;
		Triggered_Sample = Trigger(Trigger_Point, values_BUF, ADC_BUFFER_LENGTH, 1348000UL);
		//if(Triggered_Sample >=20)Triggered_Sample -=20; // Offset to see the edge in the center <- bullshit ?
		
		GUI_MEMDEV_Select(hMem0);
		GUI_MEMDEV_Clear(hMem0);
		
		GUI_SetColor(GUI_DARKGRAY);
		GUI_FillRect(0,0,480,272);
		
		GUI_SetColor(GUI_BLACK);
		GUI_DrawRect(34,5,474,266);		
		
		GUI_SetColor(GUI_WHITE);
		GUI_FillRect(35,6,475,266);
		
		Draw_GraphGrid(440,260,40,40);
		
		GUI_SetColor(GUI_BLUE);
		/*Draw garph start*/HAL_GPIO_TogglePin(GPIOI,GPIO_PIN_1);
		GUI_DrawGraph((short*)&values_BUF[Triggered_Sample],440,35,6); // Useful: GUI_COUNTOF(values)
		/*Draw garph finish*/HAL_GPIO_TogglePin(GPIOI,GPIO_PIN_1);
		
		GUI_SetColor(GUI_ORANGE);
		GUI_DrawHLine(Trigger_Point,0,480);
		GUI_FillCircle(15,Trigger_Point,10);
		
		GUI_SetColor(GUI_YELLOW);
		GUI_DrawCircle(15,Trigger_Point,10);
		
		GUI_MEMDEV_CopyToLCD(hMem0);
																															Anal_CH1_Reset(/*Main loop finish*/);
    osThreadYield ();                                           // suspend thread
  }
}
Beispiel #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);

 
}
Beispiel #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);
}
Beispiel #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);
}
Beispiel #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;
	}	

}