Example #1
0
/************************************************************************
 Function: void CreateAnimation(void)

 Overview: Creates the animation screen.

 Input: none

 Output: none
************************************************************************/
void CreateAnimation(void)
{
    SHORT   j, height, endPoint;

    // free memory for the objects in the previous linked list and start new list
    GOLFree();

    SetColor(SCREEN_BACKGROUND_COLOR);
    ClearDevice();

    // draw the band of lines with increasing thickness background of the demo
    height = 13;
    endPoint = GetMaxY() - 35;
    SetColor(RGB565CONVERT(0x4C, 0x8E, 0xFF));
    for(j = 2; j <= endPoint; j += (height + 6))
    {
        WAIT_UNTIL_FINISH(Bar(0, j, GetMaxX(), j + height));
        if(height <= 0)
            height = 0;
        else
            height -= 1;
    }

    pPicture = PictCreate
               (
                   ID_PICTURE1,                        // ID
                   PICTURE_XINDENT,
                   PICTURE_YINDENT,
                   PICTURE_XINDENT + PICTURE_WIDTH - 1,
                   PICTURE_YINDENT + PICTURE_HEIGHT - 1,
                   PICT_DRAW,                          // will be dislayed, has frame
                   2,                                  // scale factor is x1
                   (void *) &Engine1,                  // bitmap
                   altScheme
               );                                      // default GOL scheme
    pMeter = MtrCreate
             (
                 ID_METER2,
                 (2 * PICTURE_XINDENT + PICTURE_WIDTH),
                 PICTURE_YINDENT - 20,
                 (2 * (PICTURE_XINDENT + PICTURE_WIDTH)),
                 PICTURE_YINDENT + PICTURE_HEIGHT + 20,
                 MTR_DRAW | MTR_RING | MTR_ACCURACY, // draw normal meter object
                 MAX_METER_VALUE,                    // set initial value
                 0,
                 MAX_METER_VALUE,                    // set range
                 (void *) &GOLFontDefault,           // Title font to be used
                 (void *) &GOLMediumFont,            // Value font to be used
                 MeterStr,                           //
                 meterScheme
             );  // alternative GOL scheme

    //pMeter->pTitleFont = (void*)&GOLFontDefault;
    //pMeter->pValueFont = (void*)&GOLMediumFont;
    // create the demo navigation/control buttons
    CreateCtrlButtons(ExitStr, ScaleStr, LeftArrowStr, RightArrowStr);
}
Example #2
0
/************************************************************************
 Function: void DisplayErrorInfo(void)
                                                                       
 Overview: Display the error information when decoding an unsupported 
 		   image or thumb drive was removed when decoding.
 		                                          
 Input: none
                                                                       
 Output: none
************************************************************************/
void DisplayErrorInfo(void)
{
    WORD    TextX, TextY, TextHeight;
    SetFont((void *) &GOLFontDefault);
    TextHeight = GetTextHeight((void *) &GOLFontDefault);

    SetColor(WHITE);
    ClearDevice();

    SetColor(BRIGHTRED);
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)JPEGUnsupportedStr, (void *) &GOLFontDefault)) / 2;
    TextY = (IMG_SCREEN_HEIGHT - 3 * TextHeight) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, TextY, (XCHAR *)JPEGUnsupportedStr));
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)JPEGImageStr, (void *) &GOLFontDefault)) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, TextY + TextHeight, (XCHAR *)JPEGImageStr));
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)JPEGFormatStr, (void *) &GOLFontDefault)) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, TextY + 2 * TextHeight, (XCHAR *)JPEGFormatStr));

    DelayMs(800);
}
Example #3
0
/************************************************************************
 Function: void CreateMultiFontsDemo(void)
                                                                       
 Overview: Creates the Multi-Font demo screen.
  		                                         
 Input: none
                                                                       
 Output: none
************************************************************************/
void CreateMultiFontsDemo(void)
{
    SHORT           i, j;

    // we need this since Static cannot have an uninitialized pointer to text
    // plus we need the static text area but we are only using it as a place
    // holder for the text that we will overwrite on the static text area
    static XCHAR    spaceChar[2] = {0x20,0};

    GOLFree();                          // free memory for the objects in the previous linked list and start new list
    SetColor(SCREEN_BACKGROUND_COLOR);
    ClearDevice();

    // draw the small squares
    SetColor(RGB565CONVERT(0x4C, 0x8E, 0xFF));
    for(j = 5; j <= GetMaxY(); j += 16)
    {
        for(i = 5; i <= GetMaxX(); i += 16)
        {
            WAIT_UNTIL_FINISH(Bar(i, j, i + 3, j + 3));
        }
    }

    InitHWData();

    FontScheme2 = GOLCreateScheme();    // create alternative style scheme
    FontScheme2->pFont = pHWData->pHWFont;
    FontScheme2->Color0 = RGB565CONVERT(0xFF, 0xBB, 0x4C);
    FontScheme2->Color1 = RGB565CONVERT(0xFF, 0xBB, 0x4C);

    StCreate
    (
        ID_STXT,
        STXXPOS,
        STXYPOS,
        STXXPOS + STXWIDTH,
        STXYPOS + STXHEIGHT,
        ST_DRAW | ST_FRAME,
        (void *) &spaceChar,
        FontScheme2
    );

    CreateCtrlButtons(ExitStr, LeftArrowStr, NULL, RightArrowStr);
}
Example #4
0
/************************************************************************
 Function: WORD  DrawBackgroundColorPalette()
 
 Overview: Function that draws a palette on a the screen.
 		    		    		    
 Input: None

 Output: none
************************************************************************/
WORD DrawBackgroundColorPalette()
{

    // This function updates the global color variables: RedPos, GreenPos and BluePos
    // or draws the RGB color palette.
    // 		task			meaning
    //		DRAWPALCOLOR	create the palette
    //		GETPALCOLOR		update the global color based on the x position given
    // When drawing the RGB color palette. The colors changes in the X direction. Y is not
    // affecting the colors. Here's how the colors changes:

    /*
		|------------------------------   RED   --------------------------------| 		
		|	inc->	|	MAX		|	MAX		|	dec->	|	0		|	0		|
		|------------------------------  GREEN ---------------------------------| 		
		|	0		|	0		|	inc->	|	MAX		|	MAX		|	dec->	|
		|------------------------------   BLUE  --------------------------------| 		
		|	MAX		|	dec->	|	0		|	0		|	inc->	|	MAX		|	
	
		The light and dark (intensity) effects are also added into the equations. 
		Controls are applied to the global variables RedMax, GreenMax, BlueMax for
		light effect and RedMin, GreenMin and BlueMin for dark effects.
	*/
    WORD    red, green, blue, trueXPos, x;

    for(x = 0; x <= GetMaxX(); x++)
    {
        CalculatePaletteColor(&red, &green, &blue, x);

        //trueXPos = x + PLTXPOS;
        trueXPos = x;

        SetColor(RGB565CONVERT((BYTE) red, (BYTE) green, (BYTE) blue));
        WAIT_UNTIL_FINISH(Bar(trueXPos, 0, trueXPos, GetMaxY()));
    }

    return (1);
}
Example #5
0
/************************************************************************
 Function: void AnimateText(BYTE mov)
                                                                       
 Overview: Routine to move or animate the text.
  		                                         
 Input: mov - number of pixels the text will be moved
                                                                       
 Output: none
************************************************************************/
void AnimateText(BYTE mov)
{
    static SHORT    xPos = STXXPOS, yPos = STXYPOS;
    static SHORT    x, y;
    SHORT           width;
    SHORT           height;

    SHORT           newX, newY, oldX, oldY;
    XCHAR           NewChar, *pString;

    // set the clipping region
    SetClip(CLIP_ENABLE);
    SetClipRgn(STXXPOS + 2, STXYPOS + 2, STXXPOS + STXWIDTH - 2, STXYPOS + STXHEIGHT - 2);

    // set the font
    SetFont(pHWData->pHWFont);

    // calculate string width & height	
    width = GetTextWidth((XCHAR *)pHWData->pHWStr, pHWData->pHWFont);
    height = GetTextHeight(pHWData->pHWFont);

    //-----------------------------------------------------------------
    // interlace the erasing and printing of characters
    // check first if we need to move in the positive or negative direction
    if((xPos + width) >= (STXXPOS + STXWIDTH))
        x = -(mov);
    if(xPos <= (STXXPOS))
        x = (mov);

    if((yPos + height) >= (STXYPOS + STXHEIGHT))
        y = -(mov);
    if(yPos <= (STXYPOS))
        y = (mov);

    pString = pHWData->pHWStr;
    oldX = xPos;
    oldY = yPos;
    newX = xPos + x;
    newY = yPos + y;
    while((XCHAR)15 < (XCHAR)(NewChar = *pString++))
    {

        // remove the old position of the character
        SetColor(FontScheme2->CommonBkColor);
        MoveTo(oldX, oldY);
        WAIT_UNTIL_FINISH(OutChar(NewChar));
        oldX = GetX();
        oldY = GetY();

        // display the character in the new position
        SetColor(BRIGHTBLUE);
        MoveTo(newX, newY);
        WAIT_UNTIL_FINISH(OutChar(NewChar));
        newX = GetX();
        newY = GetY();
    }

    xPos += x;
    yPos += y;

    // disable the clipping
    SetClip(CLIP_DISABLE);
}
Example #6
0
    /************************************************************************
 Function: WORD CreateJPEGDemo(void)
                                                                       
 Overview: Creates the JPEG demo screen.
  		                                         
 Input: none
                                                                       
 Output: Return 0 when memory is not enough for objects of the demo.
************************************************************************/
    WORD CreateJPEGDemo(void)
{
    BYTE    TextHeight;
    WORD    TextX;

    // Free memory for the objects in the previous linked list and start new list to display
    // the files seen on the media
    GOLFree();

    // initialize the image decoder
    ImageDecoderInit();

    // initialize the screen	
    SetColor(WHITE);
    ClearDevice();

    SetFont((void *) &GOLFontDefault);
    TextHeight = GetTextHeight((void *) &GOLFontDefault);

    SetColor(BRIGHTRED);
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)ImageDisplayStr, (void *) &GOLFontDefault)) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, 1 * TextHeight, (XCHAR *)ImageDisplayStr));

    SetColor(BLACK);
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)DetectingStr, (void *) &GOLFontDefault)) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, 3 * TextHeight, (XCHAR *)DetectingStr));
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)ThumbDriveStr, (void *) &GOLFontDefault)) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, 4 * TextHeight, (XCHAR *)ThumbDriveStr));
    TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)PleaseWaitStr, (void *) &GOLFontDefault)) / 2;
    WAIT_UNTIL_FINISH(OutTextXY(TextX, 6 * TextHeight, (XCHAR *)PleaseWaitStr));

        #if defined(ENABLE_SD_MSD_DEMO)
    MDD_SDSPI_InitIO();
        #endif
    MonitorDriveMedia();

    if(mediaPresent == 0)
    {

        // erase the last line
        SetColor(WHITE);
        TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)PleaseWaitStr, (void *) &GOLFontDefault)) / 2;
        WAIT_UNTIL_FINISH(OutTextXY(TextX, 6 * TextHeight, (XCHAR *)PleaseWaitStr));

        // replace it with these
        SetColor(BRIGHTRED);
        TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)Exiting1Str, (void *) &GOLFontDefault)) / 2;
        WAIT_UNTIL_FINISH(OutTextXY(TextX, 6 * TextHeight, (XCHAR *)Exiting1Str));

        TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)Exiting2Str, (void *) &GOLFontDefault)) / 2;
        WAIT_UNTIL_FINISH(OutTextXY(TextX, 7 * TextHeight, (XCHAR *)Exiting2Str));
        DelayMs(1000);
        return (0);
    }

    blImageOnScreen = 0;
    blTextOnScreen = 0;
    pSave = NULL;
    blSlideShowOn = 0;
    NextSlide = 0xFF;

    // create the listbox, slider and buttons that will emulate a
    // list box with controls.
    pListBox = LbCreate
        (
            ID_JPGLISTBOX,
            LBJPGXPOS,
            LBJPGYPOS,
            LBJPGXPOS + LBJPGWIDTH,
            LBJPGYPOS + LBJPGHEIGHT,
            LB_DRAW | LB_SINGLE_SEL,
            pJPGItemList,
            NULL
        );

    if(pListBox == NULL)
        return (0);

    pSlider = SldCreate
        (
            ID_SLD4LB,
            SLD4LBXPOS,
            SLD4LBYPOS,
            SLD4LBXPOS + SLD4LBWIDTH,
            SLD4LBYPOS + SLD4LBHEIGHT,
            SLD_DRAW | SLD_VERTICAL | SLD_SCROLLBAR,
            2,
            1,
            1,  // these are temporary fill items will set to proper values
            NULL
        );
    if(pSlider == NULL)
        return (0);

    pBtnUp = BtnCreate
        (
            ID_BTNUP4LB,
            BTNUP4LBXPOS,
            BTNUP4LBYPOS,
            BTNUP4LBXPOS + BTNUP4LBWIDTH,
            BTNUP4LBYPOS + BTNUP4LBHEIGHT,
            0,
            BTN_DRAW,
            NULL,
            (XCHAR *)JpegUpArrowStr,
            NULL
        );

    if(pBtnUp == NULL)
        return (0);

    pBtnDn = BtnCreate
        (
            ID_BTNDN4LB,
            BTNDN4LBXPOS,
            BTNDN4LBYPOS,
            BTNDN4LBXPOS + BTNDN4LBWIDTH,
            BTNDN4LBYPOS + BTNDN4LBHEIGHT,
            0,
            BTN_DRAW,
            NULL,
            (XCHAR *)JpegDownArrowStr,
            NULL
        );

    if(pBtnUp == NULL)
        return (0);

    // create the control buttons at the bottom of the screen
    CreateCtrlButtons(ExitStr, NULL, NULL, RightArrowStr);

    // fill the list box with the file names of images in the media
    FillNewElements();

    // set the first item to be focused
    LbSetFocusedItem(pListBox, 0);

    // successful creation of the JPEG demo screen
    return (1);
}
Example #7
0
    int main(void)
{
    SHORT       width, height;	// variables to store the height and width of the 16-bit bitmap image
    SHORT       counter;		// loop control variable for each shape that controls how many shapes are printed and their scale
    SHORT  		triangle[] = {160,120,160,120,160,120,160,120};		// triangle polygon points (start triangle in center of LCD)
    
    #if defined(__dsPIC33F__) || defined(__PIC24H__)

    // Configure Oscillator to operate the device at 40Mhz
    // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
    // Fosc= 8M*40(2*2)=80Mhz for 8M input clock
    PLLFBD = 38;                    // M=40
    CLKDIVbits.PLLPOST = 0;         // N1=2
    CLKDIVbits.PLLPRE = 0;          // N2=2
    OSCTUN = 0;                     // Tune FRC oscillator, if FRC is used

    // Disable Watch Dog Timer
    RCONbits.SWDTEN = 0;

    // Clock switching to incorporate PLL
    __builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary

    // Oscillator with PLL (NOSC=0b011)
    __builtin_write_OSCCONL(0x01);  // Start clock switching
    while(OSCCONbits.COSC != 0b011);

    // Wait for Clock switch to occur	
    // Wait for PLL to lock
    while(OSCCONbits.LOCK != 1)
    { };
    #elif defined(__PIC32MX__)
    INTEnableSystemMultiVectoredInt();
    SYSTEMConfigPerformance(GetSystemClock());
    #ifdef MULTI_MEDIA_BOARD_DM00123
    CPLDInitialize();
    CPLDSetGraphicsConfiguration(GRAPHICS_HW_CONFIG);
    CPLDSetSPIFlashConfiguration(SPI_FLASH_CHANNEL);
    #endif
    #endif

    #if defined (PIC24FJ256DA210_DEV_BOARD)
    
    // _ANSG8 = 0; /* S1 */
    // _ANSE9 = 0; /* S2 */
    // _ANSB5 = 0; /* S3 */
        
    #else

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

    #endif

    /////////////////////////////////////////////////////////////////////////////
    #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
    AD1PCFGL = 0xffff;
    #endif
    InitGraph();

    while(1)
    {
	    /* Display the Kettering Logo bit image with the Welcome to the ECE in the center 
	    /* The image was taken from a JPEG and converted to a 16-bit bitmap in order to meet 
	    /* the display requirement of 16-bits per pixel. This can be done by resaving the
	    /* JPEG as 16-bit bitmap in a image editing program and then converting it using
	    /* the graphics library resource converter. The LCD only supports 4-bit, 8-bit, and
	    /* 16-bits per pixel images 
	    */
	    width = GetImageWidth((void *) &kulogo);
		SetFont((void *) &Font25);
	    WAIT_UNTIL_FINISH(PutImage(45, 20 , (void *) &kulogo,  1)); // image location is relative to the top left corner of the image
        SetColor(WHITE);
        Bar(45, 110, width + 45, 135);	// Draw a bar over the image to place the text over.
        SetColor(BLUE);
        OutTextXY(65, 110, "WELCOME TO THE ECE");
        
        DelayMs(DEMODELAY);	// delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();

		/* Display multiple circles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        for(counter = 0; counter < MIN(GetMaxX(), GetMaxY()) >> 1; counter += 14)
        {
	        SetColor(BLACK);	// refresh the screen
	        ClearDevice();	
	        SetColor(BRIGHTRED);
	        SetFont((void *) &Font25);		// draw the name of the shape in the center
	        OutTextXY(135, 110, "Circle");
            WAIT_UNTIL_FINISH(Circle(GetMaxX() >> 1, GetMaxY() >> 1, counter + 5));	// draw the shape
            DelayMs(50);	// display for 50 ms
        }

        DelayMs(DEMODELAY);	// delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();

		/* Display multiple rectangles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        for(counter = 0; counter < MIN(GetMaxX() / 2, GetMaxY() / 2) >> 1; counter += 5)
        {	
	        SetColor(BLACK);	// refresh the screen
	        ClearDevice();	
	        SetColor(BRIGHTBLUE);
	        OutTextXY(120, 110, "Rectangle");	// draw the name of the shape in the center
            WAIT_UNTIL_FINISH
            (
                Rectangle
                    (
                        GetMaxX() / 2 - counter * 3 + 6,	// x value of top left corner of rectangle
                        GetMaxY() / 2 - counter * 2 - 8,	// y value of top left corner of rectangle
                        GetMaxX() / 2 + counter * 3 - 6,	// x value of bottom right corner of rectangle
                        GetMaxY() / 2 + counter * 2 + 8     // y value of bottom right corner of rectangle        
                    )
            );
            DelayMs(20); // Display for 20 ms
            
        }

        DelayMs(DEMODELAY); // delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();
        
        /* Display multiple triangles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        int i;
		for(counter = 0; counter < MIN(GetMaxX() / 2, GetMaxY() / 2) >> 1; counter += 10)
		{
			SetColor(BLACK);	// refresh the screen
			ClearDevice();
			SetColor(GREEN);	// draw the name of the shape at the center
			OutTextXY(125, 110, "Triangle");
			
			//{160,120,160,120,160,120,160,120} start in center of screen
			triangle[1] = triangle[1] - counter * 2 - 20; 	 // top point y
			triangle[7] = triangle[1];				 		 // top point y (close triangle)
			triangle[2] = triangle[2] - counter * 2 - 58; 	 // left corner point x
			triangle[3] = triangle[3] + counter * 2 + 16;	 // left corner point y
			triangle[4] = triangle[4] + counter * 2 + 58; 	 // right corner point x
			triangle[5] = triangle[5] + counter * 2 + 16;	 // right corner point y
			
			DrawPoly(4, triangle);	// draw the triangle (4 points to enclose it)
			
			// reset each of the triangle points to the center to prevent over expansion
			for (i = 0; i < 8; i++)
				if (i % 2 == 0)
					triangle[i] = 160;
				else
					triangle[i] = 120;
				
			DelayMs(50);	// display for 50 ms
		}
		
       
		DelayMs(DEMODELAY); // delay for 1 sec and clear the screen
    	SetColor(BLACK);
    	ClearDevice();
        
    }
}
/*********************************************************************
* Function:  void TouchCalibration()
*
* PreCondition: InitGraph() must be called before
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: calibrates touch screen
*
* Note: none
*
********************************************************************/
void TouchCalibration(){
static const XCHAR scr1StrLn1[] = {'I','M','P','O','R','T','A','N','T','.',0};
static const XCHAR scr1StrLn2[] = {'N','o','w',' ','t','o','u','c','h',' ','s','c','r','e','e','n',' ','c','a','l','i','b','r','a','t','i','o','n',0};
static const XCHAR scr1StrLn3[] = {'w','i','l','l',' ','b','e',' ','p','e','r','f','o','m','e','d','.','T','o','u','c','h',' ','p','o','i','n','t','s',0};
static const XCHAR scr1StrLn4[] = {'E','X','A','C','T','L','Y',' ','a','t',' ','t','h','e',' ','p','o','s','i','t','i','o','n','s',0};
static const XCHAR scr1StrLn5[] = {'s','h','o','w','n',' ','b','y',' ','a','r','r','o','w','s','.',0};
static const XCHAR scr1StrLn6[] = {'T','o','u','c','h',' ','s','c','r','e','e','n',' ','t','o',' ','c','o','n','t','i','n','u','e','.',0};

static const XCHAR scr2StrLn1[] = {'H','o','l','d',' ','S','3',' ','b','u','t','t','o','n',' ','a','n','d',0};
static const XCHAR scr2StrLn2[] = {'p','r','e','s','s',' ','M','C','L','R',' ','r','e','s','e','t','(','S','1',')',0};
static const XCHAR scr2StrLn3[] = {'t','o',' ','R','E','P','E','A','T',' ','t','h','e',' ','c','a','l','i','b','r','a','t','i','o','n',0};
static const XCHAR scr2StrLn4[] = {'p','r','o','c','e','d','u','r','e','.',0};


SHORT x,y;

SHORT textHeight;

    SetFont((void*)&GOLFontDefault);
    textHeight = GetTextHeight((void*)&GOLFontDefault);

    SetColor(WHITE);
    ClearDevice();

    SetColor(BRIGHTRED);
    WAIT_UNTIL_FINISH(OutTextXY(0,0*textHeight, (XCHAR*)scr1StrLn1));
    SetColor(BLACK);
    WAIT_UNTIL_FINISH(OutTextXY(0,1*textHeight, (XCHAR*)scr1StrLn2));
    WAIT_UNTIL_FINISH(OutTextXY(0,2*textHeight, (XCHAR*)scr1StrLn3));
    WAIT_UNTIL_FINISH(OutTextXY(0,3*textHeight, (XCHAR*)scr1StrLn4));
    WAIT_UNTIL_FINISH(OutTextXY(0,4*textHeight, (XCHAR*)scr1StrLn5));
    SetColor(BRIGHTRED);
    WAIT_UNTIL_FINISH(OutTextXY(0,6*textHeight, (XCHAR*)scr1StrLn6));

    // Wait for touch
    do{
        x=ADCGetX(); y=ADCGetY();
    }while((y==-1)||(x==-1));

    Beep();

    DelayMs(500);

    SetColor(WHITE);
    ClearDevice();

    SetColor(BRIGHTRED);

#ifdef SWAP_X_AND_Y

    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,5,GetMaxX()-5,15));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-4,5,GetMaxX()-4,15));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-6,5,GetMaxX()-6,15));

    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,5,GetMaxX()-15,5));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,4,GetMaxX()-15,4));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,6,GetMaxX()-15,6));

    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,6,GetMaxX()-15,16));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,4,GetMaxX()-15,14));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,5,GetMaxX()-15,15));

#else

    WAIT_UNTIL_FINISH(Line(5,5,5,15));
    WAIT_UNTIL_FINISH(Line(4,5,4,15));
    WAIT_UNTIL_FINISH(Line(6,5,6,15));

    WAIT_UNTIL_FINISH(Line(5,5,15,5));
    WAIT_UNTIL_FINISH(Line(5,4,15,4));
    WAIT_UNTIL_FINISH(Line(5,6,15,6));

    WAIT_UNTIL_FINISH(Line(5,6,15,16));
    WAIT_UNTIL_FINISH(Line(5,4,15,14));
    WAIT_UNTIL_FINISH(Line(5,5,15,15));

#endif

    _calXMin = 0xFFFF;
    _calXMax = 0;
    _calYMin = 0xFFFF;
    _calYMax = 0;

    TouchGetCalPoints();

    SetColor(WHITE);
    ClearDevice();

    SetColor(BRIGHTRED);

#ifdef SWAP_X_AND_Y

    WAIT_UNTIL_FINISH(Line(5,5,5,15));
    WAIT_UNTIL_FINISH(Line(4,5,4,15));
    WAIT_UNTIL_FINISH(Line(6,5,6,15));

    WAIT_UNTIL_FINISH(Line(5,5,15,5));
    WAIT_UNTIL_FINISH(Line(5,4,15,4));
    WAIT_UNTIL_FINISH(Line(5,6,15,6));

    WAIT_UNTIL_FINISH(Line(5,6,15,16));
    WAIT_UNTIL_FINISH(Line(5,4,15,14));
    WAIT_UNTIL_FINISH(Line(5,5,15,15));

#else

    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-5,5,GetMaxY()-15));
    WAIT_UNTIL_FINISH(Line(4,GetMaxY()-5,4,GetMaxY()-15));
    WAIT_UNTIL_FINISH(Line(6,GetMaxY()-5,6,GetMaxY()-15));

    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-5,15,GetMaxY()-5));
    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-4,15,GetMaxY()-4));
    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-6,15,GetMaxY()-6));

    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-6,15,GetMaxY()-16));
    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-4,15,GetMaxY()-14));
    WAIT_UNTIL_FINISH(Line(5,GetMaxY()-5,15,GetMaxY()-15));

#endif

    TouchGetCalPoints();

    SetColor(WHITE);
    ClearDevice();

    SetColor(BRIGHTRED);    


#ifdef SWAP_X_AND_Y

    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-5,GetMaxX()/2-5,GetMaxY()-15));
    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-4,GetMaxY()-5,GetMaxX()/2-4,GetMaxY()-15));
    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-6,GetMaxY()-5,GetMaxX()/2-6,GetMaxY()-15));

    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-5,GetMaxX()/2-15,GetMaxY()-5));
    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-4,GetMaxX()/2-15,GetMaxY()-4));
    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-6,GetMaxX()/2-15,GetMaxY()-6));

    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-6,GetMaxX()/2-15,GetMaxY()-16));
    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-4,GetMaxX()/2-15,GetMaxY()-14));
    WAIT_UNTIL_FINISH(Line(GetMaxX()/2-5,GetMaxY()-5,GetMaxX()/2-15,GetMaxY()-15));

#else

    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-5,GetMaxX()-5,GetMaxY()/2-15));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-4,GetMaxY()/2-5,GetMaxX()-4,GetMaxY()/2-15));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-6,GetMaxY()/2-5,GetMaxX()-6,GetMaxY()/2-15));

    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-5,GetMaxX()-15,GetMaxY()/2-5));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-4,GetMaxX()-15,GetMaxY()/2-4));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-6,GetMaxX()-15,GetMaxY()/2-6));

    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-6,GetMaxX()-15,GetMaxY()/2-16));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-4,GetMaxX()-15,GetMaxY()/2-14));
    WAIT_UNTIL_FINISH(Line(GetMaxX()-5,GetMaxY()/2-5,GetMaxX()-15,GetMaxY()/2-15));

#endif

    TouchGetCalPoints();

    SetColor(WHITE);
    ClearDevice();

    SetColor(BLACK);
    WAIT_UNTIL_FINISH(OutTextXY(10,1*textHeight,(XCHAR*)scr2StrLn1));
    WAIT_UNTIL_FINISH(OutTextXY(10,2*textHeight,(XCHAR*)scr2StrLn2));
    WAIT_UNTIL_FINISH(OutTextXY(10,3*textHeight,(XCHAR*)scr2StrLn3));
    WAIT_UNTIL_FINISH(OutTextXY(10,4*textHeight,(XCHAR*)scr2StrLn4));
    SetColor(BRIGHTRED);
    WAIT_UNTIL_FINISH(OutTextXY(10,6*textHeight,(XCHAR*)scr1StrLn6));

    // Wait for touch
    do{
        x=ADCGetX(); y=ADCGetY();
    }while((y==-1)||(x==-1));

    Beep();

    DelayMs(500);

    SetColor(BLACK);
    ClearDevice();

}