HP Forums

Full Version: Stopwatch function implemented on WP34s
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi,

Just for fun, I've implemented a Stopwatch function like the one on the HP-55 and the HP-41C TimeModule.

Of course, it would need a quartz to be precise but I'll see later if I can implement a calibration function.

It is a simple addon to the last firmware version and if someone is interested, I can give the calc.bin and/or the source code.

How it works:

- there is now a TIMER function in the P.FCNS menu, under TIME
- Pressing F then H then EXIT quickly enters the TIMER mode too
- once in TIMER mode, R/S starts & stops the stopwatch
- EEX toggles the 10th secs display
- ENTER stores the current value in memory. 0 to start and the increments
- arrows increment/decrement the memory used
- one can also enter the memory number directly
- the memory used is displayed in the exponent zone and -> toggles it

I plan on implementing a delta mode later, like the TimeModule one but maybe simpler.

Here is what it looks like:

Cheers

Congrats, new master of convoluted C code! It took me a while before I was able to implement anything in WP 34S.

We'd like to see your sources and would also like to know the memory footprint of your additions. Maybe we can add you to the list of developers on SF. :-)

No luck sending you an email so I did it through silicium.

And received your email. Cannot respond still.

Very nice, the TIMER function is very convenient indeed! Just a question: Given the current (pun intended) worries about CR 2032 batteries being not the best ones to cope with extended activity on these calculators, how feasible is to have the timer running for significant periods of time? Are you deliberately choosing a super-slow CPU clock mode to run the timer?

TIA

This is a first implementation and I've not measured battery drain yet. I plan to do so.
Right now, running the TIMER should be the same as running a program but I guess I can try to slow down the CPU clock.

Edited: 28 Oct 2011, 10:55 a.m.

Pascal, you can wire the timer to the heartbeat interrupt. This will run at 2MHz and idle again after return. Just look into keys.c and search for K_HEARTBEAT. You will need a global variable which selects timer mode and disables all other functionality.

This is exactly what I've done. In the main loop, there is a global variable containing a function pointer. If it is not null, it is called on every key pressed including HEARTBEAT instead of the normal processing.

The TIMER function simply sets this variable and exiting it resets its to NULL. This mechanism could be used for any other interactive function which needs full control of the keyboard if we had more space :-(

Well done! :-)

We can not take some factors of conversion?
I believe it is very easy to save some factor in a memory (STO) of him to leave the system fixed.
We could gain a few bytes for further improvements.

Initialized constants are 272 bytes whilst executable code is 122 Kb according to the linker.
So this not where room can be found I guess.

But these 272 bytes could not be used for something more important?
I think that any user can use some memories (STO and RCL) to save your constants.


Edited: 28 Oct 2011, 3:36 p.m.

BTW, I ran it for 2 hours straight on brand new batteries and the voltage went from 3.0V to 2.9V.
The WP34s slows down at 2.5V and shutdowns at 2.2V.
So timer's power consumption is not that bad.

But then you need to know them. We have a few areas where we might save code such as the integer code which deserves a rewrite in ARM assembly.

I'd like to see your code as well (or diffs).

Too bad the hp20b/30b doesn't have a tone generator, I'd like to have a count down timer.

I wonder what the simplest circuit is to use one of the GPIO pins?

I suspect the conversion constants aren't in the initialised data segment. They definitely take more than 272 bytes.

They are still incredibly compact as commands go. I'd guess eight to ten conversions or constants occupy the same space as the most trivial of commands (think the single bit setting mode commands) and this is including the catalogue overheads.


- Pauli

Using general purpose registers for constants would cost more *and* have the disadvantage of not knowing the names. We won't do that.

Walter

Quote:
I suspect the conversion constants aren't in the initialised data segment.

There is no such thing as an initialized data segment, just ROM data. All data in RAM is just zero. I got rid of the 'copy ROM to RAM' sequence all together.

Code is in SVN.