$ show computed-axial-lithography/OpenCAL-Firmware
The OpenCAL firmware is a Python application designed to control a Computed Axial Lithography (CAL) 3D printer running on a Raspberry Pi 5. It orchestrates hardware components including a stepper motor (via Pololu Tic T249 or similar), LED array, projector (using mpv), camera (using picamera2), LCD display, and rotary encoder. Users interact via a menu-driven LCD interface to select video files from a USB drive and initiate print jobs, during which the system coordinates motor rotation, LED illumination, video projection, and image capture. The application follows a modular architecture with clear separation of concerns: GUI logic in `gui/`, hardware abstraction in `hardware/`, and configuration management in `utils/`. The LCD GUI implements a state machine for menu navigation, while the hardware layer uses a strategy pattern to support multiple stepper motor drivers (Tic USB, step/dir, UART, and a mock for testing). Configuration is managed through typed dataclasses loaded from a JSON file, allowing easy adaptation to different hardware setups. Key strengths include the reusable stepper motor abstraction layer, which cleanly separates the control interface from driver-specific implementations, and the configuration system that provides a robust, typed interface to hardware parameters. The USB media handler offers a simple, self-contained utility for managing media files on removable storage. The system is actively maintained and targets the Raspberry Pi 5 platform with specific hardware dependencies.
The LLM identified 3 files worth highlighting for reuse:
Provides a typed configuration system that loads JSON configuration into dataclasses for each subsystem (stepper, camera, LED, etc.). It is isolated, depends only on the standard library, and can be easily reused in other projects requiring structured configuration from JSON files.
Defines a common interface (`StepperMotorInterface`) for stepper motor control with multiple implementations (Tic USB, step/dir, UART, mock). The factory function `create_stepper` selects the appropriate driver based on configuration. This pattern allows swapping motor drivers without changing application code and is easily extractable to other projects requiring stepper motor control.
Offers a self-contained utility for managing media files on USB storage, including listing MP4 files, checking mount status, and generating unique file paths to avoid collisions. It depends only on the standard library and can be reused in any application needing to interact with USB storage devices.