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

📄 maindemo.c

📁 本代码包为该GUI LIB在PC上的测试移植. PIC_Graphics 为PIC GUI的源代码目录 Demo 为PIC GUI 测试代码目录 其他的代码和目录均是uCGUI
💻 C
📖 第 1 页 / 共 5 页
字号:
SCREEN_STATES  screenState = CREATE_BUTTONS; // current state of main demo state mashine

GOL_SCHEME*    altScheme;					 // alternative style scheme
GOL_SCHEME*    alt2Scheme;					 // alternative 2 style scheme
GOL_SCHEME*    alt3Scheme;					 // alternative 3 style scheme
GOL_SCHEME*    alt4Scheme;					 // alternative 4 style scheme
GOL_SCHEME*	   timeScheme;
GOL_SCHEME*    meterScheme;					 // meter scheme
GOL_SCHEME*    navScheme;		 			 // style scheme for the navigation
GOL_SCHEME*    redScheme;                    // alternative red style scheme
GOL_SCHEME*    greenScheme;                  // alternative green style scheme
GOL_SCHEME*    yellowScheme;                 // alternative yellow style scheme

OBJ_HEADER*	   pNavList;					 // pointer to navigation list

volatile DWORD tick = 0;                     // tick counter

char           animate;                      // switch to control animation for picture demo
OBJ_HEADER*	   pGenObj;						 // pointer to a general purpose object
PICTURE*       pPicture;                     // pointer to picture object for picture demo

PROGRESSBAR*   pProgressBar;                 // pointer to progress bar object for progress bar demo

SLIDER*		   pSlider;						 // pointer to the slider controlling the animation speed

// GLOBAL DEFINITIONS AND VARIABLES FOR SLIDER DEMO
#define CUR_BAR_SIZE    3                    // half size of center point for cursor
#define CUR_BRD_LEFT    67+CUR_BAR_SIZE      // cursor area left border
#define CUR_BRD_RIGHT   253-CUR_BAR_SIZE     // cursor area right border
#define CUR_BRD_TOP     52+CUR_BAR_SIZE      // cursor area top border
#define CUR_BRD_BOTTOM  184-CUR_BAR_SIZE     // cursor area bottom border

SHORT x;                                     // cursor X position
SHORT y;                                     // cursor Y position

// GLOBAL DEFINITIONS AND VARIABLES FOR ECG DEMO
// Array of ECG points to emulate ECG input
const SHORT ecgPoints[] ={
0x0068,0x0068,0x0068,0x0068,0x0068,0x0069,0x0068,0x0068,0x0068,0x0067,0x0067,0x0066,0x0066,0x0068,0x0068,0x0068,0x0067,0x0066,0x0066,0x0066,0x0066,0x0065,0x0065,0x0065,0x0065,0x0065,0x0065,0x0064,0x0063,0x0063,0x0063,0x0064,
0x0064,0x0065,0x0065,0x0064,0x0064,0x0064,0x0064,0x0065,0x0066,0x0066,0x0062,0x0061,0x0060,0x0059,0x0055,0x004a,0x0049,0x0047,0x0047,0x0048,0x004a,0x004f,0x0053,0x0056,0x005c,0x005d,0x0060,0x0061,0x0062,0x0064,0x0064,0x0064,
0x0065,0x0066,0x0067,0x0068,0x0068,0x0069,0x0070,0x0070,0x0055,0x0030,0x0004,0x0028,0x005d,0x006c,0x0069,0x0069,0x0069,0x0069,0x0068,0x0067,0x0065,0x0063,0x0061,0x005e,0x005e,0x0062,0x0064,0x0066,0x0067,0x0068,0x0068,0x006a
};
// Scanning window size
#define ECG_WINDOW_SIZE 8
// ECG data circular buffer size
#define ECG_BUFFER_SIZE 256
// ECG data circular buffer
SHORT  ecgBuffer[ECG_BUFFER_SIZE];

// GLOBAL DEFINITIONS AND VARIABLES FOR PLOTTING POTENTIOMETER DEMO
// Graph shift
#define POT_MOVE_DELTA  2
// Potentiometer circular buffer size
#define POT_BUFFER_SIZE 320
// Potentiometer data circular buffer
SHORT  potBuffer[POT_BUFFER_SIZE];

// Temporary buffer for graph demo screens
SHORT tempBuffer[10];

// Variables for the pulldown menus
SHORT pDwnLeft, pDwnTop, pDwnRight, pDwnBottom;

// Variables for date and time

SCREEN_STATES prevState = CREATE_BUTTONS;	// used to mark state where time setting was called
OBJ_HEADER *pListSaved;			// temporary storage for object list
WORD 		DateItemID;			// ID of date item being modified (ID_EB_MONTH(DAY)(YEAR))

XCHAR 		dateTimeStr[26];		// string variable for date and time display


/////////////////////////////////////////////////////////////////////////////
//                                  MAIN
/////////////////////////////////////////////////////////////////////////////

#if 0
int main(void)
{
	GOL_MSG msg;       			// GOL message structure to interact with GOL

/////////////////////////////////////////////////////////////////////////////
// ADC Explorer 16 Development Board Errata (work around 2)
// RB15 should be output
/////////////////////////////////////////////////////////////////////////////
	LATBbits.LATB15 = 0;
	TRISBbits.TRISB15 = 0;
/////////////////////////////////////////////////////////////////////////////

#ifdef __PIC32MX__
    INTEnableSystemMultiVectoredInt();
    SYSTEMConfigPerformance(GetSystemClock());
#endif

    EEPROMInit();   			// Initialize EEPROM
    TickInit();     			// Start tick counter
    GOLInit();      			// Initialize graphics library and crete default style scheme for GOL
    BeepInit();     			// Initialize beeper
    TouchInit();    			// Initialize touch screen
    RTCCInit(); 				// Setup the RTCC
    RTCCProcessEvents();


    // If S3 button on Explorer 16 board is pressed calibrate touch screen
    if(PORTDbits.RD6 == 0){
        TouchCalibration();
        TouchStoreCalibration();
    }

    // If it's a new board (EEPROM_VERSION byte is not programed) calibrate touch screen
    if(GRAPHICS_LIBRARY_VERSION != EEPROMReadWord(EEPROM_VERSION)){
        TouchCalibration();
        TouchStoreCalibration();
        EEPROMWriteWord(GRAPHICS_LIBRARY_VERSION,EEPROM_VERSION);
    }

    // Load touch screen calibration parameters from EEPROM
    TouchLoadCalibration();

    StartScreen();  // Show intro screen and wait for touch

	// create the alternate schemes
	navScheme = GOLCreateScheme(); 		// alternative scheme for the navigate buttons
    altScheme = GOLCreateScheme(); 		// create alternative 1 style scheme
    alt2Scheme = GOLCreateScheme(); 	// create alternative 2 style scheme
    alt3Scheme = GOLCreateScheme(); 	// create alternative 3 style scheme
    alt4Scheme = GOLCreateScheme(); 	// create alternative 4 style scheme
    timeScheme = GOLCreateScheme();
    meterScheme = GOLCreateScheme(); 	// create meter scheme
    redScheme = GOLCreateScheme();   	// create red style scheme
    greenScheme = GOLCreateScheme(); 	// create green style scheme
    yellowScheme = GOLCreateScheme(); 	// create yellow style scheme

#if (GRAPHICS_PICTAIL_VERSION == 1)
	/* for Microtips display */
	altScheme->Color0 = RGB565CONVERT(0x4C, 0x7E, 0xFF);
    altScheme->Color1 = RGB565CONVERT(0xFF, 0xCB, 0x3C);
	altScheme->EmbossDkColor = RGB565CONVERT(0x1E, 0x00, 0xE5);
	altScheme->EmbossLtColor = RGB565CONVERT(0xA9, 0xDB, 0xEF);
    altScheme->ColorDisabled = RGB565CONVERT(0xD4, 0xE1, 0xF7);
    altScheme->TextColor1 = RGB565CONVERT(0x4C, 0x7E, 0xFF);
    altScheme->TextColor0 = RGB565CONVERT(0xFF, 0xCB, 0x3C);
    altScheme->TextColorDisabled = RGB565CONVERT(0xB8, 0xB9, 0xBC);
#elif (GRAPHICS_PICTAIL_VERSION == 2)
	/* for Truly display */
	altScheme->Color0 = RGB565CONVERT(0x4C, 0x8E, 0xFF);
    altScheme->Color1 = RGB565CONVERT(0xFF, 0xBB, 0x4C);
	altScheme->EmbossDkColor = RGB565CONVERT(0x1E, 0x00, 0xE5);
	altScheme->EmbossLtColor = RGB565CONVERT(0xA9, 0xDB, 0xEF);
    altScheme->ColorDisabled = RGB565CONVERT(0xD4, 0xE1, 0xF7);

    altScheme->TextColor1 = BRIGHTBLUE;
    altScheme->TextColor0 = RGB565CONVERT(0xFF, 0xBB, 0x4C);
    altScheme->TextColorDisabled = RGB565CONVERT(0xB8, 0xB9, 0xBC);
#endif // GRAPHICS_PICTAIL_VERSION

    alt2Scheme->TextColor1 = BRIGHTRED;
    alt2Scheme->TextColor0 = BRIGHTBLUE;
	alt2Scheme->pFont = (void*)&GOLMediumFont;

    alt3Scheme->Color0 = LIGHTBLUE;
    alt3Scheme->Color1 = BRIGHTGREEN;
    alt3Scheme->TextColor0 = BLACK;
    alt3Scheme->TextColor1 = WHITE;
	alt3Scheme->pFont = &GOLMediumFont;

    redScheme->Color0 = RGB565CONVERT(0xCC, 0x00, 0x00);
    redScheme->Color1 = BRIGHTRED;
    redScheme->EmbossDkColor = RED4;
    redScheme->EmbossLtColor = FIREBRICK1;
    redScheme->TextColor0 = RGB565CONVERT(0xC8, 0xD5, 0x85);
    redScheme->TextColor1 = BLACK;

    greenScheme->Color0 = RGB565CONVERT(0x23, 0x9E, 0x0A);
    greenScheme->Color1 = BRIGHTGREEN;
    greenScheme->EmbossDkColor = DARKGREEN;
    greenScheme->EmbossLtColor = PALEGREEN;
    greenScheme->TextColor0 = RGB565CONVERT(0xDF, 0xAC, 0x83);
    greenScheme->TextColor1 = BLACK;

    yellowScheme->Color0 = BRIGHTYELLOW;
    yellowScheme->Color1 = YELLOW;
    yellowScheme->EmbossDkColor = RGB565CONVERT(0xFF, 0x94, 0x4C);
    yellowScheme->EmbossLtColor = RGB565CONVERT(0xFD, 0xFF, 0xB2);
    yellowScheme->TextColor0 = RGB565CONVERT(0xAF, 0x34, 0xF3);
    yellowScheme->TextColor1 = RED;

    meterScheme->Color0 = BLACK;
    meterScheme->Color1 = WHITE;
    meterScheme->TextColor0 = BRIGHTBLUE;
    meterScheme->TextColor1 = WHITE;
	meterScheme->pFont = &GOLSmallFont;
    meterScheme->EmbossDkColor = GRAY20;
    meterScheme->EmbossLtColor = GRAY80;

    while(1)
    {
        if(GOLDraw())
        {             // Draw GOL objects
            // Drawing is done here, process messages
            TouchGetMsg(&msg);     // Get message from touch screen
            GOLMsg(&msg);          // Process message
            SideButtonsMsg(&msg);  // Get message from side buttons
            GOLMsg(&msg);          // Process message
        }
    }
}
#else

int init_mainDemo( void )
{
	//EEPROMInit();   			// Initialize EEPROM
    TickInit();     			// Start tick counter
    GOLInit();      			// Initialize graphics library and crete default style scheme for GOL
    BeepInit();     			// Initialize beeper
    TouchInit();    			// Initialize touch screen
    RTCCInit(); 				// Setup the RTCC
    //RTCCProcessEvents();

    // If S3 button on Explorer 16 board is pressed calibrate touch screen
//    if(PORTDbits.RD6 == 0)
//    {
//        TouchCalibration();
//        TouchStoreCalibration();
//    }
//
//    // If it's a new board (EEPROM_VERSION byte is not programed) calibrate touch screen
//    if(GRAPHICS_LIBRARY_VERSION != EEPROMReadWord(EEPROM_VERSION))
//    {
//        TouchCalibration();
//        TouchStoreCalibration();
//        //EEPROMWriteWord(GRAPHICS_LIBRARY_VERSION,EEPROM_VERSION);
//    }
//
//    // Load touch screen calibration parameters from EEPROM
//    TouchLoadCalibration();

    StartScreen();  // Show intro screen and wait for touch

	// create the alternate schemes
	navScheme = GOLCreateScheme(); 		// alternative scheme for the navigate buttons
    altScheme = GOLCreateScheme(); 		// create alternative 1 style scheme
    alt2Scheme = GOLCreateScheme(); 	// create alternative 2 style scheme
    alt3Scheme = GOLCreateScheme(); 	// create alternative 3 style scheme
    alt4Scheme = GOLCreateScheme(); 	// create alternative 4 style scheme
    timeScheme = GOLCreateScheme();
    meterScheme = GOLCreateScheme(); 	// create meter scheme
    redScheme = GOLCreateScheme();   	// create red style scheme
    greenScheme = GOLCreateScheme(); 	// create green style scheme
    yellowScheme = GOLCreateScheme(); 	// create yellow style scheme

    alt2Scheme->TextColor1 = BRIGHTRED;
    alt2Scheme->TextColor0 = BRIGHTBLUE;
	alt2Scheme->pFont = &GOLMediumFont;

    alt3Scheme->Color0 = LIGHTBLUE;
    alt3Scheme->Color1 = BRIGHTGREEN;
    alt3Scheme->TextColor0 = BLACK;
    alt3Scheme->TextColor1 = WHITE;
//	alt3Scheme->pFont = &GOLMediumFont;
	alt3Scheme->pFont = (void*)&GOLMediumFont;

    alt4Scheme->Color0 = LIGHTBLUE;
    alt4Scheme->Color1 = BRIGHTGREEN;
    alt4Scheme->TextColor0 = BLACK;
    alt4Scheme->TextColor1 = WHITE;
	alt4Scheme->pFont = (void*)&GOLSmallFont;

    redScheme->Color0 = RGB565CONVERT(0xCC, 0x00, 0x00);
    redScheme->Color1 = BRIGHTRED;
    redScheme->EmbossDkColor = RED4;
    redScheme->EmbossLtColor = FIREBRICK1;
    redScheme->TextColor0 = RGB565CONVERT(0xC8, 0xD5, 0x85);
    redScheme->TextColor1 = BLACK;

    greenScheme->Color0 = RGB565CONVERT(0x23, 0x9E, 0x0A);
    greenScheme->Color1 = BRIGHTGREEN;
    greenScheme->EmbossDkColor = DARKGREEN;
    greenScheme->EmbossLtColor = PALEGREEN;
    greenScheme->TextColor0 = RGB565CONVERT(0xDF, 0xAC, 0x83);
    greenScheme->TextColor1 = BLACK;

    yellowScheme->Color0 = BRIGHTYELLOW;
    yellowScheme->Color1 = YELLOW;
    yellowScheme->EmbossDkColor = RGB565CONVERT(0xFF, 0x94, 0x4C);
    yellowScheme->EmbossLtColor = RGB565CONVERT(0xFD, 0xFF, 0xB2);
    yellowScheme->TextColor0 = RGB565CONVERT(0xAF, 0x34, 0xF3);
    yellowScheme->TextColor1 = RED;

    timeScheme->Color0 = BLACK;
    timeScheme->Color1 = WHITE;
    timeScheme->TextColor0 = BRIGHTBLUE;
    timeScheme->TextColor1 = WHITE;
    timeScheme->EmbossDkColor = GRAY20;
    timeScheme->EmbossLtColor = GRAY80;
    timeScheme->pFont = (void*)&GOLSmallFont;

    meterScheme->Color0 = BLACK;
    meterScheme->Color1 = WHITE;
    meterScheme->TextColor0 = BRIGHTBLUE;
    meterScheme->TextColor1 = WHITE;
    meterScheme->EmbossDkColor = GRAY20;
    meterScheme->EmbossLtColor = GRAY80;
    meterScheme->pFont = (void*)&GOLSmallFont;

	return 0;
}

#include <stdio.h> // for printf

int mainDemo( GOL_MSG * pMsg )
{
	if(GOLDraw())           // Draw GOL objects
    {
        // Drawing is done here, process messages
        TouchGetMsg(pMsg);     // Get message from touch screen
        GOLMsg(pMsg);          // Process message
        SideButtonsMsg(pMsg);  // Get message from side buttons
        GOLMsg(pMsg);          // Process message
        //printf("%s:%s():%d\n", __FILE__, __FUNCTION__, __LINE__);
    }

    return 0;
}

#endif

⌨️ 快捷键说明

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