# ozdemirsalih/casio-cheat-calculator architecture

> Architecture diagram of the GitHub repository ozdemirsalih/casio-cheat-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ozdemirsalih/casio-cheat-calculator
- Repository: https://github.com/ozdemirsalih/casio-cheat-calculator

## Overview

##### Project type and purpose
- This is a hardware-software integrated “mod” for a Casio fx-82MS calculator.
- Purpose: embed an ESP8285 Wi-Fi microcontroller plus analog switches (74HC4051 muxes and SN74LVC1G3157) and a BMX055 IMU to (a) remotely drive the calculator by simulating key‐presses, (b) serve a web UI over Wi-Fi, and (c) use the IMU’s accelerometer for Morse-code input.

##### File structure
- Top-level files:
- Casio-Cheating-Calculator.ino – Arduino sketch containing firmware (Wi-Fi setup, websocket server, GPIO driver, I2C IMU code).
- Eagle Project.zip / Gerber Files.zip – PCB design source and manufacturing outputs.
- README.md – detailed description, wiring, UI screenshots, calibration instructions.
- No separate “frontend” folder: UI assets (HTML/JS/CSS, font file) are embedded in the .ino (likely in PROGMEM).

##### Extract architectural insights from the README
- ESP8285 runs in Access Point mode, hosts a websocket server + static web page.
- Two 74HC4051 ICs + one SN74LVC1G3157 form a matrix of switchable connections between calculator pad “KOx” and “KIy” pads.
- BMPX055 IMU connected via I2C for real-time accelerometer data at up to 2000 fps (used for Morse input + calibration UI).
- Power domain: Li-Ion battery protected by DW01A, external charger (TP4056 recommended).

##### Main components & interactions
a. Hardware blocks:
- ESP8285 Wi-Fi SoC (Microcontroller, Wi-Fi radio)
- Analog switching matrix:
– 2× 74HC4051 (8-channel MUX)
– 1× SN74LVC1G3157 (dual analog switch)
- BMX055 IMU (accelerometer + future gyro/magnetometer)
- Casio fx-82MS calculator PCB (KI/K0 pads)
- Power subsystem (Li-Ion battery + DW01A protector + external charger)

b. Software/network flows:
- Web browser client ↔ websocket ↔ ESP8285 (over Wi-Fi AP)
- ESP firmware:
– On incoming UI commands, send GPIO switching patterns to analog switches → simulate key presses on calculator.
– Poll I2C IMU → package accel/orientation data → stream via websocket to UI for real-time graph & calibration.
- UI: HTML/CSS/JS + custom fx-82MS font served from ESP’s onboard filesystem/flash.

##### Architectural patterns & principles
- Layered separation:
- Network/API layer (websocket, HTTP server)
- Business logic (key-mapping, Morse encoder, IMU calibration routines)
- Hardware abstraction (GPIO driver for analog switches, I2C driver for BMX055)
- Embedded‐server architecture: ESP as standalone AP + server
- Modular hardware design: switch matrix ICs abstract low-level pad wiring

– Clear block labels (e.g., “ESP8285 / Wi-Fi MCU”, “74HC4051 MUX #1”)
– Callouts for key design choices (e.g., “2000 fps I2C buffer = 192 bytes”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client and network
    Browser["Web Browser Client"]:::network
    AP["Wi-Fi AP (ESP8285)"]:::network

    Browser -->|"HTTP GET / WebSocket"| AP

    %% ESP Module
    subgraph "ESP8285 / Wi-Fi MCU"
        direction TB
        HTTP["HTTP/WebSocket Service"]:::network
        BL["Business Logic (Key‐mapping, Morse, IMU Cal)"]:::micro
        GPIO["GPIO Manager"]:::micro
        I2C["I2C Manager"]:::micro
        Assets["Web UI Assets (HTML/CSS/JS/Font)"]:::network
    end

    AP --> HTTP
    HTTP --> BL
    BL --> GPIO
    BL --> I2C
    HTTP --> Assets

    click HTTP "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Casio-Cheating-Calculator/Casio-Cheating-Calculator.ino"
    click BL "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Casio-Cheating-Calculator/Casio-Cheating-Calculator.ino"
    click GPIO "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Casio-Cheating-Calculator/Casio-Cheating-Calculator.ino"
    click I2C "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Casio-Cheating-Calculator/Casio-Cheating-Calculator.ino"
    click Assets "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Casio-Cheating-Calculator/Casio-Cheating-Calculator.ino"

    %% Hardware Blocks
    subgraph "Analog Switch Matrix" 
        direction TB
        MUX1["74HC4051 MUX #1"]:::analog
        MUX2["74HC4051 MUX #2"]:::analog
        SW["SN74LVC1G3157"]:::analog
    end

    subgraph "Calculator Pad Matrix"
        direction TB
        Pads["Casio fx-82MS KI/K0 Pads"]:::hardware
    end

    GPIO -->|"Digital Control (GPIO)"| MUX1
    GPIO -->|"Digital Control (GPIO)"| MUX2
    GPIO -->|"Digital Control (GPIO)"| SW
    MUX1 -->|"Analog Line"| Pads
    MUX2 -->|"Analog Line"| Pads
    SW -->|"Analog Line"| Pads

    %% IMU Sensor
    BMX["BMX055 IMU"]:::sensor
    I2C -->|"I2C (SCL/SDA)"| BMX
    BMX -->|"Accel & Orientation Data"| BL
    BL -->|"Graph/Calibration Data"| Assets
    Assets --> Browser

    %% Power Subsystem
    subgraph "Power Subsystem"
        direction TB
        Batt["Li-Ion Battery + DW01A"]:::power
        Charger["External Charger (TP4056)"]:::power
    end

    Batt --> ESP8285
    Batt --> MUX1
    Batt --> MUX2
    Batt --> SW
    Batt --> BMX
    Charger --> Batt

    %% Documentation and artifacts
    Docs["README.md"]:::docs
    Eagle["Eagle Project.zip"]:::docs
    Gerber["Gerber Files.zip"]:::docs
    GitIgnore[".gitignore"]:::docs

    Docs --> Eagle
    Docs --> Gerber
    Docs --> GitIgnore

    click Docs "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/README.md"
    click Eagle "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Eagle Project.zip"
    click Gerber "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/Gerber Files.zip"
    click GitIgnore "https://github.com/ozdemirsalih/casio-cheat-calculator/blob/main/.gitignore"

    %% Styles
    classDef network fill:#AEDFF7,stroke:#036;    
    classDef micro fill:#C9EAC1,stroke:#070;
    classDef analog fill:#FFD59E,stroke:#E65C00;
    classDef sensor fill:#FFF4A3,stroke:#CC9C00;
    classDef power fill:#D3D3D3,stroke:#999;
    classDef hardware fill:#F2F2F2,stroke:#666;
    classDef docs fill:#E8E8E8,stroke:#555;
```
