First SMD Reflow
My iOS development license expired yesterday after I forgot to renew it. Since I hadn't received word back from Apple about it being reactivated, I decided to do some electronics.
Having recently buying an analog to digital converter and a prototype adaptor board for an SOIC, I decided to use my reflow tool I bought a few month back. One thing I didn't take into account was that my solder paste was out of date in November 2011, making it fairly thick and hard to separate.
Also it turns out the display on my reflow tool is in Fahrenheit, not Celsius.
I think it turned out rather well for my first one.
The second one however, a digital to analog converter, turned out far worse of a job. It is a TSSOP package - a fraction the size of the SOIC, and I have trouble with bridges being formed between pins, and my cheap solder wick was failing to remove them.
I'm unsure if the chips still work, as I took quite a while to get them in the correct position, but I was 40-60 degrees lower than the maximum soldering temperature. Hopefully I will have time to test them tomorrow.
Wikipedia Blackout of 2012
Historians in the future will one day look back on this day, and realise that the 18th January 2012, was the most productive day in human history.
The International Obfuscated C Code Contest
I got told about this brilliant bit of code recently. It is a magic eye. Supposedly it will compile with a GCC compiler, I was unable to get it to in Visual Studio.
More similar code is on the official IO CCC website.
SprintfCat
On the train to Cardiff yesterday, I was creating a fixed function shader generator for the Athena engine. I kept using strcat() with if statements, and in a lot of places I kept using sprintf() then copying that in with strcat().
So I decided to make SprintfCat(), all the wonderful joy of sprintf, with the ability to concatenate with a already existant string like strcat.
//
//
size_t ath::SprintfCat( char * inoutBuffer, const size_t inBufferSize, const char * inFormat, ... )
{
const size_t offset = StrLen( inoutBuffer );
size_t ret = 0;
va_list arg;
//
va_start( arg, inFormat );
{
ret = VSprintf( inoutBuffer + offset, inBufferSize - offset, inFormat, arg );
}
va_end( arg );
//
return offset + ret;
}I had already created my own wrappers around strlen() and vsprintf(), the reason being the fault of Microsoft. With their implementation of the standard library, they decided to deprecate non-safe versions complain at you until you either used their own _s variants, or defined a certain preprocessor.
//
//
size_t ath::VSprintf( char * outBuffer, const size_t inBufferSize, const char * inFormat, va_list inArgs )
{
#ifndef ATH_PLATFORM_WINDOWS
return vsnprintf( outBuffer, inBufferSize, inFormat, inArgs );
#else
return vsprintf_s( outBuffer, inBufferSize, inFormat, inArgs );
#endif
}
//
//
size_t ath::StrLen( const char * inString )
{
return strlen( inString );
}While I do prefer to have safe versions, their _s variants are not present in the standard and so it makes the code not portable.
I'm still not quite sure about my naming convention for a variable that is an input and an output. While I do like the in or out prefix, I don't think inout looks right, being slightly too long. I wasn't a fan of io either. I have however grown to like the truncation of Athena namespace to ath.
OpenGL Shader Debugging
One thing that always annoys me with using glGetShaderInfoLog(), is that when compiling OpenGL shaders multiple sources can be used. Because of this, the line numbers get shifted, and trying to find line 123 where a syntax error exists is a length process.
So I made a function that will take the sources list and output the lines with line numbers.
void OutputWithLineNumbers( const char ** inSources, const unsigned int inCount )
{
bool unendedLineNo = false;
int lineNumber = 1;
for( unsigned int i = 0; i < inCount; ++i )
{
const char * cur = inSources[i];
const char * next = NULL;
do
{
//
if( !unendedLineNo )
{
printf( "%04d: ", lineNumber );
}
//
next = strchr( cur, '\r' );
//
if( next )
{
size_t len = ( next - cur );
char * lineText = (char *)alloca( len );
memcpy( lineText, cur, len );
lineText[len] = 0;
printf( "%s\n", lineText );
unendedLineNo = false;
++lineNumber;
}
else
{
printf( "%s", cur );
unendedLineNo = true;
}
//
cur = next + 2;
} while( next );
}
if( unendedLineNo )
{
printf( "\n" );
}
}This code requires the source files to have a carriage return as well as a new line character.



