⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maindemo.c

📁 本代码包为该GUI LIB在PC上的测试移植. PIC_Graphics 为PIC GUI的源代码目录 Demo 为PIC GUI 测试代码目录 其他的代码和目录均是uCGUI
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
 * Microchip Graphics Library Demo Application
 * This program shows how to use the Graphics Objects Layer.
 *****************************************************************************
 * FileName:        MainDemo.c
 * Dependencies:    MainDemo.h
 * Processor:       PIC24, PIC32
 * Compiler:       	MPLAB C30 V3.00, MPLAB C32
 * Linker:          MPLAB LINK30, MPLAB LINK32
 * Company:         Microchip Technology Incorporated
 *
 * Software License Agreement
 *
 * Copyright ?2008 Microchip Technology Inc.  All rights reserved.
 * Microchip licenses to you the right to use, modify, copy and distribute
 * Software only when embedded on a Microchip microcontroller or digital
 * signal controller, which is integrated into your product or third party
 * product (pursuant to the sublicense terms in the accompanying license
 * agreement).
 *
 * You should refer to the license agreement accompanying this Software
 * for additional information regarding your rights and obligations.
 *
 * SOFTWARE AND DOCUMENTATION ARE PROVIDED 揂S IS?WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
 * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
 * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
 * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION,
 * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
 * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
 * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
 * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY
 * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
 * OR OTHER SIMILAR COSTS.
 *
 * Author               Date        Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Anton Alkhimenok		30/05/07	...
 * Paolo Tamayo         09/20/07    Round buttons demo screen is added
 * Paolo Tamayo			10/05/07    Modified navigation, added Meter, Dial,
 *									RTCC demos
 * Paolo Tamayo			01/21/08    Updated for v1.1
 * Sean Justice         02/07/08    PIC32 support
 *****************************************************************************/

#include "MainDemo.h"
#include "MainDemoStrings.h"

//#include <signal.h>
//#include <sys/time.h>
//#include <windows.h>
//#include <Mmsystem.h>
//typedef void TIMECALLBACK (UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
extern unsigned int timeSetEvent(unsigned int uDelay, unsigned int uResolution, void * fptc,  unsigned long  dwUser, unsigned int fuEvent);

/////////////////////////////////////////////////////////////////////////////
//                              OBJECT'S IDs
/////////////////////////////////////////////////////////////////////////////
#define ID_WINDOW1      10

#define ID_BUTTON1      11
#define ID_BUTTON2      12
#define ID_BUTTON3      13
#define ID_BUTTON4      14
#define ID_BUTTON5      15
#define ID_BUTTON6      16
#define ID_BUTTON7      17

#define ID_BUTTON_BACK  18
#define ID_BUTTON_NEXT  19

#define ID_CHECKBOX1    20
#define ID_CHECKBOX2    21
#define ID_CHECKBOX3    22
#define ID_CHECKBOX4    23
#define ID_CHECKBOX5    24

#define ID_RADIOBUTTON1 30
#define ID_RADIOBUTTON2 31
#define ID_RADIOBUTTON3 32
#define ID_RADIOBUTTON4 33
#define ID_RADIOBUTTON5 34
#define ID_RADIOBUTTON6 35
#define ID_RADIOBUTTON7 36
#define ID_RADIOBUTTON8 37

#define ID_SLIDER1      40
#define ID_SLIDER2      41
#define ID_SLIDER3      42

#define ID_GROUPBOX1    50
#define ID_GROUPBOX2    51
#define ID_STATICTEXT1  52
#define ID_STATICTEXT2  53
#define ID_STATICTEXT3  54

#define ID_PICTURE1     55

#define ID_PROGRESSBAR1 60
#define ID_CUSTOM1      70

#define ID_LISTBOX1     80
#define ID_LISTBOX2     81
#define ID_LISTBOX3     82
#define ID_EDITBOX1     83

#define ID_CALL         91
#define ID_STOPCALL		92
#define ID_HOLD			93
#define ID_BACKSPACE    94
#define ID_POUND		95
#define ID_ASTERISK		96
#define ID_KEYPAD       100	/* uses 100 to 110 for phone key pad demo */


#define ID_ROUNDDIAL    120
#define ID_METER1	    130
#define ID_METER2	    131

#define ID_BUTTONHR_P   150
#define ID_BUTTONHR_M   151
#define ID_BUTTONMN_P   152
#define ID_BUTTONMN_M   153
#define ID_BUTTONSC_P   154
#define ID_BUTTONSC_M   155

#define ID_BUTTON_DATE_UP 180
#define ID_BUTTON_DATE_DN 181

#define ID_BUTTON_MO    186
#define ID_BUTTON_DY    187
#define ID_BUTTON_YR    188
#define ID_BUTTON_RET   189

#define ID_EB_MONTH		200
#define ID_EB_DAY		201
#define ID_EB_YEAR		202

#define ID_EB_HOUR      205
#define ID_EB_MINUTE    206
#define ID_EB_SECOND    207


/////////////////////////////////////////////////////////////////////////////
//                            LOCAL PROTOTYPES
/////////////////////////////////////////////////////////////////////////////
void StartScreen();								// draws intro screen
void CreatePage(XCHAR *pText); 					// creates the navigation buttons and window for each screen

void CreateButtons();                           // creates buttons demo screen
WORD MsgButtons(WORD objMsg, OBJ_HEADER* pObj); // processes messages for buttons demo screen

void CreateRoundButtons();                      // creates rounded buttons demo screen
WORD MsgRoundButtons(WORD objMsg, OBJ_HEADER* pObj); // processes messages for rounded buttons demo screen

void CreateCheckBoxes();                        // creates checkboxes demo screen
WORD MsgCheckBoxes(WORD objMsg, OBJ_HEADER* pObj); // processes messages for checkboxes demo screen

void CreateRadioButtons();                      // creates radio buttons demo screen
WORD MsgRadioButtons(WORD objMsg, OBJ_HEADER* pObj); // processes messages for radio buttons demo screen

void CreateStaticText();                        // creates static text demo screen
WORD MsgStaticText(WORD objMsg, OBJ_HEADER* pObj); // processes messages for static text demo screen

void CreatePicture();                        	// creates picture demo screen
WORD MsgPicture(WORD objMsg, OBJ_HEADER* pObj); // processes messages for picture demo screen

void CreateSlider();                        	// creates slider demo screen
void DrawSliderCursor(WORD color);          	// draws cursor for slider demo screen
WORD MsgSlider(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg); // processes messages for slider demo screen

void CreateProgressBar();                   	// creates progress bar demo screen
WORD MsgProgressBar(WORD objMsg, OBJ_HEADER* pObj); //  processes messages for progress bar demo screen

void CreateSignature();                        	// creates signature demo screen
WORD PanelSignature();                        	// draws box for the signature
WORD MsgSignature(WORD objMsg, OBJ_HEADER* pObj,  GOL_MSG* pMsg); // processes messages for signature demo screen

void CreatePotentiometer();                 	// scrolling graph demo screen
WORD PanelPotentiometer();                  	// draws box for the scrolling graph
void GraphPotentiometer();                  	// draws scrolling graph graph
WORD GetPotSamples(WORD number);            	// adds sample from ADC potentiometer channel into temporary buffer
                                            	// returns zero if samples number in the buffer is less than defined by parameter
WORD MsgPotentiometer(WORD objMsg, OBJ_HEADER* pObj); // processes messages for ECG demo screen

void CreateECG();                           	// creates ECG demo screen
WORD PanelECG();                            	// draws box for the ECG
void GraphECG();                            	// draws ECG graph
WORD GetECGSamples(WORD number);            	// adds sample from FLASH (can be any source) into temporary buffer
                                            	// returns zero if samples number in the buffer is less than defined by parameter
WORD MsgECG(WORD objMsg, OBJ_HEADER* pObj); 	// processes messages for ECG demo screen

void CreateCustomControl();                     // creates custom control demo screen
WORD MsgCustomControl(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg); //  processes messages for custom control demo screen

void CreateListBox();                        	// creates list box demo screen
WORD MsgListBox(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg); //  processes messages for list box demo screen

void CreateEditBox();                        	// creates edit box demo screen
WORD MsgEditBox(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg); //  processes messages for edit box demo screen

void CreateDateTime();							// creates date time demo screen
WORD MsgDateTime(WORD objMsg, OBJ_HEADER* pObj);//  processes messages for date and time demo screen
void UpdateRTCCDates(LISTBOX* pLb); 			// update the date edit boxes
WORD MsgSetDate(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg); // processes messages for setting dates
void ShowPullDownMenu();						// create objects for pull down menu and draw
WORD RemovePullDownMenu();						// removes pop out pull down menu from screen
void updateDateTimeEb();						// update edit boxes with current date and time values


void CreateMeter();								// creates meter demo screen
void UpdateMeter();
WORD MsgMeter(WORD objMsg, OBJ_HEADER* pObj); 	// processes messages for meter demo screen

void CreateDial();								// creates dial demo screen
WORD MsgDial(WORD objMsg, OBJ_HEADER* pObj); 	// processes messages for dial demo screen

void ErrorTrap(XCHAR* message);              	// outputs text message on screen and stop execution

void TickInit(void);                        	// starts tick counter

void CreatePullDown();
WORD MsgPullDown(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg); // processes screen pull down menu


/////////////////////////////////////////////////////////////////////////////
//                            IMAGES USED
/////////////////////////////////////////////////////////////////////////////

// internal flash image
extern const BITMAP_FLASH intro;
extern const BITMAP_FLASH mchpLogo;
extern const BITMAP_FLASH bulbon;
extern const BITMAP_FLASH bulboff;
extern const BITMAP_FLASH gradientButton;
extern const BITMAP_FLASH Engine1;
extern const BITMAP_FLASH Engine2;
extern const BITMAP_FLASH Engine3;
extern const BITMAP_FLASH Engine4;
extern const BITMAP_FLASH arrowUp;
extern const BITMAP_FLASH arrowDown;
extern const BITMAP_FLASH redphone;
extern const BITMAP_FLASH greenphone;
extern const BITMAP_FLASH mchpIcon0;
extern const BITMAP_FLASH mchpIcon;




/////////////////////////////////////////////////////////////////////////////
//                             FONTS USED
/////////////////////////////////////////////////////////////////////////////
extern const FONT_FLASH GOLFontDefault; 	// default GOL font
extern const FONT_FLASH GOLMediumFont; 		// medium font
extern const FONT_FLASH GOLSmallFont; 		// small font

/////////////////////////////////////////////////////////////////////////////
//                            COLORS USED
/////////////////////////////////////////////////////////////////////////////
#define GRAY20             RGB565CONVERT( 51,  51,  51)
#define GRAY40             RGB565CONVERT(102, 102, 102)
#define GRAY80             RGB565CONVERT(204, 204, 204)
#define GRAY90             RGB565CONVERT(229, 229, 229)
#define GRAY95             RGB565CONVERT(242, 242, 242)

#define RED4 			   RGB565CONVERT(139,   0,   0)
#define FIREBRICK1 		   RGB565CONVERT(255,  48,  48)
#define DARKGREEN          RGB565CONVERT(  0, 100,   0)
#define PALEGREEN          RGB565CONVERT(152, 251, 152)
#define LIGHTYELLOW        RGB565CONVERT(238, 221, 130)
#define GOLD               RGB565CONVERT(255, 215,   0)
#define DARKORANGE		   RGB565CONVERT(255, 140,   0)

/////////////////////////////////////////////////////////////////////////////
//                            DEMO STATES
/////////////////////////////////////////////////////////////////////////////
typedef enum {
    CREATE_BUTTONS = 0,
    DISPLAY_BUTTONS,
    CREATE_CHECKBOXES,
    DISPLAY_CHECKBOXES,
    CREATE_RADIOBUTTONS,
    DISPLAY_RADIOBUTTONS,
    CREATE_STATICTEXT,
    DISPLAY_STATICTEXT,
    CREATE_PICTURE,
    DISPLAY_PICTURE,
    CREATE_SLIDER,
    DISPLAY_SLIDER,
    CURSOR_DRAW_SLIDER,
    CREATE_PROGRESSBAR,
    DISPLAY_PROGRESSBAR,
    CREATE_LISTBOX,
    DISPLAY_LISTBOX,
    CREATE_EDITBOX,
    DISPLAY_EDITBOX,
    CREATE_METER,
    DISPLAY_METER,
    CREATE_DIAL,
    DISPLAY_DIAL,
    CREATE_CUSTOMCONTROL,
    DISPLAY_CUSTOMCONTROL,
    CREATE_SIGNATURE,
    DISPLAY_SIGNATURE,
    BOX_DRAW_SIGNATURE,
    CREATE_POT,
    DISPLAY_POT,
    BOX_DRAW_POT,
    CREATE_ECG,
    DISPLAY_ECG,
    BOX_DRAW_ECG,
    CREATE_PULLDOWN,
    DISPLAY_PULLDOWN,

    // these states are for time and date settings 0xF3xx is used here as a
    // state ID to check when date and time are to be updated or not.
    CREATE_DATETIME = 0xF300,		// creates the date and time setting menu
    DISPLAY_DATETIME = 0xF301,		// displays the menu for the date and time setting
    DISPLAY_DATE_PDMENU = 0xF302,	// displays the pulldown menu to set one of the date items (month, day or year)
    SHOW_DATE_PDMENU = 0xF303,		// creates the pulldown menu to set one of the date items (month, day or year)
    HIDE_DATE_PDMENU = 0xF304		// hides the pulldown menu to set one of the date items (month, day or year)

} SCREEN_STATES;

/////////////////////////////////////////////////////////////////////////////
//                       GLOBAL VARIABLES FOR DEMO
/////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -