Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 267 → Rev 268

/PIC Stuff/Cerebot_32MX7_LED_Cube/ANIMATIONS.c
405,7 → 405,28
Cube_Clear();
Cube_Set_Sphere(8, YELLOW);
Delay_MS(delay_ms);
 
Cube_Clear();
Cube_Set_Sphere(7, ORANGE);
Delay_MS(delay_ms);
Cube_Clear();
Cube_Set_Sphere(6, RED);
Delay_MS(delay_ms);
Cube_Clear();
Cube_Set_Sphere(5, PURPLE);
Delay_MS(delay_ms);
Cube_Clear();
Cube_Set_Sphere(4, BLUE);
Delay_MS(delay_ms);
Cube_Clear();
Cube_Set_Sphere(3, GREEN);
Delay_MS(delay_ms);
Cube_Clear();
Cube_Set_Sphere(2, YELLOW);
Delay_MS(delay_ms);
Cube_Clear();
Cube_Set_Sphere(1, ORANGE);
Delay_MS(delay_ms);
Cube_Clear();
}
 
void Animation_Sawtooth(uint16_t delay_ms) {
/PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.c
305,7 → 305,7
 
void Cube_Set_Sphere(uint8_t layer, uint8_t R, uint8_t G, uint8_t B) {
// Super code inefficient (or is it?) lookup table
switch (layer) {
switch (layer % 9) {
case 0:
Cube_Set_Pixel(3, 3, 3, R, G, B);
Cube_Set_Pixel(3, 3, 4, R, G, B);
1172,7 → 1172,7
// Then update the empty row
for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
for (j = 0; j < CUBE_LAYER_COUNT; j++) {
if (j < values[i]) {
if (j < values[i] % 9) {
// Specify the color for each column
if (i == 0)
Cube_Set_Pixel(j, update_row, i, RED);
1209,7 → 1209,7
// Then update the empty row
for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
for (j = 0; j < CUBE_LAYER_COUNT; j++) {
if (j < values[i]) {
if (j < values[i] % 9) {
// Specify the color for each layer
if (j == 7)
Cube_Set_Pixel(j, update_row, i, RED);
1532,33 → 1532,58
}
}
 
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B) {
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B, uint16_t delay) {
// Save the character to insert
cube_data_ptr->string[0] = c;
cube_data_ptr->string_length = 1;
cube_data_ptr->string_line = 0;
cube_data_ptr->string_R = R;
cube_data_ptr->string_G = G;
cube_data_ptr->string_B = B;
 
if (delay == 0) {
int i;
for (i = 0; i < 6; i++) {
Cube_Text_Single_Char_Interupt();
}
} else {
// Start a timer to update the overlay with the inserted character
TIMER4_Stop();
TIMER4_Init(NULL, NULL, &Cube_Text_Single_Char_Interupt, delay);
TIMER4_Start();
}
}
 
void Cube_Text_Single_Char_Interupt(void) {
uint8_t layer;
uint8_t line = 0;
uint8_t i;
uint8_t line;
 
// Insert a single character to the overlay text
for (i = 0; i < 6; i++) {
// Rotate before drawing the new line at (0,0)
Cube_Overlay_Rotate_Shell(0, 0);
 
// Rotate before drawing the new line at (0,0)
Cube_Overlay_Rotate_Shell(0, 0);
// Get the next vertical line of the character currently being drawn
if (cube_data_ptr->string_line == 0) {
line = 0x0; // Leave a space between characters
} else {
line = font[(cube_data_ptr->string[0] * 5) + cube_data_ptr->string_line - 1];
}
 
// Get the next vertical line of the character currently being drawn
if (i == 0) {
line = 0x0; // Leave a space between characters
// Draw the line onto (0,0) using the specified color
for (layer = 8; layer != 0; layer--) {
if (line & 0x1) {
Cube_Overlay_Set_Pixel(layer-1, 0, 0, cube_data_ptr->string_R,
cube_data_ptr->string_G, cube_data_ptr->string_B);
} else {
line = font[(c * 5) + i - 1];
Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
}
line >>= 1;
}
 
// Draw the line onto (0,0) using the specified color
for (layer = 8; layer != 0; layer--) {
if (line & 0x1) {
Cube_Overlay_Set_Pixel(layer-1, 0, 0, R, G, B);
} else {
Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
}
line >>= 1;
}
// Increment the vertical line or stop the timer as needed
if (cube_data_ptr->string_line == 5) {
TIMER4_Stop();
} else {
cube_data_ptr->string_line += 1;
}
}
 
1789,9 → 1814,10
// Byte 1 = red channel
// Byte 2 = green channel
// Byte 3 = blue channel
// Byte 4 = character
// Byte 4 = delay x6 between shifts
// Byte 5 = character
TIMER4_Stop();
Cube_Text_Insert(buffer[4], buffer[1], buffer[2], buffer[3]);
Cube_Text_Insert(buffer[5], buffer[1], buffer[2], buffer[3], buffer[4]);
} else if (buffer[0] == CUBE_ETH_WATERFALL) { // 0x30
// Byte 1 = height of column 0
// Byte 2 = height of column 1
/PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.h
28,16 → 28,16
#define SFT_K_TRIS TRISDbits.TRISD4
#define SFT_R_TRIS TRISBbits.TRISB14
 
#define SFT_D PORTBbits.RB15
#define SFT_S PORTDbits.RD5
#define SFT_K PORTDbits.RD4
#define SFT_R PORTBbits.RB14
#define SFT_D LATBbits.LATB15
#define SFT_S LATDbits.LATD5
#define SFT_K LATDbits.LATD4
#define SFT_R LATBbits.LATB14
 
#define GSLAT_TRIS TRISDbits.TRISD9
#define XBLNK_TRIS TRISDbits.TRISD2
 
#define GSLAT PORTDbits.RD9
#define XBLNK PORTDbits.RD2
#define GSLAT LATDbits.LATD9
#define XBLNK LATDbits.LATD2
 
// String Overlay Buffer Size
#define CUBE_STRING_MAX_LENGTH 255
142,7 → 142,8
// Text control functions
void Cube_Text_Init(uint8_t *string, uint8_t length, uint16_t R, uint16_t G, uint16_t B);
void Cube_Text_Update(void);
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B);
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B, uint16_t delay);
void Cube_Text_Single_Char_Interupt(void);
void Cube_Text_Interrupt(void);
 
// Data stream in control functions
/PIC Stuff/Cerebot_32MX7_LED_Cube/ETHERNET.c
311,12 → 311,12
// uint32_t value = ETHIRQ;
if (ETHIRQbits.TXBUSE) {
// TX bus error, something -should- be done
Reset_Board(BOARD_MODE_IDLE);
Reset_Board(BOARD_MODE_ETHERNET);
ETHIRQbits.TXBUSE = 0;
}
if (ETHIRQbits.RXBUSE) {
// RX bus error, something -should- be done
Reset_Board(BOARD_MODE_IDLE);
Reset_Board(BOARD_MODE_ETHERNET);
ETHIRQbits.RXBUSE = 0;
}
if (ETHIRQbits.RXDONE) {
342,13 → 342,13
if (ETHIRQbits.RXBUFNA) {
// This is a serious error!
// TODO: handle this
Reset_Board(BOARD_MODE_IDLE);
Reset_Board(BOARD_MODE_ETHERNET);
ETHIRQbits.RXBUFNA = 0;
}
if (ETHIRQbits.RXOVFLW) {
// This is a serious error!
// TODO: handle this
Reset_Board(BOARD_MODE_IDLE);
Reset_Board(BOARD_MODE_ETHERNET);
ETHIRQbits.RXOVFLW = 0;
}
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/ETHERNET.h
2,7 → 2,7
#define ETHERNET_H
 
#define ETH_TX_DESCRIPTOR_COUNT 2
#define ETH_RX_DESCRIPTOR_COUNT 6
#define ETH_RX_DESCRIPTOR_COUNT 10
#define ETH_TX_ED_BUFFER_SIZE 2032
#define ETH_RX_ED_BUFFER_SIZE 2032
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/Ethernet API/cube.py
103,11 → 103,11
txString = string.encode('hex')
sock.send(txFrame + txOpcode + txData.decode('hex') + txString.decode('hex'))
 
def cube_update_text_insert(character, r, g, b):
def cube_update_text_insert(character, r, g, b, delay):
'''Appends a character to the beginning of the text buffer.'''
txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 5)
txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 6)
txOpcode = "22".decode('hex')
txData = ''.join("%02x%02x%02x%02x" % (r, g, b, character))
txData = ''.join("%02x%02x%02x%02x%02x" % (r, g, b, delay, character))
sock.send(txFrame + txOpcode + txData.decode('hex'))
 
def cube_update_waterfall(c0, c1, c2, c3, c4, c5, c6, c7):
/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
262,6 → 262,7
// Set the overlay text
uint8_t text_string[] = "Welcome to the CCM Lab ";
Cube_Text_Init(text_string, 27, 0xFF, 0xFF, 0xFF);
// TIMER4_Start();
 
// Loop through some preset animations
while(1) {