Ejemplo n.º 1
0
void Slider_Start(Slider *me, int16 nTarget, PFNNOTIFY pfnDone, 
                  uint32 ulDelay)
{
   int16 nDiff = me->nTarget - *me->pnInc;

   me->nTarget = nTarget;
   me->pfnDone = pfnDone;
   me->ulDelay = ulDelay;
   
   if (0 == me->ulDelay) {

      *me->pnInc = me->nTarget;

   } else if (0 < (int32)me->ulDelay) { /* if delay is positive, means
                                    total delay, calculate number of 
                                    steps to take total delay */
      int nlog;
      
      for (nlog = 1; 0 != (nDiff/=2); nlog++); /* calculate log(nDiff) */
      
      me->ulDelay = me->ulDelay / nlog;
   } else {
      me->ulDelay = 0-me->ulDelay; /* if delay is negative, 
                                              is explicit time 
                                              between steps */
   }
   
   ISHELL_SetTimerEx(me->piShell,0,&me->cb);
}
Ejemplo n.º 2
0
/**
  || Function
  || --------
  || static void Tooltip_Show(void *p)
  ||
  || Description
  || -----------
  || sets the Tooltip to showing (internal func)
  ||
  || Parameters
  || ----------
  || void *p: the Tooltip
  ||
  || Returns
  || -------
  || nothing
  ||
  || Remarks
  || -------
  ||
  */
static void Tooltip_Show(void *p)
{
    Tooltip *me = (Tooltip *)p;

    me->bShown = TRUE;

    me->pfnInvalidate(me->pInvalidateData);

    CALLBACK_Init(&me->cb,Tooltip_Hide,me);
    ISHELL_SetTimerEx(me->piShell,me->ulExpires,&me->cb);
}
Ejemplo n.º 3
0
/**
  || Function
  || --------
  || static void StatusBox_AnimateTimer(void *p)
  ||
  || Description
  || -----------
  || timer tick for non-self-animated IImages
  ||
  || Parameters
  || ----------
  || void *p: the StatusBox
  ||
  || Returns
  || -------
  || nothing
  ||
  || Remarks
  || -------
  ||
  */
static void StatusBox_AnimateTimer(void *p)
{
   StatusBox *me = (StatusBox *)p;

   if (++me->nFrame >= me->nFrames) {
      me->nFrame = 0;
   }

   me->pfnInvalidate(me->pInvalidateData);

   ISHELL_SetTimerEx(me->piShell,me->uFrameDuration,&me->cb);
}
Ejemplo n.º 4
0
/*===========================================================================
===========================================================================*/
static void SamplePosDet_GetGPSInfo_SecondTicker( CSamplePosDet *pMe )
{
   struct _GetGPSInfo *pGetGPSInfo = SamplePosDet_GetScreenData( pMe );


   if( pGetGPSInfo->bPaused == FALSE ) {
      pGetGPSInfo->wProgress++;
      SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_FIXANIM );
   }
   if( pGetGPSInfo->bAbort == FALSE ) {
      ISHELL_SetTimerEx( pMe->theApp.m_pIShell, 1000, &pGetGPSInfo->cbProgressTimer );
   }
}
Ejemplo n.º 5
0
void Tooltip_Push(Tooltip *me,const char *cpszResFile, uint16 wId,
                  int nXPercent)
{
    me->nXPercent = nXPercent;

    FREEIF(me->pStringData);

    if (SUCCESS ==
            IShell_LoadResWsz(me->piShell,cpszResFile,wId,&me->pStringData)) {
        me->pwsz = me->pStringData;
    } else {
        me->pwsz = (AECHAR *)dotdotdot;
    }

    if (!me->bShown) {
        CALLBACK_Init(&me->cb,Tooltip_Show,me);
        ISHELL_SetTimerEx(me->piShell,me->ulDelay,&me->cb);
    } else {
        Tooltip_Show(me);
    }
}
Ejemplo n.º 6
0
void setSharedTimerFireTime(double fireTime)
{
    ASSERT(sharedTimerFiredFunction);

    CALLBACK_Cancel(&sharedTimerCallback);

    double interval = fireTime - currentTime();
    int intervalInMS;

    if (interval < 0)
        intervalInMS = 0;
    else {
        interval *= 1000;
        intervalInMS = static_cast<int>(interval);
    }

    sharedTimerCallback.pfnCancel = 0;
    sharedTimerCallback.pfnNotify = invokeCallback;
    sharedTimerCallback.pNotifyData = 0;

    IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell;
    ISHELL_SetTimerEx(shell, intervalInMS, &sharedTimerCallback);
}
Ejemplo n.º 7
0
/**
  || Function
  || --------
  || static void Slider_Inc(void *p)
  ||
  || Description
  || -----------
  || internal Slider increment function, calls client's inc function
  ||  after updating *pnInc
  ||
  || Parameters
  || ----------
  || void *p: the Slider
  ||
  || Returns
  || -------
  || nothing
  ||
  || Remarks
  || -------
  ||
  */
static void Slider_Inc(void *p)
{
   Slider *me = (Slider *)p;
   int16 nDiff = me->nTarget - *me->pnInc;
   
   if (0 != nDiff) {
      if (nDiff != 1 && nDiff != -1) {
         
         if (nDiff & 1) { /* odd, round up */
            if (nDiff < 0) {
               nDiff--;
            } else {
               nDiff++;
            }
         }
         *me->pnInc += nDiff/2;
      } else {
         *me->pnInc += nDiff;
         nDiff = 0;
      }
   }
   
   /* set timer before calling the inc function (may take a while) */
   if (0 != nDiff) {
      ISHELL_SetTimerEx(me->piShell,me->ulDelay,&me->cb);
   }

   /* call the inc function for every step, even last */
   if ((PFNNOTIFY)0 != me->pfnInc) {
      me->pfnInc(me->pNotifyData);
   }

   /* call done if no diff */
   if ((0 == nDiff) && ((PFNNOTIFY)0 != me->pfnDone)) {
      me->pfnDone(me->pNotifyData);
   }
}
Ejemplo n.º 8
0
static void Loc_cbInfo( LocState *pts ) {
	
	if( pts->theInfo.status == AEEGPS_ERR_NO_ERR 
		|| (pts->theInfo.status == AEEGPS_ERR_INFO_UNAVAIL && pts->theInfo.fValid) ) {
		
#if MIN_BREW_VERSION(2,1)
		pts->pResp->lat = WGS84_TO_DEGREES( pts->theInfo.dwLat );
#ifdef AEE_SIMULATOR
		//FOR TEST
		pts->pResp->lon = -WGS84_TO_DEGREES( pts->theInfo.dwLon );
#else
		pts->pResp->lon = WGS84_TO_DEGREES( pts->theInfo.dwLon );
#endif
#else
		double    wgsFactor;
		wgsFactor = FASSIGN_STR("186413.5111");
		pts->pResp->lat = FASSIGN_INT(pts->theInfo.dwLat);
		pts->pResp->lat = FDIV(pts->pResp->lat, wgsFactor);
		
		pts->pResp->lon = FASSIGN_INT(pts->theInfo.dwLon);
		pts->pResp->lon = FDIV(pts->pResp->lon, wgsFactor);
#endif /* MIN_BREW_VERSION 2.1 */
		
		pts->pResp->height = pts->theInfo.wAltitude - 500;
		pts->pResp->velocityHor = FMUL( pts->theInfo.wVelocityHor,0.25);
		
		//当前夹角
		if (FCMP_G(FABS(pts->lastCoordinate.lat), 0))
		{
			pts->pResp->heading = Loc_Calc_Azimuth(pts->lastCoordinate.lat, pts->lastCoordinate.lon, pts->pResp->lat, pts->pResp->lon);
		}
		else
		{
			pts->pResp->heading = 0;
		}

		//For Test Hack
#ifdef AEE_SIMULATOR
		pts->pResp->lat = 38.0422378880;
		pts->pResp->lon = 114.4925141047;
#endif
		if (pts->pResp->bSetDestPos)
		{
			//计算距离和方位角
			pts->pResp->distance = Loc_Calc_Distance(pts->pResp->lat, pts->pResp->lon, pts->pResp->destPos.lat, pts->pResp->destPos.lon);
			pts->pResp->destHeading = Loc_Calc_Azimuth(pts->pResp->lat, pts->pResp->lon, pts->pResp->destPos.lat, pts->pResp->destPos.lon);
		}
		
		//记录历史定位信息
		pts->lastCoordinate.lat = pts->pResp->lat;
		pts->lastCoordinate.lon = pts->pResp->lon;
		
		pts->pResp->dwFixNum++;
		
		pts->pResp->nErr = SUCCESS;
		
		Loc_Notify( pts );
		
		if( FALSE == pts->bSetForCancellation ) {
			
			ISHELL_SetTimerEx( pts->pShell, pts->nLocInterval * 1000, &pts->cbIntervalTimer );
		}
		else {
			
			Loc_Stop( pts );
		}
	}
}
Ejemplo n.º 9
0
/*===========================================================================
===========================================================================*/
boolean SamplePosDet_GetGPSInfo_HandleEvent( CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam )
{
   boolean bHandled = FALSE;
   struct _GetGPSInfo *pGetGPSInfo = SamplePosDet_GetScreenData( pMe );

   switch( eCode ) {

   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pGetGPSInfo == 0 ) {

            pGetGPSInfo = MALLOC( sizeof( struct _GetGPSInfo ) );

            if( pGetGPSInfo ) {
               int nErr = SUCCESS;
               ZEROAT( pGetGPSInfo );

               pGetGPSInfo->theInfo.server = pMe->gpsSettings.server;
               pGetGPSInfo->theInfo.qos = pMe->gpsSettings.qos;
               pGetGPSInfo->theInfo.optim = pMe->gpsSettings.optim;

               pGetGPSInfo->wMainMenuEntry = (uint16)dwParam;
               SamplePosDet_SetScreenData( pMe, (void *)pGetGPSInfo );

               if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_POSDET,
                  (void **)&pGetGPSInfo->pPosDet ) == SUCCESS ) {

                  CALLBACK_Init( &pGetGPSInfo->cbPosDet, SamplePosDet_GetGPSInfo_Callback, pMe );
                  CALLBACK_Init( &pGetGPSInfo->cbProgressTimer, SamplePosDet_GetGPSInfo_SecondTicker, pMe );

                  nErr = Track_Init( pMe->theApp.m_pIShell, pGetGPSInfo->pPosDet, 
                                        &pGetGPSInfo->cbPosDet, &pGetGPSInfo->pts );
                  if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_ONE_SHOT ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_NETWORK, 1, 0, &pGetGPSInfo->theInfo );
                  }
                  else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_LOCAL ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_LOCAL, 0, 0, &pGetGPSInfo->theInfo );
                  }
                  else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_NETWORK ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_NETWORK, 0, 0, &pGetGPSInfo->theInfo );
                  }
                  else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_AUTO ) {
                     nErr = Track_Start( pGetGPSInfo->pts, TRACK_AUTO, 0, 0, &pGetGPSInfo->theInfo );
                  }
                  else {
                     nErr = EFAILED;
                  }
 
                  SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ALL );
                  if( nErr != SUCCESS ) {
                     pGetGPSInfo->theInfo.nErr = nErr;
                     SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ERROR );
                  }
                  else {
                     ISHELL_SetTimerEx( pMe->theApp.m_pIShell, 1000, &pGetGPSInfo->cbProgressTimer );
                  }

                  bHandled = TRUE;
               }
            }
         }
         if( !bHandled ) {
            SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 );
            bHandled = TRUE;
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         if( pGetGPSInfo ) {
            if( pGetGPSInfo->pPosDet ) {
               CALLBACK_Cancel( &pGetGPSInfo->cbProgressTimer );
               CALLBACK_Cancel( &pGetGPSInfo->cbPosDet );
               IPOSDET_Release( pGetGPSInfo->pPosDet );
            }
            FREE( pGetGPSInfo );
         }
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( !pGetGPSInfo->bPaused ) {
            SamplePosDet_GetGPSInfo_Paint( pMe, (GetGPSInfo_PaintRegions)dwParam );
         }
         bHandled = TRUE;
      }
      break;

   case EVT_KEY:
      if( wParam == AVK_CLR || wParam == AVK_SOFT2) {

		 Track_Stop(pGetGPSInfo->pts);

		if (pGetGPSInfo) {
			if (pGetGPSInfo->pPosDet) {
				CALLBACK_Cancel(&pGetGPSInfo->cbProgressTimer);
				CALLBACK_Cancel(&pGetGPSInfo->cbPosDet);
				IPOSDET_Release(pGetGPSInfo->pPosDet);
			}
			FREE(pGetGPSInfo);
		}

         SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 );

         bHandled = TRUE;
      }
      break;

   case EVT_DIALOG_START:
      pGetGPSInfo->bPaused = TRUE;
      bHandled = TRUE;
      break;

   case EVT_DIALOG_END:
      pGetGPSInfo->bPaused = FALSE;
      SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ALL );
      bHandled = TRUE;
      break;

   case EVT_COMMAND:
      break;
   }

   return bHandled;
}
Ejemplo n.º 10
0
static void Track_cbInfo( TrackState *pts )
{
   if( pts->theInfo.status == AEEGPS_ERR_NO_ERR 
      || (pts->theInfo.status == AEEGPS_ERR_INFO_UNAVAIL && pts->theInfo.fValid) ) {

#if MIN_BREW_VERSION(2,1)
      pts->pResp->lat = WGS84_TO_DEGREES( pts->theInfo.dwLat );
      pts->pResp->lon = WGS84_TO_DEGREES( pts->theInfo.dwLon );
#else
      double    wgsFactor;
      wgsFactor = FASSIGN_STR("186413.5111");
      pts->pResp->lat = FASSIGN_INT(pts->theInfo.dwLat);
      pts->pResp->lat = FDIV(pts->pResp->lat, wgsFactor);

      pts->pResp->lon = FASSIGN_INT(pts->theInfo.dwLon);
      pts->pResp->lon = FDIV(pts->pResp->lon, wgsFactor);
#endif /* MIN_BREW_VERSION 2.1 */

    pts->pResp->height = pts->theInfo.wAltitude - 500;
	  pts->pResp->wAzimuth = pts->orientInfo.wAzimuth;
	  pts->pResp->heading = pts->theInfo.wHeading;
	  pts->pResp->velocityHor = FMUL( pts->theInfo.wVelocityHor,0.25);

      pts->pResp->dwFixNum++;

      pts->pResp->nErr = SUCCESS;

      Track_Notify( pts );

      if( (!pts->nPendingFixes || --pts->nPendingFixes > 0) 
         && FALSE == pts->bSetForCancellation ) {

         if( pts->bModeAuto && pts->bModeLocal == FALSE ) {

            /* Try with local first */
            Track_Local( pts );
         }

         ISHELL_SetTimerEx( pts->pShell, pts->nTrackInterval * 1000, &pts->cbIntervalTimer );
      }
      else {

         Track_Stop( pts );
      }
   }
   else {

      if( pts->bModeAuto && pts->bModeLocal ) {

         /* Retry with TRACK_NETWORK */
         Track_Network( pts );
         Track_cbInterval( pts );
      }

      else { 
         
		  DBGPRINTF("@Track_cbInfo status:%u", pts->theInfo.status);

         /* Inform the application of failure code. */
         pts->pResp->nErr = pts->theInfo.status;
         
         Track_Notify( pts );
         
         /* On timeout re-try. For other reasons bailout. */
         if( pts->theInfo.status == AEEGPS_ERR_TIMEOUT ) {
            
            Track_cbInterval( pts );
         }
         else {
			 
            Track_Stop( pts );
         }
      }
   }
}