Coding the AstroPixels

By default the AstroPixels will run standard R2 colours, with random HP lights. The code to do this is relatively simple and just a couple of dozen lines using the ReelTwo library which I talked about here.

#include "ReelTwo.h"
#include "dome/Logics.h"
#include "dome/LogicEngineController.h"
#include "dome/HoloLights.h"
#include "dome/NeoPSI.h"
#include "i2c/I2CReceiver.h"

I2CReceiver i2cReceiver(0x0a);

AstroPixelRLD<> RLD(LogicEngineRLDDefault, 1);
AstroPixelFLD<> FLD(LogicEngineFLDDefault, 2);

NeoPixelPSI rearPSI(4, 8);
NeoPixelPSI frontPSI(3, 8);

HoloLights frontHolo(10);
HoloLights rearHolo(12);
HoloLights topHolo(13);    

void setup()
{
    REELTWO_READY();
    rearPSI.set_color(1, 0, 255, 0);  // Set the rear PSI colours
    rearPSI.set_color(2, 255, 255, 0);
}

void loop()
{
    AnimatedEvent::process();
}

Going through it, the top lines are just including the ReelTwo library, which combines all the code from the various systems into one place.

The code between the includes and setup() routine define the hardware you have. In this case it is saying use address 0x0a for i2c communications, a couple of logics using the LogicEngine, a couple of NeoPixel PSIs, and three HPs using the FlthyMcNasty system.

Next comes the setup() routine. This just initialises some ReelTwo details, and sets the colours of the rearPSI as it defaults to red/blue.

Lastly, the main loop just does a call to animate all the lights.

More details about the ReelTwo library and how to use it can be found in the documentation.

If you want to experiment with the code, you can tweak some of the settings, etc. Just make sure the ReelTwo library is installed and you should then be ready to go.

This Post Has 4 Comments

  1. John

    Hi Darren.

    I bought a set of Astropixels and they are fantastic.
    Is it possible to get them to trigger any patterns from a signal from something like an Arduino?

      1. dpoulson

        The default i2c address I send them out with is 0x0a.

  2. John

    Thanks Darren. I will give a go and let you know how I get on.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.