void UseKeyBoard(WM_MESSAGE * pMsg,int id_lenth,int id_base,int id,EWorkState front_state) { float mid; if(!keyboard_h.use_now) { keyboard_h.use_now = 1; keyboard_h.work_state = front_state; WidgetLock(pMsg->hWin,LOCK,id_lenth,id_base,id); KeyBoard_Win(&keyboard_h); WidgetLock(pMsg->hWin,UNLOCK,id_lenth,id_base,id); if(front_state == CHINESE){ EDIT_SetFont(WM_GetDialogItem(pMsg->hWin, id), &GUI_FontHZ_SongTi_16); } else if((front_state == ENGLISH_S)||(front_state == ENGLISH_B)){ EDIT_SetFont(WM_GetDialogItem(pMsg->hWin, id), &GUI_Font16_ASCII); }else if(front_state == SFLOAT){ EDIT_SetFloatMode(WM_GetDialogItem(pMsg->hWin, id),0.0,-9000,9999,1,0); } if(front_state != SFLOAT) { EDIT_SetText(WM_GetDialogItem(pMsg->hWin, id), keyboard_h.res_ch_data_head); }else{ EDIT_SetFloatValue(WM_GetDialogItem(pMsg->hWin, id),atof(keyboard_h.res_ch_data_head)); } keyboard_h.use_now = 0; } }
/********************************************************************* * * _cbCallback * * Function description * Callback function of the dialog */ void Main_cbCallback (WM_MESSAGE* pMsg) { int NCode, Id; WM_HWIN hDlg; WM_HWIN hItem; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: OSC_InitDialog(pMsg); hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); g_Disp.hItemGraph_OSC = hItem; // // Set graph attributes // MemDisp(200, 200); GRAPH_SetGridDistY(hItem, 25); GRAPH_SetGridVis(hItem, 1); GRAPH_SetGridFixedX(hItem, 1); GRAPH_SetUserDraw(hItem, Main_UserDraw); // // Create and add vertical scale // g_hScaleV = GRAPH_SCALE_Create(SCALE_V_Pos, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25); GRAPH_SCALE_SetTextColor(g_hScaleV, GUI_YELLOW); GRAPH_AttachScale(hItem, g_hScaleV); // // Create and add horizontal scale // g_hScaleH = GRAPH_SCALE_Create(SCALE_H_Pos, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50); GRAPH_SCALE_SetTextColor(g_hScaleH, GUI_DARKGREEN); GRAPH_AttachScale(hItem, g_hScaleH); case WM_PAINT: OSC_PaintDialog(pMsg); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hDlg, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hDlg, 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(hDlg, 0); break; case GUI_ID_CANCEL: if (NCode == WM_NOTIFICATION_RELEASED) GUI_EndDialog(hDlg, 0); break; case __ZoomPlusID: //Zoom+ if (NCode == WM_NOTIFICATION_RELEASED) g_OSCInfo.Time_rat = Safe_Return (g_OSCInfo.Time_rat + 1, eReslt_rat_Begin, eReslt_rat_End) ; break; case __ZoomSubID: //Zoom- if (NCode == WM_NOTIFICATION_RELEASED) g_OSCInfo.Time_rat = Safe_Return (g_OSCInfo.Time_rat - 1, eReslt_rat_Begin, eReslt_rat_End) ; break; case __AmpliPlusID: //Zoom+ if (NCode == WM_NOTIFICATION_RELEASED) g_OSCInfo.Ampli_rat = Safe_Return (g_OSCInfo.Ampli_rat + 1, eReslt_rat_Begin, eReslt_rat_End) ; break; case __AmpliSubID: //Zoom- if (NCode == WM_NOTIFICATION_RELEASED) g_OSCInfo.Ampli_rat = Safe_Return (g_OSCInfo.Ampli_rat - 1, eReslt_rat_Begin, eReslt_rat_End) ; break; case __MeasureID: //Measure if (NCode == WM_NOTIFICATION_RELEASED) if (g_GUICon.MeasureState == eClose) {//打开Measure CloseAllBSPDLG(); WindowSwitch(g_Disp.BSP_MersureDlg, eOpen); g_GUICon.MeasureState = eOpen; } else {//关闭Measure CloseAllBSPDLG(); } break; case __NumpadID: //开关Singal控制面板 if (NCode == WM_NOTIFICATION_RELEASED) if (g_GUICon.NumpadState == eClose) {//打开NumPad CloseAllBSPDLG(); WindowSwitch(g_Disp.BSP_NumpadDlg, eOpen); g_GUICon.NumpadState = eOpen; } else {//关闭NumPad CloseAllBSPDLG(); } break; case __StopID: //Stop if (NCode == WM_NOTIFICATION_RELEASED) { if (g_GUICon.GraphDispState == eClose) {//开始 g_GUICon.GraphDispState = eOpen; BUTTON_SetText(g_GraphButton.Stop.Handle, "Stop"); BUTTON_SetBkColor(g_GraphButton.Stop.Handle, BUTTON_CI_PRESSED, GUI_BLUE); BUTTON_SetBkColor(g_GraphButton.Stop.Handle, BUTTON_CI_UNPRESSED, GUI_BLUE); } else {//暂停 g_GUICon.GraphDispState = eClose; BUTTON_SetText(g_GraphButton.Stop.Handle, "Continue"); BUTTON_SetBkColor(g_GraphButton.Stop.Handle, BUTTON_CI_PRESSED, GUI_RED); BUTTON_SetBkColor(g_GraphButton.Stop.Handle, BUTTON_CI_UNPRESSED, GUI_RED); } } break; case __InputModeID: if (NCode == WM_NOTIFICATION_RELEASED) { if (g_UserInput.InputMode == eAD9834DutyInput) {//改为输入频率 g_UserInput.InputMode = eAD9834FreqInput; BUTTON_SetText(g_GraphButton.InputMode.Handle, "Freq Input"); EDIT_SetDecMode(g_UserInput.Numpad.EdirorHandle, g_Device.AD9834Freq, 1000, 1000000, 0, GUI_EDIT_SUPPRESS_LEADING_ZEROES); BUTTON_SetBkColor(g_GraphButton.InputMode.Handle, BUTTON_CI_PRESSED, GUI_BLUE); BUTTON_SetBkColor(g_GraphButton.InputMode.Handle, BUTTON_CI_UNPRESSED, GUI_BLUE); } else {//改为输入占空比 g_UserInput.InputMode = eAD9834DutyInput; BUTTON_SetText(g_GraphButton.InputMode.Handle, "Duty Input"); EDIT_SetFloatMode(g_UserInput.Numpad.EdirorHandle, g_Device.AD9834Duty, 0, 100, 2, GUI_EDIT_SUPPRESS_LEADING_ZEROES); BUTTON_SetBkColor(g_GraphButton.InputMode.Handle, BUTTON_CI_PRESSED, GUI_RED); BUTTON_SetBkColor(g_GraphButton.InputMode.Handle, BUTTON_CI_UNPRESSED, GUI_RED); } } break; } break; default: WM_DefaultProc(pMsg); } }
/***************************** Peremaljovuvannja paneli comunicaciji *****************************/ void redraw_panel_Modbus(void) { EDIT_SetText(hEdit, _aBitmapItem_Comm[COMM_MODBUS_ID].pExplanation[sel_language]); char title[256]; title[0] = '\0'; strcat_mal(title, (char *)Modbus_panel_title.ptitle[sel_language]); unsigned int error_data_1 = _CHECK_SET_BIT(diagnostyka, ERROR_SETTINGS_BS_EEPROM_BIT) | _CHECK_SET_BIT(diagnostyka, ERROR_SETTINGS_BS_EEPROM_EMPTY_BIT); if (error_data_1) { //Nalashtuvannja nemaje u tablyci nalashtuvan strcat_mal(title, (char *)ERROR_MES.ptitle[sel_language]); FRAMEWIN_SetText(Modbus_FrameWin, title); FRAMEWIN_SetBarColor(Modbus_FrameWin, 1, GUI_RED); FRAMEWIN_SetTextColor(Modbus_FrameWin, GUI_YELLOW); EDIT_SetText(Modbus_v[0], ""); DROPDOWN_SetSel(Modbus_v[1], 0); DROPDOWN_SetSel(Modbus_v[2], 0); DROPDOWN_SetSel(Modbus_v[3], 0); EDIT_SetText(Modbus_v[4], ""); } else { //Nalashtuvannja realno je u tablyci nalashtuvan if (current_ekran.edition != 0) { strcat_mal(title, (char *)MODE.ptitle[sel_language]); if (current_ekran.edition != 1) { //Помічаємо, що дані змінені strcat_mal(title, "*"); } } FRAMEWIN_SetText(Modbus_FrameWin, title); if (current_ekran.edition == 0) { FRAMEWIN_SetBarColor(Modbus_FrameWin, 1, GUI_GREEN); FRAMEWIN_SetTextColor(Modbus_FrameWin, GUI_BLUE); } else { FRAMEWIN_SetBarColor(Modbus_FrameWin, 1, GUI_YELLOW); FRAMEWIN_SetTextColor(Modbus_FrameWin, GUI_RED); } AuxCfgTbl1Dsc *point_1; if (current_ekran.edition == 0) point_1 = &eeprom_bs_settings_tbl; else point_1 = &edit_settings_1; __info_data info_data; U8 Flags; EDIT_GetUserData(Modbus_v[0], &info_data, sizeof(__info_data)); Flags = GUI_EDIT_SUPPRESS_LEADING_ZEROES; if (current_ekran.edition != 0) { if ((info_data.extra_param & FLAG_SIGNED_FATA) != 0) Flags = GUI_EDIT_SIGNED; else Flags = 0; } EDIT_SetFloatMode(Modbus_v[0], point_1->RS_comm_addres, info_data.min, info_data.max, info_data.shift, Flags); int value_int = point_1->RS_comm_addres; if ((value_int >= KOEF_ADDRESS_MIN) && (value_int <= KOEF_ADDRESS_MAX)) { EDIT_SetTextColor(Modbus_v[0], EDIT_CI_DISABLED, GUI_BLACK); EDIT_SetTextColor(Modbus_v[0], EDIT_CI_ENABLED, GUI_BLACK); } else { EDIT_SetTextColor(Modbus_v[0], EDIT_CI_DISABLED, GUI_RED); EDIT_SetTextColor(Modbus_v[0], EDIT_CI_ENABLED, GUI_RED); } DROPDOWN_SetSel(Modbus_v[1], point_1->chSpeed + 1); DROPDOWN_SetSel(Modbus_v[2], point_1->chParityCheck + 1); DROPDOWN_SetSel(Modbus_v[3], point_1->chAmtStopBit - 1 + 1); EDIT_GetUserData(Modbus_v[4], &info_data, sizeof(__info_data)); Flags = GUI_EDIT_SUPPRESS_LEADING_ZEROES; if (current_ekran.edition != 0) { if ((info_data.extra_param & FLAG_SIGNED_FATA) != 0) Flags = GUI_EDIT_SIGNED; else Flags = 0; } EDIT_SetFloatMode(Modbus_v[4], (float)point_1->chTimeOut_RS/10, info_data.min, info_data.max, info_data.shift, Flags); value_int = point_1->chTimeOut_RS; if ((value_int >= VALUE_TIME_OUT_1_INTERFACE_MIN) && (value_int <= VALUE_TIME_OUT_1_INTERFACE_MAX)) { EDIT_SetTextColor(Modbus_v[4], EDIT_CI_DISABLED, GUI_BLACK); EDIT_SetTextColor(Modbus_v[4], EDIT_CI_ENABLED, GUI_BLACK); } else { EDIT_SetTextColor(Modbus_v[4], EDIT_CI_DISABLED, GUI_RED); EDIT_SetTextColor(Modbus_v[4], EDIT_CI_ENABLED, GUI_RED); } } WM_HWIN FocussedWindow = (Modbus_v[0 + current_ekran.index_position_1]); WM_SetFocus(FocussedWindow); }
/***************************** Initializacija paneli comunikaciji *****************************/ void Modbus_panel_show(void) { if (Modbus_FrameWin == WM_UNATTACHED) { //Stvorjujemo FrameWin Modbus_FrameWin = FRAMEWIN_CreateEx(X0, Y0, X_SIZE, Y_SIZE, 0, WM_CF_HIDE, 0, ID_MODBUS_FRAMEWIN, Modbus_panel_title.ptitle[sel_language], _cbProtection_FrameWin); FRAMEWIN_SetFont(Modbus_FrameWin, &GUI_FontArialBold14_8_Unicode); FRAMEWIN_SetTextAlign(Modbus_FrameWin, GUI_TA_HCENTER); FRAMEWIN_SetBarColor(Modbus_FrameWin, 1, GUI_GREEN); FRAMEWIN_SetBarColor(Modbus_FrameWin, 0, GUI_LIGHTGRAY); FRAMEWIN_SetTextColor(Modbus_FrameWin, GUI_BLUE); #define COL_1_X 5 #define ROW_1_Y 10 #define HIGHT_Y 20 #define SHIFT_Y (ROW_1_Y + HIGHT_Y) #define WIDTH_X_T 165 #define WIDTH_X_V 60 #define SHIFT_X1 (WIDTH_X_T + 10) #define SHIFT_X2 (SHIFT_X1 + WIDTH_X_V + 10) ScrollBar_Modbus = SCROLLBAR_CreateAttached(WM_GetClientWindow(Modbus_FrameWin), SCROLLBAR_CF_VERTICAL); SCROLLBAR_SetNumItems(ScrollBar_Modbus, MAX_NUMBER_ITEMS_MODBUS*SHIFT_Y); SCROLLBAR_SetPageSize(ScrollBar_Modbus, 6*SHIFT_Y); //Address Modbus_t[0] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 0*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_ADDRESS_TITLE, Modbus_title[0].ptitle[sel_language]); TEXT_SetFont(Modbus_t[0], &GUI_FontArialStandard14_8_Unicode); Modbus_v[0] = EDIT_CreateUser(COL_1_X + SHIFT_X1, ROW_1_Y + 0*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, 0, ID_MODBUS_ADDRESS_VALUE, 3, sizeof(__info_data)); EDIT_SetFont(Modbus_v[0], &GUI_FontArialStandard14_8_Unicode); __info_data info_data; int shift = 0, max = KOEF_ADDRESS_MAX, min = 0; info_data.extra_param = 0; info_data.shift = shift; float _shift = 0.0f; for (int rozrjad = 0; rozrjad < shift; rozrjad++) { _shift /= 10.0f; _shift += 0.9f; } // int max_tmp = max; // float _max = 10; // while ( abs(max_tmp /= 10) >= 1) _max *= 10.0f; // if (max > 0) // { // _max = _max - 1 + _shift; // } // else if (max < 0) // { // _max = -(_max / 10); // } // else _max = 0; // info_data.max = _max; float _max = 255; //maksymalne odnobajtne chyslo, bo adresu ob'javleno jak typ char info_data.max = _max; int min_tmp = min; float _min = 10; while ( abs(min_tmp /= 10) >= 1) _min *= 10.0f; if (min > 0) { _min = (_min / 10); } else if (min < 0) { _min = -(_min - 1 + _shift); } else _min = 0; info_data.min = _min; EDIT_SetUserData(Modbus_v[0], &info_data, sizeof(__info_data)); EDIT_SetFloatMode(Modbus_v[0], 0, _min, _max, shift, GUI_EDIT_SUPPRESS_LEADING_ZEROES); //Baud Rate Modbus_t[1] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 1*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_BAUD_RATE_TITLE, Modbus_title[1].ptitle[sel_language]); TEXT_SetFont(Modbus_t[1], &GUI_FontArialStandard14_8_Unicode); Modbus_v[1] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 1*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_BAUD_RATE_VALUE); DROPDOWN_SetFont(Modbus_v[1], &GUI_FontArialStandard14_8_Unicode); DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_UNSEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_SEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[1],DROPDOWN_CI_SELFOCUS, GUI_BLUE); DROPDOWN_AddString(Modbus_v[1], ""); for (int i = 0; i < 7; i++) DROPDOWN_AddString(Modbus_v[1], Baud_rate_title[i]); //Parity Modbus_t[2] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 2*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_PARITY_TITLE, Modbus_title[2].ptitle[sel_language]); TEXT_SetFont(Modbus_t[2], &GUI_FontArialStandard14_8_Unicode); Modbus_v[2] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 2*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_PARITY_VALUE); DROPDOWN_SetFont(Modbus_v[2], &GUI_FontArialStandard14_8_Unicode); DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_UNSEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_SEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[2],DROPDOWN_CI_SELFOCUS, GUI_BLUE); DROPDOWN_AddString(Modbus_v[2], ""); for (int i = 0; i < 3; i++) DROPDOWN_AddString(Modbus_v[2], Parity_title[i].ptitle[sel_language]); //Stop bits Modbus_t[3] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 3*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_STOP_BITS_TITLE, Modbus_title[3].ptitle[sel_language]); TEXT_SetFont(Modbus_t[3], &GUI_FontArialStandard14_8_Unicode); Modbus_v[3] = DROPDOWN_CreateEx(COL_1_X + SHIFT_X1, ROW_1_Y + 3*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, DROPDOWN_CF_AUTOSCROLLBAR, ID_MODBUS_STOP_BITS_VALUE); DROPDOWN_SetFont(Modbus_v[3], &GUI_FontArialStandard14_8_Unicode); DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_UNSEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_SEL, GUI_GRAY); DROPDOWN_SetBkColor(Modbus_v[3],DROPDOWN_CI_SELFOCUS, GUI_BLUE); DROPDOWN_AddString(Modbus_v[3], ""); for (int i = 0; i < 2; i++) DROPDOWN_AddString(Modbus_v[3], Stop_bits_title[i]); //Time-Out Modbus_t[4] = TEXT_CreateEx(COL_1_X, ROW_1_Y + 4*SHIFT_Y, WIDTH_X_T, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_TIMEOUT_TITLE, Modbus_title[4].ptitle[sel_language]); TEXT_SetFont(Modbus_t[4], &GUI_FontArialStandard14_8_Unicode); Modbus_v[4] = EDIT_CreateUser(COL_1_X + SHIFT_X1, ROW_1_Y + 4*SHIFT_Y, WIDTH_X_V, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, 0, ID_MODBUS_TIMEOUT_VALUE, 5, sizeof(__info_data)); EDIT_SetFont(Modbus_v[4], &GUI_FontArialStandard14_8_Unicode); shift = 1; max = VALUE_TIME_OUT_1_INTERFACE_MAX/10; min = 0; info_data.extra_param = 0; info_data.shift = shift; _shift = 0.0f; for (int rozrjad = 0; rozrjad < shift; rozrjad++) { _shift /= 10.0f; _shift += 0.9f; } int max_tmp = max; _max = 10; while ( abs(max_tmp /= 10) >= 1) _max *= 10.0f; if (max > 0) { _max = _max - 1 + _shift; } else if (max < 0) { _max = -(_max / 10); } else _max = 0; info_data.max = _max; min_tmp = min; _min = 10; while ( abs(min_tmp /= 10) >= 1) _min *= 10.0f; if (min > 0) { _min = (_min / 10); } else if (min < 0) { _min = -(_min - 1 + _shift); } else _min = 0; info_data.min = _min; EDIT_SetUserData(Modbus_v[4], &info_data, sizeof(__info_data)); EDIT_SetFloatMode(Modbus_v[4], 0, _min, _max, shift, GUI_EDIT_SUPPRESS_LEADING_ZEROES); Modbus_d = TEXT_CreateEx(COL_1_X + SHIFT_X2 , ROW_1_Y + 4*SHIFT_Y, 40, HIGHT_Y, WM_GetClientWindow(Modbus_FrameWin), WM_CF_SHOW, TEXT_CF_LEFT | TEXT_CF_VCENTER, ID_MODBUS_TIMEOUT_DIMENSION, Modbus_Timeout_dimention.ptitle[sel_language]); TEXT_SetFont(Modbus_d, &GUI_FontArialStandard14_8_Unicode); #undef COL_1_X #undef ROW_1_Y #undef HIGHT_Y #undef SHIFT_Y #undef WIDTH_X_T #undef WIDTH_X_V #undef SHIFT_X1 #undef SHIFT_X2 } WM_BringToTop(Modbus_FrameWin); WM_ShowWindow(Modbus_FrameWin); }
/********************************************************************* * * 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 } }
/********************************************************************* * * _cbBk_CFG_PID */ static void _cbBk_CFG_PID(WM_MESSAGE * pMsg) { static unsigned int GirdFlag = 0; int NCode, Id; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_DispStringAt("PID Configeration", 50, 10); // GUIDEMO_DrawBk(1); break; case WM_TOUCH: GirdFlag++; GRAPH_SetGridVis(hGraph,GirdFlag%3); //!< Display the if touch the screen 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 == ID_CFG_PID_BTN_SWTITCH_2_CURVE) /* ID =210 btn Button */ { PID_CFG_Flag = 1; //WM_DeleteWindow(hGraph); GPIO_ResetBits(GPIOF,GPIO_Pin_8); hWN_Dialog_PID_Frame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbBk_Frame, hWM_HBKWIN_CFG_PID, 0, 0); BUTTON_SetText(btn1,"Parameter"); //FRAMEWIN_SetClientColor(WM_GetDialogItem(hWN_Dialog_PID_Frame,0),GUI_LIGHTBLUE); EDIT_SetMaxLen(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0),7); EDIT_SetMaxLen(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1),7); EDIT_SetMaxLen(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2),7); EDIT_SetMaxLen(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),7); EDIT_SetMaxLen(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),7); WM_SetFocus(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT)); //!< Set the Edit to Float mode { EDIT_SetFloatMode( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0),1.0, 0.0,999.999,3,/*Three bit after dot*/ 0 ); EDIT_SetFloatMode( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1),0.0, 0.0,999.999,3,/*Three bit after dot*/ 0 ); EDIT_SetFloatMode( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2),0.0, 0.0,999.999,3,/*Three bit after dot*/ 0 ); EDIT_SetFloatMode( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),0.0, 0.0,999.999,3,/*Three bit after dot*/ 0 ); EDIT_SetFloatMode( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4),0.0, 0.0,100.000,3,/*Three bit after dot*/ 0 ); } } if (Id == 203) /* ID =210 btn Button */ { BUTTON_SetText(btnClear1,"Back"); GPIO_SetBits(GPIOF,GPIO_Pin_8); WM_ShowWindow(hWM_HBKWIN_CURVE); WM_HideWindow(hWM_HBKWIN_CFG_PID); } break; default: { } } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE *pMsg) { WM_HWIN hItem; WM_HWIN const hEdit = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); int NCode; int Id; float fre; int tab = 0; static int ratio[] = { 1, 1000, 1000000}; static const char *sel[] = {"Hz", "kHz", "MHz"}; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_PAINT: WM_SetFocus(hEdit); break; case WM_INIT_DIALOG: // // Initialization of 'MeasureSet' // hItem = pMsg->hWin; FRAMEWIN_SetText(hItem, "Set Frequency"); FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetText(hItem, ""); EDIT_SetFont(hItem, GUI_FONT_20B_1); EDIT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER); fre = ptrDDS->GetFrequency(); while(fre > 999.99) { fre /= 1000; tab++; } EDIT_SetFloatMode(hItem, fre, 0.00, 999.99, 2, GUI_EDIT_NORMAL); // // Initialization of 'Button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetFont(hItem, GUI_FONT_16_1); BUTTON_SetText(hItem, "Set"); // // Initialization of 'Radio' // hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); RADIO_SetFont(hItem, GUI_FONT_20_1); RADIO_SetText(hItem, sel[0], 0); RADIO_SetText(hItem, sel[1], 1); RADIO_SetText(hItem, sel[2], 2); RADIO_SetValue(hItem, tab); // // Initialization of 'Button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetFont(hItem, GUI_FONT_16_1); BUTTON_SetText(hItem, "Cancel"); // // Initialization of 'btn1' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2); BUTTON_SetText(hItem, "1"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn2' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3); BUTTON_SetText(hItem, "2"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn3' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4); BUTTON_SetText(hItem, "3"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn4' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_5); BUTTON_SetText(hItem, "4"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn5' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_6); BUTTON_SetText(hItem, "5"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn6' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_7); BUTTON_SetText(hItem, "6"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn7' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_8); BUTTON_SetText(hItem, "7"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn8' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_9); BUTTON_SetText(hItem, "8"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn9' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_10); BUTTON_SetText(hItem, "9"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btn0' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_11); BUTTON_SetText(hItem, "0"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btnBS' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_12); BUTTON_SetText(hItem, "<--"); BUTTON_SetFocussable(hItem, 0); // // Initialization of 'btnC' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_13); BUTTON_SetText(hItem, "-->"); BUTTON_SetFocussable(hItem, 0); // USER START (Optionally insert additional code for further widget initialization) // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_EDIT_0: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_0: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) fre = EDIT_GetFloatValue(hEdit); tab = RADIO_GetValue(WM_GetDialogItem(pMsg->hWin, ID_RADIO_0)); ptrDDS->SetFrequency(fre * ratio[tab]); GUI_EndDialog(pMsg->hWin, 0); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_RADIO_0: // Notifications sent by 'Radio' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) GUI_EndDialog(pMsg->hWin, 0); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_2: // Notifications sent by 'btn1' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '1'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_3: // Notifications sent by 'btn2' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '2'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_4: // Notifications sent by 'btn3' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '3'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_5: // Notifications sent by 'btn4' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '4'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_6: // Notifications sent by 'btn5' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '5'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_7: // Notifications sent by 'btn6' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '6'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_8: // Notifications sent by 'btn7' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '7'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_9: // Notifications sent by 'btn8' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '8'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_10: // Notifications sent by 'btn9' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '9'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_11: // Notifications sent by 'btn0' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, '0'); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_12: // Notifications sent by 'btnBS' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, GUI_KEY_LEFT); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_13: // Notifications sent by 'btnC' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) EDIT_AddKey(hEdit, GUI_KEY_RIGHT); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }