How taclab/music-box works
Project Type & Purpose
• This is an embedded, hardware-software system built on an ESP8266 (Adafruit Feather HUZZAH) that reads NFC cards (via a PN532 module) to control playback on a DFPlayer Mini audio module.
• It is *not* a web or full-stack app, but an interactive, standalone device.
File Structure
• Top level:
• platformio.ini (build & deployment)
• src/ (application code: main.cpp, cards.h)
• lib/ (third-party or in-repo libraries)
• lib/NDEF: handles NDEF-format NFC payload parsing
• lib/PN532: low-level NFC driver (I2C, SPI, HSU transports + LLCP/SNEP)
• Documentation: docs/circuit.png and 3D case STL files
• No backend/frontend split: code is all on the MCU.
Extract Key Architectural Insights from README
• Hardware interfaces:
• I2C (SDA/SCL) to PN532 NFC reader
• UART (TX/RX) to DFPlayer Mini
• GPIO (BUSY pin) from DFPlayer Mini for end‐of‐track
• Software features: NDEF card scanning → ID mapping (cards.h) → play/volume/mode commands.
• Use of PlatformIO for build, Arduino‐style loop() and setup() in main.cpp.
Main Components & Their Interactions
a. Hardware Blocks
• ESP8266 MCU (power, firmware)
• PN532 NFC Reader Module (I2C bus)
• DFRobot DFPlayer Mini (UART + busy‐pin GPIO)
• microSD Card (mounted by DFPlayer Mini)
• LiPo Battery & Power Regulation
• 3D Printed Enclosure (physical housing)
b. Software Blocks
• HAL/Transport Layer (lib/PN532_* for I2C/SPI/HSU)
• NFC Protocol Layer (lib/PN532/llcp, snep)
• NDEF Parsing Library (lib/NDEF)
• Application Logic (src/main.cpp)
• Card Definitions (src/cards.h)
• Audio Library (DFRobotDFPlayerMini via Arduino Library Manager)
• Configuration & Build (platformio.ini)
Architectural Patterns & Design Principles
• Layered Abstraction:
• Transport → Protocol → Format → Application
• Event‐Driven Loop: main.cpp polls PN532, reacts to events (card tap, end-of-track, volume card).
• Separation of Concerns: NFC handling vs. audio control vs. card ID configuration.
• Hardware Abstraction: generic PN532 interface (can switch I2C to SPI by changing include/PlatformIO settings).