Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Converting a game from J2ME to Brew and so far its going good. But i was wondering what options do i have to sleep the phone for say 5ms each frame?

In J2ME i can sleep the tread for any amount of time and that works well on all J2ME phones, but what is best practice for Brew.

Also whats the safest bug free way of polling the time in Milli seconds in brew?

Many Thanks

Use ISHELL_SetTimer to give delay in milliseconds between each frame...

Use ISHELL_SetTimer to give delay in milliseconds between each frame...

Hi all, :)
sreeharig wrote:Use ISHELL_SetTimer to give delay in milliseconds between each frame...
This API call is not equal to sleep or delay the device for a specific amount of time.
Just it will call the specifed method in that API after the set timer expires in between, the app will continue its execution of statements followed after this API call or process the user events as per the App request. its all depends on your coding sequence.
For Eample:
ISHELL_SetTimer(pMe->a.m_pIShell,6000, (PFNNOTIFY)DisplayScreen, pMe );
So after 6 Sec "DisplayScreen" method will be called but b4 that happens the following image will be displayed on the screen.
IIMAGE_GetInfo(pMe->pImageStill, &ii);
IIMAGE_Draw(pMe->pImageStill, ((pMe->cxScreen-ii.cx)/2), ((pMe->cyScreen-ii.cy)/2) );
IDISPLAY_UpdateEx(pMe->a.m_pIDisplay,FALSE);
In C we have delay() method which stop executing the App further for the given time, But in BREW i didn't come accross an API call that exactly suits for your purpose -- May be some seniors guys will comment on this.
:cool: Have a nice day.

Hi all, :)
sreeharig wrote:Use ISHELL_SetTimer to give delay in milliseconds between each frame...
This API call is not equal to sleep or delay the device for a specific amount of time.
Just it will call the specifed method in that API after the set timer expires in between, the app will continue its execution of statements followed after this API call or process the user events as per the App request. its all depends on your coding sequence.
For Eample:
ISHELL_SetTimer(pMe->a.m_pIShell,6000, (PFNNOTIFY)DisplayScreen, pMe );
So after 6 Sec "DisplayScreen" method will be called but b4 that happens the following image will be displayed on the screen.
IIMAGE_GetInfo(pMe->pImageStill, &ii);
IIMAGE_Draw(pMe->pImageStill, ((pMe->cxScreen-ii.cx)/2), ((pMe->cyScreen-ii.cy)/2) );
IDISPLAY_UpdateEx(pMe->a.m_pIDisplay,FALSE);
In C we have delay() method which stop executing the App further for the given time, But in BREW i didn't come accross an API call that exactly suits for your purpose -- May be some seniors guys will comment on this.
:cool: Have a nice day.

Why you wouldn't be able to use ISHELL_SetTimer, BREW's timer is singleshot timer, it does set periodic call unless you set the timer periodically, may be I don't understand your requirements.

Why you wouldn't be able to use ISHELL_SetTimer, BREW's timer is singleshot timer, it does set periodic call unless you set the timer periodically, may be I don't understand your requirements.

Yes as Ruben suggested, ISHELL_SetTimer is the best option available AFAIK. In j2me, the thread will execute continuously once it starts. So there is no better way to control it except to sleep the thread for the required period.
In brew its more simpler to set a Timer call back using ISHELL_SetTimer, from which call the required paint functions (or indeed any other function) and set the timer again for the next call back.
--
R.Pradeep

Yes as Ruben suggested, ISHELL_SetTimer is the best option available AFAIK. In j2me, the thread will execute continuously once it starts. So there is no better way to control it except to sleep the thread for the required period.
In brew its more simpler to set a Timer call back using ISHELL_SetTimer, from which call the required paint functions (or indeed any other function) and set the timer again for the next call back.
--
R.Pradeep

>Also whats the safest bug free way of polling the time in Milli seconds in brew?
GETTIMEMS is the safest way.
you can forcibly delay brew apps for a few ms simply by either a simple delay, or a check in the handleevent loop, just stall it for the amount of time desire.
however its not a great idea, and you may upset the watchdog., the SetTimer method is better and depending on how you setup the handleevent function, it should work the same.

>Also whats the safest bug free way of polling the time in Milli seconds in brew?
GETTIMEMS is the safest way.
you can forcibly delay brew apps for a few ms simply by either a simple delay, or a check in the handleevent loop, just stall it for the amount of time desire.
however its not a great idea, and you may upset the watchdog., the SetTimer method is better and depending on how you setup the handleevent function, it should work the same.