Paso 3: Escribir un programa buttons.c
Buttons.c
El buttons() se llama en principal antes de bucle infinito! GUI_Exec() proporciona alojarse en la función buttons(). Si desea crear más de windows sólo añadir un indicador global.
#include <stdio.h>
#include "buttons.h" #include "stm32f429i_discovery.h" #include "WM.h"
/********************************************************************* * * _cbMainWindow * * Callback function of the WELCOME dialog */ static void _cbMainWindow(WM_MESSAGE * pMsg) { WM_HWIN hItem; // Universal handler for all widgets int Id; // Id of source widget int NCode = pMsg -> Data.v; // Code of message WM_HWIN hDlg = pMsg -> hWin;
switch (pMsg->MsgId) { case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(hDlg, ID_W1_BUTTON0); // LIGHT ON button BUTTON_SetFont(hItem, GUI_FONT_24_ASCII); // set button text size
hItem = WM_GetDialogItem(hDlg, ID_W1_BUTTON1); // LIGHT OFF button BUTTON_SetFont(hItem, GUI_FONT_24_ASCII); // set button text size
FRAMEWIN_SetTitleHeight(hDlg, 30); // set title bar height FRAMEWIN_SetTextColor(hDlg, GUI_DARKRED); // set framewin text color FRAMEWIN_SetFont(hDlg, GUI_FONT_20_ASCII); // set framewin text size FRAMEWIN_SetTextAlign(hDlg, GUI_TA_CENTER); // set framewin text align
WM_SetDesktopColor(GUI_DARKRED); // background color
break;
case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg -> hWinSrc);
interruptor (Id) {caso ID_W1_BUTTON0: interruptor (NCode) {caso WM_NOTIFICATION_RELEASED: //button lanzado reacción {BSP_LED_On(LED3); / / leds en BSP_LED_On(LED4);} switch (Id) { case ID_W1_BUTTON0: switch (NCode) { case WM_NOTIFICATION_RELEASED: //button released reaction { BSP_LED_On(LED3); // leds on BSP_LED_On(LED4); } break; } break; } case ID_W1_BUTTON1: switch (NCode) { case WM_NOTIFICATION_RELEASED: //button released reaction { BSP_LED_Off(LED3); // leds off BSP_LED_Off(LED4); } break; } break; } break;
caso ID_W1_BUTTON1: interruptor (NCode) {caso WM_NOTIFICATION_RELEASED: //button lanzado reacción {BSP_LED_Off(LED3); / / leds apagados BSP_LED_Off(LED4);} default: WM_DefaultProc(pMsg); break; } } } /********************************************************************* * * WelcomeButtons(); * * Main Window of this file */ void Buttons(void) { BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX); // create buttons with default skin FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX); // create framewin with default skin GUI_CreateDialogBox(_MainWindow, GUI_COUNTOF(_MainWindow), &_cbMainWindow, WM_HBKWIN, 0, 0); } while (1) { GUI_Exec(); } }
default: WM_DefaultProc(pMsg);