Look Here First

Curious why I created this blog? The following two posts explain it all. Click on the titles below to read more.

What this Blog is about.

Project Description.

Sunday, April 3, 2011

Display Driver Part 5

Outputting numeric values directly to the screen would be another tool that would be useful in debugging ADC input and also for the game.  The student would like to output a number including its leading zeros to the screen.  The student thinks it would be useful to output WORD and DWORD values to the screen.

The student coded the following two functions to output numeric values to the screen.

// begin example

void LCDPutDWORD(DWORD num, int x, int y, int fColor, int bColor)
{
//Size of a DWORD is as follows
//FFFFFFFF
//4294967295
// 10 places
const int sizeOFDWORD = 10;
char outString[sizeOFDWORD + 1];
outString[sizeOFDWORD] = '\0';
int loopCtr;
for (loopCtr = 0; loopCtr < sizeOFDWORD; loopCtr++)
{
// pull of the last digit and store it
char curDigit = num % 10;
// convert digit to it's ASCII value
curDigit = curDigit + 48; 
// store ASCII value into the string in the correct spot
outString[sizeOFDWORD - loopCtr - 1] = curDigit;
// prep number to pull of next digit. 
// (0/10 =0) is expected to happen multiple times
num = num / 10;
}
LCDPutStr(outString, x, y, fColor, bColor);
}

void LCDPutWORD(WORD num, int x, int y, int fColor, int bColor)
{
// Size of a WORD is as follows
// FFFF
// 65535
const int sizeOFWORD = 5;
char outString[sizeOFWORD + 1];
outString[sizeOFWORD] = 0x00;
int loopCtr;
for (loopCtr = 0; loopCtr < sizeOFWORD; loopCtr++)
{
// pull of the last digit and store it
char curDigit = num % 10;
// convert digit to it's ASCII value
curDigit = curDigit + 48; 
// store ASCII value into the string in the correct spot
outString[sizeOFWORD - loopCtr - 1] = curDigit;
// prep number to pull of next digit. 
// (0/10 =0) is expected to happen multiple times
num = num / 10;
}
LCDPutStr(outString, x, y, fColor, bColor);
}

// end example

The functions above allowed the student to output numeric values received as a result of an analog to digital conversion.

No comments:

Post a Comment