How anycubic-3d/kobra2_neo works
Major Architectural Layers and Components
• Core Modules and Firmware Framework: The “Marlin/src” folder contains “MarlinCore.cpp/h”, core board definitions, and various “core” files (such as drivers, utility functions, and configurations). This layer orchestrates overall firmware logic.
• G-code Interpreter: The “Marlin/src/gcode” directory handles all the command definitions and parsing, subdividing into further directories like “bedlevel,” “calibrate,” “control,” “lcd,” “motion,” etc. Represent this as a block that receives commands from external sources (e.g., USB/serial from a host computer or SD card).
• Feature Modules: The “Marlin/src/feature” directory shows dedicated modules for advanced functionalities like bed leveling algorithms (ABL, BDL, MBL, UBL), ammeter, direct stepping, bltouch, etc.
• User Interface & LCD/Touch Modules: The “Marlin/src/lcd” directory (including subfolders for various display types such as DOGM, TFTGLCD, and e3v2) plus “Marlin/src/menu” constitute the UI layer. Represent these as one or multiple blocks that interact with user inputs and provide status feedback.
Out the Data Flow and Interactions
• Input from External Host (via USB/Serial) or SD Card is received by the Communication Interface module.
• The G-code Interpreter block processes these commands and then routes them to appropriate feature or motion modules.
• The Motion, Temperature, and Extrusion modules (found in “Marlin/src/module”) use the HAL to interact with PWM drivers, stepper motors, sensors, etc.
• The User Interface (LCD/menus) receives updates from core modules and may also provide user input or override commands.
Relevant Build and Configuration Elements
• Presence of “Configuration.h” and “Configuration_adv.h” at the project root (and inside the Marlin folder). These files customize behavior and can be represented as configuration “inputs” that affect nearly every layer.
Architectural Patterns and Design Principles
• Layered / Modular Architecture: Distinct separation between HAL, core processing, interpreter, feature modules, and UI.
• Hardware Abstraction: The use of multiple HAL directories to hide platform-specific details.
• Extensibility and configurability: Separately maintained configuration and pin mapping files.
• Command Flow Pattern: Commands (G-code) being parsed and distributed among discrete modules (motion, temperature, UI, etc.), with clear input–processing–output flow.