Skip to content

1612elphi/pigs

Repository files navigation

PIGS

Opinionated RPN Calculator

PIGS is an opinionated, personal and unmarketable calculator for graphic designers and everyone who's a weirdo enough to still use reverse polish notation, but doesn't like the 12C.

PIGS has a beautiful interface and doesn't care what you think. It's not designed to be intuitive, and if you're not used to it, you'll hate it. This is by design.

PIGS doesn't explain itself to you. The help button is mostly there to mock you. It will not get a classic mode, but if you need it, you can always use little bitch mode. It's in the menu.

PIGS will most likely never be used by anyone other than the author. It is part coding project, part challenge, and part performance art. This is not for you. Go buy a Texas Instruments one.


What is this thing?

PIGS is a dedicated-device RPN (Reverse Polish Notation) calculator built with Next.js and React. It's designed to run on a physical device with a specific keyboard layout (A-Z keys, P-Q-R for dial controls, etc.) and provides:

  • Extended 50-register stack - Because five registers are for cowards (Please don't actually use 50 regs)
  • Calculation history tape - Cookie based, couldn't be arsed to build a DB
  • Unit conversion mode - Convert between 13 categories including area, distance, mass, temperature, cooking measurements, and more
  • Paper sizes library - Instant access to ISO A/B/C series, US/ANSI, Japanese JIS, Chinese, Swedish SIS, French traditional, Imperial UK, and more
  • Constants library - Mathematical and physical constants with proper academic names (Archimedes', Euler's, Pythagoras', etc.)
  • Deeper math functions - 28 advanced operations including trig, hyperbolic, logarithmic, inverse trig, and combinatorics
  • Advanced math operations - Powers, roots, modulo, and all the basics
  • Undo/redo - Had to put something there
  • Lift/Drop - It's cut and paste but teenage engineering might sue you
  • Stack roll mode - Manipulate your stack

Features

Core Calculator

  • RPN stack operations: Push, pop, swap, roll
  • Basic operations: Add, subtract, multiply, divide, modulo
  • Advanced functions: Power (X^R1, X²), roots (√X, ᴿ¹√X), sign inversion
  • 50-register deep stack with scrollable viewport (R1-R5 visible at a time)
  • Undo/redo history (last 50 operations)
  • Calculation tape (last 100 operations)

Conversion Mode

13 conversion categories with multiple units each:

  • Area - mm², cm², m², km², in², ft², yd², acres, hectares
  • Cooking - mL, L, tsp, tbsp, fl oz, cups, pints, quarts, gallons
  • Density - kg/m³, g/cm³, lb/ft³, lb/in³
  • Distance - mm, cm, m, km, in, ft, yd, mi, nmi
  • Energy - J, kJ, cal, kcal, Wh, kWh, BTU
  • Force - N, kN, lbf, ozf, dyn
  • Light - lx, fc, ph, lm/ft²
  • Mass - mg, g, kg, t, oz, lb, stone
  • Power - W, kW, MW, hp
  • Pressure - Pa, kPa, bar, atm, psi, Torr
  • Speed - m/s, km/h, mph, kn, ft/s
  • Temperature - °C, °F, K, °R (with non-linear conversion)
  • Time - µs, ms, s, min, h, d, wk
  • Volume - cm³, m³, L, mL, in³, ft³, gal

Paper Sizes Mode

Comprehensive paper size database with dimensions in both mm and inches:

  • Common sizes - Quick access to A4, A3, SRA3, Letter
  • ISO A Series (4A0 → A13)
  • ISO B Series (B0 → B13)
  • ISO C Series (C0 → C10) - Envelope sizes
  • RA Series - Raw format sizes for printing
  • SRA Series - Supplementary raw format with bleed area
  • US Classic - Letter, Legal, Tabloid, Ledger, etc.
  • US ANSI (A → E)
  • US Architectural (Arch A → E3)
  • Japanese JIS (JB0 → JB12, Shiroku ban, Kiku)
  • Chinese Standard (D0 → D6)
  • Swedish SIS (D/E/F/G series)
  • French Traditional - Cloche, Tellière, Raisin, Jésus, Grand Aigle, etc.
  • Imperial UK - Crown, Demy, Elephant, Royal, etc.

Key Bindings

PIGS expects a physical keyboard with keys A-Z and dial controls P, Q, R. Here's what they do:

Number Entry

  • 0-9: Append digit to X register
  • . or ,: Decimal point

Meta Keys (A-D)

  • A (short): Show calculation tape
  • A (long hold): Help mode - shows what each key does while held
  • B (short): Undo
  • B (long): Redo
  • C (short): Cut X to clipboard
  • C (long): Paste clipboard to X
  • D (short): Open menu
  • D (very long): Hard reset (force reload)

Advanced Math (E-F)

  • E (short): X^R1
  • E (long): X²
  • F (short): √X
  • F (long): ᴿ¹√X (R1st root of X)

Edit/Control (G-J)

  • G: Invert sign (-X)
  • H (short): Backspace
  • H (long): Clear X register
  • I (short): Swap X and R1
  • I (long hold): Roll mode - use P/Q to roll stack
  • J (short): Push X onto stack
  • J (long): Pop from stack into X

Dial Controls (P-Q-R)

  • P: Dial turn counterclockwise (scroll up/decrement)
  • Q: Dial turn clockwise (scroll down/increment)
  • R: Dial click (confirm/select)

Basic Operations (V-Z)

  • V: Modulo (X mod R1)
  • W: Divide (R1 ÷ X)
  • X: Multiply (X × R1)
  • Y: Subtract (R1 - X)
  • Z: Add (X + R1)

Tech Stack

  • Next.js 15.5.4 with Turbopack
  • React 19.1.0
  • Tailwind CSS 4
  • Client-side only (no server rendering)
  • No external APIs - Everything runs locally

Project Structure

src/
├── app/
│   ├── layout.js          # Root layout with fonts
│   ├── page.js             # Main calculator interface
│   └── globals.css         # Tailwind globals
├── components/
│   ├── ConversionMode.js   # Unit conversion interface
│   ├── ConversionValueBox.js
│   ├── EntryPanel.js       # X register display
│   ├── MenuOverlay.js      # Menu system
│   ├── PaperSizesMode.js   # Paper size browser
│   ├── StackDisplay.js     # Stack visualization
│   ├── StackRow.js         # Individual stack register
│   ├── StatusBar.js        # Top status/time bar
│   └── TapeDisplay.js      # Calculation history overlay
├── hooks/
│   ├── useCalculatorState.js    # Core calculator state
│   └── useKeyboardHandlers.js   # Keyboard input handling
└── utils/
    ├── calculatorOperations.js  # Math operations
    ├── conversions.js           # Unit conversion logic
    ├── helpText.js              # Help text definitions
    └── paperSizes.js            # Paper size database

Installation & Development

# Install dependencies
npm install

# Run development server with Turbopack
npm run dev

# Build for production
npm run build

# Start production server
npm start

Open http://localhost:3000 in your browser.


Design Philosophy

Not Responsive

This is intentionally designed for a fixed-size dedicated device. There is no responsive design. This is not a web app. It's a device UI that happens to be built with web technologies.

No Explanations

The interface assumes you know RPN. If you don't, this isn't for you. There are no tooltips (except in help mode), no gentle onboarding, no hand-holding.

Monospace Everything

Numbers use tabular figures to prevent layout jumping during calculations, as it should be.

Dark Mode Only

Black background, white text, minimal UI. No themes either.

Local-First

No network requests. No analytics. No telemetry. It's a calculator. You'd have to be a special kind of miscreant for that.


Menu Options

  • Conversion Mode ✓ Implemented
  • Paper Sizes ✓ Implemented
  • Constants Library ✓ Implemented
  • Deeper Math ✓ Implemented
  • Little Bitch Mode ✓ Implemented - For people who can't handle PIGS
  • Math Settings - Coming eventually (maybe)
  • Experience Settings - Coming eventually (maybe)
  • System Settings - Coming eventually (maybe)

Why?

Because:

  1. Modern calculators are too simple or too complex
  2. RPN is superior and anyone who disagrees is wrong
  3. Graphic designers need quick access to paper sizes and unit conversions
  4. Physical calculators can't be updated with new features
  5. This was more fun than doing actual work
  6. Performance art

Why "PIGS"?

It's a reference to an old piece of digital art made for the TI-83. It was called DRUGWARS. It was a management simulator game that was popular in the 1980s, and had been ported to TI-BASIC. Used to play it back in the day. Every so often, prices went up or down. One of the messages that could randomly occur was "PIGS MADE A BIG COKE BUST! PRICES ARE OUTRAGEOUS!!!!".


License

Do whatever you want with this. PIGS doesn't care about your license compliance. If you find this useful enough to steal, congratulations - you're even weirder than the author thought.


Contributing

PIGS doesn't accept contributions. This is a personal project. Fork it if you want to change something. That's what git is for.


Support

There is no support. If something breaks, you get to keep both pieces. Read the code. Figure it out. Or don't. PIGS will still be here, not caring about your problems.


Acknowledgments

  • HP for making the 12C and then making approximately 47 years of identical hardware
  • The RPN community for being stubborn enough to keep this notation alive
  • Everyone who said "why would you build this?" - you motivated me
  • Coffee

Built with contempt for modern UX conventions. Suck my dick, SwissMicros

About

Opinionated Personal Unmarketable RPN Calculator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published