kierdavis / sb-servo-asm-fw

Rewrite of SourceBots servo assembly firmware
0 stars 0 forks source link

Make compatible with arduino IDE #7

Open kierdavis opened 6 years ago

kierdavis commented 6 years ago

As mentioned in #6, the firmware may be extended by competitors, who will likely be using the Arduino IDE. At the least this project should be buildable out of the box with the Arduino IDE - ideally this should be our primary build tool, to ensure compatibility.

per1234 commented 6 years ago

The requirements of an Arduino sketch is that there be at least one file with the .ino extension in a folder of the same name.

I was able to compile your code using the Arduino IDE after simply:

  1. Creating a blank file named src.ino under the src folder.
  2. Opening src.ino in the Arduino IDE.
  3. Installing the Adafruit PWM Servo Driver Library via the Arduino IDE's Library Manager.

Most Arduino users would probably be a bit thrown off by the primary sketch file being empty since this is the open tab when the sketch is opened (even though all the other source files are right there in the Arduino IDE as tabs). For the most user friendly experience I would recommend:

If you prefer to bundle a specific version of the Adafruit PWM Servo Driver Library (instead of requiring the user to install the library) the use of submodules is not ideal since they are not included in the file provided by GitHub's Clone or download > Download ZIP (which is commonly used instead of git clone by Arduino users). Instead I would recommend using a Git subtree, which does not have that issue. Put the library inside the src subfolder of the sketch folder and change the includes in the sketch from:

#include <Adafruit_PWMServoDriver.h>

to:

#include "src/Adafruit_PWM_Servo_Driver_Library/Adafruit_PWMServoDriver.h"

Unfortunately the author of that library used the incorrect include syntax (https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/pull/33) for the internal include of the library so line 18 of Adafruit_PWMServoDriver.cpp also needs to be changed from:

#include <Adafruit_PWMServoDriver.h>

to:

#include "Adafruit_PWMServoDriver.h"