|
【TI首届低功耗设计大赛】智能手表之无线控制智能家居
[复制链接]
void GUI_Buletooth( void )
{
WM_HWIN hButton0;
WM_HWIN hButton1;
WM_HWIN hButton2;
WM_HWIN hText;
USART_printf(USART1, "a");//给msp430传输指令,建立连接,允许传输数据
WinPara.hBuletooth = WM_CreateWindowAsChild(0, 0,
WinPara.xSizeWin, WinPara.ySizeWin,
WinPara.hWinMain,
WM_CF_SHOW | WM_CF_STAYONTOP,
_cbBuletooth, 0);
hDlg = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, WinPara.hBuletooth, 0, 0);
hButton0 = BUTTON_CreateEx(10, 280,
40, 20,
WinPara.hBuletooth,
WM_CF_SHOW | WM_CF_HASTRANS,
0, GUI_ID_BUTTON3);
BUTTON_SetText(hButton0, "Exit");
BUTTON_SetFont(hButton0, GUI_FONT_13B_1);
BUTTON_SetBkColor(hButton0, BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetBkColor(hButton0, BUTTON_CI_PRESSED,GUI_BLUE);
hButton1 = BUTTON_CreateEx(130, 205,
100, 40,
WinPara.hBuletooth,
WM_CF_SHOW | WM_CF_HASTRANS,
0, GUI_ID_BUTTON1);
BUTTON_SetBitmapEx(hButton1,BUTTON_BI_UNPRESSED,&bmOFF,2,2);
BUTTON_SetBitmapEx(hButton1,BUTTON_BI_PRESSED,&bmON,2,2);
/* BUTTON_SetText(hButton1, "ON|OFF");
BUTTON_SetFont(hButton1, GUI_FONT_20B_ASCII);
BUTTON_SetBkColor(hButton1, BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetBkColor(hButton1, BUTTON_CI_PRESSED,GUI_BLUE);*/
hButton2 = BUTTON_CreateEx(130, 255,
100, 40,
WinPara.hBuletooth,
WM_CF_SHOW | WM_CF_HASTRANS,
0, GUI_ID_BUTTON2);
BUTTON_SetBitmapEx(hButton2,BUTTON_BI_UNPRESSED,&bmOFF,2,2);
BUTTON_SetBitmapEx(hButton2,BUTTON_BI_PRESSED,&bmON,2,2);
/* BUTTON_SetText(hButton2, "ON|OFF");
BUTTON_SetFont(hButton2, GUI_FONT_20B_ASCII);
BUTTON_SetBkColor(hButton2, BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetBkColor(hButton2, BUTTON_CI_PRESSED,GUI_BLUE);*/
hText = TEXT_CreateEx(0, 235,
60, 30,
WinPara.hBuletooth,
WM_CF_SHOW,
TEXT_CF_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT7,
"Status:");
TEXT_SetFont(hText,GUI_FONT_20_ASCII);
TEXT_SetTextColor(hText, GUI_BLUE);
hText = TEXT_CreateEx(60, 220,
70, 20,
WinPara.hBuletooth,
WM_CF_SHOW,
TEXT_CF_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT8,
"Fan OFF");
TEXT_SetTextColor(hText, GUI_YELLOW);
hText = TEXT_CreateEx(60, 265,
70, 20,
WinPara.hBuletooth,
WM_CF_SHOW,
TEXT_CF_HCENTER|TEXT_CF_VCENTER,
GUI_ID_TEXT9,
"Light OFF");
TEXT_SetTextColor(hText, GUI_YELLOW);
}
/*********************************************************************
*回调函数
* _cbCallback
*
* Purpose:
* Callback function of the dialog
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
int i, NCode, Id, Value;
WM_HWIN hDlg, hItem;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
/* Add graphs */
for (i = 0; i < GUI_COUNTOF(_aColor); i++) {
_aValue = rand() % 180;
_ahData = GRAPH_DATA_YT_Create(_aColor, 500, 0, 0);
GRAPH_AttachData(hItem, _ahData);
}
/* Set graph attributes */
GRAPH_SetGridDistY(hItem, 25);
GRAPH_SetGridVis(hItem, 1);
GRAPH_SetGridFixedX(hItem, 1);
GRAPH_SetUserDraw(hItem, _UserDraw);
/* Create and add vertical scale */
_hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 200);
GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
GRAPH_AttachScale(hItem, _hScaleV);
GRAPH_SCALE_SetFactor(_hScaleV, 0.4f);
GRAPH_SCALE_SetNumDecs(_hScaleV,1);
/* Create and add horizontal scale */
_hScaleH = GRAPH_SCALE_Create(105, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 80);
GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
GRAPH_AttachScale(hItem, _hScaleH);
GRAPH_SCALE_SetPos(_hScaleH,105);
/* Init check boxes */
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK2);
CHECKBOX_SetText(hItem, "L");
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK3);
CHECKBOX_SetText(hItem, "T");
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK4);
CHECKBOX_SetText(hItem, "R");
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK5);
CHECKBOX_SetText(hItem, "B");
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0);
CHECKBOX_SetText(hItem, "Stop");
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK1);
CHECKBOX_SetText(hItem, "Grid");
CHECKBOX_SetState(hItem, 1);
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK6);
CHECKBOX_SetText(hItem, "HScroll");
CHECKBOX_SetState(hItem, 1);
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK7);
CHECKBOX_SetText(hItem, "VScroll");
hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK8);
CHECKBOX_SetText(hItem, "MirrorX");
/* Init slider widgets */
hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0);
SLIDER_SetRange(hItem, 0, 10);
SLIDER_SetValue(hItem, 5);
SLIDER_SetNumTicks(hItem, 6);
hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER1);
SLIDER_SetRange(hItem, 0, 20);
SLIDER_SetValue(hItem, 5);
SLIDER_SetNumTicks(hItem, 6);
/* Init radio widget */
hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
RADIO_SetText(hItem, "3D", 0);
RADIO_SetText(hItem, "flat", 1);
RADIO_SetText(hItem, "-", 2);
/* Init button widget */
hItem = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
WM_SetStayOnTop(hItem, 1);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
switch (Id) {
case GUI_ID_BUTTON0:
_ToggleFullScreenMode(hDlg);
break;
}
break;
case WM_NOTIFICATION_VALUE_CHANGED:
switch (Id) {
case GUI_ID_CHECK0:
/* Toggle stop mode */
_Stop ^= 1;
break;
case GUI_ID_CHECK1:
/* Toggle grid */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
GRAPH_SetGridVis(hItem, CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK1)));
break;
case GUI_ID_CHECK2:
case GUI_ID_CHECK3:
case GUI_ID_CHECK4:
case GUI_ID_CHECK5:
/* Toggle border */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
GRAPH_SetBorder(hItem,
CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK2)) * 40,
CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK3)) * 5,
CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK4)) * 5,
CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK5)) * 5);
break;
case GUI_ID_SLIDER0:
/* Set horizontal grid spacing */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
Value = SLIDER_GetValue(pMsg->hWinSrc) * 10;
GRAPH_SetGridDistX(hItem, Value);
GRAPH_SCALE_SetTickDist(_hScaleH, Value);
break;
case GUI_ID_SLIDER1:
/* Set vertical grid spacing */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
Value = SLIDER_GetValue(pMsg->hWinSrc) * 5;
GRAPH_SetGridDistY(hItem, Value);
GRAPH_SCALE_SetTickDist(_hScaleV, Value);
break;
case GUI_ID_RADIO0:
/* Set the widget effect */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
switch (RADIO_GetValue(pMsg->hWinSrc)) {
case 0:
WIDGET_SetEffect(hItem, &WIDGET_Effect_3D);
break;
case 1:
WIDGET_SetEffect(hItem, &WIDGET_Effect_Simple);
break;
case 2:
WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
break;
}
break;
case GUI_ID_CHECK6:
/* Toggle horizontal scroll bar */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK6))) {
GRAPH_SetVSizeX(hItem, 500);
} else {
GRAPH_SetVSizeX(hItem, 0);
}
break;
case GUI_ID_CHECK7:
/* Toggle vertical scroll bar */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK7))) {
GRAPH_SetVSizeY(hItem, 300);
} else {
GRAPH_SetVSizeY(hItem, 0);
}
break;
case GUI_ID_CHECK8:
/* Toggle alignment */
hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0);
for (i = 0; i < GUI_COUNTOF(_aColor); i++) {
if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK8))) {
GRAPH_DATA_YT_SetAlign(_ahData, GRAPH_ALIGN_LEFT);
GRAPH_DATA_YT_MirrorX (_ahData, 1);
} else {
GRAPH_DATA_YT_SetAlign(_ahData, GRAPH_ALIGN_RIGHT);
GRAPH_DATA_YT_MirrorX (_ahData, 0);
}
}
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
|
|