planet.cpp
/*
// planet.cpp
//
//
// Created by Rory McKay on 12/08/12.
//
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <inttypes.h>
#include <math.h>
#include <avr/interrupt.h>
#include "Charliplexing.h"
#include "planet.h"
const int GLOBALDELAY = 100;
stargroup::stargroup()
{
noOfStars = 0;
xPos[16] = 0;
yPos[16] = 0;
}
stargroup::stargroup(int x, prog_int16_t a[], prog_int16_t b[])
{
noOfStars = x;
for (int i = 0; i < noOfStars; i++)
{
xPos[i] = a[i];
yPos[i] = b[i];
}
for (int i = noOfStars; i < 16; i++)
{
xPos[i] = 13;
yPos[i] = 8;
}
}
stargroup& stargroup::operator= (const stargroup &source)
{
noOfStars = source.noOfStars;
for (int i = 0; i < noOfStars; i++)
{
xPos[i] = source.xPos[i];
yPos[i] = source.yPos[i];
}
for (int i = noOfStars; i < 16; i++)
{
xPos[i] = 13;
yPos[i] = 8;
}
return *this;
}
void stargroup::fadeOn()
{
for (int h = 0; h < 8; h++) //for all the different shades.
{
for (int i = 0; i < noOfStars; i++) //for each of the stars in the constilation.
{
LedSign::Set(xPos[i], yPos[i], h); //h is shade value
}
delay(GLOBALDELAY);
}
}
void stargroup::on()
{
for (int i = 0;i < noOfStars; i++) //for each of the stars in the constilation.
{
LedSign::Set(xPos[i], yPos[i], 7);
}
delay (GLOBALDELAY);
}
void stargroup::off()
{
for (int i = 0;i < noOfStars; i++) //for each of the stars in the constilation.
{
LedSign::Set(xPos[i], yPos[i], 0);
}
delay (GLOBALDELAY);
}
void stargroup::fadeOff()
{
for (int h = 8; h > 0; h--) //for all the different shades.
{
for (int i = 0; i < noOfStars; i++) //for each of the stars in the constilation.
{
LedSign::Set(xPos[i], yPos[i], h); //h is shade value
}
delay (GLOBALDELAY);
}
}
void stargroup::fadeOffAll()
{
for (int h = 8; h > 0; h--) //for all the different shades.
{
for (int i = 0; i < noOfStars; i++) //for each of the stars in the constilation.
{
LedSign::Set(xPos[i], yPos[i], h); //h is shade value
}
delay (1);
}
}
void empty(int a[], int b[])
{
for (int i = 0; i < 12; i++)
{
a[i] = 13;
b[i] = 0;
}
}