# jasontitcomb/grblhalcuttercomp architecture

> Architecture diagram of the GitHub repository jasontitcomb/grblhalcuttercomp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jasontitcomb/grblhalcuttercomp
- Repository: https://github.com/jasontitcomb/grblhalcuttercomp

## Overview

This is a grblHAL cutter-compensation plugin: G-code motion enters through an adapter, is converted to 2D moves, compensated and checked by the core, then emitted through saved motion callbacks. The README also documents parser-side mode/radius resolution, `$702` options, look-ahead gouge checking, deferred dwells/pauses, and modal-state restoration. Core and adapter excerpts are partial; the graph follows documented integrations and avoids inferring internal call order where source wiring was not shown.

Main entry points: [`cutter_comp_grblhal.c`](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c) (grblHAL adapter), [`cutter_comp.c`](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c) (Compensation core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["grblHAL integration"]
  node_shim["grblHAL adapter"]
  node_input["Motion conversion"]
  node_markers["Deferred markers"]
  node_modal["Modal restoration"]
end

subgraph group_engine["Compensation engine"]
  node_core["Compensation core<br/>[cutter_comp.c]"]
  node_buffer["Move buffering<br/>[cutter_comp.c]"]
  node_geometry["Offset geometry<br/>[cutter_comp.c]"]
  node_junctions["Junction handling<br/>[cutter_comp.c]"]
  node_lookahead["Gouge checking<br/>[cutter_comp.c]"]
end

subgraph group_state["Options and state"]
  node_settings_api["Option application"]
end

node_gcode(("G-code parser"))
node_settings["$702 settings"]
node_planner["Motion callbacks"]
node_reports["Status messages"]

node_gcode -->|"routes motion"| node_shim
node_settings -->|"provides options"| node_settings_api
node_settings_api -->|"sets modes"| node_core
node_shim -->|"converts moves"| node_input
node_input -->|"submits moves"| node_core
node_shim -->|"queues pauses"| node_markers
node_markers -->|"submits markers"| node_core
node_shim -->|"saves and restores"| node_modal
node_core -->|"buffers moves"| node_buffer
node_buffer -->|"processes moves"| node_geometry
node_geometry -->|"resolves corners"| node_junctions
node_core -.->|"checks paths"| node_lookahead
node_core -->|"emits moves"| node_shim
node_shim -->|"calls saved callbacks"| node_planner
node_core -->|"reports issues"| node_reports
node_shim -->|"formats messages"| node_reports

click node_shim "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c"
click node_input "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c"
click node_markers "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c"
click node_modal "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c"
click node_core "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c"
click node_buffer "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c"
click node_geometry "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c"
click node_junctions "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c"
click node_lookahead "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c"
click node_settings_api "https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shim,node_input,node_markers,node_modal toneBlue
class node_core,node_buffer,node_geometry,node_junctions,node_lookahead toneAmber
class node_settings_api toneMint
class node_gcode,node_settings,node_planner,node_reports toneIndigo
```

## Components

### grblHAL integration

- [grblHAL adapter](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c): `cutter_comp_grblhal.c`
- [Motion conversion](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c): `cutter_comp_grblhal.c`
- [Deferred markers](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c): `cutter_comp_grblhal.c`
- [Modal restoration](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c): `cutter_comp_grblhal.c`

### Compensation engine

- [Compensation core](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c): `cutter_comp.c`
- [Move buffering](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c): `cutter_comp.c`
- [Offset geometry](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c): `cutter_comp.c`
- [Junction handling](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c): `cutter_comp.c`
- [Gouge checking](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp.c): `cutter_comp.c`

### Options and state

- [Option application](https://github.com/jasontitcomb/grblhalcuttercomp/blob/main/cutter_comp_grblhal.c): `cutter_comp_grblhal.c`

### Other components

- **G-code parser**
- **$702 settings**
- **Motion callbacks**
- **Status messages**

## Connections

- G-code parser → grblHAL adapter: routes motion
- $702 settings → Option application: provides options
- Option application → Compensation core: sets modes
- grblHAL adapter → Motion conversion: converts moves
- Motion conversion → Compensation core: submits moves
- grblHAL adapter → Deferred markers: queues pauses
- Deferred markers → Compensation core: submits markers
- grblHAL adapter → Modal restoration: saves and restores
- Compensation core → Move buffering: buffers moves
- Move buffering → Offset geometry: processes moves
- Offset geometry → Junction handling: resolves corners
- Compensation core → Gouge checking: checks paths
- Compensation core → grblHAL adapter: emits moves
- grblHAL adapter → Motion callbacks: calls saved callbacks
- Compensation core → Status messages: reports issues
- grblHAL adapter → Status messages: formats messages
