Let’s say you love
blinklib, but just wish that it did one thing differently. You can actually customize
blinklib to suit your needs!
For this example, we are are going to pretend that you have created a game that is played on the ceiling and so you want the
buttonDown() function to return
true normally and
false when the button is pressed (the opposite of the normal behavior).
- Open the
ButtonPressexample program in the Arduino IDE
“Save as…” it to something like
Download this program to a blink and confirm that the LEDs are RED when the button is pressed and GREEN when it is not pressed.
Open the sketch folder using
Show Sketch Folder
- Copy the
blinklibb.cppfile into the sketch folder. Note that you will have to find this file yourself since where it lands is dependent on how your computer is set up and how you installed the blinks SDK. On my machine it is in
D:\Github\Move38-Arduino-Platform\cores\blinklib. Make sure you copy and not move the file.
- Quit out of the Arduino IDE and start it again. You should now see the
blinklibtab in the IDE
blinklib.cpp, find the
- Change the
buttonDown()function to do the opposite (ceiling-style)
- Download the program into a blink and confirm that up is now down!
Yeay! You now can very easily customize any
blinklib functionality you want!
This is a silly example, more likely you would want to customize things like how the IR set value system updates, or maybe reduce the memory used by some functionality that you don’t need, or change the way that blinks keep each other awake when buttons are pressed.
The changes you make to
blinklib.cpponly affect the current project. If you want to use these same changes on other projects, you will have to copy the
blinklib.cppto their sketch folders. Having many copies of the same file can be a version control hassle since you will be responsible for keeping all the copies in sync (you could use symbolic links to help here, but they can be problematic when you want to move or share your codebase).
Your version of
blinklib.cppis locked in the moment you copy it so it will not automatically get updates if that file is updates in the main repository. Again this could be a version control hassle since you will have to manually merge in any updates that you want.
If you are looking to really overhaul the API and make it available to others, then there are better ways. You could, for example, fork the
blinklib repo and then do whatever you want and push and pull changes to and from the main repo. This would be great if you, say, wanted to create a new actor-model style API. LMK if this is something you’d be interested in and we can help you out!