/*********************************************************************
*
*       _OnValueChanged
*/
static void _OnValueChanged(WM_HWIN hDlg, int Id) {
  unsigned Index;
  unsigned v;
  WM_HWIN  hSlider;
  WM_HWIN  hEdit;

  Index = 0;
  v     = 0;
  if ((Id >= GUI_ID_SLIDER0) && (Id <= GUI_ID_SLIDER2)) {
    Index = Id - GUI_ID_SLIDER0;
    //
    // SLIDER-widget has changed, update EDIT-widget
    //
    hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
    hEdit   = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
    v = SLIDER_GetValue(hSlider);
    EDIT_SetValue(hEdit, v);
  } else if ((Id >= GUI_ID_EDIT0) && (Id <= GUI_ID_EDIT2)) {
    Index = Id - GUI_ID_EDIT0;
    //
    // If EDIT-widget has changed, update SLIDER-widget
    //
    hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
    hEdit   = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
    v = EDIT_GetValue(hEdit);
    SLIDER_SetValue(hSlider, v);
  }
  _duty[Index] = v;
  //
  // At last invalidate dialog client window
  //
  WM_InvalidateWindow(WM_GetClientWindow(hDlg));
}
static void _EditHex(int Nibble, EDIT_Obj* pObj, EDIT_Handle hObj) {
  int Pos = pObj->MaxLen - pObj->CursorPos - 1;   /* Nibble position */
  U32 AndMask = ~(15     << (Pos << 2));
  U32 OrMask  =   Nibble << (Pos << 2);
  I32 Result  = pObj->CurrentValue & AndMask;
  Result     |= OrMask;
  EDIT_SetValue(hObj, Result);
}
Example #3
0
void change_usercash1(char value)
{
    WM_HWIN hItem;

    hItem = WM_GetDialogItem(hinuse1, ID_EDIT_3);
    EDIT_SetValue(hItem,value);


}
Example #4
0
/*********************************************************************
*
*       EDIT_SetFloatValue
*/
void EDIT_SetFloatValue(EDIT_Handle hObj, float Value) {
  if (hObj) {
    float Scale;
    EDIT_Obj * pObj;
    WM_LOCK();
    pObj  = EDIT_H2P(hObj);
    Scale = (float)GUI_Pow10[pObj->NumDecs];
    Value *= Scale;
    EDIT_SetValue(hObj, (I32)(Value + (Value >= 0 ? 0.5 : -0.5)));
    WM_UNLOCK();
  }
}
static void _AddPosition(EDIT_Obj* pObj, EDIT_Handle hObj, int Sign) {
  int Pos;
  U32 v;
  v = 1;
  Pos = pObj->MaxLen - pObj->CursorPos-1;
  while (Pos--) {
    v <<= 4;
  }
  if (Sign <0)
    v = ~v;
  EDIT_SetValue(hObj, pObj->CurrentValue + v);
}
/*********************************************************************
*
*       _OnValueChanged
*/
static void _OnValueChanged(WM_HWIN hDlg, int Id) {
  unsigned Index, v;
  WM_HWIN hItem;
  if ((Id >= GUI_ID_SLIDER0) && (Id <= GUI_ID_SLIDER3)) {
    Index = Id - GUI_ID_SLIDER0;
    /* SLIDER-widget has changed, update EDIT-widget */
    hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
    v = SLIDER_GetValue(hItem);
    hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
    EDIT_SetValue(hItem, v);
    _aSlider[Index] = v;
  }
}
static void _AddPosition(EDIT_Obj* pObj, EDIT_Handle hObj, int Sign) {
  int Pos;
  I32 v;
  v = Sign;
  Pos = pObj->MaxLen - pObj->CursorPos-1;
  if (pObj->NumDecs && (Pos > pObj->NumDecs)) {
    Pos--;
  }
  while (Pos--) {
    v *= 10;
  }
  EDIT_SetValue(hObj, (I32)pObj->CurrentValue + v);
}
Example #8
0
static void _EditBin(U8 Bit, EDIT_Obj* pObj, EDIT_Handle hObj) {
  int Pos = pObj->MaxLen - pObj->CursorPos - 1;   /* Bit position */
  U32 AndMask = ~(1   << Pos);
  U32 OrMask  =   Bit << Pos;
  I32 Result  = pObj->CurrentValue & AndMask;
  Result     |= OrMask;
  EDIT_SetValue(hObj, Result);
  /*
  U32 AndMask = ~(1   << Pos);
  U32 OrMask  =   Bit << Pos;
  pObj->CurrentValue &= AndMask;
  pObj->CurrentValue |= OrMask;
  if (pObj->CurrentValue > (U32)pObj->Max)
    pObj->CurrentValue = pObj->Max;
  if (pObj->CurrentValue < (U32)pObj->Min)
    pObj->CurrentValue = pObj->Min;
  */
}
static void _EditDec(int Digit, EDIT_Obj* pObj, EDIT_Handle hObj) {
  I32 Result = 0;
  int i, Pos = 0;
  char * s = (char*) WM_HMEM2Ptr(pObj->hpText);
  for (i = 0; i < pObj->MaxLen; i++) {
    int Index = pObj->MaxLen - i - 1;
    if (Index == pObj->CursorPos) {
      Result += GUI_Pow10[Pos++] * Digit;
    } else {
      char c = *(s + Index);
      int Value = _DecChar2Int(c);
      if (Value >= 0) {
        Result += GUI_Pow10[Pos++] * Value;
      }
      if (c == '-') {
        Result *= -1;
      }
    }
  }
  EDIT_SetValue(hObj, Result);
}
void Edit_Set_Value(WM_HWIN hWin, int editId, long editValue)
{
    WM_HWIN hItem;
    hItem = WM_GetDialogItem(hWin, editId);
    EDIT_SetValue(hItem, editValue);
}
Example #11
0
/*********************************************************************
*
*       Dialog callback routine
*/
static void _cbCallback(WM_MESSAGE * pMsg)
{
    int NCode, Id;
    static int num_backup = 0;
    WM_HWIN hWin = pMsg->hWin;
    switch (pMsg->MsgId)
    {
    case WM_PAINT:
        PaintDialog(pMsg);
        break;
    case WM_INIT_DIALOG:
        InitDialog(pMsg);
        break;
    case WM_KEY:
        switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
        {
        case GUI_KEY_ESCAPE:
            GUI_EndDialog(hWin, 1);
            break;
        case GUI_KEY_ENTER:
            GUI_EndDialog(hWin, 0);
            break;
        }
        break;
    case WM_NOTIFY_PARENT:
        Id = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        switch (Id)
        {
        case GUI_ID_OK:
            if(NCode==WM_NOTIFICATION_RELEASED)
            {
                GUI_EndDialog(hWin, EDIT_GetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0)));
                num_backup = 0;
            }
            break;
        case GUI_ID_CANCEL:
            if(NCode==WM_NOTIFICATION_CLICKED)
            {
                num_backup = 0;
                EDIT_SetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0),num_backup);
                // GUI_EndDialog(hWin, 0);
            }
            break;
        case GUI_ID_EDIT0:
            switch(NCode)
            {
            case WM_NOTIFICATION_CLICKED:
                OnEditNumberClicked(pMsg);
                break;
            }
            break;
        case GUI_ID_BUTTON0:
        case GUI_ID_BUTTON1:
        case GUI_ID_BUTTON2:
        case GUI_ID_BUTTON3:
        case GUI_ID_BUTTON4:
        case GUI_ID_BUTTON5:
        case GUI_ID_BUTTON6:
        case GUI_ID_BUTTON7:
        case GUI_ID_BUTTON8:
        case GUI_ID_BUTTON9:
            if(NCode==WM_NOTIFICATION_CLICKED)
            {
                if(num_backup < 999999999)
                {
                    num_backup = num_backup *10 +(Id - GUI_ID_BUTTON0);
                }
                if(num_backup > 999999999)
                {
                    num_backup = 999999999;
                }
                EDIT_SetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0),num_backup);
            }
            break;
        }
        break;
    default:
        WM_DefaultProc(pMsg);
    }
}
static void _MakePositive(EDIT_Obj* pObj, EDIT_Handle hObj) {
  if ((I32)pObj->CurrentValue < 0) {
    EDIT_SetValue(hObj, (I32)pObj->CurrentValue * -1);
  }
}
Example #13
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) 
{
		
	GUI_Init();
	
	
	WM_SetDesktopColor(GUI_BLUE);	//!< SetDesktopColor
	
	 /* The First window to display the Temperature Curve */
	{
		hWM_HBKWIN_CURVE =
		WM_CreateWindow(0,0,400,240,WM_CF_SHOW | WM_CF_MEMDEV ,0,0);
		
		btn = 		 BUTTON_CreateAsChild(315, 10, 75, 35,hWM_HBKWIN_CURVE, ID_CURVE_BTN_SWTITCH_2_PARA, WM_CF_SHOW);
		btnClear = BUTTON_CreateAsChild(315, 60, 75, 35,hWM_HBKWIN_CURVE, 202, WM_CF_SHOW);
		
		/** PWM Edit **/
		{
			/* Edit to display the PWM1 */
				Edit_PWM1 = EDIT_CreateEx			 (370, 170, 25, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_PWM1,
																				 3);
				EDIT_SetDecMode(Edit_PWM1,0,0,255,0,0);
				EDIT_SetValue(Edit_PWM1,0);
				
				/* Edit to display the PWM2 */
				Edit_PWM2 = EDIT_CreateEx			 (370, 190, 25, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_PWM2,
																				 3);
				EDIT_SetDecMode(Edit_PWM2,0,0,255,0,0);
				EDIT_SetValue(Edit_PWM2,0);
				
					/* Edit to display the PWM3 */
				Edit_PWM3 = EDIT_CreateEx			 (370, 210, 25, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_PWM3,
																				 3);
				EDIT_SetDecMode(Edit_PWM3,0,0,255,0,0);
				EDIT_SetValue(Edit_PWM3,0);
		}


		
		
		// Set Callback function for background window
		WM_SetCallback(hWM_HBKWIN_CURVE, _cbBk);
	}
		
	{
		hWM_HBKWIN_CFG_PID =
		WM_CreateWindow(0,0,400,240,WM_CF_HIDE | WM_CF_MEMDEV ,0,0); //Add the | WM_CF_MEMDEV flah
		
	

		btn1 			= BUTTON_CreateAsChild(320, 30 , 60, 35,hWM_HBKWIN_CFG_PID, ID_CFG_PID_BTN_SWTITCH_2_CURVE, WM_CF_SHOW);
		btnClear1 = BUTTON_CreateAsChild(320, 75, 60, 35,hWM_HBKWIN_CFG_PID, 203, WM_CF_SHOW);
		BUTTON_SetText(btn1,"PID_Set");
		BUTTON_SetText(btnClear1,"Back");
		
		BUTTON_SetText(btn     ,"Running");
		BUTTON_SetText(btnClear,"PID_Set");
	

		WM_SetCallback(hWM_HBKWIN_CFG_PID, _cbBk_CFG_PID);
	}
	

	
	//!< Create a graph widget
	{
		hGraph = GRAPH_CreateEx(8, 10, 300, 220, hWM_HBKWIN_CURVE, WM_CF_SHOW | WM_CF_CONST_OUTLINE | WM_CF_MEMDEV_ON_REDRAW , 0, 100);
		//GRAPH_DATA_YT_MirrorX(hGraph , 1);
		
		//!< Create a YT_data 
		hData  = GRAPH_DATA_YT_Create(GUI_BLUE, 292,0, 0); // Set the	MaxItemNum to 0	
		hData2 = GRAPH_DATA_YT_Create(GUI_RED,292,0,0);
		
		GRAPH_AttachData(hGraph, hData); //!< Attach the data to graph
		GRAPH_AttachData(hGraph, hData2); //!< Attach the data to graph
		
	}
	
	WM_ShowWindow(hWM_HBKWIN_CURVE);
	WM_HideWindow(hWM_HBKWIN_CFG_PID);
/*
	WM_BringToTop(hWM_HBKWIN);
	WM_BringToBottom(hWM_HBKWIN_CFG_PID);
	WM_MoveTo(hWM_HBKWIN_CFG_PID,400,240);
	WM_ResizeWindow(hWM_HBKWIN_CFG_PID,1,1);
*/	
	#ifdef PWM_TEXT		
			/** PWM Text **/
		{
			/* Edit to display the PWM1 */
				Text_PWM1 = TEXT_CreateEx			 (310, 170, 30, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_TXT_PWM1,
																				 "PMW1");				
				/* Edit to display the PWM2 */
				Text_PWM2 = TEXT_CreateEx			 (310, 190, 30, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_TXT_PWM2,
																				 "PWM2");
					/* Edit to display the PWM3 */
				Text_PWM3 = TEXT_CreateEx			 (310, 210, 30, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_TXT_PWM3,
																				 "PWM3");
		}
#endif
		
#ifdef EDIT_AD		
	 {
				/* Edit to display the AD1 */
				Edit_AD1 = EDIT_CreateEx			 (350, 120, 35, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_AD1,
																				 5);
				EDIT_SetDecMode(Edit_AD1,0,0,4095,0,0);
				EDIT_SetValue(Edit_AD1,0);
				
				/* Edit to display the AD2 */
				Edit_AD2 = EDIT_CreateEx			 (350, 140, 35, 20,hWM_HBKWIN_CURVE, 
																				 WM_CF_SHOW,EDIT_CF_HCENTER | EDIT_CF_VCENTER,ID_CFG_PID_EDT_AD2,
																				 5);
				EDIT_SetDecMode(Edit_AD2,0,0,4095,0,0);
				EDIT_SetValue(Edit_AD2,0);
		 

				EDIT_SetFloatMode(
													Edit_AD1,1.0,
													0.0,99.9,1,/*1 bit after dot*/
													0
													);
				EDIT_SetFloatMode(
													Edit_AD2,0.0,
													0.0,99.9,1,/*1 bit after dot*/
													0
													);
	 }
#endif		

	//!< Graph configuration
	{
		hScale = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);
		GRAPH_SCALE_SetTextColor(hScale,GUI_GREEN);
		GRAPH_SCALE_SetFactor(hScale,0.5);
		GRAPH_SCALE_SetNumDecs(hScale,1);
		GRAPH_AttachScale(hGraph, hScale);
		
		GRAPH_SetGridDistX(hGraph,0); // Hide the X Grid
		GRAPH_SetGridDistY(hGraph,20);	
		GRAPH_SetGridVis(hGraph,1);  //!< Display the Grid
		
		GRAPH_SetBorder(hGraph,30,5,5,5);  //!< Set the frame border 
		
		//GRAPH_SetGridFixedX(hGraph,1);
		//GRAPH_SetVSizeX(hGraph,500);  //加入此会导致死掉 程序卡死在获取此指针上面.
		//GRAPH_SetGridFixedY(hGraph,1);
		GRAPH_SetColor(hGraph,GUI_BLUE,GRAPH_CI_BORDER);
		GRAPH_SetColor(hGraph,GUI_WHITE,GRAPH_CI_BK);
		GRAPH_SetColor(hGraph,GUI_WHITE,GRAPH_CI_FRAME);

	}	
	/* Button Configuration */
	{
	
		BUTTON_SetBkColor(btn,BUTTON_CI_UNPRESSED,GUI_LIGHTBLUE);
		BUTTON_SetBkColor(btn,BUTTON_CI_PRESSED,GUI_RED);
			
		BUTTON_SetFocusColor(btn,GUI_YELLOW);	
	}
			
  while(1) 
	{
		GUI_Exec();	

	 	OSTimeDlyHMSM(0,0,0,50);
//#define DRAWPOINT
#ifdef DRAWPOINT
		
		itoa(usValue, buf, 10);
		BUTTON_SetText(btn,buf);

	//	GRAPH_DATA_YT_AddValue(hData,usValue/20);
#endif		
	}
}
Example #14
0
/*********************************************************************
*
*       _cbDialogColor
*
* Function description
*   Callback routine of DialogColor
*/
static void _cbDialogColor(WM_MESSAGE * pMsg) {
  GUI_COLOR Color;
  WM_HWIN   hDlg;
  WM_HWIN   hItem;
  int       i;
  int       NCode;
  int       Id;

  hDlg = pMsg->hWin;
  Color = 0;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    //
    // Draw RGB values
    //
    GUI_SetColor(_aColorSep[0]);
    GUI_FillRect(180,  60, 199,  79);
    GUI_SetColor(_aColorSep[1] << 8);
    GUI_FillRect(180,  90, 199, 109);
    GUI_SetColor(((U32)_aColorSep[2]) << 16);
    GUI_FillRect(180, 120, 199, 139);
    //
    // Draw resulting color
    //
    GUI_SetColor(_aColorSep[0] | (((U32)_aColorSep[1]) << 8) | (((U32)_aColorSep[2]) << 16));
    GUI_FillRect(205,  60, 285, 139);
    return;
  case WM_INIT_DIALOG:
    _ColorIndex = 0;
    for (i = 0; i < 3; i++) {
      hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i);
      _aColorSep[i] = (_ColorBackGround & (0xff << (i * 8))) >> (i * 8);
      SLIDER_SetRange(hItem, 0, 255);
      SLIDER_SetValue(hItem, _aColorSep[i]);
      //
      // Init EDIT-widgets
      //
      hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i);
      EDIT_SetDecMode(hItem, _aColorSep[i],   0, 255, 0, 0);
    }
    //
    // Init dropdown widgets
    //
    hItem = WM_GetDialogItem(hDlg, GUI_ID_DROPDOWN0);
    DROPDOWN_SetAutoScroll(hItem, 1);
    DROPDOWN_AddString(hItem, "Background");
    DROPDOWN_AddString(hItem, "Grid");
    DROPDOWN_AddString(hItem, "Label");
    DROPDOWN_AddString(hItem, "Temperature 1");
    DROPDOWN_AddString(hItem, "Temperature 2");
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    // Id of widget
    NCode = pMsg->Data.v;               // Notification code
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:      // React only if released
      if (Id == GUI_ID_OK) {            // OK Button
        _SaveCurrentColor();
        _UpdateTextColors(_hDialogMain);
        hItem = WM_GetClientWindow(WM_GetDialogItem(_hDialogMain, ID_TEMPERATURE));
        WM_InvalidateWindow(hItem);
        WM_SetFocus(WM_GetDialogItem(_hDialogMain, ID_TEMPERATURE));
        GUI_SetOrg(0, 0);
      }
      break;
    case WM_NOTIFICATION_SEL_CHANGED:
      _SaveCurrentColor();
      if (Id == GUI_ID_DROPDOWN0) {
        for (i = 0; i < 3; i++) {
          hItem = WM_GetDialogItem(hDlg, GUI_ID_DROPDOWN0);
          _ColorIndex = DROPDOWN_GetSel(hItem);
          hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i);
          switch (_ColorIndex) {
          case 0: Color = _ColorBackGround; break;
          case 1: Color = _ColorGrid;       break;
          case 2: Color = _ColorLabel;      break;
          case 3: Color = _ColorTemp1;      break;
          case 4: Color = _ColorTemp2;      break;
          }
          _aColorSep[i] = (Color & (0xff << (i * 8))) >> (i * 8);
          SLIDER_SetRange(hItem, 0, 255);
          SLIDER_SetValue(hItem, _aColorSep[i]);
          //
          // Init EDIT-widgets
          //
          hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i);
          EDIT_SetDecMode(hItem, _aColorSep[i],   0, 255, 0, 0);
        }
      }
      break;
    case WM_NOTIFICATION_VALUE_CHANGED: // Value has changed
      {
        unsigned Index, v;
        WM_HWIN hSlider, hEdit;
        Index = 0;
        v     = 0;
        if ((Id >= GUI_ID_SLIDER0) && (Id <= GUI_ID_SLIDER2)) {
          Index = Id - GUI_ID_SLIDER0;
          //
          // SLIDER-widget has changed, update EDIT-widget
          //
          hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
          hEdit   = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
          v = SLIDER_GetValue(hSlider);
          EDIT_SetValue(hEdit, v);
        } else if ((Id >= GUI_ID_EDIT0) && (Id <= GUI_ID_EDIT2)) {
          Index = Id - GUI_ID_EDIT0;
          //
          // If EDIT-widget has changed, update SLIDER-widget
          //
          hSlider = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + Index);
          hEdit   = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + Index);
          v = EDIT_GetValue(hEdit);
          SLIDER_SetValue(hSlider, v);
        }
        _aColorSep[Index] = v;
        //
        // At last invalidate dialog client window
        //
        WM_InvalidateWindow(WM_GetClientWindow(hDlg));
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}