How syurazo/cardputer works
• Library Entry Point (cardputer crate): This is the integration point that lets an application use the hardware utilities. The public API is exposed via src/lib.rs.
• Module Components:
• Module (src/display.rs): Responsible for initializing and managing the ST7789 driver.
• Backlight Module (src/backlight.rs): Manages the LCD backlight control.
• Keyboard Module (src/keyboard.rs): Decodes signals using the 74HC138 chip logic and converts them to keycodes.
• Grove Module (src/grove.rs): Initializes and handles the I2C driver for the Grove interface.
• Build & Configuration Component:
• build.rs & Cargo.toml: Handle the build process and dependency management.
• Examples:
• The examples directory with key_monitor.rs shows how to use the library in an application context.
Relationships and Interactions
• Application Layer: At the top, illustrate a user’s application (like the key_monitor example) that utilizes the public API provided by the cardputer crate.
• API Layer (cardputer Library): Indicate that the application interacts with the different modules (display, backlight, keyboard, grove) via clearly defined functions.
• The Display Module interacts with the ST7789 display hardware.
• The Backlight Module controls the physical backlight circuitry.
• The Keyboard Module decodes hardware signals (via 74HC138 multiplexing) which are then passed to the application.
• The Grove Module uses I2C communication to interface with various Grove sensors/actuators.
Architectural Patterns or Design Principles
• Modular Design: Emphasize the clear separation of concerns by dividing functionalities into distinct modules.
• Hardware Abstraction: The library acts as an abstraction layer that decouples the application logic from the underlying hardware specifics.
• Use of Rust’s Module System: Having a lib.rs that re-exports the functionalities from individual modules (display, keyboard, backlight, grove).
Relevant Technologies and Frameworks
• Rust language and Cargo build system (indicated by Cargo.toml, rust-toolchain.toml, build.rs).
• Embedded systems concepts: Direct interfacing with GPIOs, I2C communications, and hardware initialization protocols typical in embedded Rust projects.
• Specific hardware: ST7789 (for LCD), 74HC138 (for keycode decoding), Grove I/F devices.