Day 15 (week 3) — The RPN Calculator
The Friday morning huddle consisted of a nice presentation on stress management by Shahzad Khan. We watched a TED Talk on stress by Kelly McGonical and then had a roundtable discussion of the different ways we deal with stress.
I have set my sights on developing a web-version of the classic HP 15C calculator. This calculator was manufactured between 1982 and 1989 and uses Reverse Polish Notation.
The calculator has many functions and you can write small programs for it as well. I doubt that I will be able to code all the functions, but I can certainly get the more popular ones working. I’ll be making use of the mathjs library to handle the computations for me on the client side. And if I run into any longer, more intensive computations, I’ll have to develop some sort of backend nodeJS server. I’m not sure how this will play out, but I’m just going to take it one step at a time.
I also located the owner’s manual for the 15C, linked here, which will be helpful in understanding what keypresses perform what functions.
I’ll also be using MathJAX for some of the buttons, as they require special symbols like the integral sign or a summation sign.
Each key has at most three functions. There is the primary function (shown in white), the alternate function (shown in orange) and the shifted-alternate function (shown in green). There is a four-level stack in the calculator’s memory, with the first stack location being the displayed value.
I’ve got a working prototype put together that looks fairly decent, and I’ll be writing the code to handle some more functions over this weekend. Since there are so many functions to handle, it quickly becomes apparent that I need to organize the code into manageable pieces. One thing I did right away was to divide the keyboard into three regions. The 5-by-4 array of keys on the left is one group, the middle column of three keys in another group, and the remaining 4-by-4 array of keys on the right is the last group.
I also need to be careful in how I hook up my event handlers that register where the user has clicked. In my original project, I put an event handler on every button. Since there weren’t that many buttons and functions, this solution was acceptable. With the 15-C, I need a better strategy. So I’ll have three event handlers and then use the id of each button to determine what function to execute.
I’m just going to take this one step at a time. It’s a big undertaking, for sure. I may not finish all the functions. My goal for this weekend is to finish as many of the “easy” functions as I can. All the normal operations, the trig functions, the log functions, the power functions, and maybe the stack roll operations.
At the same time, Sara Harless from my cohort is going to help with some of the CSS styling so that the calculator looks good.