Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 275 → Rev 276

/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
114,6 → 114,21
while(1);
}
 
void Test_Callback(uint8_t controller, CTRL_BTN_STATUS value) {
LED1_LAT = 0;
LED2_LAT = 0;
LED3_LAT = 0;
LED4_LAT = 0;
if (value.BTN_R_N)
LED1_LAT = 1;
if (value.BTN_R_E)
LED2_LAT = 1;
if (value.BTN_R_S)
LED3_LAT = 1;
if (value.BTN_R_W)
LED4_LAT = 1;
}
 
void main() {
// WARNING!! THIS BOARD WILL RESET EVERY 1048.576s DUE TO THE WDT!!
 
131,7 → 146,8
 
// Enable the watchdog timer with windowed mode disabled
// WDT prescaler set to 1048576 (1048.576s) (see config bits)
WDTCON = 0x00008000;
// WDTCON = 0x00008000;
WDTCON = 0x00000000;
 
// Configure onboard LEDs
LED1_TRIS = 0;
157,12 → 173,12
SPI1_Init(&spi_1_data, NULL);
 
// Initialize the SPI4 module
SPI4_DATA spi_4_data;
SPI4_Init(&spi_4_data);
// SPI4_DATA spi_4_data;
// SPI4_Init(&spi_4_data);
 
// Initialize the I2C1 module
I2C1_DATA i2c_1_data;
I2C1_Init(&i2c_1_data, I2C1_400KHZ, 0x20);
I2C1_Init(&i2c_1_data, I2C1_200KHZ, 0x20);
 
// // Initialize the UART1 module
// UART1_DATA uart_data;
176,11 → 192,11
Cube_Init(&cube_data, 0x40);
 
// Start the cube update layer interrupt
// 2083 = 60Hz, 500 = 250Hz, 250 = 500Hz
// 2084 = 60Hz, 500 = 250Hz, 250 = 500Hz
TIMER5_DATA timer_5_data;
TIMER5_Init(&timer_5_data, &Cube_Timer_Interrupt, 500);
 
// Start the controller polling and overlay rotation interrupt
// Initialize timer for controller polling and overlay rotation interrupt
TIMER4_DATA timer_4_data;
TIMER4_Init(&timer_4_data, NULL, NULL, 0);
 
190,7 → 206,7
 
// Initialize controllers
CONTROLLER_DATA ctrl_data;
Controller_Init(&ctrl_data);
Controller_Init(&ctrl_data, NULL);
 
// Initialize the Ethernet module
if (op_state == BOARD_MODE_ETHERNET) {
203,7 → 219,6
TRON_DATA tron_data;
 
PWM2_Start();
TIMER5_Start();
/* -------------------- END OF INITIALIZATION -------------------- */
/* ------------------------ BEGIN DISPLAY ------------------------ */
211,24 → 226,35
// Figure out what to do at this point (depending on current state)
switch (op_state) {
case BOARD_MODE_IDLE:
TIMER5_Start(); // Use the default refresh rate (250Hz)
Idle_Animation_Sequence();
break;
case BOARD_MODE_SNAKE:;
Controller_Init(&ctrl_data);
case BOARD_MODE_SNAKE:
// Change refresh rate to ~60Hz
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2000);
TIMER5_Start();
// Poll the controllers at 1kHz
Controller_Init(NULL, &Snake_Update_Direction);
TIMER4_Init(NULL, &Controller_Update, NULL, 0);
TIMER4_Start();
// Initialize and start the game
Snake_Init(&snake_data);
Snake_Main();
break;
case BOARD_MODE_TRON:
Controller_Init(&ctrl_data);
// Change refresh rate to ~60Hz
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2000);
TIMER5_Start();
// Poll the controllers at 1kHz
Controller_Init(&ctrl_data, NULL);
TIMER4_Init(NULL, &Controller_Update, NULL, 0);
// Initialize and start the game
Tron_Init(&tron_data);
TIMER4_Start();
Tron_Init(&tron_data);
Tron_Main();
break;
case BOARD_MODE_ETHERNET:
TIMER4_Stop();
TIMER5_Start();
LED2_LAT = 1;
while(1);
break;
250,6 → 276,12
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
uint8_t connected, i;
connected = Controller_Get_Connected();
for (i = 0; i < connected; i++) {
Controller_Set_Idle(i);
}
 
// Start the scrolling text
TIMER4_Stop();
286,8 → 318,8
// Animation_Layer_Alternate(300);
// Animation_Pixel_Alternate(200);
// 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);