Subversion Repositories Code-Repo

Compare Revisions

Regard whitespace Rev 206 → Rev 207

/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;
}