Skip to content

CrustyKnight/rpn-shell-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RPN calculator for rockbox on ipod

URN-RPN

This is a small lua project to create a mostly scientific postfix notation calculator for the shell. This comes from a project for an ipod that failed because of not having floating number support.

I still plan on using the same interface, just with a few tweaks

This is a work in progress, most of the stuff below is planning

Interface

So basically, you will just need to use the 8 home row keys your fingers naturally rest on.

Layered input system

5 buttons, one is select 1st layer -> button for digit input, button for symbol input, button for enter

Symbol Input

while in a layer, the keys for each layer are shown somewhere or the screen

“Layers” Center button is next layer

  1. basic operations (+ - * /)
  2. other stuff (^ sqrt sq inv) (exponent, square root, square, inverse(1/x))
  3. trig stuff (sin, cos, tan, trig2)
    1. trig2 (asin, acos, atan, nil)
  4. Logamarithic (log, inverse_log, ln, inverse_ln) (Log, 10^x, Ln, e^x)
  5. (factorial function)

Attempting to go to 6th layer exits

Language of choice?

So, I have to use a lua lang, or one that can compile to lua. I know of moonscript (my usual), lua, and fennel, and can find some more. So, I want to use oczor or haxe, but perhaps fennel. Fennel is the only one I know. Maybe Urn? also a lisp, more influenced by cl

Definately Urn. It just seems more like cl then fennel

Mockups

./imgs/mockup1.jpg

./imgs/mockup2.jpg

Text mockup

Dimensions are I think 39x16 (WxH)

Basic layout

+----------------------------+---------+
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|                            |         |
|----------------------------+---------+
|                            |         |
+--------------------------------------+

Help menu

+----------------------------+--------+
|                            |        |
|          shshs             |        |
|                            |        |
|                            |        |
|                            |        |
|                            |        |
|   shshs          shshs     |        |
|                            |        |
|                            |        |
|                            |        |
|                            |        |
|           shshs            |        |
|                            |        |
|----------------------------+--------+
|                            |        |
+-------------------------------------+

Home screen (filled in with stacks)

+----------------------------+---------+
| ***                        |      ** |
| ***                        |       * |
| ***                        |       * |
| ***                        |      ** |
| ***                        |     *** |
| ***                        |       * |
| ***                        |      ** |
| ***                        |       * |
| ***                        |      ** |
| ***                        |      ** |
| ***                        |       * |
| ***                        |     *** |
| ***                        |       * |
|----------------------------+---------+
|                            |         |
+--------------------------------------+

Features

  • P1 Digit entry
  • P1 stack
  • P2 Symbol entry
  • P2 basic operations
  • P2 Evaluation
  • P3 History
  • P3 layer/sybol input help
  • P3 all scientific commands

Programming Stuff

Stack init

(define stack '())

Op functions

L1

Add

(defun add (stack)
  (push! stack (+ (pop-last! stack)(pop-last! stack))))

Subtract

(defun sub (stack)
  (let [(b (pop-last! stack)) (a (pop-last! stack))]
       (push! stack (- a b))))

Mult

(defun mult (stack)
  (push! stack (* (pop-last! stack)(pop-last! stack))))

Div

(defun div (stack)
  (let [(b (pop-last! stack)) (a (pop-last! stack))]
  (push! stack (\ a b))))

L2

Exponent

(defun exp (stack)
  (let [(b (pop-last! stack)) (a (pop-last! stack))]
       (push! stack (expt b a))))

Sqrt

(defun sqrt (stack)
  (let [(b (pop-last! stack)) (a (pop-last! stack))]
       (push! stack (math/sqrt b a))))

Square

(defun sqrt (stack) (push! (expt (pop-last! stack) 2)))

Inverse

(defun sqrt (stack) (push! (\ 1 (pop-last! stack))))

L3

sin

(defun sin (stack) (push! (math/sin (pop-last! stack))))

cos

(defun cos (stack) (push! (math/cos (pop-last! stack))))

tan

(defun tan (stack) (push! (math/tan (pop-last! stack))))

Trig 2

asin

(defun asin (stack) (push! (math/asin (pop-last! stack))))

acos

(defun acos (stack) (push! (math/acos (pop-last! stack))))

atan

(defun atan (stack) (push! (math/atan (pop-last! stack))))

L4

Log_10

(defun log10 (stack) (push! (math/log (pop-last! stack) 10)))

Log-Inverse

(defun log10-inverse (stack) (push! (expt 10 (pop-last! stack))))

Natural log

(defun ln (stack) (push! (math/log (pop-last! stack))))

Ln-Inverse

(defun ln-inverse (stack) (push! (math/exp (pop-last! stack))))

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published