Ejemplo n.º 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);
}
/*******************************************************************************
 * FUNCTION: vCreateWallpaperPage
 *
 * PARAMETERS:
 * ~ void
 *
 * RETURN:
 * ~ void
 *
 * DESCRIPTIONS:
 * Create the page to show the wallpaper.
 *
 *******************************************************************************/
void vCreateWallpaperPage (void)
{
    // Clear the GOL objects and screen.
    GOLFree();
    SetColor(BLACK);
    ClearDevice();

    // Create the wallpaper image.
    PictCreate( GID_IMG_WALLPAPPER,
                0,         0,
                GetMaxX(), GetMaxY(),
                PICT_DRAW, 1, "/Theme/Wallpaper.bmp", pxDefaultScheme );
}
Ejemplo n.º 3
0
/************************************************************************
 Function: void CreateAnimationDemo(void)
                                                                       
 Overview: Creates the animation screen.
 		                                                                          
 Input: none
                                                                       
 Output: none
************************************************************************/
void CreateAnimationDemo(void)
{
    SHORT   pixWidth, pixHeight;

	pixHeight = GetImageHeight((void *) &Engine1);
	pixWidth = GetImageWidth((void *) &Engine1);

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

    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_METER1,
            (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

    CreateCtrlButtons(ExitStr, ScaleStr, DownStr, UpStr);

    // draw the colorful background 
    DrawBackgroundColorPalette();
}
Ejemplo n.º 4
0
void InitializeScreen( void )
{
    GOLFree();
    SetColor(BLACK);        // set color to BLACK
    ClearDevice();          // set screen to all BLACK

    PictCreate(     ID_ICON,                    // ID
                    0,0,15,15,                  // dimension
                    PICT_DRAW,                  // will be dislayed, has frame
                    1,                          // scale factor is x1
                    &iconMicrochip,             // bitmap
                    NULL );                     // default GOL scheme

    StCreate(       ID_TITLE,
                    16, 0, GetMaxX()-11, GetTextHeight( (void *)&FONTDEFAULT )-1,
                    ST_DRAW,
                    pageInformation.title,
                    NULL );

    previousTick = tick; 
}
Ejemplo n.º 5
0
void PerformBoardTest( void )
{
    static int  elapsedSeconds = 0;
    static void *picture;
    
    
    RTCCProcessEvents();

    if (previousSecond != _time_str[11])
    {
        switch ( elapsedSeconds )
        {
            case 0:
                // We will test to see if we are plugged into the PC as a
                // device (on the right side of the board) or if the debugger
                // side is plugged in (on the left side of the board).  If
                // we are plugged in as a device, we will receive SOF tokens,
                // which sets the SOF interrupt.
                picture = &intro;
             
                // Turn on the USB module in device mode.  First, disable all
                // USB interrupts, since we are just doing a local test.  Then
                // enable the module in default device mode and turn on the 
                // power.  We will let the module take care of pulling up the
                // correct lines.  Note that the interrupt flags in U1IR are
                // cleared by writing a "1" to each flag.
                U1IE                    = 0;
                U1IR                    = 0xFF;
                U1CONbits.USBEN         = 1;
                U1PWRCbits.USBPWR       = 1;
            
                // Fall through
                
            case 2:
                GOLFree();
                SetColor( WHITE );
                ClearDevice();          
                break;
            
            case 1:
            case 3:
                GOLFree();
                SetColor( BLACK );
                ClearDevice();          
                break;

            case 4:
                // See if we are plugged into the PC as a device.  If so, we
                // will display a slightly different picture.
                if (U1IRbits.SOFIF)
                {
                    // We are receiving SOF tokens, so we must be plugged 
                    // into a host.
                    picture = &introDevice;
                }

                // Disable and power off the USB module.
                U1CONbits.USBEN         = 1;
                U1PWRCbits.USBPWR       = 0;
                    
                // Display the selected graphic.
                PictCreate(     ID_ICON,                    // ID
                                0,0,GetMaxX(),GetMaxY(),    // dimension
                                PICT_DRAW,                  // will be dislayed, has frame
                                1,                          // scale factor is x1
                                picture,                    // bitmap
                                NULL );                     // default GOL scheme
                break;
                
            case 5:
                RGBTurnOnLED( RGB_SATURATION_MINIMUM, RGB_SATURATION_MINIMUM, RGB_SATURATION_MINIMUM );
                break;

            case 6: 
                // Red
                RGBSetRed( RGB_SATURATION_MAXIMUM );
                break;
                
            case 7:
                // Yellow
                RGBSetGreen( RGB_SATURATION_MAXIMUM );
                break;
                
            case 8:
                // Green
                RGBSetRed( RGB_SATURATION_MINIMUM );
                break;
                
            case 9:
                // Aqua
                RGBSetBlue( RGB_SATURATION_MAXIMUM );
                break;
                
            case 10:
                // Blue
                RGBSetGreen( RGB_SATURATION_MINIMUM );
                break;
                
            case 11:
                // Fuschia            
                RGBSetRed( RGB_SATURATION_MAXIMUM );
                break;
                
            case 12:
                // White
                RGBSetGreen( RGB_SATURATION_MAXIMUM );
                break;
                
            case 13:
                // Pause
                break;
                
            case 14:
                RGBTurnOffLED();
                screenState    = SCREEN_DISPLAY_MAIN;    
                previousSecond = ' ';
                elapsedSeconds = 0;
                return;
                break;
                            
        }
                   
        previousSecond = _time_str[11];
        elapsedSeconds ++;
    }
}
Ejemplo n.º 6
0
/****************************************************************************
  Function:
    WORD GOLDrawCallback( void )
  Description:
    This callback is performed at the beginning of the GOLDraw() function.
    Processing that needs to be done on a regular basis and is not triggered
    by a message should be done here.
  Precondition:
    None
  Parameters:
    None
  Returns:
    None
  Remarks:
    All graphic control adding and removing must be done from this function,
    not from the message callback.
  ***************************************************************************/
WORD GOLDrawCallback( void )
{
	
    switch (screenState)
    {
	    // Display Start-up screen and play Welcome message
        case SCREEN_START:
            // Display the start up screen
		    PictCreate(     ID_ICON,                    // ID
		                    0,0,GetMaxX(),GetMaxY(),    // dimension
		                    PICT_DRAW,                  // will be displayed, has frame
		                    1,                          // scale factor is x1
		                    picture,                    // bitmap
		                    NULL );                     // default GOL scheme
        	screenState     = SCREEN_START_DELAY;
            break;
            
        case SCREEN_START_DELAY:
        	if(enableSoundFlag)
        	{
        		while(speakerBusy());
        		// Speaker: Welcome to MPLAB Starter Kit for PIC24H MCU Demonstration
        		speakerActivate(SPEECH_ADDR_WELCOME, SPEECH_SIZE_WELCOME);		
        		Delay(6000);
        	}
        	// Initialize the reference timer
    		TickInit();
			// Initialize the accelerometer
    		AccelerometerInit();
        	screenState     = SCREEN_DISPLAY_MAIN;
        	break;
        
        // Display Main screen                
        case SCREEN_DISPLAY_MAIN:
            ShowScreenMain();            
            screenState         = SCREEN_MAIN;
            displayChangeTime   = tick;
            break;
               	
        case SCREEN_MAIN:
            break;
        
        // Display Accelerometer Tri-axial Outputs graph	            
        case SCREEN_DISPLAY_GRAPH:
            ShowScreenGraph();
            screenState         = SCREEN_GRAPH;
            displayChangeTime   = tick;
            break;

        case SCREEN_GRAPH:
        	AccelerometerStop();			
            UpdateGraph();
            break;
		
		// Display connect External Sensor information
		case SCREEN_DISPLAY_ES_INFO:
		  	ShowScreenESInfo();
		  	screenState 		= SCREEN_ES_INFO;
		  	displayChangeTime   = tick;
		  	break;

		case SCREEN_ES_INFO:
			Delay(2000);
		  	screenState = SCREEN_DISPLAY_ES_GRAPH;
		  	break;
		
		// Display External Sensor output graph   			
        case SCREEN_DISPLAY_ES_GRAPH:
        	AccelerometerStop();
            ShowScreenESGraph();                      
            initESADC();
            screenState         = SCREEN_ES_GRAPH;
            displayChangeTime   = tick;
            break;

        case SCREEN_ES_GRAPH:
	        UpdateESGraph();
            break;
        
        // Display Orientation screen     
        case SCREEN_DISPLAY_ORIENTATION:
            ShowScreenOrientation();
            screenState         = SCREEN_ORIENTATION;
            displayChangeTime   = tick;
            break;

        case SCREEN_ORIENTATION:
            UpdateOrientation();
            break;
 
 		// Display Games screen
        case SCREEN_DISPLAY_GAMES:
            ShowScreenGames();
            screenState         = SCREEN_GAMES;
            displayChangeTime   = tick;
            break;

        case SCREEN_GAMES:
            break;
        
        // Display Bomber Jet screen                         
        case SCREEN_DISPLAY_JET:
            ShowScreenJet();
            AccelerometerStop();
        	AccelerometerInit();    
         	if(enableSoundFlag)
         	{
	         	while(speakerBusy());
				speakerActivate(SPEECH_ADDR_START, SPEECH_SIZE_START); 
				while(speakerBusy());
			}
            screenState         = SCREEN_JET;
            displayChangeTime   = tick;
            break;

        case SCREEN_JET:    	
            DrawJet();
            break;
        
        // Display Snake screen    
        case SCREEN_DISPLAY_SNAKE:
            ShowScreenSnake();
            AccelerometerStop();
        	AccelerometerInit();   
        	if(enableSoundFlag)
         	{
	         	while(speakerBusy());
				speakerActivate(SPEECH_ADDR_START, SPEECH_SIZE_START); 
				while(speakerBusy());
			} 
            screenState         = SCREEN_SNAKE;
            displayChangeTime   = tick;
            break;

        case SCREEN_SNAKE:    	
            DrawSnake();
            break;
            
        // Display Score screen    
        case SCREEN_DISPLAY_SCORE:
            ShowScreenScore();
            if(enableSoundFlag)
            {
				while(speakerBusy());
				speakerActivate(SPEECH_ADDR_GAME, SPEECH_SIZE_GAME); 
				while(speakerBusy());
				speakerActivate(SPEECH_ADDR_OVER, SPEECH_SIZE_OVER); 
			}
            displayChangeTime   = tick;
            screenState         = SCREEN_SCORE;			
            break;

        case SCREEN_SCORE:
            break;
    }

    return 1;   // Callback complete
}