Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Share Your Creations
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Share Your Creations Show your developed application to Basic4ppc community. Please include source code if possible.

Small stopwatch

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-10-2008, 09:09 AM
Junior Member
 
Join Date: Jul 2007
Posts: 40
Default Small stopwatch

As the title says - a small stopwatch.

Regards: Token
Attached Files
File Type: zip StoppUhr.zip (17.7 KB, 207 views)

Last edited by token : 08-13-2008 at 09:44 PM.
Reply With Quote
  #2 (permalink)  
Old 08-13-2008, 12:43 PM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default

Hi Token,

I like your code and design especially the "Retour-en-vol" feature aka "Flyback", where the reset button works even while the stopwatch is running. This feature is very usefull for tennis umpires and golf referees.

If screen space permits maybe you could add a "Lap" feature which would stop updating the display (whilst still running the stopwatch) until the button is pushed again.

One thing I did notice is that it takes 67 real seconds on my PC for the stopwatch to clock up 1 minute and similar times in My PPC.

I think this is because the timer does not wake you up exactly as requested.

On My PC I observed an occasional 101 ms interval and about once every 10 or so events the interval was 110 ms (which explains the extra 7 seconds per minute). On the PPC the intervals tended to be more regular but were usually about 102 or 103 ms but still with the odd very large one.

One way to combat this would be to get the msec value of GetTickCount (from the dz.dll library) whenever the start button is pushed and divide by 10 to get a tenths of a second value. Then set the timer value to (for example) 31 msec so that you definetly get woken up multiple times every 1/10th of a second. Each time you wake up get a new value of Get TickCount, divide by 10 and if this value is greater than the last sample then increment your counters.

Cheers
Nick
Reply With Quote
  #3 (permalink)  
Old 08-13-2008, 01:16 PM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default



After all that I found that the answer is even more simple.

Your counter for tenths of a second has 11 values (0 to 10) instead of 10

Therefore if you change If TimerTenSec < 10 to If TimerTenSec < 9 then the stopwatch wil be a lot more accurate.

However the method I suggested would ( I think) be still more accurate. I'll do some more timing test now.
Reply With Quote
  #4 (permalink)  
Old 08-13-2008, 02:33 PM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default

Hi again,

Even after changing your constants "10 60 60" to "9 59 59" the stopwatch still lost about 10 seconds in 10 minutes on the PPC.

Using GetTickCount (divided by 100, not 10 as I said) the stopwatch was only 1 second out after 10 minutes on the PPC - I think the mechanical stopwatch I was checking it against may have a small problem. I'll check it now against a couple of quartz chronographs.

I'll get this right soon, I hope.
Reply With Quote
  #5 (permalink)  
Old 08-13-2008, 08:49 PM
Junior Member
 
Join Date: Jul 2007
Posts: 40
Default

Quote:
Originally Posted by nm7s9 View Post


After all that I found that the answer is even more simple.

Your counter for tenths of a second has 11 values (0 to 10) instead of 10

Therefore if you change If TimerTenSec < 10 to If TimerTenSec < 9 then the stopwatch wil be a lot more accurate.

However the method I suggested would ( I think) be still more accurate. I'll do some more timing test now.
Seems to be right - stupid mistake of me...

Thanks a lot to everyone for the nice and helpfull feedback!

I've clicked this app together cause someone asked for a stopwatch for his diamond in an user-forum - seems to be not totaly trivial to build a really accurate timing, even aside from my mistake.

Many regards:

Token

p.s.: I've corrected the constants and updated the attachement within the first post.

Last edited by token : 08-13-2008 at 08:56 PM.
Reply With Quote
  #6 (permalink)  
Old 08-13-2008, 09:47 PM
Junior Member
 
Join Date: Jul 2007
Posts: 40
Default

As nm7s9 suggested, I've added some kind of a Laptimer. I'm not shure, if each lap has to start with 0 again - please advice me, if this is the case.

Will try to get a better timer-accuracy in a later version.

Regards:

Token

Last edited by token : 08-13-2008 at 09:51 PM.
Reply With Quote
  #7 (permalink)  
Old 08-14-2008, 12:03 AM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default

LapTimer feature works perfectly. No need to reset any counters since Lap time is just a "snapshot" of current counters.

I wonder if it is possible to display the bottom bit of the table rather than the top bit without having to reverse sort it or remove the top entries.

I don't seem to be able to use TableLap.RowCount in a filter expression.


PS -the GetTickCount method is still losing 8 seconds each hour on my PPC but is exactly correct on the desktop. I WILL find those missing seconds (maybe this weekend).
Reply With Quote
  #8 (permalink)  
Old 08-14-2008, 05:09 AM
Junior Member
 
Join Date: Jul 2007
Posts: 40
Default

Quote:
Originally Posted by nm7s9 View Post
LapTimer feature works perfectly. No need to reset any counters since Lap time is just a "snapshot" of current counters.

I wonder if it is possible to display the bottom bit of the table rather than the top bit without having to reverse sort it or remove the top entries.

I don't seem to be able to use TableLap.RowCount in a filter expression.


PS -the GetTickCount method is still losing 8 seconds each hour on my PPC but is exactly correct on the desktop. I WILL find those missing seconds (maybe this weekend).
Could you tell me where I can find the dz.dll you've mentioned? Did a forum-search but without success.

I've searched for "timer" in the forum to get any hint about accuracy but also without success.

Perhaps the problem is, I'am adding only 1/10 tick-events together. I do not know if executing of every tick in windows-mobile is guaranted or if it can be lost by heavy os-load. I even not know, if one can trust the timer of a windows-mobile device.
Reply With Quote
  #9 (permalink)  
Old 08-14-2008, 06:46 AM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by nm7s9 View Post

PS -the GetTickCount method is still losing 8 seconds each hour on my PPC but is exactly correct on the desktop. I WILL find those missing seconds (maybe this weekend).
You should take in account that the desktop processing speed is much greater that the device, so the time lost in processing the code at each "Tick" is discrdable, BUT in the device is something to keep in mind... I would suggest to try different timer.interval values...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #10 (permalink)  
Old 08-14-2008, 08:09 AM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default

Hi Paulo,

Thanks for the reply. I believe that my method is independent from processing time in the subroutines and cpu workload. I just use the difference of the GetTickCount at button start to what it is now to determine whether to bump the counters or not (and make sure I am woken up multiple times in each time window.

What I have noticed is that I allowed a very small incemental error to accumulate, which I think explains my 7 sec/hour error. I've coded around this and will test its accuracy a bit later tonight.

BTW do you know of a method to display the bottom bit of a table rather than the top bit. I.E can you scroll the scrollbars under program control??

Token, The GetTickCount function can be called using the dzHW.dll and dzHWdesktop.dll. See the thread "Font Problem" in the Questions and answers section which contains a link to this "Useful Library"

Cheers
Nick
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Italy-StopWatch v1.01 Filippo Share Your Creations 6 10-26-2008 05:07 AM
Italy-StopWatch (Cronometro) Filippo Italian Forum 3 09-04-2008 12:27 PM
Italy-StopWatch Filippo German Forum 0 09-03-2008 05:26 PM
Stopwatch ilasm1.1 ?? colin9876 Questions (Windows Mobile) 13 12-09-2007 11:44 AM
Small messagebox bug (?) BjornF Bug Reports 2 05-24-2007 11:35 AM


All times are GMT. The time now is 12:04 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0