tag:blogger.com,1999:blog-89046394351506700282024-03-13T05:00:45.827+00:00NAPALMCORERandom notes, not a metal band.Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-8904639435150670028.post-85425653436830560672014-09-14T23:41:00.000+01:002014-12-20T19:00:26.742+00:00AVR CLI Parser SnippetThis snippet can be used to provide a basic CLI (Command Line Interface) support to the ATmega, parsing the arguments in a single line of text transmitted via USART or other serial interface.<br />
<br />
With this it's possible to change parameters in the running program without flashing the MCU.<br />
<br />
Source:<br />
<div style="background-color: white; color: black; font-family: Courier; height: 300px; overflow-y: scroll; width: 100%;">
<br />
#define CLI_MAX_ARGS 8 // Max arguments<br />
#define CLI_MAX_LENGTH 8 // Max characters per argument<br />
<br />
#define CLI_MAX_LENGTH_PAD CLI_MAX_LENGTH+1<br />
#define CLI_ERROR_MAX_ARGS -1<br />
#define CLI_ERROR_MAX_LENGTH -2<br />
<br />
struct CLI_Parser_Context{<br />
uint8_t currentArg;<br />
uint8_t currentMode;<br />
uint8_t currentSize;<br />
char args[CLI_MAX_ARGS][CLI_MAX_LENGTH_PAD];<br />
};<br />
<br />
void CLI_Parser_Clear(struct CLI_Parser_Context * ctx){<br />
ctx->currentArg = 0;<br />
ctx->currentMode = 0;<br />
ctx->currentSize = 0;<br />
for(uint8_t i = 0;i < CLI_MAX_ARGS;i++)<br />
memset(ctx->args[i],0,CLI_MAX_LENGTH_PAD);<br />
}<br />
<br />
int8_t CLI_Parse_Character(struct CLI_Parser_Context * ctx, char ch)<br />
{<br />
if(ctx->currentArg >= CLI_MAX_ARGS)<br />
return CLI_ERROR_MAX_ARGS;<br />
<br />
if(ch == ' ' || ch == '\t'){<br />
if(ctx->currentMode == 0){<br />
ctx->currentArg++;<br />
ctx->currentSize = 0;<br />
ctx->currentMode = 1;<br />
}<br />
}<br />
else{<br />
if(ctx->currentSize >= CLI_MAX_LENGTH)<br />
return CLI_ERROR_MAX_LENGTH;<br />
ctx->args[ctx->currentArg][ctx->currentSize++] = ch;<br />
ctx->args[ctx->currentArg][ctx->currentSize] = '\0';<br />
ctx->currentMode = 0;<br />
}<br />
<br />
return ctx->currentArg;<br />
}</div>
<br />
Sample:<br />
<div style="background-color: white; color: black; font-family: Courier; height: 300px; overflow-y: scroll; width: 100%;">
#define F_CPU 16000000<br />#define BAUD 9600<br /><br />#include <stdlib.h><br />#include <stdio.h><br />#include <string.h><br />#include <stdint.h><br /><br />#include <avr/io.h><br />#include <avr/interrupt.h><br /><br />#define USART_RX_SIZE 64 // Receive queue max size<br />#define USART_TX_SIZE 64 // Transmit queue max size<br /><br />#define USART_RX_MASK ( USART_RX_SIZE - 1 )<br />#define USART_TX_MASK ( USART_TX_SIZE - 1 )<br /><br />static uint8_t USART_RxBuf [USART_RX_SIZE];<br />static uint8_t USART_TxBuf [USART_TX_SIZE];<br /><br />int USART_Tx_File(char ch, FILE *stream);<br />static FILE USART_StdOut = FDEV_SETUP_STREAM(USART_Tx_File, NULL, _FDEV_SETUP_WRITE); <br />static volatile uint8_t USART_RxHead;<br />static volatile uint8_t USART_RxTail;<br />static volatile uint8_t USART_TxHead;<br />static volatile uint8_t USART_TxTail;<br /><br />void (*USART_RxCallback)(uint8_t ch) = NULL;<br /><br />void USART_Init(long baudrate){<br /> long baud_setting = (F_CPU / 8 / baudrate - 1) / 2;<br /><br /> memset(USART_RxBuf,0,USART_RX_SIZE);<br /> memset(USART_TxBuf,0,USART_TX_SIZE);<br /><br /> // Set STDOUT to custom file stream.<br /> stdout = &USART_StdOut;<br /><br /> UBRRH = (baud_setting >> 8);<br /> UBRRL = baud_setting;<br /><br /> // Don't use U2X<br /> UCSRA &= ~(1 << U2X);<br /> // Enable TX(TXEN), Enable RX(RXEN), Enable RX Interrupt(RXCIE)<br /> UCSRB = (1<<TXEN) | (1<<RXEN) | (1<<RXCIE);<br /> // Asyncronous, Write to UCSRC(URSEL), 8 bit<br /> UCSRC = (1<<URSEL) | (3<<UCSZ0);<br /><br /> USART_RxTail = 0;<br /> USART_RxHead = 0;<br /> USART_TxTail = 0;<br /> USART_TxHead = 0;<br />}<br /><br />void USART_Tx(uint8_t data){<br /> uint8_t tmphead;<br /> tmphead = ( USART_TxHead + 1 ) & USART_TX_MASK;<br /> // Wait while full<br /> while ( tmphead == USART_TxTail ){};<br /> USART_TxBuf[tmphead] = data;<br /> USART_TxHead = tmphead;<br /> // If the UART ain't busy sending bytes, send the first byte.<br /> if((UCSRB & (1<<TXCIE)) != (1<<TXCIE)){<br /> // Enable Tx interrupt for the following bytes<br /> UCSRB |= (1<<TXCIE); <br /> // Emulate the TX interruption for the first character<br /> uint8_t tmptail = ( USART_TxTail + 1 ) & USART_TX_MASK;<br /> USART_TxTail = tmptail;<br /> UDR = USART_TxBuf[tmptail];<br /> }<br />}<br /><br />int USART_Tx_File(char ch, FILE *stream){<br /> USART_Tx(ch);<br /> return 0;<br />}<br /><br />uint8_t USART_RxByte(void){<br /> uint8_t tmptail;<br /> while ( USART_RxHead == USART_RxTail ){};<br /> tmptail = ( USART_RxTail + 1 ) & USART_RX_MASK;<br /> USART_RxTail = tmptail;<br /> return USART_RxBuf[tmptail]; <br />}<br /><br />ISR(USART_RXC_vect){<br /> uint8_t tmphead;<br /> uint8_t data = UDR;<br /> tmphead = ( USART_RxHead + 1 ) & USART_RX_MASK;<br /> USART_RxHead = tmphead;<br /> if ( tmphead != USART_RxTail ) <br /> USART_RxBuf[tmphead] = data;<br /> if( USART_RxCallback != NULL )<br /> USART_RxCallback(data);<br />}<br /><br />ISR(USART_TXC_vect){<br /> uint8_t tmptail;<br /> if ( USART_TxHead != USART_TxTail ){<br /> tmptail = ( USART_TxTail + 1 ) & USART_TX_MASK;<br /> USART_TxTail = tmptail;<br /> UDR = USART_TxBuf[tmptail];<br /> }<br /> else{<br /> // Empty queue, disable interrupt.<br /> UCSRB &= ~(1<<TXCIE); <br /> }<br />}<br /><br />#define CLI_MAX_ARGS 8 // Max arguments<br />#define CLI_MAX_LENGTH 8 // Max characters per argument<br /><br />#define CLI_MAX_LENGTH_PAD CLI_MAX_LENGTH+1<br />#define CLI_ERROR_MAX_ARGS -1<br />#define CLI_ERROR_MAX_LENGTH -2<br /><br />struct CLI_Parser_Context{<br /> uint8_t currentArg;<br /> uint8_t currentMode;<br /> uint8_t currentSize;<br /> char args[CLI_MAX_ARGS][CLI_MAX_LENGTH_PAD];<br />};<br /><br />void CLI_Parser_Clear(struct CLI_Parser_Context * ctx){<br /> ctx->currentArg = 0;<br /> ctx->currentMode = 0;<br /> ctx->currentSize = 0;<br /> for(uint8_t i = 0;i < CLI_MAX_ARGS;i++)<br /> memset(ctx->args[i],0,CLI_MAX_LENGTH_PAD);<br />}<br /><br />int8_t CLI_Parse_Character(struct CLI_Parser_Context * ctx, char ch)<br />{<br /> if(ctx->currentArg >= CLI_MAX_ARGS)<br /> return CLI_ERROR_MAX_ARGS;<br /> <br /> if(ch == ' ' || ch == '\t'){<br /> if(ctx->currentMode == 0){<br /> ctx->currentArg++;<br /> ctx->currentSize = 0;<br /> ctx->currentMode = 1;<br /> }<br /> }<br /> else{<br /> if(ctx->currentSize >= CLI_MAX_LENGTH)<br /> return CLI_ERROR_MAX_LENGTH;<br /> ctx->args[ctx->currentArg][ctx->currentSize++] = ch;<br /> ctx->args[ctx->currentArg][ctx->currentSize] = '\0';<br /> ctx->currentMode = 0;<br /> }<br /> <br /> return ctx->currentArg;<br />}<br /><br />struct CLI_Parser_Context cli_context;<br /><br />void cli_led(uint8_t argc, char argv[][CLI_MAX_LENGTH_PAD]);<br /><br />void InputCallback(uint8_t ch){<br /> if(ch == '\r'){ <br /> USART_Tx('\n');<br /> USART_Tx('\r');<br /><br /> if(strcmp(cli_context.args[0],"led") == 0){<br /> cli_led(cli_context.currentArg+1,cli_context.args);<br /> }<br /> <br /> CLI_Parser_Clear(&cli_context);<br /> }<br /> else{<br /> int8_t flag = CLI_Parse_Character(&cli_context,ch);<br /> if(flag < 0){<br /> printf("CLI_Parse Error : %d\n\r",flag);<br /> CLI_Parser_Clear(&cli_context);<br /> }<br /> else<br /> USART_Tx(ch);<br /> }<br />}<br /><br />void cli_led(uint8_t argc, char argv[][CLI_MAX_LENGTH_PAD]){<br /> if(argc == 2){<br /> if(strcmp(argv[1],"on") == 0){<br /> PORTB |= (1 << PB1);<br /> printf("Led is ON\n\r");<br /> }<br /> else if(strcmp(argv[1],"off") == 0){<br /> PORTB &= ~(1 << PB1);<br /> printf("Led is OFF\n\r");<br /> }<br /> }<br />}<br /><br />int main(void)<br />{<br /> CLI_Parser_Clear(&cli_context);<br /> USART_RxCallback = InputCallback;<br /> USART_Init(BAUD);<br /> DDRB |= (1<<PB1);<br /> sei();<br /> printf("CLI Led Switch, Build %s at %s\n\r",__DATE__,__TIME__);<br /> while(1){}<br /> return 0;<br />}</div>
<br />
Usage:<br />
1) Declare parser context and init/clear:<br />
<span style="font-family: "Courier New",Courier,monospace;">struct CLI_Parser_Context cli_context;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">CLI_Parser_Clear(&cli_context);</span><br />
<br />
2) Parse received character:<br />
<span style="font-family: "Courier New",Courier,monospace;">char rxChar = ... </span><br />
<span style="font-family: "Courier New",Courier,monospace;">CLI_Parse_Character(&cli_context, rxChar);</span><br />
<br />
3) On line end character (CR or LF), check the arguments and clear the context:<br />
<span style="font-family: "Courier New",Courier,monospace;">for(uint8_t i = 0;i<cli_context.currentArg+1;i++)</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> printf("%s\n\r",</span><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;">cli_context.args[i]);</span> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">CLI_Parse_Clear(&cli_context); </span><br />
<br />
Updated: 2014/12/20, changed to avoid using malloc.Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-56332876555320720072014-08-04T20:20:00.000+01:002015-01-03T21:43:14.838+00:00Caravela PortuguesaSome time ago I modelled a low poly model of a <a href="http://en.wikipedia.org/wiki/Caravel">Portuguese Caravel</a>, but due to lack of detailed references it seemed poor, eventually I reworked the model and added more detail after a trip to the <a href="http://museu.marinha.pt/">national navy museum</a>. Armed with more photos and patience, the following model was accomplished with 32000 Triangles and 5 textures (+bumpmaps generated on demand in Blender). The wood textured was generated in Blender (for the wood seams) and GIMP (contrast, color correction, levels and seamless texture generation). It can be downloaded <a href="https://sites.google.com/site/nczeroshift/models/caravela_v3_final.zip?attredirects=0&d=1">here</a> under the CC license.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Fy-x4xdA08A/VKhNG93vovI/AAAAAAAACPw/VUP0aI6hdc8/s1600/caravela_v3_low.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-Fy-x4xdA08A/VKhNG93vovI/AAAAAAAACPw/VUP0aI6hdc8/s1600/caravela_v3_low.png" height="420" width="640" /></a></div>
<br />
<br />
The previous model was also updated with a few tweaks and it's available to <a href="https://sites.google.com/site/nczeroshift/models/caravela_v1.1.zip?attredirects=0&d=1">download</a>.<br />
<span id="goog_369443110"></span><span id="goog_369443111"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-S3XFJPNcXvg/VKhgbs2KKgI/AAAAAAAACQA/zmx0whdZYIk/s1600/caravela_v1_glsl.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-S3XFJPNcXvg/VKhgbs2KKgI/AAAAAAAACQA/zmx0whdZYIk/s1600/caravela_v1_glsl.jpg" height="460" width="640" /></a></div>
<br />Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-10980993401930282902014-02-15T16:40:00.000+00:002014-12-21T12:24:55.333+00:00AVR USART Queue SnippetThis snippet defines queue buffers to be used with the USART RX/TX for the Atmel AVR ATmega 8/32, it uses interruptions to release the MCU from continuous polling. This was based on <a href="http://www.zmitac.aei.polsl.pl/Electronics_Firm_Docs/ATMEL/Atmel/acrobat/doc1451.pdf">AVR306</a> app note source code from Atmel.<br />
<br />
Defines & Includes:
<br />
<div style="background-color: white; color: black; font-family: Courier; height: 190px; overflow-y: scroll; width: 100%;">
#define F_CPU 16000000<br />
#define BAUD 9600<br />
<br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <string.h><br />
#include <stdint.h><br />
#include <avr/io.h><br />
#include <avr/interrupt.h></div>
<br />
Source:<br />
<div style="background-color: white; color: black; font-family: Courier; height: 300px; overflow-y: scroll; width: 100%;">
#define USART_RX_SIZE 64 // Receive queue max size<br />
#define USART_TX_SIZE 64 // Transmit queue max size<br />
<br />
#define USART_RX_MASK ( USART_RX_SIZE - 1 )<br />
#define USART_TX_MASK ( USART_TX_SIZE - 1 )<br />
<br />
static uint8_t USART_RxBuf [USART_RX_SIZE];<br />
static uint8_t USART_TxBuf [USART_TX_SIZE];<br />
<br />
int USART_Tx_File(char ch, FILE *stream);<br />
static FILE USART_StdOut = FDEV_SETUP_STREAM(USART_Tx_File, NULL, _FDEV_SETUP_WRITE); <br />
static volatile uint8_t USART_RxHead;<br />
static volatile uint8_t USART_RxTail;<br />
static volatile uint8_t USART_TxHead;<br />
static volatile uint8_t USART_TxTail;<br />
<br />
void (*USART_RxCallback)(uint8_t ch) = NULL;<br />
<br />
void USART_Init(long baudrate){<br />
long baud_setting = (F_CPU / 8 / baudrate - 1) / 2;<br />
<br />
memset(USART_RxBuf,0,USART_RX_SIZE);<br />
memset(USART_TxBuf,0,USART_TX_SIZE);<br />
<br />
// Set STDOUT to custom file stream.<br />
stdout = &USART_StdOut;<br />
<br />
UBRRH = (baud_setting >> 8);<br />
UBRRL = baud_setting;<br />
<br />
// Don't use U2X<br />
UCSRA &= ~(1 << U2X);<br />
// Enable TX(TXEN), Enable RX(RXEN), Enable RX Interrupt(RXCIE)<br />
UCSRB = (1<<TXEN) | (1<<RXEN) | (1<<RXCIE);<br />
// Asyncronous, Write to UCSRC(URSEL), 8 bit<br />
UCSRC = (1<<URSEL) | (3<<UCSZ0);<br />
<br />
USART_RxTail = 0;<br />
USART_RxHead = 0;<br />
USART_TxTail = 0;<br />
USART_TxHead = 0;<br />
}<br />
<br />
void USART_Tx(uint8_t data){<br />
uint8_t tmphead;<br />
tmphead = ( USART_TxHead + 1 ) & USART_TX_MASK;<br />
// Wait while full<br />
while ( tmphead == USART_TxTail ){};<br />
USART_TxBuf[tmphead] = data;<br />
USART_TxHead = tmphead;<br />
// If the UART ain't busy sending bytes, send the first byte.<br />
if((UCSRB & (1<<TXCIE)) != (1<<TXCIE)){<br />
// Enable Tx interrupt for the following bytes<br />
UCSRB |= (1<<TXCIE); <br />
// Emulate the TX interruption for the first character<br />
uint8_t tmptail = ( USART_TxTail + 1 ) & USART_TX_MASK;<br />
USART_TxTail = tmptail;<br />
UDR = USART_TxBuf[tmptail];<br />
}<br />
}<br />
<br />
int USART_Tx_File(char ch, FILE *stream){<br />
USART_Tx(ch);<br />
return 0;<br />
}<br />
<br />
uint8_t USART_RxByte(void){<br />
uint8_t tmptail;<br />
while ( USART_RxHead == USART_RxTail ){};<br />
tmptail = ( USART_RxTail + 1 ) & USART_RX_MASK;<br />
USART_RxTail = tmptail;<br />
return USART_RxBuf[tmptail]; <br />
}<br />
<br />
ISR(USART_RXC_vect){<br />
uint8_t tmphead;<br />
uint8_t data = UDR;<br />
tmphead = ( USART_RxHead + 1 ) & USART_RX_MASK;<br />
USART_RxHead = tmphead;<br />
if ( tmphead != USART_RxTail ) <br />
USART_RxBuf[tmphead] = data;<br />
if( USART_RxCallback != NULL )<br />
USART_RxCallback(data);<br />
}<br />
<br />
ISR(USART_TXC_vect){<br />
uint8_t tmptail;<br />
if ( USART_TxHead != USART_TxTail ){<br />
tmptail = ( USART_TxTail + 1 ) & USART_TX_MASK;<br />
USART_TxTail = tmptail;<br />
UDR = USART_TxBuf[tmptail];<br />
}<br />
else{<br />
// Empty queue, disable interrupt.<br />
UCSRB &= ~(1<<TXCIE); <br />
}<br />
}</div>
<br />
Updated: 2014/12/20, changed to use stdout and removed malloc usage.Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-36280353365652088482014-02-14T14:56:00.000+00:002014-12-21T12:24:15.245+00:00AVR I2C Master SnippetThis snippet defines functions to read/write bytes from i2c with an Atmel AVR ATmega 8/32, this can be used with EEPROM(24C02), IO Expander(PFC8574), Clock & Calendar(PCF8583) and other kind of slave i2c devides. This is based on <a href="http://www.ermicro.com/blog/?p=744">Ronald Willem Besinga i2c tutorial</a>, extended to execute page read/write operations.<br />
<br />
<div style="background-color: white; color: black; font-family: Courier,Sans; height: 300px; overflow-y: scroll; padding: 5px; width: 100%;">
#define I2C_START 0<br />
#define I2C_STOP 1<br />
#define I2C_DATA_NACK 2<br />
#define I2C_DATA_ACK 3<br />
<br />
function UART_Log(const char * str, ...){ <br />
// Dummy log<br />
}<br />
<br />
void I2C_Init(uint32_t clock)<br />
{<br />
// initialize TWI clock: 100 kHz clock, TWPS = 0 => prescaler = 1<br />
TWSR = 0; /* no prescaler */<br />
TWBR = ((F_CPU/clock)-16)/2; /* must be > 10 for stable operation */<br />
}<br />
<br />
unsigned char I2C_Transmit(uint8_t type) {<br />
switch(type) {<br />
case I2C_START: // Send start condition<br />
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);<br />
break;<br />
case I2C_DATA_NACK: // Send data<br />
TWCR = (1 << TWINT) | (1 << TWEN);<br />
break;<br />
case I2C_DATA_ACK: // Send data with acknowledge.<br />
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);<br />
break;<br />
case I2C_STOP: // Send stop condition<br />
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);<br />
return 0;<br />
}<br />
<br />
// Wait for TWINT flag set in TWCR Register<br />
while (!(TWCR & (1 << TWINT)));<br />
<br />
// Return TWI Status Register, mask the prescaler bits (TWPS1,TWPS0)<br />
return (TWSR & 0xF8);<br />
}<br />
<br />
uint8_t I2C_Start(uint8_t dev_id, uint8_t dev_addr, uint8_t addr){<br />
uint8_t s;<br />
<br />
// First step, send start<br />
s = I2C_Transmit(I2C_START);<br />
<br />
if (s == TW_MT_ARB_LOST || (s != TW_START && s != TW_REP_START)){<br />
USART_Log("Error(Start): %x\r\n",s);<br />
goto failure;<br />
}<br />
<br />
// Second step, set device id and device address<br />
TWDR = (dev_id & 0xF0) | ((dev_addr << 1) & 0x0E) | TW_WRITE;<br />
<br />
s = I2C_Transmit(I2C_DATA_ACK);<br />
<br />
if (s == TW_MT_ARB_LOST || s != TW_MT_SLA_ACK || s == TW_MT_SLA_NACK){<br />
USART_Log("Error(Device Id/Address): %x\r\n",s);<br />
goto failure;<br />
}<br />
<br />
// Third step, set memory address<br />
TWDR = addr;<br />
<br />
s = I2C_Transmit(I2C_DATA_ACK);<br />
<br />
if (s != TW_MT_DATA_ACK){<br />
USART_Log("Error(EEPROM Address): %x\r\n",s);<br />
goto failure;<br />
}<br />
<br />
return 0;<br />
<br />
failure:return 1;<br />
}<br />
<br />
uint8_t I2C_Random_Read(uint8_t dev_id,<br />
uint8_t dev_addr,<br />
uint8_t addr, uint8_t *data)<br />
{<br />
uint8_t ret = 0;<br />
<br />
// First step, setup i2c and addresses (dummy write)<br />
if(I2C_Start(dev_id,dev_addr,addr))<br />
goto exit;<br />
<br />
// Second step, start again<br />
uint8_t s = I2C_Transmit(I2C_START);<br />
<br />
if (s == TW_MT_ARB_LOST || (s != TW_START && s != TW_REP_START)){<br />
USART_Log("Error(Start again): %x\r\n",s);<br />
goto exit;<br />
}<br />
<br />
// Third step, set device id and device address<br />
TWDR = (dev_id & 0xF0) | ((dev_addr << 1) & 0x0E) | TW_READ;<br />
<br />
s = I2C_Transmit(I2C_DATA_ACK);<br />
<br />
if (s == TW_MR_ARB_LOST || s != TW_MR_SLA_ACK || s == TW_MR_SLA_NACK){<br />
USART_Log("Error(Device address 2): %x\r\n",s);<br />
goto exit;<br />
}<br />
<br />
// Forth step, read data<br />
s = I2C_Transmit(I2C_DATA_NACK);<br />
<br />
if (s != TW_MR_DATA_NACK){<br />
USART_Log("Error(Data reception NACK): %x\r\n",s);<br />
goto exit;<br />
}<br />
<br />
*data = TWDR;<br />
<br />
ret = 1;<br />
<br />
exit: I2C_Transmit(I2C_STOP);<br />
return ret;<br />
}<br />
<br />
uint8_t I2C_Sequencial_Read(uint8_t dev_id,<br />
uint8_t dev_addr,<br />
uint8_t addr, uint8_t * data, uint8_t size)<br />
{<br />
uint8_t ret = 0;<br />
<br />
// First step, setup i2c and addresses (dummy write)<br />
if(I2C_Start(dev_id,dev_addr,addr))<br />
goto exit;<br />
<br />
// Second step, start again<br />
uint8_t s = I2C_Transmit(I2C_START);<br />
<br />
if (s == TW_MT_ARB_LOST || (s != TW_START && s != TW_REP_START)){<br />
USART_Log("Error(Start again): %x\r\n",s);<br />
goto exit;<br />
}<br />
<br />
// Third step, set device id and device address<br />
TWDR = (dev_id & 0xF0) | ((dev_addr << 1) & 0x0E) | TW_READ;<br />
<br />
s = I2C_Transmit(I2C_DATA_ACK);<br />
<br />
if (s == TW_MR_ARB_LOST || s != TW_MR_SLA_ACK || s == TW_MR_SLA_NACK){<br />
USART_Log("Error(Device address 2): %x\r\n",s);<br />
goto exit;<br />
}<br />
<br />
for(uint8_t i = 0;i < size;i++){<br />
if(i == size - 1){<br />
// Fifth step, read and finish with NACK<br />
s = I2C_Transmit(I2C_DATA_NACK);<br />
if (s != TW_MR_DATA_NACK){<br />
USART_Log("Error(Data reception NACK): %x\r\n",s);<br />
break;<br />
}<br />
}else{<br />
// Forth step, read data with ACK<br />
s = I2C_Transmit(I2C_DATA_ACK);<br />
if (s != TW_MR_DATA_ACK){<br />
USART_Log("Error(Data reception ACK): %x\r\n",s);<br />
break;<br />
}<br />
}<br />
<br />
data[i] = TWDR;<br />
ret += 1;<br />
}<br />
<br />
exit: I2C_Transmit(I2C_STOP);<br />
return ret;<br />
}<br />
<br />
uint8_t I2C_Byte_Write(uint8_t dev_id,<br />
uint8_t dev_addr,<br />
uint8_t addr, uint8_t data)<br />
{<br />
uint8_t ret = 0;<br />
<br />
// First step, setup i2c and addresses<br />
if(I2C_Start(dev_id,dev_addr,addr))<br />
goto exit;<br />
<br />
// Second step, write byte into memory<br />
TWDR = data;<br />
<br />
uint8_t s = I2C_Transmit(I2C_DATA_ACK);<br />
<br />
if (s != TW_MT_DATA_ACK){<br />
USART_Log("Error(Data dispatch): %x\r\n",s);<br />
goto exit;<br />
}<br />
<br />
ret = 1;<br />
<br />
exit: I2C_Transmit(I2C_STOP);<br />
return ret;<br />
}<br />
<br />
uint8_t I2C_Page_Write(uint8_t dev_id,<br />
uint8_t dev_addr,<br />
uint8_t addr, uint8_t * data, uint8_t size)<br />
{<br />
uint8_t ret = 0;<br />
<br />
// First step, setup i2c and addresses<br />
if(I2C_Start(dev_id,dev_addr,addr))<br />
goto exit;<br />
<br />
// Second step, write byte into memory<br />
for(uint8_t i = 0;i < size;i++){<br />
TWDR = data[i];<br />
<br />
uint8_t s = I2C_Transmit(I2C_DATA_ACK);<br />
<br />
if (s != TW_MT_DATA_ACK){<br />
USART_Log("Error(Data dispatch): %x\r\n",s);<br />
break;<br />
}<br />
<br />
ret ++;<br />
}<br />
<br />
exit: I2C_Transmit(I2C_STOP);<br />
return ret;<br />
}</div>
<br />
Usage Example:
<br />
<div style="background-color: white; color: black; font-family: Courier,Sans; height: 150px; overflow-y: scroll; padding: 5px; width: 100%;">
#define DEV_24C02 0xA4<br />
#define SCL_CLOCK 100000L<br />
I2C_Init(SCL_CLOCK);<br />
I2C_Byte_Write(DEV_24C02,0,1,0xF0);<br />
uint8_t val;<br />
I2C_Random_Read(DEV_24C02,0,1,&val);</div>
<br />
Use <b>I2C_Page_Write</b> and <b>I2C_Sequencial_Read</b> for more than one byte operations, otherwise i2c communication may start to fail.<br />
<br />
Last update: 20/08/2014 Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-77918610383195283232013-12-24T23:04:00.000+00:002014-08-13T23:09:30.600+01:00Postal de natal 2013Esta é a minha entrada para a <a href="http://forum.blender-pt.com/viewtopic.php?id=239">competição de natal de 2013</a> do forum Blender-PT de postais de natal, é algo simples sem elementos 3D, ré-imaginando a cena toda em 2.5D no Blender, Inkscape foi usado para adicionar o texto.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-4BPtVqexi04/U-vhDcxSVGI/AAAAAAAACFE/ECQ0bXC9U1s/s1600/postal_natal2_final.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-4BPtVqexi04/U-vhDcxSVGI/AAAAAAAACFE/ECQ0bXC9U1s/s320/postal_natal2_final.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bem podia ter usado uma fonte mais natalícia, ups :)</td></tr>
</tbody></table>
<div style="text-align: center;">
</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-46826346260125044882013-08-21T22:54:00.000+01:002015-01-03T23:22:08.877+00:00Shishi Odoshi<div style="text-align: center;">
<div style="text-align: left;">
This was my entry for the <a href="http://forum.blender-pt.com/viewtopic.php?id=176">first Blender-PT competition</a>, with the theme "Loop" animation, the idea was to make a small but loop capable animation, my entry is based on the japanese <a href="http://en.wikipedia.org/wiki/Shishi-odoshi">Shishi Odoshi</a>. Rendered with BI (Blender Internal) and fluids simulation for water splash animation.<br />
</div>
<div style="text-align: left;">
</div>
</div>
<div style="text-align: center;">
<a href="http://4.bp.blogspot.com/-Yxkw2RkVuAQ/VKhJ6fBEPtI/AAAAAAAACPk/hR8XwP2GgJg/s1600/render.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-Yxkw2RkVuAQ/VKhJ6fBEPtI/AAAAAAAACPk/hR8XwP2GgJg/s1600/render.png" height="360" width="640" /></a> </div>
<div style="text-align: left;">
Check it on <a href="https://www.youtube.com/watch?v=iLlfNR0fZbg">youtube</a></div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-37487353895196494892013-08-09T17:19:00.004+01:002014-08-13T19:11:32.289+01:00Using old iSight camera via USBThis is small note regarding the usage of the iSight camera as a regular web camera, which can be used on any computer with linux/ubuntu.<br />
<br />
The camera has a small USB lookalike plug, which I removed, and replaced by a regular USB male plug. The cables followed the standard USB coloring scheme, which helped a lot find D+ and D- (check electrodroid app > USB pinout), GND and VCC where quite obvious. <br />
<br />
After that I installed the packages on ubuntu to support the iSight:<br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">sudo apt-get install isight-firmware-tools</span><br />
<br />
To run the re-configure (if the binary blob path path is set incorrectly):<br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">sudo dpkg-reconfigure isight-firmware-tools</span><br />
<br />
After connecting the camera, typed: <br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">dmesg | tail -10</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] usb 2-2: new high-speed USB device number 5 using ehci_hcd</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] usb 2-2: New USB device found, idVendor=05ac, idProduct=8501</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] usb 2-2: Product: Built-in iSight</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] usb 2-2: Manufacturer: Micron</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] Linux video capture interface: v2.00</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] uvcvideo: Found UVC 1.00 device Built-in iSight (05ac:8501)</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] usbcore: registered new interface driver uvcvideo</span><br />
<span style="font-family: "Courier New",Courier,monospace; font-size: small;">[...] USB Video Class driver (1.1.1)</span>
<br />
<br />
Installed cheese and voilà, it works :)Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-87645644234924194262013-06-09T18:20:00.000+01:002014-08-13T17:55:03.926+01:00SyncCopy<div style="text-align: justify;">
TL;DR</div>
<div style="text-align: justify;">
<b>SyncCopy </b>is a selective files and folder copier with a UI, which basically, helps creating backups to the cloud(like Dropbox, MeoCloud, etc...) without copying the databases, compilation files, version control and other crap programmers have to deal everyday.</div>
<table style="text-align: center; width: 100%;">
<tbody>
<tr>
<td><a href="http://3.bp.blogspot.com/-aV84gHf6Pzc/UbTCbehL7DI/AAAAAAAABn8/QdUSFHiz82E/s1600/main.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-aV84gHf6Pzc/UbTCbehL7DI/AAAAAAAABn8/QdUSFHiz82E/s200/main.png" height="150" width="200" /></a>
</td>
<td><a href="http://3.bp.blogspot.com/-GSCucruKv8I/UbTCZUWXOFI/AAAAAAAABnw/JdthOapiLkQ/s1600/linkedit.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-GSCucruKv8I/UbTCZUWXOFI/AAAAAAAABnw/JdthOapiLkQ/s200/linkedit.png" height="150" width="200" /></a>
</td>
<td><a href="http://4.bp.blogspot.com/-iF_PGWlDUG0/UbTCbNrWXoI/AAAAAAAABn4/r3-9SPlYHG0/s1600/commitchanges.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-iF_PGWlDUG0/UbTCbNrWXoI/AAAAAAAABn4/r3-9SPlYHG0/s200/commitchanges.png" height="150" width="200" /></a>
</td>
</tr>
</tbody></table>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Description:</div>
<div style="text-align: justify;">
This is the small application I have been working on in the last weeks, which helps users synchronize contents of one folder to another, it's like a "version control thing" but simpler. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The main target I had in mind was to copy my projects source code and resources to the dropbox, but excluding all the unnecessary data, like the IDE database and compilation products. This way I could synchronize my small projects between my machines and easily update/commit the changed files.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The program works this way:</div>
<div style="text-align: justify;">
1) Add a "link", like a new svn/git repository in the server;</div>
<div style="text-align: justify;">
2) Set the link name;</div>
<div style="text-align: justify;">
3) Set the project folder (where you have your work folder);</div>
<div style="text-align: justify;">
4) Set the sync folder (inside a Dropbox share somewhere in your system);</div>
<div style="text-align: justify;">
5) Add excluded file extensions(for example "o" to exclude gcc compiled objects);</div>
<div style="text-align: justify;">
6) Add excluded folder paths(for example "Debug" to exclude visual studio compilation folders);</div>
<div style="text-align: justify;">
7) Hit "OK";</div>
<div style="text-align: justify;">
8) Select link on links list;</div>
<div style="text-align: justify;">
9) Hit "Sync" on main window;</div>
<div style="text-align: justify;">
10) Select "Commit" on the dialog message;</div>
<div style="text-align: justify;">
11) The sync window is now scanning the project and sync folder to find the differences;</div>
<div style="text-align: justify;">
12) Check the suggested changes and disable those you don't want to be executed;</div>
<div style="text-align: justify;">
13) Hit "Sync" and the files will be submitted to the dropbox folder;</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
With the "update" function it's the opposite operation, it will copy the changed files on the cloud to your local work folder.</div>
<div style="text-align: justify;">
<br />
The application was developed in <strike>the devil language, I mean, Sun</strike> Oracle java, it's supposed to run everywhere. It's still in a early beta-testing and it will be opensource a link should appear soon.<br />
<br />
<a href="https://sites.google.com/site/nczeroshift/files/SyncCopy.jar?attredirects=0&d=1" target="_blank">[Download]</a></div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-16839321851563598002013-04-15T23:16:00.003+01:002014-08-13T18:32:15.426+01:00Iberanime 2013 Cosplay<div style="text-align: justify;">
Agora que finalmente tenho uma câmara fotográfica boa, esforcei-me para tentar tirar umas fotos fixes aos <a href="http://en.wikipedia.org/wiki/Cosplay">cosplayers</a> no <a href="http://www.iberanime.com/">Iberanime</a>, ou tentar pelo menos. Fica aqui as melhores fotos, quer dizer, as mais focadas...</div>
<br />
<table style="text-align: center; width: 100%;">
<tr>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-O0B7Nq-SQ98/UWx4MgMLB1I/AAAAAAAABis/vpy2tco1vks/s1600/DSC_0137.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-O0B7Nq-SQ98/UWx4MgMLB1I/AAAAAAAABis/vpy2tco1vks/s200/DSC_0137.JPG" height="200" width="132" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Desconheço :(</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-loB5amYp9-0/UWx4KovG1UI/AAAAAAAABic/rI_lms1URek/s1600/DSC_0136.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-loB5amYp9-0/UWx4KovG1UI/AAAAAAAABic/rI_lms1URek/s200/DSC_0136.JPG" height="200" width="132" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Ezio - Assassins Creed</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-F09sfuCDOFY/UWx4gPTLh1I/AAAAAAAABjk/bnxgudyuEro/s1600/DSC_0169.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-F09sfuCDOFY/UWx4gPTLh1I/AAAAAAAABjk/bnxgudyuEro/s200/DSC_0169.JPG" height="200" width="125" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"> Eruka Frog - Soul Eater</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-DwMzsvbvfww/UWx4pFu0NfI/AAAAAAAABj0/dvihOP18lXI/s1600/DSC_0173.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-DwMzsvbvfww/UWx4pFu0NfI/AAAAAAAABj0/dvihOP18lXI/s200/DSC_0173.JPG" height="200" width="132" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mascote do evento</td></tr>
</tbody></table>
</td>
</tr>
</table>
<table style="width:100%;text-align:center;">
<tr>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-OMGC2ltZ9-E/UWx4Rr-Ri3I/AAAAAAAABi0/kemhKx3KtQE/s1600/DSC_0149.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-OMGC2ltZ9-E/UWx4Rr-Ri3I/AAAAAAAABi0/kemhKx3KtQE/s200/DSC_0149.JPG" height="200" width="132" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Nyan Nyan cat</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-mKe9HCzyGe4/UWx4YsbGHdI/AAAAAAAABjM/lqHXwH-JX5c/s1600/DSC_0156.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-mKe9HCzyGe4/UWx4YsbGHdI/AAAAAAAABjM/lqHXwH-JX5c/s200/DSC_0156.JPG" height="200" width="132" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Chi ou a "irmã" - Chobits</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-pWbL-KCl2mg/UWx4VHy9c_I/AAAAAAAABjE/iRgS9wAMgOk/s1600/DSC_0155.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-pWbL-KCl2mg/UWx4VHy9c_I/AAAAAAAABjE/iRgS9wAMgOk/s200/DSC_0155.JPG" height="200" width="132" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Franken Stein<span style="font-weight: normal;"> - Soul Eater</span></td></tr>
</tbody></table>
</td>
</tr>
</table>
<table style="width:100%;text-align:center;">
<tr>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-GmbXVwfOXN0/UWx4UE8kJ_I/AAAAAAAABi8/wjVDLcO56bM/s1600/DSC_0147.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-GmbXVwfOXN0/UWx4UE8kJ_I/AAAAAAAABi8/wjVDLcO56bM/s200/DSC_0147.JPG" height="132" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Loading...</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-amWziJNK9LQ/UWx4nVNGHKI/AAAAAAAABjs/WVEqT2bF5dA/s1600/DSC_0171.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-amWziJNK9LQ/UWx4nVNGHKI/AAAAAAAABjs/WVEqT2bF5dA/s200/DSC_0171.JPG" height="132" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Ryu x Baby x Ken</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-tPagSdxTdXE/UWx4eDbjt1I/AAAAAAAABjc/UY7-G2He-MM/s1600/DSC_0164.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-tPagSdxTdXE/UWx4eDbjt1I/AAAAAAAABjc/UY7-G2He-MM/s200/DSC_0164.JPG" height="132" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Minecraft + Nyan Cat = WIN</td></tr>
</tbody></table>
</td>
</tr>
</table>
<table style="width:100%;text-align:center;">
<td>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-qKyjUN15k60/UWx4K2DK5hI/AAAAAAAABik/vXgwkzngdiE/s1600/DSC_0134.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-qKyjUN15k60/UWx4K2DK5hI/AAAAAAAABik/vXgwkzngdiE/s200/DSC_0134.JPG" height="132" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Riuk Shinigami - Death Note</td></tr>
</tbody></table>
</td>
<td>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-g_YPaE1hu5k/UWx4crCP75I/AAAAAAAABjU/-liVOh6OS_8/s1600/DSC_0162.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-g_YPaE1hu5k/UWx4crCP75I/AAAAAAAABjU/-liVOh6OS_8/s200/DSC_0162.JPG" height="132" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bora lá fazer aqui uma pergunta complicada<br />
em português aos nossos colegas nipónicos... </td></tr>
</tbody></table>
</td>
</tr>
</table>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-59786918584404496792013-04-06T23:59:00.002+01:002014-08-13T22:49:10.191+01:00SRAM DDS<div style="text-align: justify;">
While poking around some PCB boards for components I found a SRAM(LH5116) chip with 16K and a supply of 5V, in the same instant I thought:</div>
<br />
<div style="text-align: center;">
<i>It would would be fun add a DAC at the SRAM output...</i></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
There are already some DDS (<a href="http://www.myplace.nu/avr/minidds/index.htm" target="_blank">Jesper’s DDS</a>) made for the atmega that manage to generate 200kHz~300kHz sinewaves, but, maybe with an external RAM I could achieve better performance ?</div>
<table style="text-align:center;width:100%;">
<tr>
<td>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-dcbItzHxhfg/UWCoB5I-eJI/AAAAAAAABhw/7ik3Ihn0Zzo/s1600/ram_dds.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-dcbItzHxhfg/UWCoB5I-eJI/AAAAAAAABhw/7ik3Ihn0Zzo/s1600/ram_dds.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The 250kHz "wobbly" sinewave, the FFT is clean enough</td></tr>
</tbody></table>
</td>
<td>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-MKAtmcJNYik/UWCnM-wELdI/AAAAAAAABho/JJ9tp1Nhb0I/s1600/DDS_Model1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-MKAtmcJNYik/UWCnM-wELdI/AAAAAAAABho/JJ9tp1Nhb0I/s1600/DDS_Model1.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Data flow schematic (8 bit for address used of the 11 available)</td></tr>
</tbody></table>
</td>
</tr>
</table>
<span id="goog_2091785879"></span><span id="goog_2091785880"></span>
<div style="text-align: justify;">
The basic idea was to load the waveform to the SRAM to save some operations in the uC, since the atmega isn't a very fast processor and the <u>load takes 3 cycles</u>. Currently I did managed to generate a 250kHz sinewave with some resolution. The biggest issue is the lack of a Sample & Hold, which makes the output sensible to RAM logic propagation times and sometimes produces glitches.<br />
<br />
I may continue to poke around this, but, hopefully I will received a new DDS generator soon. Nevertheless it was a fun idea to try out. <br />
</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-45110274765187238122013-03-29T23:34:00.003+00:002014-08-13T22:46:20.567+01:00Power Supply Noise<div style="text-align: justify;">
Após construir uma pcb para fonte de alimentação para uma breadboard com um conversor de níveis MAX232, estive a analisar o ruído da saída de tensão de 5V e deparei-me com alguns picos de tensão na casa do 20~30mV, após fazer um probe, reparei que a fonte de ruído era a fonte de alimentação (um SMPS de 1997 de um portátil toshiba).</div>
<br />
<table style="text-align:center;width:100%;">
<tr>
<td>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-g5yFcvlmsho/UVYdC_40M2I/AAAAAAAABgk/Ga-38VLyvlY/s1600/noise_analysis.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-g5yFcvlmsho/UVYdC_40M2I/AAAAAAAABgk/Ga-38VLyvlY/s1600/noise_analysis.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Escala vertical 20mV/div</td></tr>
</tbody></table>
</td>
<td>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-JsAqifvfCpI/UVYknZbd8CI/AAAAAAAABgs/2Hw5EiG2qbo/s1600/breadboard_psu_rev2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-JsAqifvfCpI/UVYknZbd8CI/AAAAAAAABgs/2Hw5EiG2qbo/s320/breadboard_psu_rev2.jpg" height="160" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Breadboard psu rev2</td></tr>
</tbody></table>
</td>
</tr>
</table>
<br />
<div style="text-align: justify;">
A figura "A" mostra a saida de 5V usando como fonte de alimentação a fonte SMPS.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
A figura "B" mostra a mesma saída usando como fonte de alimentação linear, mas estando a fonte SMPS ligada a corrente eléctrica na mesma régua.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
A figura "C" difere apenas no facto da fonte SMPS estar desligada da rede, nota-se agora menos ruído.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Curiosamente um dos vídeos do <a href="http://www.youtube.com/watch?v=BFLZm4LbzQU">Dave Jones/eevblog</a> fala exactamente deste problema, de fontes de alimentação SMPS (de má qualidade ou antigas) que colocam ruído em tudo o que esteja perto.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Também acabei por detectar ruído na casa dos 300kHz gerado pelo conversor max232, que acabei por "matar" acrescentando um condensador de 500uF.</div>
<br />
<div style="text-align: justify;">
Quando desenhei a placa não tinha feito grande estudo de quais eram as fontes de ruído e acabei por adicionar condensadores a mais, footprints erradas ou mal posicionados, mas já sei o que fazer, fica para proxima revisão board, já aprendi mais umas coisas! </div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-362982907625816732013-01-20T11:24:00.004+00:002014-08-13T19:10:58.743+01:00Sudo e portas de serie virtuaisPara aceder as portas de serie emuladas (FTDI 232 chip), o linux requer sempre que o acesso root, contudo isto tem solução:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">sudo chmod 666 /dev/ttyUSB0 </span> <br />
<br />
Ou seja, todos os utilizadores podem ler, escrever mas não podem executar. Agora os programas em java, C# e C++ já podem correr em debug com permissões do utilizador :)Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-59151953255229940862012-12-09T17:35:00.001+00:002014-08-13T19:12:56.374+01:00Flashing de um Atmega novoQuando tentei flashar um Atmega 8 novo usando o USBASP, o avrdude não consegui-o obter a assinatura do dispositivo, lançado a seguinte mensagem:<br />
<blockquote class="tr_bq">
<div style="text-align: center;">
<i>avrdude: error: programm enable: target doesn't answer. 1</i></div>
</blockquote>
<div style="text-align: justify;">
Por defeito todos os atmega novos estão configurados para usar o oscilador interno, que é demasiado lento para o sinal de SCK do USBASP.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Mas existe uma opção para resolver o problema que consiste em activar a opção de SCK lento, conectando o pino 25 do Atmega8 do USBASP à massa, assim obtém-se a seguinte mensagem executado o comando de leitura do dispositivo:</div>
<div style="text-align: justify;">
</div>
<blockquote class="tr_bq">
<div style="text-align: center;">
<i>avrdude: Device signature = 0x1e9307</i></div>
</blockquote>
<div style="text-align: justify;">
Comando de leitura da assinatura:<span style="font-family: "Courier New",Courier,monospace;"> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo avrdude -c usbasp -p m8 </span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Comando para flashar o Atmega 8 para usar o oscilador de cristal de 12 MHz:<span style="font-family: "Courier New",Courier,monospace;"> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo avrdude -c usbasp -p m8 -U lfuse:w:0xde:m -U hfuse:w:0xd9:m </span></div>
<div style="text-align: justify;">
<br />
Os fusíveis podem ser calculados com a ajuda deste <a href="http://www.engbedded.com/fusecalc">site</a>, o start time escolhido não foi o maior que era possível, parece ser boa prática escolher o tempo mais longo para que o sinal gerado durante o arranque esteja o mais estável possível.</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-80568412063227816432012-02-18T22:42:00.000+00:002014-08-14T11:19:00.670+01:00Lowpoly human brain texturing<div style="text-align: justify;">
<b>PT</b>: Criação do mapa de relevo para um modelo de baixa resolução de um cérebro em Blender 2.6X.</div>
<div style="text-align: justify;">
<b>EN</b>: Creating the bumpmap for a lowpoly brain model in Blender 2.6X.</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-mjyajB1SjdY/T0APsID9nEI/AAAAAAAABR8/Eti_gQWWdHk/s1600/tutorial_brain_creation_tutorial.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-mjyajB1SjdY/T0APsID9nEI/AAAAAAAABR8/Eti_gQWWdHk/s640/tutorial_brain_creation_tutorial.jpg" height="640" width="347" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Download or click on View Image to see full-size version</td></tr>
</tbody></table>
<div style="text-align: justify;">
<b>PT</b></div>
<ol style="text-align: justify;">
<li>Modelo de baixo detalhe criado a partir de uma referência encontrada na <a href="http://en.wikipedia.org/wiki/Human_brain">wikipedia</a>;</li>
<li>Pintar os relevos do cérebro no modelo usando a opção de edição Texture Paint na 3D View; </li>
<li>Mapa da textura não organizada(o mapa UV foi feito com o auto-unwrapping, não é recomendável eu é que fui perguiçoso ... :P ); </li>
<li>Mapa da textura reorganizada (criar uma nova camada de mapeamento UV,
criar os seams necessários e unwrap, usar Render > Bake > Texture
gerar então a textura reorganizada); Desfocar a textura pouco para
suavizar a pintura;</li>
<li>Adicionar os modificadores de multires e displace; No displace usar nova
textura para deformar a geometria e depois carregar em Apply, isto vai
transferir a deformação para o multires; </li>
<li>Colocar o preview do multires em zero e ir ao separador Render >
Bake > Normals para transferir os normais para uma textura;</li>
<li>Mapa da textura de relevo gerada; </li>
<li>Previsualização em tempo real do modelo com as texturas criadas.</li>
</ol>
<div style="text-align: justify;">
<b>EN</b></div>
<ol style="text-align: justify;">
<li>Lowpoly model created from a <a href="http://en.wikipedia.org/wiki/Human_brain">wikipedia</a> reference;</li>
<li>Paint brain relief using Texture Paint editing option in the 3D View;</li>
<li>Unsorted texture map (the uvmapping was made with auto-unwrapping because i was too lasy ... :P );</li>
<li>Fixed texture map with a new uv layout, the texture was created using
the Render > Bake > Texture feature; The texture should be blurred
a bit to smooth the painting;</li>
<li>Add multires & displace modifiers; On displace modifier use the new
texture to displace the geometry, then press on the Apply Button to merge
the displace modifier with the multires;</li>
<li>Set the preview on Multires to zero and go to Render > Bake > Normals to generate the bumpmap;</li>
<li>The generated bumpmap texture;</li>
<li>Profit :) !</li>
</ol>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-4014452403381477902012-02-14T22:03:00.002+00:002014-08-13T23:17:01.255+01:00Sawtooth oscilator<div style="text-align: justify;">
This is a small sawtooth (almost) oscillator circuit which I have been tweaking the last weeks to generate a reasonably decent 100kHz waveform at Vcc=5V. It was based on some random schematic on the web, which didn't generated the output from 0V to Vcc, so I added a few more components and changed a few parts.</div></br>
<table style="text-align: center; width: 100%;">
<tbody>
<tr>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-_P_HC_wL-l8/TzrZL9GC6EI/AAAAAAAABRs/eUKyRlJyRe8/s1600/sawtoothosciladorcircuit.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-_P_HC_wL-l8/TzrZL9GC6EI/AAAAAAAABRs/eUKyRlJyRe8/s320/sawtoothosciladorcircuit.png" height="159" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Circuit schematic</td><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
</td>
<td><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-twSyP_Cz2BQ/TzrZK121kGI/AAAAAAAABRg/4HonRTkdPrI/s1600/sawtooth_circuit.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-twSyP_Cz2BQ/TzrZK121kGI/AAAAAAAABRg/4HonRTkdPrI/s200/sawtooth_circuit.JPG" height="150" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Assembled circuit</td></tr>
</tbody></table>
</td>
<td><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-yy89b4wNogk/TzrZLYxy8LI/AAAAAAAABRk/p31JFTLBDmk/s1600/sawtoothcapture.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-yy89b4wNogk/TzrZLYxy8LI/AAAAAAAABRk/p31JFTLBDmk/s200/sawtoothcapture.png" height="146" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Oscilloscope signal capture</td></tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<br />
<div style="text-align: justify;">
Basically it charges a capacitor (C1) and uses the 555 comparators to trigger the discharge via other PNP transistor(Q2). The triggering voltage is calibrated with the POT_2 and the capacitor fill time is calibrated with the POT_1. </div>
<br />
<div style="text-align: justify;">
It has a few glitches which didn't appeared on the simulation and neither on the breadboard(parasite capacitances FTW), but I also used some BC560 instead of the BC557.</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-27207188948215431432011-04-22T16:31:00.062+01:002014-08-13T23:18:08.673+01:00USBasp & Noise Troubles<div style="text-align: justify;">
USBasp is a small circuit to flash atmel processors which uses the USB port, but since the USB communication isn't a feature available in the processor by default, it must use the V-USB firmware/drivers to deal with it.</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-gm6ZlC5A22E/TbGUCUEDSgI/AAAAAAAABIk/ATWD6lxHoZM/s1600/usbasp_messed_up.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-gm6ZlC5A22E/TbGUCUEDSgI/AAAAAAAABIk/ATWD6lxHoZM/s320/usbasp_messed_up.JPG" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Never ever do this for the USB data lines !</td></tr>
</tbody></table>
<div style="text-align: justify;">
After assembling the circuit i had a few problems trying to understand why it did work on a older machine and didn't work on my recent laptops, using <b>dmesg</b> on the newer laptops I got these messages:</div>
<br />
<span style="font-family: "Courier New",Courier,monospace;">[ 7486.876197] usb 3-2: device descriptor read/64, error -71</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[ 7487.105059] usb 3-2: device descriptor read/64, error -71</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[ 7487.320153] usb 3-2: new low speed USB device using uhci_hcd and address 4</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[ 7487.441052] usb 3-2: device descriptor read/64, error -71</span><br />
<span style="font-family: "Courier New",Courier,monospace;">[ 7487.664184] usb 3-2: device descriptor read/64, error -71</span><br />
<br />
And with the older machine using the <b>lsusb</b> command:<br />
<span style="font-family: "Courier New",Courier,monospace;">Bus 003 Device 016: ID 16c0:05dc VOTI shared ID for use with libus</span><br />
<br />
<div style="text-align: justify;">
It seems the usb controler was unable to read the device description, but after an week and some google searches i found that the electromagnetic interference affects a lot with the circuit. To reduce this problem i rewired the circuit and replace the usb port with a short usb male cable instead of the female port and the problem was fixed. (And the circuit also works fine with an usb extension cable)</div>
<table align="center" border="0" cellpadding="0" cellspacing="0" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr> <td><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-5ZQqUSDyO5Y/TbGVeSUMHrI/AAAAAAAABIo/qMTYttDfg_s/s1600/usbasp_improved.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-5ZQqUSDyO5Y/TbGVeSUMHrI/AAAAAAAABIo/qMTYttDfg_s/s200/usbasp_improved.JPG" height="150" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Rewired version</td></tr>
</tbody></table>
</td> <td><br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-xbtGIM3PRtY/TbGVfc3H6bI/AAAAAAAABIs/q1-Ap3YFF1Q/s1600/usbasp_improved_back.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-xbtGIM3PRtY/TbGVfc3H6bI/AAAAAAAABIs/q1-Ap3YFF1Q/s200/usbasp_improved_back.JPG" height="150" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Back wiring</td></tr>
</tbody></table>
</td> </tr>
</tbody></table>
<div style="text-align: justify;">
It appears that the Intel USB controller is more exigent with the quality of the signal than the SiS controller !</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-9035734955984511522011-04-22T15:28:00.017+01:002014-08-13T18:40:30.239+01:00Ubuntu/Linux CommandsA list of useful commands which i keep forgetting :<br />
<br />
<b>Misc</b><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo su <span class="Apple-style-span" style="color: #38761d;"><b>// Change user to root</b></span></span><br />
<br />
<b>Installers</b><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install build-essential <span class="Apple-style-span" style="color: #38761d;"><b>// C++ support</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install freeglut3-dev <span class="Apple-style-span" style="color: #38761d;"><b>// FreeGLUT and OpenGL support</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install avrdude <span class="Apple-style-span" style="color: #38761d;"><b>// AVR firmware upload tool</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install gcc-avr <span class="Apple-style-span" style="color: #38761d;"><b>// AVR atmel processors compiler</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install avr-libc <span class="Apple-style-span" style="color: #38761d;"><b>// C lib for AVR atmel processors</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install xorg-dev <span class="Apple-style-span" style="color: #38761d;"><b>// X11 headers and libraries</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install libpng-dev <span class="Apple-style-span" style="color: #38761d;"><b>// PNG headers and libraries</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install libjpeg-dev <span class="Apple-style-span" style="color: #38761d;"><b>// JPEG headers and libraries</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install libasound-dev <span class="Apple-style-span" style="color: #38761d;"><b>// Alsa headers and libraries</b></span></span><br />
<br />
<b>Tools</b><br />
<span style="font-family: "Courier New",Courier,monospace;">top<b><span style="color: #38761d;"> // Real-time list of processes</span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">ps<b><span style="color: #38761d;"> // Show running processes</span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">chmod a+rwx <i>fileorfolder</i> -R<b style="color: #38761d;"> // Change permissions of all files to read/write recursively</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">dmesg<b><span style="color: #38761d;"> // Get drivers messages</span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">dmesg | grep tty<b style="color: #38761d;"> // Get serial ports drivers messages</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">lsusb<b><span style="color: #38761d;"> // Get usb devices</span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">tail -f /var/log/messages<b style="color: #38761d;"> // Similar to dmesg | tail</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">otool -hv <i>library.a</i><b style="color: #38761d;"> // Get compiled objects architecture</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">du -k <i>filename</i><b style="color: #38761d;"> // Get file size</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">ldd <i>filename</i> <b style="color: #38761d;">// Get shared libraries dependencies</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">find . -iname '*c' | xargs grep '<i>foo</i>' -sl <span style="color: #38761d;"><b>// search C files for the string fo</b><b>o</b></span></span><br />
<b><br />
Network</b><br />
<span style="font-family: "Courier New",Courier,monospace;">nslookup <i>address</i> <b><span style="color: #38761d;">// Get the IP address of a domain name</span></b><span class="Apple-style-span" style="color: #38761d;"><span style="color: black;"><span style="font-size: small;"><b><span style="color: #274e13;"> </span></b></span></span></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">dig <i>address</i><b><span style="color: #38761d;"> // DNS servers interrogator</span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">traceroute / tracert <i>address</i><b><span style="color: #38761d;"> // Show the path of a packet to a certain address</span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">ping <i>address</i><b><span style="color: #38761d;"> // Check if address is reachable </span></b></span><br />
<span style="font-family: "Courier New",Courier,monospace;">lsof -i :<i>port</i> <b><span class="Apple-style-span" style="color: #38761d;">// Get process using this port</span></b></span><br />
<span class="Apple-style-span" style="color: #38761d;"><span style="color: black;"><span style="font-size: small;"> </span></span><b><span style="color: black;"> </span><br />
</b></span><br />
Last update 1:47 23/12/2011Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-66111767474488596352011-02-26T19:40:00.000+00:002014-08-13T18:36:55.056+01:00AutoBFont<div style="text-align: justify;">
AutoBFont is small tool for text rendering on OpenGL(and can be easily ported to DX) with bitmap fonts, providing a way to draw perfectly aligned text with bitmap sheets created in Fireworks/Photoshop/Gimp and Inkscape. The tool is composed by two parts : an generator and a loader class.</div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://lh4.googleusercontent.com/-l-xy59lRxSE/TWjg5K8_gbI/AAAAAAAABIQ/9utH_PTVGB0/s1600/autobfont_example.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://lh4.googleusercontent.com/-l-xy59lRxSE/TWjg5K8_gbI/AAAAAAAABIQ/9utH_PTVGB0/s1600/autobfont_example.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The monospace font with and without a drop shadow(effect created in Inkscape) rendered with the help of autobfont</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: justify;">
The generator computes each character limits from the character sheet bitmap, which should be a <b>RGBA TGA </b>image with no compression. It should have 16 columns by 16 rows to fill with characters and the size of the image should be power of 2 (1024x1024 for example). If only the first 8 rows are used, the remaining rows can be used to fit a "bold" version of the font.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
The generator program requires 3 mandatory arguments :</div>
<div style="text-align: justify;">
<b>-i CHARACTER_CONVERSION_MAP.TXT </b></div>
<div style="text-align: justify;">
<b>-m CHARACTER_BITMAP_SHEET.TGA</b></div>
<div style="text-align: justify;">
<b>-o OUTPUT_MAP.TXT</b></div>
<div style="text-align: justify;">
Optional arguments :</div>
<div style="text-align: justify;">
<b>-b</b> Compute the Bold characters in the last 8 rows.</div>
<div style="text-align: justify;">
<b>-h VALUE</b> Set all characters line height (the default value is 3*CELL_SIZE/4).</div>
<div style="text-align: justify;">
<b>-t</b> <b>VALUE </b>Set alpha threshold value, improves character boundaries detection (default value is 50, max is 255).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The conversion map is a text file with the ASCII character for each cell in the bitmap sheet, although it's limited to Latin characters, the generator and loader can be changed to use <b>wchar_t</b> structure instead of <b>char </b>for other languages such as japanese. All the characters in the bitmap font should by white (if you want to use color blending in OGL, but isn't mandatory) with a background transparent (below the alpha threshold value).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The loader class is available in the demo.cpp class, which loads the generated output map and the renders the characters with OpenGL.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To convert the SVG to TGA use gimp with no RLE compression and bottom left origin.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The typical commands to compile and run the generator and demo on linux:</div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">make</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">./generator -i ct_PT.txt -m font_ubuntu.tga -o font_ubuntu_map.txt</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">./demo font_ubuntu_map.txt font_ubuntu.tga</span><br />
<br />
<a href="https://sites.google.com/site/nczeroshift/code-samples/ogl_autobfont.7z?attredirects=0&d=1">DOWNLOAD</a></div>
<div style="text-align: justify;">
<br /></div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-88008526842544288932011-02-08T00:04:00.122+00:002014-08-14T11:32:50.418+01:00Logotype<div style="text-align: justify;">
Ok, a little explanation about the logo I finished recently.</div>
<div style="text-align: justify;">
</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;">
For me the demoscene "thing" started around the year 1992 before i even understood what the heck "demoscene" meant or had any skills to do anything with computers beyond playing games. Back then my sister had received her first computer, a 486DX with 4MB of RAM. After some months she got some games from her friends and some of them included some cracktro apps, which back then where a confusing concept for me, since they had no propose beyond showing the artwork and moving letters plus some audio.<br />
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/_gR712w2riTk/TVCHCufs5_I/AAAAAAAABFU/2RXdy3I4f7g/s1600/oldschool2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/_gR712w2riTk/TVCHCufs5_I/AAAAAAAABFU/2RXdy3I4f7g/s320/oldschool2.jpg" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">NapalmCore logo created with Blender 2.56</td></tr>
</tbody></table>
<div style="text-align: justify;">
The first cracktro i saw was the <a href="http://www.youtube.com/watch?v=A7nSo27fFyo">TEKNO SKULL by TDT / TRSi</a>, which impressed me since I was a little kid and had a particular fear of skeletons. In the course of the time, with the influence of the cyberpunk culture in animes and movies from the 80's & 90's, the fear was lost and this goreish characteristic remained as a symbol from those years and the culture it self.<br />
<br />
The logotype creation started back then at the Euskal 2008 for the 3D competition, at the time it only featured the skull. Recently i decided to recycle the model, remaking the skull with better detail and adding the extra details, such as the mechanical stuff and the sun glasses. I also was inspired by latest razor 1911 prods which have an unique new-old-school style, mimicking the 90's hardware with the latest graphics effects, for example, the grid pattern effect can be seen on the "<a href="http://www.pouet.net/prod.php?which=55471">StarCraft 2 cracktro</a>" or the "<a href="http://www.pouet.net/prod.php?which=56549">Pirates of the 777 seas</a>". The sunglasses are due to the influences of Motoko Kusanagi from the ghost in the shell :)<br />
<br />
With this, i can finally conclude by saying that the name of this blog/website/demoscene group reflects the unique cyberpunk culture from the last years of the 20 century, plus the cracking culture which evolved to the demoscene which we have currently.</div>
<div style="text-align: justify;">
<br /></div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-68950321237739329362011-01-15T18:44:00.002+00:002011-01-15T21:32:14.595+00:00DIY Pseudo "iMac"<div style="text-align: justify;">This was the situation : I have an laptop (HP-DV5000) with 5 years which still works pretty well apart from the broken LCD, which was due it had already been at Breakpoint, Inercia, Euskal and almost all the college period in my backpack. So the LCD started to show some weird vertical coloured lines which would require a new LCD, which is almost the price of a new laptop...</div><div style="text-align: justify;">After i started my current job, which is purely macintosh based, i noticed the iMac where actually an interesting concept to keep all the cables inside the computer. So i though maybe i can do something similar to my old laptop !</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">The basic idea was to mount the laptop behind an LCD monitor, my monitor (Sony SDM-S93) had a sliding plate behind which helped to mount the metal holder bars. After that I only needed some sort of electronic connection to power up the laptop, since the power button would be hidden under the lid. </div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">The electronic circuit consists in a relay which is activated when we press the front power/iddle button in the monitor, the relay acts as the power switch of the laptop. I could have connected directly the two switches, but that wouldn't be very safe and healthy for both the devices. The circuit steals 12V from the monitor PSU, which is always available whatever the current state(idle or on). On idle state the available current is very low, because the PSU switching circuit is working at a very small duty cycle to use less mains power, so the laptop switching circuit must be power efficient.</div><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr> <td style="padding: 5px; text-align: center;"><a href="http://2.bp.blogspot.com/_gR712w2riTk/TTHhFAAXRzI/AAAAAAAABEw/sMIdN-uuSPM/s1600/SDC12407.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="http://2.bp.blogspot.com/_gR712w2riTk/TTHhFAAXRzI/AAAAAAAABEw/sMIdN-uuSPM/s200/SDC12407.JPG" width="200" /></a></td> <td style="padding: 5px; text-align: center;"><a href="http://3.bp.blogspot.com/_gR712w2riTk/TTHhHzAuETI/AAAAAAAABE0/P9YttjdZAis/s1600/SDC12414.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="http://3.bp.blogspot.com/_gR712w2riTk/TTHhHzAuETI/AAAAAAAABE0/P9YttjdZAis/s200/SDC12414.JPG" width="200" /></a></td> </tr>
<tr> <td class="tr-caption" style="max-width: 90px; text-align: center;">Monitor PSU and control circuit plus my circuit in the breadboard</td> <td class="tr-caption" style="max-width: 90px; text-align: center;">The compact version of the laptop switching circuit </td> </tr>
</tbody> </table><br />
<div style="text-align: justify;">After building the circuit I only needed to add some cables to the laptop which would intercept the power button signal, using my trusty Dremel i drilled a path through the plastic and used the hole of one screw to pass the cables. The cables end with a male conector to help mount and unmount the laptop from the suport, or even still use the laptop .. as a laptop :)</div><div style="text-align: justify;"><br />
</div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/_gR712w2riTk/TTHl8Nr7ycI/AAAAAAAABE4/j7pIvOM_fcA/s1600/SDC12416.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="http://3.bp.blogspot.com/_gR712w2riTk/TTHl8Nr7ycI/AAAAAAAABE4/j7pIvOM_fcA/s200/SDC12416.JPG" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Drilled path to pass the cables</td><td class="tr-caption" style="text-align: center;"><br />
</td></tr>
</tbody></table><div style="text-align: justify;"></div><div style="text-align: justify;">The end result isn't a iMac, but still, I managed to recycle old hardware to create a new "computer" which manages to accomplish all my current needs (Blender, development, office and minecraft :P). It was still has some issues due to idle/on/off state of monitor, when it's on iddle mode and we press the power button, it powers up the laptop and powers down the monitor (iddle->off), but pressing it again it powers up the monitor without powering down the laptop. I could easily fix this by intercepting also the monitor power switch and with some extra logic, but for now it's enough ! </div><div style="text-align: justify;"><br />
</div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr> <td style="padding: 5px; text-align: center;"><a href="http://1.bp.blogspot.com/_gR712w2riTk/TTHnqxVi6uI/AAAAAAAABE8/VQyFXk1DBUE/s1600/SDC12419.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="http://1.bp.blogspot.com/_gR712w2riTk/TTHnqxVi6uI/AAAAAAAABE8/VQyFXk1DBUE/s200/SDC12419.JPG" width="200" /></a></td> <td style="padding: 5px; text-align: center;"><a href="http://2.bp.blogspot.com/_gR712w2riTk/TTHnrQwSawI/AAAAAAAABFA/oZBOXkWjvVU/s1600/SDC12424.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="http://2.bp.blogspot.com/_gR712w2riTk/TTHnrQwSawI/AAAAAAAABFA/oZBOXkWjvVU/s200/SDC12424.JPG" width="200" /></a></td> </tr>
<tr> <td class="tr-caption" style="text-align: center;">Back view</td> <td class="tr-caption" style="text-align: center;">Front view</td> </tr>
</tbody> </table>Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-2202441831273420552010-12-26T23:04:00.007+00:002011-01-05T23:10:04.571+00:00Blender Armatures and Exporting<div style="text-align: justify;"><br />
<div style="text-align: justify;"><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">One of the things i have spent many time trying to understand is the Blender animation data for the armatures. Since the quaternions and translation vectors have their own special space, which depends on the bone orientation and roll vector as shown in <a href="http://www.blender.org/development/release-logs/blender-240/how-armatures-work/">how armatures work</a>, it isn't always easy to translate the animations to other formats like collada, fbx, bvh or to export the data for real-time applications.</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">The first thing to take in consideration is the matrix theoretical layout used to describe armature chain, like OpenGL, Blender uses the translation vector in a column, which may create some confusion. One typical example of this issue is the OpenGL <b>(2)</b> and DirectX <b>(1)</b> shaders, at machine level, they are done in the same way (see the gluProject source from Mesa), but from the programmers high level, the syntax is quite the opposite for the following cases :</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">out.pos = mul(float4(in.vertex,1.0), WorldViewProj ) <b>(1)</b></span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">gl_Position = WorldViewProj * vec4(vertex, 1.0) <b>(2)</b></span></div></div><div style="-webkit-text-decorations-in-effect: none; text-align: justify; text-decoration: line-through;"></div><br />
<br />
Keeping this in mind we rewrite the blender armature expression the way i like <b>(3)</b>.<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">b.matrix = IK(b) * Constrains(b) * actions(b) * bonemat(b) * head(b) * tail(b-1) * b.parent.matrix <b>(3)</b></span><br />
<br />
Ignoring the IK and Constrains we have something similar to what i use for my armatures <b>(4)</b>, but still, the action data (quaternions and translations) are affected by the bonemat matrix, which disables the direct use of the animation data from blender.<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">bone.matrix = Scale(bone.scale) * Rotate(bone.quaternion) * Translate(bone.head+bone.translation) *Translate(bone.parent.tail-bone.parent.head)*bone.parent.matrix <b>(4)</b></span><br />
<s><br />
</s><br />
To fix this issue, i found this expression to be the solution to export Blender animation data for my applications and the bXporter API <b>(5)</b>.<br />
<br />
<div style="text-align: left;"><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">matArmatureSpace = b.matrix['ARMATURESPACE']</span></div></div><div style="text-align: left;"><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">matInvArmatureSpace = Matrix(matArmatureSpace).invert()</span></div></div><div style="text-align: left;"><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span></div></div><div style="text-align: left;"><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">rotFixed = (matInvArmatureSpace.rotationPart()* graphQuaternion.toMatrix()</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">*</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">matArmatureSpace.rotationPart()).toQuat()</span></div></div><div style="text-align: left;"><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span></div></div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">posFixed = (matInvArmatureSpace*</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">TranslationMatrix(graphPosition)*</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">matArmatureSpace.rotationPart()).translationPart() <b>(5)</b></span><br />
<br />
This peculiar transformation applies the transformation of the bone rest pose in armature space to the current action data, this way we get the bone animated in armature space, then by applying the inverse bone rest pose matrix, we get the the rotation and translation relative to bone space and independent of the bonemat matrix, enabling the use of the expression <b>(4)</b>.<br />
<br />
Currently i have even fixed the issue with the animation beziers with another solution which doesn't use Cardano solver like in Blender or ILM ones, which consists in recalculate the bezier coefficients, but that will be another blogpost :)<br />
<br />
</div>Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-2255008970600343512010-11-11T21:01:00.015+00:002014-08-14T11:43:21.165+01:00Event Report - FIBDA 2010<div style="text-align: justify;">
This year event was dedicated to the 100th birthday of the portuguese republic, with many works related to the satire of portuguese people and the events during the implantation of the republic. It also exhibited some comics with almost 100 years, pretty well conserved!<br />
<br />
This year there wasn't an official cosplay event, because there weren't enough conditions to support the event, but still some contestants still appeared. It had some awesome installations with comics and sculptures of some artists but in general it was a bit weaker in relation to last year. The japanese section was a bit short for my taste, but had a huge scroll exposed over the walls with a colab work of many artists. It also featured a video installation with an animation of ancient japanese drawings.</div>
<div style="text-align: justify;">
<table align="center" cellpadding="0" cellspacing="0" style="text-align: center; width: 100%;"><tbody>
<tr> <td><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/_gR712w2riTk/TNx-72CqdaI/AAAAAAAABEM/PHRax13rA30/s1600/SDC12295.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/_gR712w2riTk/TNx-72CqdaI/AAAAAAAABEM/PHRax13rA30/s200/SDC12295.JPG" height="150" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The courageous ones who still came to the event</td></tr>
</tbody> </table>
</td> <td><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/_gR712w2riTk/TNyBlcGEtxI/AAAAAAAABEU/wAxTW7jepBQ/s1600/SDC12299.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/_gR712w2riTk/TNyBlcGEtxI/AAAAAAAABEU/wAxTW7jepBQ/s200/SDC12299.JPG" height="150" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">1/2 of the wall scroll</td></tr>
</tbody> </table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/_gR712w2riTk/TNxaTUXFQ8I/AAAAAAAABEI/uLLQ2s99p0E/s1600/gunnm%255B1%255D.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/_gR712w2riTk/TNxaTUXFQ8I/AAAAAAAABEI/uLLQ2s99p0E/s200/gunnm%255B1%255D.jpg" height="150" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">GUNMM Mangas Collection, 18 books </td></tr>
</tbody></table>
</td>
</tr>
</tbody>
</table>
I also bought the full collection of the GUNMM manga which I wasn't expecting to find and it was well worth the price, it's an specular cyberpunk story from the 90's, although it's a bit gore'ish :P</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-1686876976893088102010-10-13T11:55:00.003+01:002014-08-13T18:38:00.912+01:00XNA 4.0 - Binary Model LoaderSo i was trying to avoid the standard xna pipeline classes to start porting some features of my "graphic engine" to XNA. The first thing i wanted was to render a model with my custom file format, the C# and the XNA API stood well to the task, allowing me to read a buffers of bytes from filestream and copying it to vertex and index buffer.<br />
<pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: 250px; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> public class CustomModel
{
int m_Vertices;
int m_Triangles;
byte[] m_VerticeData;
byte[] m_TrianglesData;
GraphicsDevice m_GraphicsDevice;
VertexBuffer m_VertexBuffer;
IndexBuffer m_IndexBuffer;
public CustomModel()
{
m_Vertices = 0;
m_Triangles = 0;
}
public void Render()
{
m_GraphicsDevice.SetVertexBuffer(m_VertexBuffer);
m_GraphicsDevice.Indices = m_IndexBuffer;
m_GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, m_Vertices, 0, m_Triangles);
m_GraphicsDevice.SetVertexBuffer(null);
m_GraphicsDevice.Indices = null;
}
public void Load(GraphicsDevice graphics, ContentManager manager, string filename)
{
m_GraphicsDevice = graphics;
String StageIndexPath = manager.RootDirectory + "\\" + filename;
StreamReader st = new StreamReader(StageIndexPath);
BinaryReader bin = new BinaryReader(st.BaseStream);
m_Vertices = bin.ReadInt32();
m_Triangles = bin.ReadInt32();
m_VerticeData = new byte[m_Vertices * 32];
m_TrianglesData = new byte[m_Triangles * 12];
bin.Read(m_VerticeData, 0, m_Vertices * 32);
bin.Read(m_TrianglesData, 0, m_Triangles * 12);
bin.Close();
st.Close();
VertexDeclaration vdx = new VertexDeclaration(
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
);
m_VertexBuffer = new VertexBuffer(m_GraphicsDevice, vdx, m_Vertices, BufferUsage.None);
m_IndexBuffer = new IndexBuffer(m_GraphicsDevice, IndexElementSize.ThirtyTwoBits, 3 * m_Triangles, BufferUsage.None);
m_VertexBuffer.SetData<byte>(m_VerticeData);
m_IndexBuffer.SetData<byte>(m_TrianglesData);
}
}
</code></pre>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-22636632454847606202010-10-10T15:15:00.010+01:002014-08-13T23:31:21.406+01:00Event Report - Euskal 2010<div style="text-align: justify;">
Awesome place to sleep, if you still like concrete floor.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Yet again after one year of abstention the portuguese crew was back to Bilbao and Euskal, as usual our driver was Evil and is mighty mitsubishi, but this time we used a GPS to get there, although the roads in the frontier messed the GPS a bit :), we arrived at 23pm local hours after leaving Porto at 10:30am.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
As usual the place was full gamers and scene spirit kept being replaced by stupid videos on youtube at the big screen, which was the biggest mistake, if I wanted to see video on youtube I could stayed in home and didn't needed to waste 300€ on trips and food :(</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This year we learned how to waste less money on food, we bought microwave food on the local supermarket and we heated it at the local party microwaves, 2.5€ per meal, a great deal!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The sleeping space was ... the same, the showers were ... the same. But the big issue was the first night, I tried to slept under the hall lights and it didn't work very well since I didn't even had a tent.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
During the party i bought an external hard drive with esata port with a good price tag, but the first impressions weren't the best, since the hard drive blew up in my face, which was interesting :), but the guys at the shop gave me a new kit and everything was fine. It's a 1-Tera Byte HD were i store my projects that I need a faster access, since the USB drives are awfully slow.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The demoparty was meh, no demoshow during the event, the competitions didn't went well to evil and me, only xernobyl managed win something and still he had to share the price with someone, because in Euskal it's pretty common the entry's classification being tied(like the ASD and XPSV demos, seriously wtf ?)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
My 3D art entry didn't got any prize, I admit it still needed some improvements, but I didn't agree with the second and third place, oh well ...</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The party is becoming less and less interesting for sceners, although the prizes are interesting, it can't be the unique reason to attend to the party, for me it's was the final Euskal, if the opportunity appears in the near future, I will go to Main DemoParty.<br />
<br />
At least it was good to see the spanish sceners, Ham, Stage7 and the guys markan and pope with their awesome laser demo, props for putting napalmcore in the greetings :)<br />
<br />
In the last day me and jae went out to take photos in Bilbau, the city is amazing place, saldy we didn't had time to visit the Guggenheim.</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0tag:blogger.com,1999:blog-8904639435150670028.post-84925363319035778492010-10-10T15:01:00.003+01:002014-08-13T23:30:53.607+01:00Event Report - Portugal Tecnológico 2009<div style="text-align: justify;">
In 15 October of 2009, I participated in the national technology event with my driving simulator, which was the fourth time in public events. It's always good to see how the people react to the game and it's a good chance to find new bugs and get more feedback. The only problem was the driving wheel, which didn't resist the fair.</div>
<div style="text-align: justify;">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_gR712w2riTk/TLHH8JL0dJI/AAAAAAAABDQ/34Iy31qYurQ/s1600/pttech2009.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/_gR712w2riTk/TLHH8JL0dJI/AAAAAAAABDQ/34Iy31qYurQ/s320/pttech2009.jpg" height="240" width="320" /></a></div>
<br /></div>
<div style="text-align: justify;">
The fair was also a excellent opportunity to see top tech from public and private companies, awesome fair indeed.</div>
Luíshttp://www.blogger.com/profile/12231132045775007280noreply@blogger.com0