/*******************************************************************************
 * FUNCTION: usMsgNumericKeypadPage
 *
 * PARAMETERS:
 * ~ objMsg     - Translated message for the object.
 * ~ pObj       - Pointer to the object.
 * ~ pMsg       - Pointer to the non-translated, raw GOL message.
 *
 * RETURN:
 * ~ If the function returns non-zero, the message will be processed by default.
 *
 * DESCRIPTIONS:
 * Handle the touchscreen event of the Set ID page.
 *
 *******************************************************************************/
WORD usMsgNumericKeypadPage(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg)
{
    unsigned short usObjectId = GetObjID(pObj);
    EDITBOX *pxEditbox1 = (EDITBOX*)GOLFindObject(GID_KEYPAD_EB_VALUE1);
    EDITBOX *pxEditbox2 = (EDITBOX*)GOLFindObject(GID_KEYPAD_EB_VALUE2);
    
    // Make sure button is released.
    if (objMsg == BTN_MSG_RELEASED) {
        // Clear message on editbox 1.
        vEditBoxUpdateText(pxEditbox1, "");

        // If key 0 - 9 is pressed...
        if ((usObjectId >= GID_KEYPAD_0) && (usObjectId <= GID_KEYPAD_9)) {
            // Add the pressed key to editbox 2.
            if (pxEditbox2 != NULL) {
                EbAddChar(pxEditbox2, '0' + (usObjectId - GID_KEYPAD_0));
                SetState(pxEditbox2, EB_DRAW);
            }
        }

        // DEL button.
        else if (usObjectId == GID_KEYPAD_DEL) {
            // Remove 1 character from editbox 2.
            if (pxEditbox2 != NULL) {
                EbDeleteChar(pxEditbox2);
                SetState(pxEditbox2, EB_DRAW);
            }
        }

    }
    
    
    return 1;
}
Пример #2
0
void UpdateDateTime( void )
{
    OBJ_HEADER* obj;

    RTCCProcessEvents();                // update the time and date

    // update time edit boxes
    obj = GOLFindObject(ID_HOUR);
    EbSetText((EDITBOX*)obj, &_time_str[4]);
    SetState(obj, EB_DRAW);
    obj = GOLFindObject(ID_MINUTE);
    EbSetText((EDITBOX*)obj, &_time_str[7]);
    SetState(obj, EB_DRAW);

    // update date edit boxes
    obj = GOLFindObject(ID_MONTH);
    EbSetText((EDITBOX*)obj, &_date_str[0]);
    SetState(obj, EB_DRAW);
    obj = GOLFindObject(ID_DAY);
    EbSetText((EDITBOX*)obj, &_date_str[4]);
    SetState(obj, EB_DRAW);
    obj = GOLFindObject(ID_YEAR);
    EbSetText((EDITBOX*)obj, &_date_str[8]);
    SetState(obj, EB_DRAW);
}
Пример #3
0
/************************************************************************
 Function: WORD MultiFontDemoMsgCallback(WORD objMsg, OBJ_HEADER* pObj, 
 										GOL_MSG* pMsg)

 Overview: This function is called by GOLMsg() function when in this 
 		   particular demo each time the valid message is received for the 
  		   objects in the demo.
           
 Input: objMsg - translated message for the object,
        pObj - pointer to the object,
        pMsg - pointer to the non-translated, raw GOL message 

 Output: If the function returns non-zero the message will 
 		 be processed by the object directly affected by the message.
 		 Default action on the object based on the message will be 
 		 performed.
************************************************************************/
WORD MultiFontDemoMsgCallback(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg)
{
    WORD        objectID;
    STATICTEXT  *pSt;

    objectID = GetObjID(pObj);
    switch(objectID)
    {
        case ID_BUTTON_A:
            if(objMsg == BTN_MSG_RELEASED)
            {   // check if button is pressed
                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);
                free(FontScheme2);
                screenState = CREATE_DEMOSELECTION;
                return (1);
            }

        case ID_BUTTON_B:
            if(objMsg == BTN_MSG_RELEASED)
            {   // check if button is pressed
                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);

                pHWData = pHWData->pHWPrev;
                pSt = (STATICTEXT *)GOLFindObject(ID_STXT); // get pointer to static text
                SetState(pSt, ST_DRAW);                     // set redraw state
            }

            break;

        case ID_BUTTON_D:
            if(objMsg == BTN_MSG_RELEASED)
            {

                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);

                pHWData = pHWData->pHWNext;
                pSt = (STATICTEXT *)GOLFindObject(ID_STXT); // get pointer to static text
                SetState(pSt, ST_DRAW);                     // set redraw state
            }

            break;

        default:
            break;
    }

    return (1);
}
Пример #4
0
/*****************************************************************************
 * WORD MsgSecurityScreen(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg)
 *****************************************************************************/
WORD MsgSecurityScreen(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg)
{
    EDITBOX     *pEb;
    SHORT       id;
    XCHAR       temp;
    static char status = 0; // status to check if calling, holding or not
    id = GetObjID(pObj);

    MsgPanelScreen(objMsg, pObj);  //get messages from the panel also

    // If number key is pressed
    if(objMsg == BTN_MSG_PRESSED)
    {
        if(id >= SERCURITY_SCREEN_ID_KEYPAD_0_BUT)
        {
            if(id <= SERCURITY_SCREEN_ID_KEYPAD_9_BUT)
            {
                if(!status)
                {
                    pEb = (EDITBOX *)GOLFindObject(SERCURITY_SCREEN_ID_CODE_EDIT_BOX);
                    EbAddChar(pEb, '*');
                    SetState(pEb, EB_DRAW);
                }

                return (1);
            }
        }
    }

    switch(id)
    {

    case SERCURITY_SCREEN_ID_CLEAR_BUT:
    case SERCURITY_SCREEN_ID_ENTER_BUT:
        if(!status)
        {
            if(objMsg == BTN_MSG_PRESSED)
            {
                pEb = (EDITBOX *)GOLFindObject(SERCURITY_SCREEN_ID_CODE_EDIT_BOX);
                temp = 0x0000;
                EbSetText(pEb, &temp);
                SetState(pEb, EB_DRAW);
                status = 0;
            }
        }

        return (1);

    default:
        return (0);                         // process by default
    }
}
Пример #5
0
void IndicateFocus( SHORT lineColor )
{
    EDITBOX *currentEditbox;
    BUTTON  *currentMinus;

    currentEditbox  = (EDITBOX *)GOLFindObject( CURRENT_EDITBOX );
    currentMinus    = (BUTTON *) GOLFindObject( CURRENT_MINUS );

    SetColor( lineColor );
    SetLineType( SOLID_LINE );

    Rectangle(  currentEditbox->hdr.left-1, currentEditbox->hdr.top-1,
                currentMinus->hdr.right+1, currentMinus->hdr.bottom+1 );
}
Пример #6
0
/************************************************************************
 Function: void UpdateTime(WORD force)

 Overview: This function updates the date and time variables.

 Input: none.

 Output: none
************************************************************************/
void UpdateTime(WORD force)
{
    static char previousChar;
    char changeIndicator;
    OBJ_HEADER  *pObject;
    char currentHour;
    char hourStr[3];

    RTCCProcessEvents();

    changeIndicator = _time_str[8];

    if ((previousChar != changeIndicator) || (force == FORCE_UPDATE))
    {
        previousChar = changeIndicator;

        if ((pObject = GOLFindObject(ID_TIME)) != NULL)
        {
            strncpy(CurrentTimeStr, _time_str, 9);

            // change hour to AM/PM format
            currentHour = mRTCCGetBinHour();

            if (hour >= 12)
                strncpy(&CurrentTimeStr[10], DayNightItems[1], 3);
            else
                strncpy(&CurrentTimeStr[10], DayNightItems[0], 3);

            if (currentHour > 12)
            {
                currentHour = currentHour - 12;

                // now set the hour in the string
                NumberToString(currentHour, hourStr, 2, 0);
                CurrentTimeStr[4] = hourStr[0];
                CurrentTimeStr[5] = hourStr[1];

            }

            StSetText((STATICTEXT *)pObject, CurrentTimeStr);
            SetState( pObject, ST_DRAW );
        }

        if ((pObject = GOLFindObject(ID_BATLEVEL)) != NULL)
        {
            PbSetPos( (PROGRESSBAR*)pObject, GetBatteryLevel());
            SetState( pObject, PB_DRAW_BAR );
        }
    }
}
Пример #7
0
/*****************************************************************************
 * void CreateLightingScreen(void)
 *
 * NOTE:  The lighting demo is not available when using the PIC24FJ256GB210.
 *        The demo requires loading an image from the external memory, the Epson
 *        S1D13517 () has some routing conflicts which make loading the image
 *        difficult and not robust.  For these reasons, the lighting demo has
 *        been take out for a better out of box experience.
 *****************************************************************************/
void CreateLightingScreen(void)
{

    GOL_SCHEME *currentScheme;

    currentScheme = GFX_SchemeGetCurrentScheme();

    SetColor(currentScheme->Color0);

    while(!FillBevel((GetMaxX() >> 2) + 20,90 ,GetMaxX() - 10, GetMaxY()-10,5));				     	

	while(!AlphaBlendWindow(GetDrawBufferAddress(), (GetMaxX() >> 2) + 15, 85,
					 GFX_PAGE1, (GetMaxX() >> 2) + 15, 85,
					 GetDrawBufferAddress(), (GetMaxX() >> 2) + 15, 85,
				     (GetMaxX())-((GetMaxX() >> 2) + 15), 
				     GetMaxY() - 90,  	
				     GFX_SchemeGetDefaultScheme()->AlphaValue));

    SetState(GOLFindObject(PANEL_SCREEN_ID_LIGHTING_BUT), BTN_DISABLED);

    if(GetState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT),BTN_DISABLED))
    {
        ClrState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT), BTN_DISABLED);
        SetState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT),BTN_DRAW);
    }

    if(GetState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT),BTN_DISABLED))
    {
        ClrState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT), BTN_DISABLED);
        SetState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT),BTN_DRAW);
    }

    if(GetState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT),BTN_DISABLED))
    { 
        ClrState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT), BTN_DISABLED);
        SetState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT),BTN_DRAW);
    }

/***
 * See above note in the function comment for more information
 **/
    #ifndef __PIC24FJ256GB210__
    GFX_BlockUntilFinished(PutImage((GetMaxX() >> 2)+40, 90+10, (void *) &House, IMAGE_NORMAL));
    #endif

}
Пример #8
0
/*****************************************************************************
 * void UpdateListBox()
 *****************************************************************************/		
void UpdateListBox( BOOL up, BOOL down )
{
	LISTBOX *  pLb = (LISTBOX *)GOLFindObject(ID_LBS_LISTBOX1);
	SHORT    count = LbGetCount(pLb);
	SHORT  CurItem = LbGetFocusedItem(pLb);	
	SLIDER  * pSld = (SLIDER *)GOLFindObject(ID_LBS_SLIDER1);
	SHORT      pos = SldGetPos(pSld);
	WORD y;
	
	if( up )
	{
	    LbSetFocusedItem(pLb, CurItem - 1);
	    SetState(pLb, LB_DRAW_ITEMS);
	    if ( CurItem - 1 < count )
	      SldSetPos(pSld, pos + 1);
	    SetState(pSld, SLD_DRAW_THUMB);
	    
	    if ( CurItem )
	    {	    
	    	y = ( CurItem - 1 ) * GetTextHeight((void *) altScheme->pFont);
	    	y += GetTextHeight((void *) altScheme->pFont)/2;
	    	GFX_DRIVER_MoveLayer( GFX_CURSOR_LAYER, LB_ORIGIN_START_X + 180, LB_ORIGIN_START_Y + y );
	    }
	}
	
	if( down )
	{
	    LbSetFocusedItem(pLb, CurItem + 1);
	    SetState(pLb, LB_DRAW_ITEMS);
	    if ( count - CurItem - 1 > 0 )
	      SldSetPos(pSld, pos - 1);	    
	    SetState(pSld, SLD_DRAW_THUMB);
	    
	    if ( CurItem + 1 < count )
	    {
	    	y = ( CurItem + 1 ) * GetTextHeight((void *) altScheme->pFont);
	    	y += GetTextHeight((void *) altScheme->pFont)/2;
	    	GFX_DRIVER_MoveLayer( GFX_CURSOR_LAYER, LB_ORIGIN_START_X + 180, LB_ORIGIN_START_Y + y );
	    }
	}
    	
}
Пример #9
0
/*********************************************************************
* Function: BOOL GOLDeleteObject(OBJ_HEADER * object)
*
* PreCondition: none
*
* Input: pointer to the object
*
* Output: none
*
* Side Effects: none
*
* Overview: Deletes an object to the linked list objects for the current screen using
*           the given ID to search for the object.
*
* Note: none
*
********************************************************************/
BOOL GOLDeleteObjectByID(WORD ID)
{
    OBJ_HEADER  *object;

    object = GOLFindObject(ID);

    if(!object)
        return (FALSE);

    return (GOLDeleteObject(object));
}
Пример #10
0
/*****************************************
 * void PrepareDemoPage(XCHAR *pText)
 *****************************************/
void PrepareDemoPage(XCHAR *pText)
{
    SetColor(WHITE);   
    Bar(26, 40, GetMaxX()-26, GetMaxY()-1);
    
    if ( pText )
    {		    		    
	    WINDOW * pMainWin  = (WINDOW*)GOLFindObject(ID_WINDOW1);
	    WndSetText(pMainWin, pText);
	    SetState(pMainWin, WND_DRAW_TITLE);
        WndDraw(pMainWin);
    } 
}
Пример #11
0
static WORD DrawOrHideDecoration(void)
{
	static int drawState;

	OBJ_HEADER *pObj;
	SHORT l, t, r, b;

	if (showDecoration != showDecorationPrev) {
		showDecorationPrev = showDecoration;
		drawState = 0;
	}

	switch (drawState) {
	case 0:
		// prepare style
		SetLineThickness(THICK_LINE);
		SetLineType(DASHED_LINE);

		if (showDecoration)
			SetColor(GFX_SCHEMEDEFAULT.Color1);
		else
			SetColor(GFX_SCHEMEDEFAULT.CommonBkColor);

		drawState++;
		/* fall through */

	case 1:
		// draw/hide decoration
		pObj = GOLFindObject(ID_BUTTON);
		if (pObj == NULL)
			break;

		l = pObj->left - 5;
		t = pObj->top - 5;
		r = pObj->right + 5;
		b = pObj->bottom + 5;

		if (!Rectangle(l, t, r, b))
			return 0;

		drawState++;
		/* fall through */

	default:
		break;
	}

	return 1;
}
Пример #12
0
/*****************************************************************************
 * void ListBoxSelected(void)
 *****************************************************************************/	
static WORD ListBoxSelected( void )	
{
	LISTBOX * pLb = (LISTBOX *)GOLFindObject(ID_LBS_LISTBOX1);    
    SHORT      ix = LbGetFocusedItem(pLb);
    
    switch (ix)
    {
    	default:
    	case 0:
    		return PIP_SHOW_CURSOR;
    		
    	case 1:
    		return PIP_MOVE_CURSOR;
    		
    	case 2:
    		return PIP_MOVE;
    
    	case 3:
    		return PIP_EXIT;
    }	
}
Пример #13
0
/*****************************************************************************
 * void ListBoxSelected(void)
 *****************************************************************************/	
WORD ListBoxSelected( void )	
{
	LISTBOX * pLb = (LISTBOX *)GOLFindObject(ID_LBS_LISTBOX1);    
    SHORT      ix = LbGetFocusedItem(pLb);
    
    switch (ix)
    {
    	default:
    	case 0:
    		return DEMO_INTRO_SCREEN_CREATE;
    		
    	case 1:
    		return DEMO_FONT_SCREEN_CREATE;
    		
    	case 2:
    		return DEMO_FOREIGN_FONT_SCREEN_CREATE;
    
    	case 3:
    		return DEMO_PICTURE_SCREEN_CREATE;
    
    	case 4:
    		return DEMO_WIDGETS_SCREEN_CREATE;
    
    	case 5:
    		return DEMO_CHART_SCREEN_CREATE;
    		
    	case 6:
    		return DEMO_QR_SCREEN_CREATE;
    		
    	case 7:
    		return DEMO_EKG_SCREEN_CREATE;
    		
    	case 8:
    		return DEMO_PIP_SCREEN_CREATE;
    }	
}
/*******************************************************************************
 * TASK: taskSetPath
 *
 * DESCRIPTIONS:
 * Read the position from the G15 and determine its angle limit.
 *
 *******************************************************************************/
void taskSetPath (void *pvParameters)
{
    signed short ssCurrentAngle = 0;
    signed short ssPreviousAngle = 0;
    signed short ssLinearPosition = 0;
    signed short ssCwLimit = 0;
    signed short ssCcwLimit = 0;
    signed short ssLinearCwLimit = 0;
    signed short ssLinearCcwLimit = 0;
    signed short ssOriCwLimit = 0;
    signed short ssOriCcwLimit = 0;
    signed short ssTargetPosition = 0;
    signed short ssTorqueLimit = 0;
    unsigned char ucPreviousWheelMode = 0;
    unsigned char ucWheelMode = 0;
    
    
    
    // Running set path.
    ucSaveDiscard = 2;



    // Get the original angle limit.
    eG15GetAngleLimit(ucG15Id, (unsigned short*)&ssOriCwLimit, (unsigned short*)&ssOriCcwLimit);

    // Get the first position from the G15.
    eG15GetPosition(ucG15Id, (unsigned short*)&ssCurrentAngle);
    ssPreviousAngle = ssCurrentAngle;
    ssLinearPosition = ssCurrentAngle;
    ssLinearCwLimit = ssCurrentAngle;
    ssLinearCcwLimit = ssCurrentAngle + 1;      // +1 to make sure it won't set as wheel mode.
    
    
    
    // Temporary set the angle limit to make sure the G15 is in position mode.
    eG15SetAngleLimit(ucG15Id, 0, 1);

    // Set the speed to maximum.
    eG15SetSpeed(ucG15Id, WRITE_NOW, 1023, POSITION_SPEED_CONTROL);
    

    
    // Get the current tick time.
    portTickType prevTick = xTaskGetTickCount();

    // Read the position and convert the path limit to linear value until asked to save or discard.
    while (ucSaveDiscard == 2) {
        // Loop every 100ms.
        vTaskDelayUntil( &prevTick, 100 / portTICK_RATE_MS );



        // Read the G15 position.
        eG15GetPosition(ucG15Id, (unsigned short*)&ssCurrentAngle);

        // Get the angle difference.
        signed short ssAngleDiff = ssCurrentAngle - ssPreviousAngle;

        // Make correction to the angle difference if crossing 0.
        if (ssAngleDiff < -(1088/2)) {
            ssAngleDiff += 1088;
        }
        else if (ssAngleDiff > (1088/2)) {
            ssAngleDiff -= 1088;
        }



        // Moving CCW.
        if (ssAngleDiff > 0) {
           ssLinearPosition += ssAngleDiff;

           // update the CCW limit.
           if (ssLinearCcwLimit < ssLinearPosition) {
               ssLinearCcwLimit = ssLinearPosition;
           }

           // Drag the CW limit along if overlapped.
           if ((ssLinearCcwLimit - ssLinearCwLimit) > 1087) {
               ssLinearCwLimit = ssLinearCcwLimit - 1087;
           }



           // Torque limit is depending on how fast we move.
           ssTorqueLimit = (ssAngleDiff * 7) + 30;
           if (ssTorqueLimit > 500) {
               ssTorqueLimit = 500;
           }
           eG15SetTorqueLimit(ucG15Id, (unsigned short)ssTorqueLimit);
           eG15SetTorque(ucG15Id, WRITE_NOW, 1);

           // Set the target position to assist moving.
           ssTargetPosition = ssCurrentAngle + (1088 / 2);
           if (ssTargetPosition > 1087) {
               ssTargetPosition -= 1088;
           }
           eG15SetPosition(ucG15Id, WRITE_NOW, (unsigned short)ssTargetPosition, DIRECTION_POSITIONING_CCW);
        }

        // Moving CW.
        else if (ssAngleDiff < 0) {
           ssLinearPosition += ssAngleDiff;

           // update the CW limit.
           if (ssLinearCwLimit > ssLinearPosition) {
               ssLinearCwLimit = ssLinearPosition;
           }

           // Drag the CCW limit along if overlapped.
           if ((ssLinearCwLimit - ssLinearCcwLimit) < -1087) {
               ssLinearCcwLimit = ssLinearCwLimit + 1087;
           }



           // Torque limit is depending on how fast we move.
           ssTorqueLimit = (-ssAngleDiff * 7) + 30;
           if (ssTorqueLimit > 500) {
               ssTorqueLimit = 500;
           }

           eG15SetTorqueLimit(ucG15Id, (unsigned short)ssTorqueLimit);
           eG15SetTorque(ucG15Id, WRITE_NOW, 1);

           // Set the target position to assist moving.
           ssTargetPosition = ssCurrentAngle - (1088 / 2);
           if (ssTargetPosition < 0) {
               ssTargetPosition += 1088;
           }
           eG15SetPosition(ucG15Id, WRITE_NOW, (unsigned short)ssTargetPosition, DIRECTION_POSITIONING_CW);
        }

        // Not moving.
        else {
            eG15SetTorque(ucG15Id, WRITE_NOW, 0);
        }



        // Convert the path limit to within the range of 0 - 1087.
        ssCcwLimit = ssLinearCcwLimit % 1088;
        if (ssCcwLimit < 0) {
            ssCcwLimit += 1088;
        }

        ssCwLimit = ssLinearCwLimit % 1088;
        if (ssCwLimit < 0) {
            ssCwLimit += 1088;
        }
        
        
        // Check whether the wheel mode is selected.
        RADIOBUTTON *pxRbWheel = (RADIOBUTTON*)GOLFindObject(GID_G15_RB_WHEEL);
        if (pxRbWheel != NULL) {
            if (GetState(pxRbWheel, RB_CHECKED) != 0) {
                ucWheelMode = 1;
            }
            else {
                ucWheelMode = 0;
            }
        }

        

        // Update the GUI when there is changes.
        // Make sure the meter is there.
        vTaskEnterCritical();
        if (GOLFindObject(GID_G15_MTR) != NULL) {
            if ((ssPreviousAngle != ssCurrentAngle) || (ucPreviousWheelMode != ucWheelMode)) {
                // Update the angle limit and position.
                vUpdateMeterLimit((unsigned short)ssCwLimit, (unsigned short)ssCcwLimit);
                vUpdateMeterAngle((unsigned short)((unsigned long)ssCurrentAngle * 360ul / 1088ul));
            }
        }
        vTaskExitCritical();
        
        // Save the current angle as previous angle.
        ssPreviousAngle = ssCurrentAngle;

        // Save the current wheel mode as previous wheel mode.
        ucPreviousWheelMode = ucWheelMode;
        


        // Read the stack watermark and record it if it's below threshold.
        unsigned portBASE_TYPE uxHighWaterMark = uxTaskGetStackHighWaterMark(NULL);
        if (uxHighWaterMark < MIN_STACK_WATERMARK) {
            xSystemError.bStackLowError = 1;

            // Only log it when the watermark value changed.
            static portBASE_TYPE uxPreviousWatermark = 0;
            if (uxHighWaterMark != uxPreviousWatermark) {
                vLogStackWatermark("Set Path Task", (unsigned short)uxHighWaterMark);
            }
            uxPreviousWatermark = uxHighWaterMark;
        }
    }   // End of loop.

    

    // Turn off the torque and set the limit to maximum.
    eG15SetTorque(ucG15Id, WRITE_NOW, 0);
    eG15SetTorqueLimit(ucG15Id, 1023);


    // If we need to save the limits...
    if (ucSaveDiscard == 1) {
        // Reset the limit if it's wheel mode.
        if (ucWheelMode != 0) {
            ssCwLimit = 0;
            ssCcwLimit = 0;
        }
        
        // Send the command to G15 to set the limit.
        eG15SetAngleLimit(ucG15Id, (unsigned short)ssCwLimit, (unsigned short)ssCcwLimit);
    }
    // Diacard the angle limit.
    else if (ucSaveDiscard == 0) {
        // Send the command to G15 to set the limit back to its original value.
        eG15SetAngleLimit(ucG15Id, (unsigned short)ssOriCwLimit, (unsigned short)ssOriCcwLimit);
    }

    // Clear the setting path flag.
    xSystemState.bSetPath = 0;

    // Delete this task after complete.
    vTaskDelete(NULL);
}
Пример #15
0
/****************************************************************************
  Function:
    void TranslateMessageGeneric( GOL_MSG* msg )
  Description:
    This function translates the keypad message into the appropriate message
    for a generic, 4-button menu screen.  It can be used as the message
    processing function for any generic screen.
  Precondition:
    None
  Parameters:
    GOL_MSG * msg    - The current message information
  Returns:
    None
  Remarks:
    None
  ***************************************************************************/
void TranslateMessageGeneric( GOL_MSG * pMsg )
{

    if ((pMsg->uiEvent == EVENT_KEYSCAN) &&
        (pMsg->type    == TYPE_KEYBOARD) &&
        (pMsg->param1  == ID_ACCELEROMETER_PAD))
    {
        switch (pMsg->param2)
        {
            case SCAN_UP_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED | BTN_DRAW );
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
	                {
	                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED );
	                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_DRAW );
	                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED | BTN_DRAW );
                    }
                }
                break;

            case SCAN_DOWN_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED | BTN_DRAW );
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
	                {
	                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED );
	                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_DRAW );
	                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED | BTN_DRAW );
	                }
                }
                break;

            case SCAN_RIGHT_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
	                {
	                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED );
	                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_DRAW );
	                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED | BTN_DRAW );
                    }
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED | BTN_DRAW );
                }
                break;

            case SCAN_LEFT_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
	                {
	                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED );
	                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_DRAW );
	                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED | BTN_DRAW );
	                }
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED |  BTN_DRAW );
                }
                break;

            case SCAN_UP_RELEASED:
                break;

            case SCAN_DOWN_RELEASED:
                break;

            case SCAN_RIGHT_RELEASED:
                break;

            case SCAN_LEFT_RELEASED:
                break;

            case SCAN_CR_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
               	    	pMsg->param1 = ID_TOP_RIGHT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_RIGHT;
                }
                break;

            case SCAN_CR_RELEASED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
                    	pMsg->param1 = ID_TOP_RIGHT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_RIGHT;
                }
                break;
                
            case SCAN_CRA_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
                    	pMsg->param1 = ID_TOP_RIGHT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_RIGHT;
                }
                break;

            case SCAN_CRA_RELEASED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
	                if(screenState != SCREEN_GAMES)
                    	pMsg->param1 = ID_TOP_RIGHT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_RIGHT;
                }
                break;
        }
    }
}
Пример #16
0
/************************************************************************
 Function: void CreateAnimation(void)

 Overview: Shows next image in animation sequence

 Input: none

 Output: none
************************************************************************/
void NextAnimation(DWORD tick)
{
    static DWORD    prevTick = 0;
    static DWORD    prevBtnTick = 0;
    static DWORD    repeatT = REPEAT_TIMEOUT;
    BUTTON          *pBtn;
    WORD            value;

    // check if increasing speed button is pressed
    pBtn = (BUTTON *)GOLFindObject(ID_BUTTON_C);
    if(GetState(pBtn, BTN_PRESSED))
    {
        if((tick - prevBtnTick) > repeatT)
        {
            MtrSetVal(pMeter, (MtrGetVal(pMeter) - 1));
            SetState(pMeter, MTR_DRAW_UPDATE);
            if(repeatT > 30)
                repeatT -= 10;
            prevBtnTick = tick;
        }

        // check if decreasing speed button is pressed
    }
    else
    {
        pBtn = (BUTTON *)GOLFindObject(ID_BUTTON_D);
        if(GetState(pBtn, BTN_PRESSED))
        {
            if((tick - prevBtnTick) > repeatT)
            {
                MtrSetVal(pMeter, (MtrGetVal(pMeter) + 1));
                SetState(pMeter, MTR_DRAW_UPDATE);
                prevBtnTick = tick;
                if(repeatT > 30)
                    repeatT -= 10;
            }
        }
        else
        {
            repeatT = REPEAT_TIMEOUT;
            prevBtnTick = tick;
        }
    }

    // change the speed of the animation here based on the current
    // meter value
    value = MtrGetVal(pMeter);
    if(value != 0)
    {
        if((tick - prevTick) > ((500) - (3 * MtrGetVal(pMeter))))
        {
            switch(animate)
            {
            case 1:
                PictSetBitmap(pPicture, (void *) &Engine1);
                animate++;
                break;
            case 2:
                PictSetBitmap(pPicture, (void *) &Engine2);
                animate++;
                break;
            case 3:
                PictSetBitmap(pPicture, (void *) &Engine3);
                animate++;
                break;
            case 4:
                PictSetBitmap(pPicture, (void *) &Engine4);
                animate = 1;
                break;
            default:
                animate = 1;
                break;
            }

            SetState(pPicture, PICT_DRAW);  // redraw
            prevTick = tick;
        }
    }
}
Пример #17
0
/************************************************************************
 Function: WORD MsgAnimation(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg)

 Overview: This function is called by GOLMsg() function when in this
 		   particular demo each time the valid message is received for the
  		   objects in the demo.

 Input: objMsg - translated message for the object,
        pObj - pointer to the object,
        pMsg - pointer to the original GOL message.

 Output: If the function returns non-zero the message will
 		 be processed by the object directly affected by the message.
 		 Default action on the object based on the message will be
 		 performed.
************************************************************************/
WORD MsgAnimation(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg)
{
    static BYTE scale = 2;
    WORD        value;

    if(objMsg == BTN_MSG_RELEASED)
    {
        switch(GetObjID(pObj))
        {
        case ID_BUTTON_A:
            if(objMsg == BTN_MSG_RELEASED)
            {

                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);

                // implements some form of debounce
                // add code here.
                screenState = CREATE_DEMOSELECTION;
                return (0);
            }

        case ID_BUTTON_B:
            if(objMsg == BTN_MSG_RELEASED)
            {

                // do not process if user moved the touch away from the button
                // returning 1 wil update the button
                if(pMsg->uiEvent == EVENT_MOVE)
                    return (1);
            }

            if(scale == 1)
            {
                PictSetScale(pPicture, 2);      // x2
                scale = 2;
                ClrState(pPicture, PICT_FRAME); // set redraw state
            }
            else
            {
                PictSetScale(pPicture, 1);      // x1
                scale = 1;
                SetState(pPicture, PICT_FRAME); // set redraw state
            }

            SetState(pPicture, PICT_DRAW);      // set redraw state
            return (1);                         // process by default

        case ID_BUTTON_C:
            if(GetState((BUTTON *)GOLFindObject(ID_BUTTON_C), BTN_PRESSED))
            {
                value = MtrGetVal(pMeter);      // get current value
                MtrDecVal(pMeter, 1);
                SetState(pMeter, MTR_DRAW_UPDATE);
            }

            return (1);

        case ID_BUTTON_D:
            if(GetState((BUTTON *)GOLFindObject(ID_BUTTON_D), BTN_PRESSED))
            {
                value = MtrGetVal(pMeter);      // get current value
                MtrIncVal(pMeter, 1);
                SetState(pMeter, MTR_DRAW_UPDATE);
            }

            return (1);                         // process by default

        default:
            return (1);                         // process by default
        }
    }

    return (1); // process by default
}
Пример #18
0
void CalibrateCTMU( void )
{
    unsigned int    calculatedTrip;
    int             i;

    switch( calibrationState )
    {
        case CTMU_INITIALIZE:
            for (i=0; i<NUM_TOUCHPADS; i++)
            {
                sumCTMUPressed[i]         = 0;
                sumCTMUReleased[i]        = 0;
            }
            // Fall through...

        case CTMU_SHOW_PRESS_SCREEN:
            sprintf( pageInformation.instructions, "Hold touchpad %d", currentTouchpad+1 );
            SetState( (STATICTEXT *)GOLFindObject( ID_INSTRUCTIONS ), ST_DRAW );
            calibrationState ++;
            countCTMU       = 0;
            previousTick    = tick;
            stateTick       = tick;
            break;

        case CTMU_PRESS_WAIT:
            if ((tick - stateTick) >= CTMU_USER_LAG)
            {
                stateTick = tick;
                calibrationState ++;
            }
            break;

        case CTMU_READ_PRESS:
            if (tick != previousTick)
            {
                sumCTMUPressed[currentTouchpad] += rawCTMU[currentTouchpad];
                countCTMU ++;
                previousTick = tick;
            }

            if (countCTMU == CTMU_NUM_READINGS)
            {
                stateTick = tick;
                calibrationState ++;
            }
            break;

        case CTMU_SHOW_RELEASE_SCREEN:
            strcpy( pageInformation.instructions, "Release all touchpads" );
            SetState( (STATICTEXT *)GOLFindObject( ID_INSTRUCTIONS ), ST_DRAW );
            calibrationState ++;
            countCTMU       = 0;
            previousTick    = tick;
            stateTick       = tick;
            break;

        case CTMU_RELEASE_WAIT:
            if ((tick - stateTick) >= CTMU_USER_LAG)
            {
                stateTick = tick;
                calibrationState ++;
            }
            break;

        case CTMU_READ_RELEASE:
            if (tick != previousTick)
            {
                sumCTMUReleased[currentTouchpad] += rawCTMU[currentTouchpad];
                countCTMU ++;
                previousTick = tick;
            }

            if (countCTMU == CTMU_NUM_READINGS)
            {
#if defined TOUCHPAD_DIRECT_TOUCH
                // Calculate and store the trip and hysteresis for a button press.
                // Trip value is 2/3 of unpressed - pressed
                calculatedTrip = ((sumCTMUReleased[currentTouchpad] - sumCTMUPressed[currentTouchpad]) / CTMU_NUM_READINGS /3)*2;
#else

                // Calculate and store the trip and hysteresis for a button press.
                // Trip value is 9/10 of unpressed - pressed
                calculatedTrip = ((sumCTMUReleased[currentTouchpad] - sumCTMUPressed[currentTouchpad]) / CTMU_NUM_READINGS /16)*15;
#endif

                //Test for case where buttons are not pressed or incorrectly pressed during calibration
                if(calculatedTrip  < TRIP_MINIMUM)
                {
                    trip[currentTouchpad] = DEFAULT_TRIP_VALUE;
                }
                else
                {
                    trip[currentTouchpad] = calculatedTrip;

                }
#if defined TOUCHPAD_DIRECT_TOUCH
                hyst[currentTouchpad] = trip[currentTouchpad] / 4;
#else
                hyst[currentTouchpad] = trip[currentTouchpad] / 8;
#endif
                stateTick = tick;
                currentTouchpad ++;
                if (currentTouchpad >= NUM_TOUCHPADS)
                {
                    // We are done with calibration
                    calibrationState ++;
                }
                else
                {
                    // Calibrate the next touchpad.
                    calibrationState = CTMU_SHOW_PRESS_SCREEN;
                }
            }
            break;

        case CTMU_SHOW_COMPLETE:
            strcpy( pageInformation.instructions, "Calibration complete!" );
            SetState( (STATICTEXT *)GOLFindObject( ID_INSTRUCTIONS ), ST_DRAW );
            calibrationState ++;
            stateTick = tick;
            break;

        case CTMU_COMPLETE_WAIT:
            if ((tick - stateTick) >= CTMU_USER_LAG)
            {
                screenState = SCREEN_DISPLAY_MAIN;
            }
            break;
    }
}
Пример #19
0
/*****************************************************************************
 * void CreateSecurityScreen(void)
 *****************************************************************************/
void CreateSecurityScreen(void)
{
    GOL_SCHEME *currentScheme;

    currentScheme = GFX_SchemeGetCurrentScheme();

    CreatePanelScreen();                    // This adds the widgets seen on the left of the screen

    SetState(GOLFindObject(PANEL_SCREEN_ID_SECURITY_BUT), BTN_DISABLED);

    if(GetState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT),BTN_DISABLED))
    {
        ClrState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT), BTN_DISABLED);
        SetState(GOLFindObject(PANEL_SCREEN_ID_COMFORT_BUT),BTN_DRAW);
    }

    if(GetState(GOLFindObject(PANEL_SCREEN_ID_LIGHTING_BUT),BTN_DISABLED))
    {
        ClrState(GOLFindObject(PANEL_SCREEN_ID_LIGHTING_BUT), BTN_DISABLED);
        SetState(GOLFindObject(PANEL_SCREEN_ID_LIGHTING_BUT),BTN_DRAW);
    }

    if(GetState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT),BTN_DISABLED))
    {
        ClrState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT), BTN_DISABLED);
        SetState(GOLFindObject(PANEL_SCREEN_ID_ENERGY_USAGE_BUT),BTN_DRAW);
    }


    SetFont((void *) &FONTDEFAULT);
    SetColor(WHITE);
    OutTextXY(SECURITY_EB_ORIGIN_X + 70,SECURITY_EB_ORIGIN_Y -25, (XCHAR *)EnterPINStr);
    OutTextXY(SECURITY_BUTTON_ORIGIN,SECURITY_EB_ORIGIN_Y -25, (XCHAR *)SecurityOptionsStr);

    BtnCreate    //Disarmed
    (
        SERCURITY_SCREEN_ID_DISARMED_BUT,                         // button ID
        SECURITY_BUTTON_ORIGIN,
        SECURITY_EB_ORIGIN_Y,
        SECURITY_BUTTON_ORIGIN + (SECURITY_KEYSIZEX << 1),
        SECURITY_EB_ORIGIN_Y + 1 * SECURITY_KEYSIZEY,                                // dimension
        5,                                 // set radius
        BTN_DRAW,                           // draw a beveled button
        NULL,                               // no bitmap
        (XCHAR *)DisarmedStr,                 // "Button",     	// text
        currentScheme
    );

    BtnCreate    //Armed
    (
        SERCURITY_SCREEN_ID_ARMED_BUT,                         // button ID
        SECURITY_BUTTON_ORIGIN,
        SECURITY_EB_ORIGIN_Y + 1 * SECURITY_KEYSIZEY + 3,
        SECURITY_BUTTON_ORIGIN + (SECURITY_KEYSIZEX << 1),
        SECURITY_EB_ORIGIN_Y + 2 * SECURITY_KEYSIZEY,                                // dimension
        5,                                 // set radius
        BTN_DRAW,                           // draw a beveled button
        NULL,                               // no bitmap
        (XCHAR *)ArmedStr,                 // "Button",     	// text
        currentScheme
    );

    BtnCreate         //Sleeping
    (
        SERCURITY_SCREEN_ID_SLEEPING_BUT,                         // button ID
        SECURITY_BUTTON_ORIGIN,
        SECURITY_EB_ORIGIN_Y + 2 * SECURITY_KEYSIZEY +3,
        SECURITY_BUTTON_ORIGIN + (SECURITY_KEYSIZEX << 1),
        SECURITY_EB_ORIGIN_Y + 3 * SECURITY_KEYSIZEY,                                // dimension
        5,                                 // set radius
        BTN_DRAW,               // draw a beveled button
        NULL,                               // no bitmap
        (XCHAR *)SleepingStr,                 // "Button",     	// text
        currentScheme
    );

    BtnCreate         //Vacation
    (
        SERCURITY_SCREEN_ID_VACATION_BUT,                         // button ID
        SECURITY_BUTTON_ORIGIN,
        SECURITY_EB_ORIGIN_Y + 3 * SECURITY_KEYSIZEY +3,
        SECURITY_BUTTON_ORIGIN + (SECURITY_KEYSIZEX << 1),
        SECURITY_EB_ORIGIN_Y + 4 * SECURITY_KEYSIZEY,                                // dimension
        5,                                 // set radius
        BTN_DRAW,                           // draw a beveled button
        NULL,                               // no bitmap
        (XCHAR *)VacationStr,                 // "Button",     	// text
        currentScheme
    );

    BtnCreate       //Entertaining
    (
        SERCURITY_SCREEN_ID_ENTERTAINING_BUT,                         // button ID
        SECURITY_BUTTON_ORIGIN,
        SECURITY_EB_ORIGIN_Y + 4 * SECURITY_KEYSIZEY +3,
        SECURITY_BUTTON_ORIGIN + (SECURITY_KEYSIZEX << 1),
        SECURITY_EB_ORIGIN_Y + 5 * SECURITY_KEYSIZEY,                                // dimension
        5,                                 // set radius
        BTN_DRAW,                           // draw a beveled button
        NULL,                               // no bitmap
        (XCHAR *)EntertainingStr,                 // "Button",     	// text
        currentScheme
    );

    EbCreate
    (
        SERCURITY_SCREEN_ID_CODE_EDIT_BOX,    // ID
        SECURITY_KEYSTARTX+5,
        SECURITY_KEYSTARTY + 1,
        SECURITY_KEYSTARTX + (3 * SECURITY_KEYSIZEX)-5,
        SECURITY_KEYSTARTY + 1 * SECURITY_KEYSIZEY - GOL_EMBOSS_SIZE, // dimension
        EB_DRAW | EB_CARET | EB_FOCUSED,            // will be dislayed after creation
        NULL,
        17,
        currentScheme
    );                              // default GOL scheme


    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_0_BUT,              // ID
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 4 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 5 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[0],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_1_BUT,              // ID
        SECURITY_KEYSTARTX + 0 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 1 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 2 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[1],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_2_BUT,              // ID
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 1 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 2 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[2],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_3_BUT,              // ID
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 1 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 3 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 2 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[3],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_4_BUT,              // ID
        SECURITY_KEYSTARTX + 0 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 2 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 3 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[4],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_5_BUT,              // ID
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 2 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 3 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[5],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_6_BUT,              // ID
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 2 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 3 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 3 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[6],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_7_BUT,              // ID
        SECURITY_KEYSTARTX + 0 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 3 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 4 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[7],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_8_BUT,              // ID
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 3 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 4 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[8],              // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_KEYPAD_9_BUT,              // ID
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 3 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 3 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 4 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        padNumbers[9],              // text
        currentScheme
    );                              // alternative GOL scheme

    BtnCreate
    (
        SERCURITY_SCREEN_ID_CLEAR_BUT,                // ID
        SECURITY_KEYSTARTX + 0 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 4 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 1 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 5 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        (XCHAR *)ClearStr,             // text
        currentScheme
    );                              // alternative GOL scheme
    BtnCreate
    (
        SERCURITY_SCREEN_ID_ENTER_BUT,                   // ID
        SECURITY_KEYSTARTX + 2 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 4 * SECURITY_KEYSIZEY,
        SECURITY_KEYSTARTX + 3 * SECURITY_KEYSIZEX,
        SECURITY_KEYSTARTY + 5 * SECURITY_KEYSIZEY,   // dimension
        5,
        BTN_DRAW,                   // will be dislayed after creation
        NULL,                       // no bitmap
        (XCHAR *)EnterStr,             // text
        currentScheme
    );                              // alternative GOL scheme


}
Пример #20
0
WORD GOLDrawCallback( void )
{
	unsigned char           i;
    OBJ_HEADER              *pObject;
	extern unsigned int     trip[NUM_TOUCHPADS];

    switch (screenState)
    {
        case SCREEN_BOARD_TEST:
            PerformBoardTest();
            break;
            
        case SCREEN_DISPLAY_MAIN:
            ShowScreenMain();
            displayChangeTime   = tick;
            screenState         = SCREEN_MAIN;
            break;

        case SCREEN_MAIN:
            RTCCProcessEvents();

            if (previousSecond != _time_str[11])
            {
                previousSecond = _time_str[11];
                strcpy( pageInformation.instructions, _date_str );
                strcat( pageInformation.instructions, "  " );
                strcat( pageInformation.instructions, _time_str );

                pObject = GOLFindObject( ID_INSTRUCTIONS );
                StSetText( (STATICTEXT *)pObject, pageInformation.instructions );
                SetState( pObject, ST_DRAW );
            }
            break;

        case SCREEN_DISPLAY_FLASH:
            ShowScreenFlash();
            displayChangeTime   = tick;
            screenState         = SCREEN_FLASH;
            break;

        case SCREEN_FLASH:
            FlashMonitorMedia();
            break;

        case SCREEN_DISPLAY_FLASH_ERROR:
            ShowScreenFlashError();
            displayChangeTime   = tick;
            screenState         = SCREEN_FLASH_ERROR;
            break;

        case SCREEN_FLASH_ERROR:
            break;

        case SCREEN_DISPLAY_GAMES:
            ShowScreenGames();
            displayChangeTime   = tick;
            screenState         = SCREEN_GAMES;
            break;

        case SCREEN_GAMES:
            break;

        case SCREEN_DISPLAY_SNAKE:
            ShowScreenSnake();
            displayChangeTime   = tick;
            screenState         = SCREEN_SNAKE;
            break;

        case SCREEN_SNAKE:
            DrawSnake();
            break;

        case SCREEN_DISPLAY_SNAKE_SCORE:
            ShowScreenScore();
            displayChangeTime   = tick;
            screenState         = SCREEN_SNAKE_SCORE;
            break;

        case SCREEN_SNAKE_SCORE:
            break;

        case SCREEN_DISPLAY_BLASTER:
            ShowScreenBlaster();
            // Set the touchpad sensitivity for quicker game play.
			for (i=0; i<NUM_TOUCHPADS; i++) 
			{
    			trip[i]=TRIP_VALUE_BLASTER;
            } 			
            displayChangeTime   = tick;
            screenState         = SCREEN_BLASTER;
            break;

        case SCREEN_BLASTER:
            DrawBlaster();
            break;

        case SCREEN_DISPLAY_BLASTER_SCORE:
            ShowScreenScore();
            // Reset the touchpad sensitivity to normal.
			for(i=0; i<NUM_TOUCHPADS; i++) 
			{
    			trip[i]=TRIP_VALUE;
            } 			
            displayChangeTime   = tick;
            screenState         = SCREEN_BLASTER_SCORE;
            break;

        case SCREEN_BLASTER_SCORE:
            break;

        case SCREEN_DISPLAY_SHAPELET:
            ShowScreenShapelet();
            displayChangeTime   = tick;
            screenState         = SCREEN_SHAPELET;
            break;

        case SCREEN_SHAPELET:
            break;

        case SCREEN_DISPLAY_SHAPELET_SCORE:
            ShowScreenScore();
            displayChangeTime   = tick;
            screenState         = SCREEN_SHAPELET_SCORE;
            break;

        case SCREEN_SHAPELET_SCORE:
            break;

        case SCREEN_DISPLAY_DEMOS:
            ShowScreenDemos();
            displayChangeTime   = tick;
            screenState         = SCREEN_DEMOS;
            break;

        case SCREEN_DEMOS:
            break;

        case SCREEN_DISPLAY_RGB:
            ShowScreenRGB();
            displayChangeTime   = tick;
            screenState         = SCREEN_RGB;
            break;

        case SCREEN_RGB:
            break;

        case SCREEN_DISPLAY_GRAPH:
            ShowScreenGraph();
            displayChangeTime   = tick;
            screenState         = SCREEN_GRAPH;
            break;

        case SCREEN_GRAPH:
            UpdateGraph();
            break;

        case SCREEN_DISPLAY_CAPTURE_MEDIA:
            ShowScreenCaptureMedia();
            displayChangeTime   = tick;
            screenState         = SCREEN_CAPTURE_MEDIA;
            break;

        case SCREEN_CAPTURE_MEDIA:
            CaptureMonitorMedia();
            break;

        case SCREEN_DISPLAY_CAPTURE:
            ShowScreenCapture();
            displayChangeTime   = tick;
            screenState         = SCREEN_CAPTURE;
            break;

        case SCREEN_CAPTURE:
            UpdateGraph();
            CaptureMonitorMedia();
            break;

        case SCREEN_DISPLAY_UTILITIES:
            ShowScreenUtilities();
            displayChangeTime   = tick;
            screenState         = SCREEN_UTILITIES;
            break;

        case SCREEN_UTILITIES:
            break;

        case SCREEN_DISPLAY_TIME:
            ShowScreenTime();
            displayChangeTime   = tick;
            screenState         = SCREEN_TIME;
            break;

        case SCREEN_TIME:
            break;

        case SCREEN_DISPLAY_CTMU:
            ShowScreenCTMU();
            displayChangeTime   = tick;
            screenState         = SCREEN_CTMU;
            break;

        case SCREEN_CTMU:
            CalibrateCTMU();
            break;

		case SCREEN_DISPLAY_BAR_DEMO:
			ShowScreenBarDemo();
			displayChangeTime	= tick;
			screenState			= SCREEN_BAR_DEMO;
			break;

		case SCREEN_BAR_DEMO:
			DrawBarDemo();
			break;
    }

    return 1;   // Callback complete
}
Пример #21
0
  Function:
    void TranslateMessageGeneric( GOL_MSG* msg )

  Description:
    This function translates the keypad message into the appropriate message
    for a generic, 4-button menu screen.  It can be used as the message
    processing function for any generic screen.

  Precondition:
    None

  Parameters:
    GOL_MSG * msg    - The current message information

  Returns:
    None

  Remarks:
    None
  ***************************************************************************/

void TranslateMessageGeneric( GOL_MSG * pMsg )
{

    if ((pMsg->uiEvent == EVENT_KEYSCAN) &&
        (pMsg->type    == TYPE_KEYBOARD) &&
        (pMsg->param1  == ID_TOUCH_PAD))
    {
        switch (pMsg->param2)
        {
            case SCAN_UP_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED | BTN_DRAW );
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED | BTN_DRAW );
                }
				else if (GetState( (BUTTON *)GOLFindObject( ID_THIRDROW ), BTN_PRESSED ) && !strcmp(pageInformation.title,"Demonstrations"))
				{
					ClrState( (BUTTON *)GOLFindObject( ID_THIRDROW ),    BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_THIRDROW ),    BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED | BTN_DRAW );
				}
                break;

            case SCAN_DOWN_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED | BTN_DRAW );
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED | BTN_DRAW );
                }
				else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ) && !strcmp(pageInformation.title,"Demonstrations"))
				{
					ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),    BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),    BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_THIRDROW ), BTN_PRESSED | BTN_DRAW );
				}
                break;

            case SCAN_RIGHT_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED | BTN_DRAW );
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED | BTN_DRAW );
                }
                break;

            case SCAN_LEFT_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ),    BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ),     BTN_PRESSED | BTN_DRAW );
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    ClrState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_DRAW );
                    SetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ),  BTN_PRESSED |  BTN_DRAW );
                }
                break;

            case SCAN_UP_RELEASED:
                break;

            case SCAN_DOWN_RELEASED:
                break;

            case SCAN_RIGHT_RELEASED:
                break;

            case SCAN_LEFT_RELEASED:
                break;

            case SCAN_CR_PRESSED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_RIGHT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_RIGHT;
                }
				else if (GetState( (BUTTON *)GOLFindObject( ID_THIRDROW ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_THIRDROW;
                }
                break;

            case SCAN_CR_RELEASED:
                if (GetState( (BUTTON *)GOLFindObject( ID_TOP_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_LEFT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_LEFT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_TOP_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_TOP_RIGHT;
                }
                else if (GetState( (BUTTON *)GOLFindObject( ID_BOTTOM_RIGHT ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_BOTTOM_RIGHT;
                }
				else if (GetState( (BUTTON *)GOLFindObject( ID_THIRDROW ), BTN_PRESSED ))
                {
                    pMsg->param1 = ID_THIRDROW;
                }
                break;

        }
    }
}