How ftservo/ftservo_arduino works
Project Type and Purpose
• Project type: Embedded‐library for Arduino/ESP32.
• Purpose: Provide a uniform C++ API to command three series of FEETECH BUS servos (HLSCL, SCSCL, SMS_STS) via a serial bus.
• Key features: layered architecture (hardware interface, communication, application), example sketches illustrating usage.
File Structure
• Top‐level:
– examples/ → Arduino sketches grouped by servo series (HLSCL, SCSCL, SMS_STS).
– src/ → core library modules.
– library.properties, README.md, LICENSE.
• src/ layers:
– Hardware Interface: SCSerial.{h,cpp}
– Communication Layer: SCS.{h,cpp}
– Instruction Definitions: INST.h
– Application Layer: HLSCL.{h,cpp}, SCSCL.{h,cpp}, SMS_STS.{h,cpp}
README Insights
• It explicitly calls out three layers:
– Hardware interface (serial drivers)
– Communication (packet formation/parsing)
– Application (series‐specific high‐level APIs)
• Examples demonstrate end‐to‐end usage: sketch → library → servo.
Main Components
a. External:
– Arduino IDE/Sketch (user code)
– FEETECH BUS Servo devices on the physical serial bus
– Underlying MCU hardware (Arduino board or ESP32)
b. Library Layers (inside MCU):
1. Application Layer
• HLSCL API module
• SCSCL API module
• SMS_STS API module
2. Instruction Definitions
• INST.h (common command codes, memory tables)
3. Communication Layer
• SCS module: packet builder/parser
4. Hardware Interface Layer
• SCSerial: low‐level UART control, TX/RX
Relationships and Data Flow
• Sketch calls functions in the Application Layer (e.g., SCSCL.writePos(...)).
• Application Layer consults INST definitions for opcode, parameters.
• Data passed to Communication Layer (SCS) to frame packets.
• Framed packet passed to SCSerial to send via UART pins.
• Physical serial bus carries bytes to servo devices.
• Servo replies flow back: UART → SCSerial → SCS → Application → sketch callback.
Architectural Patterns & Principles
• Layered architecture (clear dependency direction: App → INST → Comm → HW).
• Separation of concerns: hardware details isolated from high‐level API.
• Extensibility: new servo series can add another Application module that reuses INST + Comm + HW layers.
Technologies & Frameworks
• C++17 (Arduino core)
• Arduino IDE / Arduino Library Manager
• UART serial protocol over FEETECH BUS