Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 206 → Rev 207

/PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.h
11,13 → 11,13
 
#define CUBE_STRING_MAX_LENGTH 32
 
#define RED 0x0FF,0x000,0x000
#define ORANGE 0x0FF,0x020,0x000
#define YELLOW 0x0FF,0x0FF,0x000
#define GREEN 0x000,0x0FF,0x000
#define TEAL 0x000,0x0FF,0x0FF
#define BLUE 0x000,0x000,0x0FF
#define PURPLE 0x0FF,0x000,0x0FF
#define RED 0x08F,0x000,0x000
#define ORANGE 0x08F,0x020,0x000
#define YELLOW 0x08F,0x08F,0x000
#define GREEN 0x000,0x08F,0x000
#define TEAL 0x000,0x08F,0x08F
#define BLUE 0x000,0x000,0x08F
#define PURPLE 0x08F,0x000,0x08F
 
#define SFT_D_TRIS TRISBbits.TRISB15
#define SFT_S_TRIS TRISDbits.TRISD5
/PIC Stuff/Cerebot_32MX7_LED_Cube/TIMER4.c
26,8 → 26,8
} else if (time_us < 52428) {
time = 1.25 * time_us;
T4CONSET = 0x0060; // Prescaler at 1:64
} else { // Minimum time_us of 209712
time = 0.3125 * time_us;
} else {
time = 0.3125 * time_us; // Minimum time_us of 209712
T4CONSET = 0x0070; // Prescaler at 1:256
}
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
90,49 → 90,53
SPI1_DATA spi_data;
SPI1_Init(&spi_data);
 
// Initializs the PWM output to 20MHz
PWM2_Init();
PWM2_Start();
 
// Initialize the cube
CUBE_DATA cube_data;
Cube_Init(&cube_data, 0x40);
 
// Start the cube update layer interrupt
// 2083 = 60Hz, 500 = 250Hz, 250 = 500Hz
TIMER5_DATA timer_5_data;
TIMER5_Init(&timer_5_data, &Cube_Timer_Interrupt, 500);
TIMER5_Start();
 
// Start the overlay rotation interrupt
TIMER4_DATA timer_4_data;
TIMER4_Init(&timer_4_data, &Cube_Text_Interrupt, 150000);
TIMER4_Start();
TIMER4_Init(&timer_4_data, &Cube_Text_Interrupt, 120000);
 
// Process button inputs
BTN_DATA btn_data;
BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, NULL);
// Begin display
// Cube_Set_All(0xFF,0xFF,0xFF);
// Delay_MS(6000);
// Cube_Set_All(0xFF,0,0);
// Delay_MS(6000);
// Cube_Set_All(0,0xFF,0);
// Delay_MS(6000);
// Cube_Set_All(0,0,0xFF);
// Delay_MS(6000);
 
Cube_Set_All(0xFF,0,0);
Delay_MS(6000);
Cube_Set_All(0,0xFF,0);
Delay_MS(6000);
Cube_Set_All(0,0,0xFF);
Delay_MS(6000);
 
// Set the overlay text
char text_string[] = "CCMLab ";
Cube_Text_Init(text_string, 7, 0xFF, 0xFF, 0xFF);
TIMER4_Start();
 
// Loop through some preset animations
while(1) {
Animation_Solid_Colors(2,300);
Animation_Layer_Alternate(2,300);
Animation_Pixel_Alternate(1,200);
Animation_Full_Color_Sweep(2,1000);
// Animation_Solid_Colors(2,300);
// Animation_Layer_Alternate(2,300);
// Animation_Pixel_Alternate(1,200);
// Animation_Full_Color_Sweep(2,1000);
Animation_Row_Column_Sweep(2,40);
Animation_Pseudo_Random_Colors(10,300);
Animation_Random_Colors(10,300);
Animation_Cube_In_Cube(4,300);
Animation_Double_Rotation(2,40);
Animation_Pseudo_Random_Colors(10,300);
// Animation_Random_Colors(10,300);
}
}
 
143,19 → 147,19
TIMER5_Stop();
switch (state) {
case 0:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 500);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 500); // 250Hz
break;
case 1:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2083);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2083); // 60Hz
break;
case 2:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 4166);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 4166); // 30Hz
break;
case 3:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 13107);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 12498); // 10Hz
break;
case 4:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 200000);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 24996); // 5Hz
break;
}
TIMER5_Start();
166,7 → 170,6
static char state;
state = (state == 6) ? 0 : state + 1;
TIMER5_Stop();
TIMER4_Stop();
Delay_MS(1); // Need to wait for all SPI writes to complete
char BC;
switch (state) {
194,7 → 197,6
}
Cube_Write_DCS(BC);
TIMER5_Start();
TIMER4_Start();
}
 
// Function call on button 3 press to change text scroll speed
213,10 → 215,10
TIMER4_Init(NULL, &Cube_Text_Interrupt, 150000);
break;
case 3:
TIMER4_Init(NULL, &Cube_Text_Interrupt, 100000);
TIMER4_Init(NULL, &Cube_Text_Interrupt, 120000);
break;
case 4:
TIMER4_Init(NULL, &Cube_Text_Interrupt, 10000);
TIMER4_Init(NULL, &Cube_Text_Interrupt, 90000);
break;
}
TIMER4_Start();
527,38 → 529,38
switch (z % 3) {
case 0:
for (y = 0; y < CUBE_LAYER_COUNT; y++) {
Cube_Set_Pixel(y, 0, 0, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 1, 1, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 2, 2, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 3, 3, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 4, 4, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 5, 5, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 6, 6, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y, 7, 7, 0xFF, 0x00, 0x00);
Cube_Set_Pixel(y,0,0,RED);
Cube_Set_Pixel(y,1,1,RED);
Cube_Set_Pixel(y,2,2,RED);
Cube_Set_Pixel(y,3,3,RED);
Cube_Set_Pixel(y,4,4,RED);
Cube_Set_Pixel(y,5,5,RED);
Cube_Set_Pixel(y,6,6,RED);
Cube_Set_Pixel(y,7,7,RED);
}
break;
case 1:
for (y = 0; y < CUBE_LAYER_COUNT; y++) {
Cube_Set_Pixel(y, 0, 0, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 1, 1, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 2, 2, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 3, 3, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 4, 4, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 5, 5, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 6, 6, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y, 7, 7, 0x00, 0xFF, 0x00);
Cube_Set_Pixel(y,0,0,GREEN);
Cube_Set_Pixel(y,1,1,GREEN);
Cube_Set_Pixel(y,2,2,GREEN);
Cube_Set_Pixel(y,3,3,GREEN);
Cube_Set_Pixel(y,4,4,GREEN);
Cube_Set_Pixel(y,5,5,GREEN);
Cube_Set_Pixel(y,6,6,GREEN);
Cube_Set_Pixel(y,7,7,GREEN);
}
break;
case 2:
for (y = 0; y < CUBE_LAYER_COUNT; y++) {
Cube_Set_Pixel(y, 0, 0, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 1, 1, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 2, 2, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 3, 3, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 4, 4, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 5, 5, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 6, 6, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y, 7, 7, 0x00, 0x00, 0xFF);
Cube_Set_Pixel(y,0,0,BLUE);
Cube_Set_Pixel(y,1,1,BLUE);
Cube_Set_Pixel(y,2,2,BLUE);
Cube_Set_Pixel(y,3,3,BLUE);
Cube_Set_Pixel(y,4,4,BLUE);
Cube_Set_Pixel(y,5,5,BLUE);
Cube_Set_Pixel(y,6,6,BLUE);
Cube_Set_Pixel(y,7,7,BLUE);
}
break;
}
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties
1,5 → 1,5
#
#Mon Jul 01 16:20:04 EDT 2013
#Mon Jul 01 23:43:27 EDT 2013
default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=6b4fa04caf3910c7c3a4666b1aea8c5c
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc32\\v1.20\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=415494acd195d89b2f6d7a36797a5ab4