//PIC Stuff/Cerebot_32MX7_LED_Cube/ANIMATIONS.c |
---|
281,6 → 281,56 |
} |
} |
void Animation_Cube_In_Out(uint16_t delay_ms, uint16_t r, uint16_t g, uint16_t b) { |
uint8_t x,i,j,k; |
for (x = 0; x < 7; x++) { |
Cube_Clear(); |
for (i = 0; i < CUBE_LAYER_COUNT; i++) { |
if ((x == 0 || x == 6)&&(i == 0 || i == 7)) { |
Cube_Set_Layer(i,r,g,b); |
} else if ((x == 1 || x == 5)&&(i == 1 || i == 6)) { |
for (j = 1; j < CUBE_ROW_COUNT-1; j++) |
for (k = 1; k < CUBE_COLUMN_COUNT-1; k++) |
Cube_Set_Pixel(i,j,k,r,g,b); |
} else if ((x == 2 || x == 4)&&(i == 2 || i == 5)) { |
for (j = 2; j < CUBE_ROW_COUNT-2; j++) |
for (k = 2; k < CUBE_COLUMN_COUNT-2; k++) |
Cube_Set_Pixel(i,j,k,r,g,b); |
} else if ((x == 3)&&(i == 3 || i == 4)) { |
for (j = 3; j < CUBE_ROW_COUNT-3; j++) |
for (k = 3; k < CUBE_COLUMN_COUNT-3; k++) |
Cube_Set_Pixel(i,j,k,r,g,b); |
} |
if ((x == 0 || x == 6)&&(i > 0 && i < 8)) { |
for (j = 0; j < 8; j++) { |
Cube_Set_Pixel(i,j,0,r,g,b); |
Cube_Set_Pixel(i,j,7,r,g,b); |
Cube_Set_Pixel(i,0,j,r,g,b); |
Cube_Set_Pixel(i,7,j,r,g,b); |
} |
} |
if ((x == 1 || x == 5)&&(i > 1 && i < 7)) { |
for (j = 1; j < 7; j++) { |
Cube_Set_Pixel(i,j,1,r,g,b); |
Cube_Set_Pixel(i,j,6,r,g,b); |
Cube_Set_Pixel(i,1,j,r,g,b); |
Cube_Set_Pixel(i,6,j,r,g,b); |
} |
} |
if ((x == 2 || x == 4)&&(i > 2 && i < 6)) { |
for (j = 2; j < 6; j++) { |
Cube_Set_Pixel(i,j,2,r,g,b); |
Cube_Set_Pixel(i,j,5,r,g,b); |
Cube_Set_Pixel(i,2,j,r,g,b); |
Cube_Set_Pixel(i,5,j,r,g,b); |
} |
} |
} |
Delay_MS(delay_ms); |
} |
} |
void Animation_Double_Rotation(uint16_t delay_ms) { |
Cube_Clear(); |
uint8_t x,y,z; |
//PIC Stuff/Cerebot_32MX7_LED_Cube/ANIMATIONS.h |
---|
12,5 → 12,7 |
void Animation_Cube_In_Cube(uint16_t delay_ms); |
void Animation_Double_Rotation(uint16_t delay_ms); |
void Animation_Cube_In_Out(uint16_t delay_ms, uint16_t r, uint16_t g, uint16_t b); |
#endif /* ANIMATIONS_H */ |
//PIC Stuff/Cerebot_32MX7_LED_Cube/SNAKE.c |
---|
3,6 → 3,7 |
#include "SNAKE.h" |
static SNAKE_DATA *data_p; |
static uint32_t rand_value __attribute__((persistent)); |
void Snake_Init(SNAKE_DATA *data) { |
data_p = data; |
16,6 → 17,8 |
data_p->level = 1; |
data_p->delay = 800; |
srand(rand_value); |
// Generate a starting location for the candy |
data_p->candy_loc = Snake_Generate_Candy(); |
35,6 → 38,9 |
// Main function, loops and delays while updating the frame every x milliseconds |
Delay_MS(2000); |
while (1) { |
// Regenerate the seed upon each update so that the candy starts somewhere new every time |
rand_value = rand(); |
Snake_Update_Frame(); |
Delay_MS(data_p->delay); |
} |
90,8 → 96,10 |
data_p->direction.y == data_p->body[pos].y && |
data_p->direction.z == data_p->body[pos].z) { |
// Indicate the overlapping pixel, delay, then return to idle state |
Cube_Overlay_Set_Pixel(data_p->direction.z, data_p->direction.x, data_p->direction.y, SNAKE_HEAD_COLOR); |
Cube_Set_Pixel(data_p->direction.z, data_p->direction.x, data_p->direction.y, SNAKE_COLLISION_COLOR); |
Delay_MS(3000); |
Cube_Overlay_Clear(); |
Animation_Cube_In_Out(200, ORANGE); |
Reset_Board(BOARD_MODE_IDLE); |
} |
pos = (pos == CUBE_PIXELS - 1) ? 0 : pos + 1; |
//PIC Stuff/Cerebot_32MX7_LED_Cube/SNAKE.h |
---|
3,9 → 3,10 |
#include "CUBE.h" |
#define SNAKE_BODY_COLOR BLUE |
#define SNAKE_HEAD_COLOR RED |
#define SNAKE_CANDY_COLOR GREEN |
#define SNAKE_BODY_COLOR BLUE |
#define SNAKE_HEAD_COLOR RED |
#define SNAKE_CANDY_COLOR GREEN |
#define SNAKE_COLLISION_COLOR ORANGE |
#define SNAKE_LEVEL_STEP 10 |
//PIC Stuff/Cerebot_32MX7_LED_Cube/TRON.c |
---|
34,8 → 34,8 |
void Tron_Main(void) { |
// Main function, loops and delays while updating the frame every x milliseconds |
Tron_Update_Direction(0x04,0x04); |
Delay_MS(2000); |
Tron_Update_Direction(0x04,0x04); |
while (1) { |
Tron_Update_Frame(); |
Delay_MS(data_p->delay); |
93,6 → 93,7 |
data_p->p1_direction.z == data_p->p2_direction.z) { |
Cube_Set_Pixel(data_p->p1_direction.z, data_p->p1_direction.x, data_p->p1_direction.y, TRON_COLLISION); |
Delay_MS(3000); |
Animation_Cube_In_Out(200, TRON_COLLISION); |
Reset_Board(BOARD_MODE_IDLE); |
} |
149,6 → 150,12 |
if (p2_collision) |
Cube_Set_Pixel(data_p->p2_body[ind].z, data_p->p2_body[ind].x, data_p->p2_body[ind].y, TRON_COLLISION); |
Delay_MS(3000); |
if (p1_collision && p2_collision) |
Animation_Cube_In_Out(200, TRON_COLLISION); |
else if (p1_collision) |
Animation_Cube_In_Out(200, TRON_PLAYER_2_HEAD); |
else if (p2_collision) |
Animation_Cube_In_Out(200, TRON_PLAYER_1_HEAD); |
Reset_Board(BOARD_MODE_IDLE); |
} |
//PIC Stuff/Cerebot_32MX7_LED_Cube/main.c |
---|
188,15 → 188,10 |
// Determine what to do at this point. We either choose to idle (on POR) |
// or go into a mode specified prior to the software reset event |
uint8_t last_reset = Get_Reset_Condition(); |
switch (last_reset) { |
// If our last reset was a POR/BOR/PIN/WDT/CFG, go into idle mode |
case RESET_POR: |
case RESET_BOR: |
case RESET_PIN: |
case RESET_WDT: |
case RESET_CFG: |
op_state.cube_mode = BOARD_MODE_IDLE; |
break; |
if (last_reset == RESET_POR || last_reset == RESET_BOR || |
last_reset == RESET_PIN || last_reset == RESET_WDT || |
last_reset == RESET_CFG) { |
op_state.cube_mode = BOARD_MODE_IDLE; |
} |
PWM2_Start(); |
//PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties |
---|
1,5 → 1,5 |
# |
#Thu Dec 12 05:36:33 EST 2013 |
#Thu Dec 12 13:21:23 EST 2013 |
default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=a7430524a414be59f5ce2a8f8797db6d |
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc32\\v1.21\\bin |
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=0d2b1469ad71adb787c711a416386331 |
//PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/configurations.xml |
---|
180,7 → 180,6 |
<property key="ToolFirmwareFilePath" |
value="Press to browse for a specific firmware version"/> |
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/> |
<property key="firmware.download.all" value="false"/> |
<property key="memories.bootflash" value="false"/> |
<property key="memories.configurationmemory" value="false"/> |
<property key="memories.eeprom" value="false"/> |