LED light strip based project for Blink 2019
We're using The Pitchfork Layout for our project directory structure.
So far we have the following root-level directories defined:
This is where we can keep example programs, demo code, PoC's and their ilk. Nothing intended to be actually published, but this is a good way to codify functionality we expect to work. It's also a good place to keep any troubleshooting programs too.
Any external or third party libs should be cloned into this directory as their own subdirectory, and can be included as git submodules or just source or whatever. Don't modify these files manually, but do try to keep them updated. Or don't - idk actually now that I think about it 🤔
All project source code files go in /src
, with .h and .cpp files smushed up against each other because they're close friends like that. It's a merged-header-placement flavored library-source-layout. I really can't believe that's a sentence in English.
This project is mainly set up to build and deploy with VSCode using the platformio plugin. That should be enough to develop in this project. Platformio should handle all of the library dependencies we need
Ardiuno files consist of two methods: setup() and loop(). The setup method runs once when the program starts running. Loop then loops infinitely until power is cut off. This main file is in src/main.cpp. All other classes are imported through .h header files.
The four main classes are detailed in the next section, but in summary: The game class holds all subclasses, logic, and states. To initialize, it requires a Display object, which hold an array (or array of arrays) of CRGB objects. The game takes in inputs from a Controls object and the draws them to the Display object using Animation objects. Finally, display->Show() is called at the end of each loop to write to the LED strips.
Controls and animations are kept within their respective class folders, so that we can reuse them between different games. Feel free to keep all your stuff in a specific folder though, PlatformIO lets you just do an include on any .h file in the library, just make sure not to reuse names.
Each Game Requires the following classes:
1. Game
Holds all Game specific objects, subclasses, logic and game states, as well as method for setup and loop
- Location: lib/games/game.h
- Required Methods/ Members:
- constructor - constructor is required to take in a display object
- background - Animation object for background
- display - Display object for LED strip setup game will be running on
- setup() - Method to run in the setup loop
- loop() - Method to run in the main loop
2. Display
Holds all LED strips as an array of arrays. These are built and likely won't need much editing.
- Location: lib/Displays/Display.h
- Required Methods/ Members:
- strip_count - number of strips, i.e. width of matrix
- strip_length - how long the strips are
- strips - Array of Arrays generated by NumStrips and strip_length
3. Animation
Draws animations to a display object
- Location: lib/Animations/Animation.h
- Required Methods/ Members:
- drawy(display) - writes animation to a display
4. Controls
The wild child of the main classes. Holds all Buttons/ Controllers, you can kinda do whatever with these but should all be set up. Does not need to inheret from base Controls class. Basically take what you want from the control library folder and Frankenstein yourself some controls.
- Location: lib/Controls/Controls.h
- Required Methods/ Members:
- none, but you probably want like at least a button or something
- Important Button Methods *