The Glitch
 All Files Pages
Library



GlitchLib

The GlitchLib library contains basic resources for developing software for The Glitch. This library is part of the Resource Files. Follow the Install Libraries instruction to get GlitchLib installed into the Arduino environment.


Code Template

Most software written using GlitchLib should contain the following code:

#include <glitchlib.h>
#include <SD.h>
short selection = 0; // Value set by DIP switch
// CODE HERE
void setup() {
// CODE HERE
glitchSetLED(); // Set LED Pins
glitchSetDIP(short & selection); // Set DIP switch PINs and return selection.
if (!glitchSetSD()) { // Initialize SD card reader
return; // Stop execution.
}
// CODE HERE
}


Variables

The following are the variables in GlitchLib.

extern const short chipSelectSD // SS pin for SPI Select for SD card
extern const short ledRed // Pin to control Red LED. Set HIGH for on, and LOW for off.
extern const short ledYellow // Pin to control Yellow LED. Set HIGH for on, and LOW for off.
extern const short ledGreen // Pin to control Green LED. Set HIGH for on, and LOW for off.
extern const short DIP_1 // Pin selection for DIP position 1. Default pulled up. Use negative logic to read input.
extern const short DIP_2 // Pin selection for DIP position 2. Default pulled up. Use negative logic to read input.
extern const short DIP_3 // Pin selection for DIP position 3. Default pulled up. Use negative logic to read input.
extern const short DIP_4 // Pin selection for DIP position 4. Default pulled up. Use negative logic to read input.
extern const short DIP_5 // Pin selection for DIP position 5. Default pulled up. Use negative logic to read input.


Functions

The following are the functions in GlitchLib.

extern short glitchSetDIP(short & selection) // Sets the pins for the DIP switch. Short selection returns the value set on the DIP switch. Return 0 for success.
extern short glitchSetLED() // Sets the pins for LEDs. Return 0 for success.
extern short glitchSetSD() // Initialize Micro SD card. Return 0 for success. Return 1 for failure.