Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 263 → Rev 264

/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
182,7 → 182,7
 
// Start the controller polling and overlay rotation interrupt
TIMER4_DATA timer_4_data;
TIMER4_Init(&timer_4_data, &Controller_Update, NULL, 0);
TIMER4_Init(&timer_4_data, NULL, NULL, 0);
 
// Process button inputs
BTN_DATA btn_data;
193,8 → 193,10
Controller_Init(&ctrl_data, NULL);
 
// Initialize the Ethernet module
ETH_DATA eth_data;
ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
if (op_state == BOARD_MODE_ETHERNET) {
ETH_DATA eth_data;
ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
}
SNAKE_DATA snake_data;
TRON_DATA tron_data;
201,12 → 203,11
 
PWM2_Start();
TIMER5_Start();
TIMER4_Start();
/* -------------------- END OF INITIALIZATION -------------------- */
/* ------------------------ BEGIN DISPLAY ------------------------ */
 
// Figure out what state to go into here
// Figure out what to do at this point (depending on current state)
switch (op_state) {
case BOARD_MODE_IDLE:
Idle_Animation_Sequence();
213,11 → 214,15
break;
case BOARD_MODE_SNAKE:;
Controller_Init(&ctrl_data, &Snake_Update_Direction);
TIMER4_Init(NULL, &Controller_Update, NULL, 0);
TIMER4_Start();
Snake_Init(&snake_data);
Snake_Main();
break;
case BOARD_MODE_TRON:
Controller_Init(&ctrl_data, &Tron_Update_Direction);
TIMER4_Init(NULL, &Controller_Update, NULL, 0);
TIMER4_Start();
Tron_Init(&tron_data);
Tron_Main();
break;
230,7 → 235,6
}
 
void Idle_Animation_Sequence(void) {
Delay_MS(250);
 
// Cube_Set_All(RED);
// Delay_MS(2000);
247,7 → 251,7
 
// Start the scrolling text
TIMER4_Stop();
TIMER4_Init(NULL, &Controller_Update, &Cube_Text_Interrupt, 100);
TIMER4_Init(NULL, NULL, &Cube_Text_Interrupt, 100);
// TIMER4_Start();
 
// int8_t start_text[] = "Cube Initialized\r\n";
259,6 → 263,22
 
// Loop through some preset animations
while(1) {
 
Animation_Sawtooth(100);
Animation_Sawtooth(100);
Animation_Sawtooth(100);
Animation_Sphere(100);
Animation_Sphere(100);
Animation_Sphere(100);
Animation_Sphere(100);
Animation_Wave1(100);
Animation_Wave1(100);
Animation_Wave1(100);
Animation_Wave1(100);
Animation_Wave2(100);
Animation_Wave2(100);
Animation_Wave2(100);
Animation_Wave2(100);
// Animation_Solid_Colors(300);
// Animation_Layer_Alternate(300);
// Animation_Pixel_Alternate(200);
265,14 → 285,21
// Animation_Full_Color_Sweep(1000);
Animation_Row_Column_Sweep(40);
Animation_Row_Column_Sweep(40);
Animation_Row_Column_Sweep(40);
Animation_Cube_In_Cube(300);
Animation_Cube_In_Cube(300);
Animation_Cube_In_Cube(300);
Animation_Double_Rotation(40);
Animation_Double_Rotation(40);
Animation_Double_Rotation(40);
// Animation_Pseudo_Random_Colors(300);
Animation_Double_Rotation(30);
Animation_Double_Rotation(30);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
Animation_Pseudo_Random_Colors(300);
// Animation_Random_Colors(300);
 
// ClearWDT(); // Clear the WDT if we dont want the board to reset
279,34 → 306,50
}
}
 
// Function call on button 1 press to change refresh rate
// Function call on button 1 press to change cube operation
void BTN1_Interrupt(void) {
static uint8_t state;
state = (state == 4) ? 0 : state + 1;
TIMER5_Stop();
switch (state) {
case 0:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 500); // 250Hz
switch (op_state) {
case BOARD_MODE_IDLE:
Reset_Board(BOARD_MODE_SNAKE);
break;
case 1:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2083); // 60Hz
case BOARD_MODE_SNAKE:
Reset_Board(BOARD_MODE_TRON);
break;
case 2:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 4166); // 30Hz
case BOARD_MODE_TRON:
Reset_Board(BOARD_MODE_ETHERNET);
break;
case 3:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 12498); // 10Hz
case BOARD_MODE_ETHERNET:
Reset_Board(BOARD_MODE_IDLE);
break;
case 4:
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 24996); // 5Hz
break;
}
TIMER5_Start();
 
// Code to change refresh rate on button press
// static uint8_t state;
// state = (state == 4) ? 0 : state + 1;
// TIMER5_Stop();
// switch (state) {
// case 0:
// TIMER5_Init(NULL, &Cube_Timer_Interrupt, 500); // 250Hz
// break;
// case 1:
// TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2083); // 60Hz
// break;
// case 2:
// TIMER5_Init(NULL, &Cube_Timer_Interrupt, 4166); // 30Hz
// break;
// case 3:
// TIMER5_Init(NULL, &Cube_Timer_Interrupt, 12498); // 10Hz
// break;
// case 4:
// TIMER5_Init(NULL, &Cube_Timer_Interrupt, 24996); // 5Hz
// break;
// }
// TIMER5_Start();
}
 
// Function call on button 2 press to change brightness
void BTN2_Interrupt(void) {
static uint8_t state;
static uint8_t state = 6;
state = (state == 6) ? 0 : state + 1;
TIMER5_Stop();
Delay_MS(1); // Need to wait for all SPI writes to complete