Post Reply 
Scientific RPN Calculator (with ATTINY85)
03-08-2018, 12:34 PM
Post: #23
RE: Scientific RPN Calculator (with ATTINY85)
A pretty good win so far Smile


(03-08-2018 11:05 AM)deetee Wrote:  * Own CASE for atan and atanh (+16 bytes)

This comes back to the inefficient switch implementation I suspect. These should both save space but don't. A table of function pointers indexed by the key codes is worth a try. Keep the key code in a global so the functions are reusable. That is, sin/cos and tan can all use the same function and return different values based on the key code used. This will require renumbering the key codes.


Quote:* Replace log10() with log()/log(10) (+50 bytes)

I found the source for the maths library, it uses log()*.43429... for this and avoids C's overheads. The is no chance on a saving from log10.


Quote:* @Pauli: I can not see how to merge asinh and acosh

Probably unnecessary with sqrt as a separate function. The idea was that the difference between the two was the sign: x2 + 1 or x2 - 1 and thus the duplicate equation could be avoided.


Quote:* I would like to place data in the EEPROM (512 bytes) and read it with EEPROM.read. But when I flash the ATTINY85 (via Uno as ISP) the EEPROM of the ATTINY is deleted. I read something about setting fuse EESAVE. How can do this in the arduino suite (IDE)?

You could keep the calculator state in EEPROM to allow more registers and add some user program space.

Could the firmware set the fuse? You might need one firmware to load the constants and set the fuse and a second for the calculator.

512 bytes of data is a lot, but it will be hard to program up front. Better might be to think of things a user might want to put there:
  • A command / result history?
  • Save and restore stack?
  • User defined constants?

As far as I'm aware, the only calculator with EEPROM was the Elektronika MK 52 and it was hard to use but could store registers and programs.


Quote:What is your opinion what to implement first (as long as free memory exists)?
  • I'd go for the gamma function or log gamma. Factorial is free given gamma. Combinations and permutations are quite cheap if log gamma is available (but not if only gamma is available due to overflow concerns). Rskey.org has a wide variety of implementations for calculators.
  • log(1+x) and ex-1 are useful in their own right and are present in the code already (well the former appears).
  • Stopwatch mode.
  • Printing via IR LED (using one of the remaining three pins on the ATTINY).

Implementing h/h.ms properly is difficult with decimal arithmetic and very difficult when using binary like you are.


BTW: all the variables declared static inside functions are globals and possibly could be moved out of the function to the global namespace which might make the layout nicer.


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Scientific RPN Calculator (with ATTINY85) - Paul Dale - 03-08-2018 12:34 PM



User(s) browsing this thread: 1 Guest(s)