Thursday, October 6, 2011

My Kingdom for a Calculator

Building the bc utility reminded me (yet again) that given it's form factor, the zipit really ought to have a decent calculator program.  Bc is ok I guess, but I can't remember more than the most basic syntax, and besides, it segfaults when I run it with the -l switch to pull in the math functions like sin() and cos().  I gotta see if I can fix that.  Maybe the IZ2S mathlib  is busted.  I sorta remember removing all references to doubles from  nightsky to get it to run right.  Maybe I need to rebuild a new libm.so with different floating point settings...

Anyhow, what I'd really like is to get bc working well and get a nice GUI wrapper for it like x-bc so I don't have to remember the syntax. I've already got something *almost* like that with the emacs calculator mode.
The emacs calculator has it's own command line math system like bc that works pretty well, and comes with a GUI that's ok with a real mouse, but quite a chore to navigate with the zipit dpad or via emacs key commands.  Besides, it's Reverse Polish Notation (RPN).  Yuck!  That's just not natural.  And finally, all the digits are still ALT key combinations on the zipit keypad which makes them difficult to type.  I suppose it could handy though if I want to calculate some numbers and paste them into a document, or vice versa.  I might look into tweaking the emacs lisp code to let me type digits into the calculator pane without the ALT key, but I'm not sure where my ancient lisp skills stand aftar all these years.

I did find a fairly simple SDLcalc program for the caanoo that might meet my needs someday.  It looks nice, but it has no keyboard input yet. Apparently the caanoo has a touchscreen?  Plus it's got some screen refresh issues, possibly due to the rotated screen on the zipit.  I think I'm gonna try to keep the GUI but add keyboard support and maybe switch to a bc backend when (if?) I get the bc mathlib problem fixed.
I'm not sure if it uses SDL, but the cal2x calculator for the gp2x looks pretty decent.  It even does some grahping if you're into that.  Me, I really want that hex button.  Unfortunately the source web site is korean and full of dead links.  Oh well.

Meanwhile, I thought to myself, there's gotta be an ncurses calculator out there somewhere that'll do the trick.  However the only ones I could find were all RPN style, like dcalc.  Err, yuck?

Then I stumbled onto tcalc, the mighty console calculator.  It's nothing more than a simple bash script, with ANSI escape sequences to draw the boxy graphics characters.  Wow!  Talk about retro, low-tech chic.  I had to dig up a console font with the box chars small enough to display the entire calculator.  And I had to adjust the ANSI sequences to move the whole display to the top left of the screen so it would show up on the zipit.  I'd like to add some color, but even so, I think it looks ok as is.

The last tweak I did was to adjust the key parsing routines to let me enter all the digits and the basic math keys without touching the dreaded ALT button.  That's a huge win for me!  It could do with a few function buttons, and once again, maybe a bc backend.  Someday, maybe...

tcalc-iz2s.zip

1 comment: