Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(library): Restructure entire repository #46

Merged
merged 39 commits into from
Oct 31, 2023
Merged

Conversation

ZZ-Cat
Copy link
Owner

@ZZ-Cat ZZ-Cat commented Oct 24, 2023

Overview

This will take some time to complete.

When I first started CRSF for Arduino, I had to learn how to use PlatformIO. At the same time, I decided to make a project that integrates with PlatformIO and the Arduino IDE, and have it interoperate between both environments. I also wanted to make the project cool and interesting. Thus, CRSF for Arduino was born.

Fast forward a few months, and I have learned a lot. I now know how to properly configure PlatformIO to suit my own needs and my projects.
Now, the time has come to clean up CRSF for Arduino's janky mess that is its folder structure.

To-Do List

  • Change all *.h file extensions in CRSF for Arduino to *.hpp.
  • Streamline folder structure.
  • Fix Arduino IDE compilation errors.
  • Rewrite information in README.md to be more concise.
  • Refactor platformio.ini configuration file.
    • Put target development boards into their own *.ini file.
    • Use main platformio.ini file only to decide how the environment should compile (EG "Production", "Debug" etc).

The problem

CRSF for Arduino's folder structure looks like this:
Screenshot 2023-10-24 172520

This is far from ideal, because one must go through folder after folder in order to get to anything.
This has implications for some compilers (for different targets) where the linkers freak out whenever a nested structure like this exists. The Arduino IDE is infamous for also completely losing its shit over nested folder structures. Especially one that is as unnecessarily complex as CRSF for Arduino.

It also makes it harder for yours truly to debug.
Plus, it makes it harder for you guys to find anything and read CRSF for Arduino's code base.

To drive the point home, here is a screenshot of the folder structure of another project of mine:
Screenshot 2023-10-24 174445
As you can see, despite there being more modules in the project, each folder structure is straightforward and everything is easily accessible.
Even the folder structure for all of my drivers in this project is way more accessible than what I have with CRSF for Arduino:
Screenshot 2023-10-24 174859

What I want to achieve

A streamlined folder structure similar to the examples above, that retains compatibility with both the Arduino IDE and PlatformIO.

IIRC, the Arduino IDE prefers a folder structure that looks like this:

MyLibary
  |--examples
  |    |--MyExample.ino
  |
  |--src
  |    |--NestedFolder
  |    |    |--MySubModule.hpp
  |    |    |--MySubModule.cpp
  |    |
  |    |--MyLibrary.hpp
  |    |--MyLibrary.cpp
  |
  |--library.properties

I cannot guarantee that CRSF for Arduino will look exactly like this, however I will do all I can to streamline the folder structure.
Keep in mind that this may introduce breaking changes (of which I will list here, as and when they arise).

Additional

I keep referencing PlatformIO because it is now my IDE of choice. CRSF for Arduino is developed in PlatformIO, with Visual Studio Code being my code viewer and editor.

I am also aware that Linguist (GitHub's coding language detection software) has done this:
Screenshot 2023-10-24 180217
This is incorrect, because CRSF for Arduino is written exclusively in C++.
When I click on the 'C' component, I get this:
Screenshot 2023-10-24 180455
This is CRSF for Arduino's boiler plate. 😆
Hardly C (or any language at all).
This has come about because all of CRSF for Arduino's header files are *.h (which is a C extension) and not *.hpp (which is a C++ extension).
I have found out that it is bad practice to mix-and-match these headers, if it contains pure C++ code (which CRSF for Arduino does).

So, one of the first things I am doing with the restructure is changing the extensions in all of CRSF for Arduino's header files from *.h to *.hpp, and (hopefully) linguist will give a more accurate portrayal of the language that CRSF for Arduino is written in.

@ZZ-Cat ZZ-Cat added 🚨 Blocks Release 🚨 No release is to be made, until this is resolved. Arduino IDE ♾️ This is specific to the Arduino IDE PlatformIO 👽 This is specific to PlatformIO. ...in progress 🚧 Development on this is in progress labels Oct 24, 2023
@ZZ-Cat ZZ-Cat self-assigned this Oct 24, 2023
@ZZ-Cat ZZ-Cat added this to the Version 0.5.0 milestone Oct 24, 2023
This should help associate every header file to C++.
…ROJECT_DIR` as the root directory

This allows me to put files and folders wherever I want in CRSF for Arduino.
…he `platformio` subfolder in `examples` folder
For now, CRSF for Arduino will not compile in the Arduino IDE. This is being worked on, and will be fixed in the next commit.
… DMA enabled

Currently, DMA is _highly_ experimental and its current implementation may not function as it's expected to... yet.
This provides a more concise description of what CRSF for Arduino is, and what the Crossfire Protocol is.
… Studio Code & PlatformIO` section

These are more concise
…ction

Explicitly specifying the development board in the command line is the preferred option.
…` list of `Do's & don'ts of CRSF for Arduino`
…ates"

The Issue Templates are now the only choices, when submitting Issues.
… Guidelines

This defines what 'ghosting' is and how it is dealt with.
Just taking care of a minor bug-bear of mine. I no longer use ampersands in my written work.
This saves me from having to add this label manually, when someone submits an issue.
…after seven days from being slated for closure.
…ied files, based on their vendors and chipsets
@ZZ-Cat ZZ-Cat marked this pull request as ready for review October 31, 2023 04:52
@ZZ-Cat ZZ-Cat merged commit 4ab3e09 into Main-Trunk Oct 31, 2023
4 checks passed
@ZZ-Cat ZZ-Cat deleted the repo-cleanup branch October 31, 2023 04:57
@ZZ-Cat ZZ-Cat removed ...in progress 🚧 Development on this is in progress 🚨 Blocks Release 🚨 No release is to be made, until this is resolved. labels Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arduino IDE ♾️ This is specific to the Arduino IDE PlatformIO 👽 This is specific to PlatformIO.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant