A professional-grade scientific calculator designed for Raspberry Pi with support for physical displays (LCD/OLED), hardware button matrices, and comprehensive mathematical operations.
- Basic Arithmetic: Addition, subtraction, multiplication, division, power, modulo
- Scientific Functions: Trigonometric (sin, cos, tan, asin, acos, atan), logarithmic (log, ln), exponential, square root, factorial
- Hyperbolic Functions: sinh, cosh, tanh
- Constants: Ο (pi), e, Ο (phi - golden ratio)
- Expression Evaluation: Complex mathematical expressions with proper operator precedence
- Angle Modes: Degrees and Radians
- Multiple Display Types: Terminal, LCD 16x2, OLED 128x64
- Hardware Buttons: Physical button matrix support
- Themes: Default, Dark, High Contrast
- Sound Effects: Button clicks and error beeps (optional)
- Memory Functions: Store, recall, add, clear
- Calculation History: Track and review past calculations
- Persistent Storage: Save history and memory between sessions
- Input Validation: Prevents invalid expressions
- Expression Parser: Handles complex nested expressions
- Configurable: YAML configuration file for easy customization
pycomputus/
β
βββ π main.py # Application entry point
βββ π config.yaml # Configuration file
βββ π requirements.txt # Python dependencies
βββ π README.md # Complete documentation
βββ π LICENSE.md # MIT License
β
βββ π src/ # Core application logic
βββ display.py # Handles main calculator functions
βββ display.py # Handles display
βββ keyboard.py # Handles keyboard
β
βββ π math_engine/ # Mathematical operations
β
βββ π ui/ # User interface
β
βββ π hardware/ # Hardware interface
β
βββ π utils/ # Utilities
β
βββ π tests/ # Unit tests
β
βββ π docs/ # Documentation
β
βββ π assets/ # Resources
# Update system
sudo apt-get update
sudo apt-get upgrade
# Install Python 3 and pip
sudo apt-get install python3 python3-pip git
# Enable I2C (for LCD/OLED displays)
sudo raspi-config
# Navigate to: Interface Options -> I2C -> Enable# Clone repository
git clone https://github.com/yourusername/pycomputus.git
cd pycomputus
# Install dependencies
pip3 install -r requirements.txt
# Run the calculator
python3 main.py# For LCD/OLED displays
pip3 install adafruit-circuitpython-charlcd adafruit-circuitpython-ssd1306
# For sound effects
pip3 install pygame
# For button matrix
pip3 install RPi.GPIOpython3 main.py> 2 + 3
Result: 5.0
> 15 * 4
Result: 60.0
> 2^8
Result: 256.0
> sqrt(144)
Result: 12.0
> sin(45)
Result: 0.7071067811865476
> log(100)
Result: 2.0
> exp(1)
Result: 2.718281828459045
> factorial(5)
Result: 120.0
> 2 * pi * 5
Result: 31.41592653589793
> sin(30) + cos(60)
Result: 1.0
> (2 + 3) * 4
Result: 20.0
> 42 + 8
Result: 50.0
> ms # Store to memory
Stored 50.0 to memory
> 5 * 3
Result: 15.0
> mr # Recall from memory
Result: 50.0
> m+ # Add to memory
Added 15.0 to memory
Memory: 65.0
> mc # Clear memory
Memory cleared
> mode
[Angle Mode: DEG]
> deg # Toggle to radians
[Angle Mode: RAD]
> rad # Toggle to degrees
[Angle Mode: DEG]
> history # Show calculation history
> clearhistory # Clear history
> help # Show help menu
> clear # Clear display
> quit # Exit calculator
Edit config.yaml to customize PyComputus:
# Display type
display:
type: "terminal" # terminal, lcd16x2, oled128x64
# Input mode
input:
mode: "keyboard" # keyboard, buttons, both
# Calculator settings
calculator:
angle_mode: "DEG"
decimal_places: 10
max_history: 50
save_history: true
# Enable sound effects
sound:
enabled: false
volume: 0.5
# Theme
theme:
name: "default" # default, dark, high_contrastWiring:
LCD Pin β Raspberry Pi Pin
VCC β 5V (Pin 2)
GND β GND (Pin 6)
SDA β GPIO 2 (Pin 3)
SCL β GPIO 3 (Pin 5)
Configuration:
display:
type: "lcd16x2"
lcd:
i2c_address: 0x27Wiring:
OLED Pin β Raspberry Pi Pin
VCC β 3.3V (Pin 1)
GND β GND (Pin 6)
SDA β GPIO 2 (Pin 3)
SCL β GPIO 3 (Pin 5)
Configuration:
display:
type: "oled128x64"
oled:
i2c_address: 0x3CWiring:
Rows: GPIO 17, 27, 22, 23, 24
Cols: GPIO 5, 6, 13, 19, 26
Configuration:
input:
mode: "buttons"
button_matrix:
enabled: true
layout: "standard"
row_pins: [17, 27, 22, 23, 24]
col_pins: [5, 6, 13, 19, 26]See docs/hardware_setup.md for detailed hardware instructions.
# Run all tests
pytest tests/
# Run with coverage
pytest --cov=src tests/
# Run specific test file
pytest tests/test_math_engine.pyfrom src.calculator_core import CalculatorCore
calc = CalculatorCore()
# Perform calculation
result = calc.calculate("2 + 3 * 4")
# Scientific function
result = calc.calculate_function("sin", 45)
# Memory operations
calc.memory_store(42)
value = calc.memory_recall()
calc.memory_add(10)
calc.memory_clear()
# Mode control
calc.toggle_angle_mode()
calc.set_angle_mode("RAD")
# History
history = calc.get_history()
calc.clear_history()
# State
state = calc.get_state()Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Install development dependencies
pip3 install -r requirements.txt
# Install pre-commit hooks
pip3 install pre-commit
pre-commit install
# Run linting
pylint src/
# Format code
black src/
# Type checking
mypy src/- Built for the Raspberry Pi community
- Thanks to all contributors
- Graphing capabilities
- Unit conversions
- Statistical functions
- Complex number support
- Programmable functions
- Web interface
- Mobile app companion
- 3D printed enclosure designs
- Initial release
- Basic and scientific operations
- Multiple display support
- Button matrix support
- Configuration system
- History and memory
This project is licensed under the Mozilla Public License Version 2.0 - see the LICENSE.md file for more details.