Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 265 → Rev 266

/PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.c
1493,7 → 1493,7
cube_data_ptr->string_B = B;
}
 
void Cube_Text_Interrupt(void) {
void Cube_Text_Update(void) {
uint8_t layer;
uint16_t line;
 
1500,9 → 1500,9
// Rotate before drawing the new line at (0,0)
Cube_Overlay_Rotate_Shell(0, 0);
 
// Get the next vertical line of the int8_tacter currently being drawn
// Get the next vertical line of the character currently being drawn
if (cube_data_ptr->string_line == 5) {
line = 0x0; // Leave a space between int8_tacters
line = 0x0; // Leave a space between characters
} else {
line = font[(cube_data_ptr->string[cube_data_ptr->string_index] * 5)
+ cube_data_ptr->string_line];
1519,7 → 1519,7
line >>= 1;
}
 
// Increment the vertical line and the int8_tacter as needed
// Increment the vertical line and the character as needed
if (cube_data_ptr->string_line == 5) {
cube_data_ptr->string_line = 0;
if (cube_data_ptr->string_index == cube_data_ptr->string_length-1) {
1532,6 → 1532,40
}
}
 
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B) {
uint8_t layer;
uint8_t line = 0;
uint8_t i;
 
// 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);
 
// Get the next vertical line of the character currently being drawn
if (i == 0) {
line = 0x0; // Leave a space between characters
} else {
line = font[(c * 5) + i - 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;
}
}
}
 
void Cube_Text_Interrupt(void) {
Cube_Text_Update();
}
 
/////////////////////////////////////////////
// Functions for processing streaming data //
/////////////////////////////////////////////
1560,7 → 1594,7
// Process data
switch (cube_data_ptr->frame_state) {
case IDLE:
// Reflect the int8_tacter back to the transmitter
// Reflect the character back to the transmitter
UART1_Write(&c, 1);
break;
case READ_LENGTH_MSB: // Save MSB of length
1644,10 → 1678,10
// Read and process the ethernet packet
if (!ETH_Read_Packet(buffer, &length)) {
// Check the opcode (first byte) to determine what to do
 
if (buffer[0] == CUBE_ETH_RESET) { // 0x1 - Reset into Ethernet mode
Reset_Board(BOARD_MODE_ETHERNET);
} else if (Get_Board_State() == BOARD_MODE_ETHERNET) {
ClearWDT();
if (buffer[0] == CUBE_EHT_IDLE) { // 0x2 - Reset back to idle mode
Reset_Board(BOARD_MODE_IDLE);
} else if (buffer[0] == CUBE_ETH_CLEAR) { // 0xA
1657,17 → 1691,14
Cube_Write_DCS(buffer[1]);
} else if (buffer[0] == CUBE_ETH_ROTATE) { // 0xC
// Byte 1 = directon to rotate
ClearWDT();
Cube_Rotate(buffer[1]);
} else if (buffer[0] == CUBE_ETH_ROTATE_LAYER) { // 0xD
// Byte 1 = layer to rotate
// Byte 2 = direction to rotate
ClearWDT();
Cube_Rotate_Shell(buffer[1], buffer[2]);
} else if (buffer[0] == CUBE_ETH_WRITE_ALL) { // 0x10
// Byte 1+ = pixel color data (R/G/B)
if (length == 0x0601) {
ClearWDT();
uint16_t index = 1;
for (i = 0; i < CUBE_LAYER_COUNT; i++) {
for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
1685,7 → 1716,6
// Byte 4 = red channel
// Byte 5 = green channel
// Byte 6 = blue channel
ClearWDT();
Cube_Set_Pixel(buffer[3], buffer[1], buffer[2], buffer[4], buffer[5], buffer[6]);
} else if (buffer[0] == CUBE_ETH_WRITE_CHANNEL) { // 0x12
// Byte 1 = color channel, 0 = red, 1 = green, 2 = blue
1692,7 → 1722,6
// Byte 2+ = color data
uint16_t r, g, b;
uint16_t index = 2;
ClearWDT();
if (buffer[1] % 3 == 0) {
for (i = 0; i < CUBE_LAYER_COUNT; i++) {
for (j = 0; j < CUBE_ROW_COUNT; j++) {
1724,7 → 1753,7
}
}
}
} else if (buffer[0] == CUBE_ETH_WRITE_TEXT) { // 0x20
} else if (buffer[0] == CUBE_ETH_WRITE_TEXT_SCROLL) { // 0x20
// Byte 1 = length of string
// Byte 2 = red channel
// Byte 3 = green channel
1732,15 → 1761,37
// Byte 5 = update speed (ms)
// Byte 6+ = text string
if (buffer[1] != 0) {
TIMER4_Stop();
Cube_Text_Init(&buffer[6], buffer[1], buffer[2], buffer[3], buffer[4]);
 
TIMER4_Stop();
TIMER4_Init(NULL, NULL, &Cube_Text_Interrupt, buffer[5]);
TIMER4_Start();
} else {
TIMER4_Stop();
Cube_Overlay_Clear();
}
} else if (buffer[0] == CUBE_ETH_WRITE_TEXT_STATIC) { // 0x21
// Byte 1 = length of string
// Byte 2 = red channel
// Byte 3 = green channel
// Byte 4 = blue channel
// Byte 5+ = text string
if (buffer[1] != 0) {
TIMER4_Stop();
Cube_Text_Init(&buffer[5], buffer[1], buffer[2], buffer[3], buffer[4]);
for (i = 0; i < buffer[1] * 5; i++) {
Cube_Text_Update();
}
} else {
TIMER4_Stop();
Cube_Overlay_Clear();
}
} else if (buffer[0] == CUBE_EHT_WRITE_TEXT_INSERT) { // 0x22
// Byte 1 = red channel
// Byte 2 = green channel
// Byte 3 = blue channel
// Byte 4 = character
TIMER4_Stop();
Cube_Text_Insert(buffer[4], buffer[1], buffer[2], buffer[3]);
} 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
66,7 → 66,9
#define CUBE_ETH_WRITE_ALL 0x10
#define CUBE_ETH_WRITE_PIXEL 0x11
#define CUBE_ETH_WRITE_CHANNEL 0x12
#define CUBE_ETH_WRITE_TEXT 0x20
#define CUBE_ETH_WRITE_TEXT_SCROLL 0x20
#define CUBE_ETH_WRITE_TEXT_STATIC 0x21
#define CUBE_EHT_WRITE_TEXT_INSERT 0x22
#define CUBE_ETH_WATERFALL 0x30
#define CUBE_ETH_SPHERE 0x31
 
139,6 → 141,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_Interrupt(void);
 
// Data stream in control functions
/PIC Stuff/Cerebot_32MX7_LED_Cube/Ethernet API/cube.py
87,7 → 87,7
payload = txFrame + txOpcode + txColorCh.decode('hex') + txData.decode('hex')
sock.send(payload)
 
def cube_update_text(string, r, g, b, update_rate):
def cube_update_text_scrolling(string, r, g, b, update_rate):
'''Sets the scrolling text on the cube.'''
txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, len(string) + 6)
txOpcode = "20".decode('hex')
95,6 → 95,21
txString = string.encode('hex')
sock.send(txFrame + txOpcode + txData.decode('hex') + txString.decode('hex'))
 
def cube_update_text_static(string, r, g, b):
'''Sets the static text on the cube.'''
txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, len(string) + 5)
txOpcode = "21".decode('hex')
txData = ''.join("%02x%02x%02x%02x" % (len(string), r, g, b))
txString = string.encode('hex')
sock.send(txFrame + txOpcode + txData.decode('hex') + txString.decode('hex'))
 
def cube_update_text_insert(character, r, g, b):
'''Appends a character to the beginning of the text buffer.'''
txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 5)
txOpcode = "22".decode('hex')
txData = ''.join("%02x%02x%02x%02x" % (r, g, b, character))
sock.send(txFrame + txOpcode + txData.decode('hex'))
 
def cube_update_waterfall(c0, c1, c2, c3, c4, c5, c6, c7):
'''Fills in one row and shifts rows by one.'''
txFrame = struct.pack("!6s6sH", dst_addr, hw_addr, 9)
/PIC Stuff/Cerebot_32MX7_LED_Cube/defines.h
8,8 → 8,8
#include <stdint.h>
 
// Uncomment ONE of the following:
#define CEREBOT_32MX7
// #define CEREBOT_MX7CK
//#define CEREBOT_32MX7
#define CEREBOT_MX7CK
 
// Power supply must be 5V for proper operation of the board!
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
194,6 → 194,7
 
// Initialize the Ethernet module
if (op_state == BOARD_MODE_ETHERNET) {
LED1_LAT = 1;
ETH_DATA eth_data;
ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
}
228,6 → 229,7
break;
case BOARD_MODE_ETHERNET:
TIMER4_Stop();
LED2_LAT = 1;
while(1);
break;
}
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties
1,5 → 1,5
#
#Fri Feb 07 17:53:36 EST 2014
#Mon Feb 10 11:52:56 EST 2014
default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=83f4565fa27ad9b8015f63d69ef74f66
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc32\\v1.31\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1f98a0eed69cb2a45c12981fa9470927
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/configurations.xml
185,7 → 185,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"/>
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/private/configurations.xml
4,7 → 4,7
<defaultConf>0</defaultConf>
<confs>
<conf name="default" type="2">
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>8108:=&lt;rev>0002:=&lt;man>Digilent:=&lt;prod>Cerebot 32MX7:=&lt;sn>D370400:=&lt;drv>x:=&lt;xpt>h:=end</platformToolSN>
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>8108:=&lt;rev>0002:=&lt;man>Digilent:=&lt;prod>CerebotMX7CK:=&lt;sn>D459520:=&lt;drv>x:=&lt;xpt>h:=end</platformToolSN>
<languageToolchainDir>C:\Program Files (x86)\Microchip\xc32\v1.31\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>