Kinetic Sculpture: Extravaganza

Home

Current Objective: Make the Extravanganza of your Kinetic Sculpture

Requirements

  1. Cleanly format your code to maximize organization and readability like theĀ dpeaArduinoStyleGuide.
  2. Clarify the purpose of each function and variable through smartĀ naming.
  3. Use headers and comments as needed to enhance organization.

Setting up

  1. Using your previous Interpolating code, make a list of colors you like.
  2. Make a list of motor speeds for your disks using MotorTesting in class examples.
  3. Also in class examples, use DiskVelocitiesTesting to update your motor speeds to be disk velocities.

Using the steps below and in the next couple of pages, create the actual code to run Extravaganza

  1. Create a new sketch titled YourInitials_KineticSculpture_Extravaganza.
  2. Copy the code from YourInitials_KineticSculpture_Interpolating.
  3. Add the following code to create your table:
/* KS_Extravaganza - Written by Kyle Stewart - Updated 04132017 */

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                    //
//                                                RGB Color Definitions                                               //
//                                                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

enum Colour {red, green, blue};

#define rgbPureGreen {0, 255, 0}
#define rgbPinkForAllGenders {188, 42, 167}
#define rgbRazzleDazzle {3, 121, 198}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                    //
//                                           Motor Velocities Definitions                                             //
//                                                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//enum Disc {front, back};

#define velocitiesOff {0, 0}
#define velocitiesDizzyUp {-5, 5}
#define velocitiesBlaster {3, 6}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                    //
//                                                 Extravaganza Table                                                 //
//                                                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef struct {
const byte rgb[3];
const float discVelocities[2];
const unsigned int transitionDuration;
const unsigned int delayDuration;
} ExtravaganzaEntry;

const ExtravaganzaEntry ExtravaganzaTable[] = {
{rgbPureGreen, velocitiesDizzyUp, 5000, 1500},
{rgbPinkForAllGenders, velocitiesBlaster, 2500, 500},
{rgbRazzleDazzle, velocitiesOff, 5000, 750}
};

const byte ExtravaganzaLength = sizeof(ExtravaganzaTable) / sizeof(ExtravaganzaEntry);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                    //
//                                            Function Declarations (Verbs)                                           //
//                                                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Transitioning Functions
void updateElapsedTime();
void checkIfTransitioning();
void finishTransition();
void setFinalVelocities();
void interpolateColor();
void setColor();
void interpolateVelocities();

// Gamma Correction Functions
void calculateGammaCorrection(byte rgbArray[]);
byte readGammaTable(byte input);

// Next Transition Functions
void parseTableForNextEntry();
void calculateSlope();
void updateTransitionStartTime();
void updateIndex();
Next Page