Standardizing ASTRA's embedded code.
- Overview
- Usage in PlatformIO
- Naming conventions
- File List
- Theory
- Updating this Repository
- Responsible People
This library provides classes, structs, functions, pin number macros, and team-wide constants, just to name a few. Here are a few examples:
parseInput(const String, std::vector<String>&): takes input from USB or UART and separates it into the vector, using commas as delimiters. Very useful for dealing with commands and data input from other mcu's.CAN_sendDutyCycle(uint8_t, AstraCAN&): Formats and sends a CAN packet to a REV motor controller with a duty cycle. All communication with REV motor controllers should reside inAstraREVCAN.{h,cpp}.isCalibrated(Adafruit_BNO055&): Attempts to check whether the BNO has been calibrated in EEPROM.COMMS_UART: Macro for the UART interface used by each MCU.SERIAL_BAUD: Standard baudrate for USB Serial used by all of ASTRA's mcu's.
- Add the following line to
lib_depsin your/platformio.ini:
https://github.com/SHC-ASTRA/rover-Embedded-Lib
- Add the include statement for your project. E.g.,
#include "project/CITADEL.h" - Make sure to grab the correct dependencies for
/platformio.inifrom the project headers.
- Copy the example file from
/.pio/libdeps/[board]/rover-Embedded-Lib/examples/Template/ - Grab the correct project header from
include/project/or create one fromTEMPLATE.h
PlatformIO provides a button which will check for updates in all of your dependencies and update them for you. Here's how to take advantage of it:
- Open the PlatformIO side-bar (the alien on the left)
- Under "Project Tasks" (the top pane), for each microcontroller specified in your platformio.ini, there are a handful of folders. "General" and "Platform" should be open already.
- Open the "Dependencies" folder.
- Click "Update".
- Library files - Depending on context, either the files generally contained in the library, or the main functional C++ files containing functions and classes.
- Project header - A header file that corresponds to one PlatformIO project, residing in
include/project/.
- Library files - Camel case with the first letter of all words, including the first, capitalized. Ex:
AstraArm.cpp - Project headers - All caps. Ex:
CITADEL.h
AstraArm.h/.cpp- ArmAstraMotors.h/.cpp- REV motorAstraNP.h/.cpp- Status indicator using NeoPixel
library.json- PlatformIO stuffREADME.md- this file. Documentation and GitHub front page.
AstraREVCAN.h/.cpp- ASTRA's implementation of CAN communication with REV motorsAstraSensors.h/.cpp- functions for sensorsAstraMisc.h/.cpp- functions, consts, etc. useful to all ASTRA projects.
- One per project.
- All caps file name, aside from
.h - Found in
include/project/ - Includes pinouts (all pinouts important for code, optionally ones not needed for code)
- Includes constants relating to hardware
- DOES NOT include constants only relevant to the code
- The goal is too put less work on the embedded programmer, abstracting away electronics
- The embedded programmer SHOULD NOT have to edit their project's library. When in doubt, it goes in
main.cpp.
main.cppincludes all the library headers it needs- Only if a library header is included by
main.cppwill it throw#includeerrors. If the header isn't included inmain.cpp, then no include errors, but if it is, then you will get required include errors. .cppfiles enable themselves when all of its required external libraries are found. External libraries are 90% of the reason the.cppfiles need the option to be disabled.
When making any update to this repository, before updating main, make sure to increment the version number in library.json, line 3.
Without making this change, projects using this library will not update automatically. Instead, they will have to delete the library
locally and let PlatformIO re-download it. (Not sure if this is true.......)
When making commits, it would be amazing if you use Conventional Commits.
- Copy
TEMPLATE.hinrover-Embedded-Lib/include/project/. - Choose a project macro and add it to
ASTRA.h.
- Place the header file in
include/and its implementation.cppinsrc/. - Choose a library macro to enable its files.
- Place the library macro in this file for documentation.
Name: David Sharpe
Email: ds0196@uah.edu
Name: David Sharpe
Email: ds0196@uah.edu