Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
192 / 100 = 1, then 1 + '0' = 0x31 = '1'
192 % 100 = 92
92 / 10 = 9, then 9 + '0' = 0x39 = '9'
92 % 10 = 2, then 2 + '0' = 0x32 = '2'
static void DisplayIPValue(IP_ADDR IPVal)
{
// printf("%u.%u.%u.%u", IPVal.v[0], IPVal.v[1], IPVal.v[2], IPVal.v[3]);
BYTE IPDigit[4];
BYTE i;
#ifdef USE_LCD
BYTE j;
BYTE LCDPos=16;
#endif
for(i = 0; i < sizeof(IP_ADDR); i++)
{
uitoa((WORD)IPVal.v[i], IPDigit);
#if defined(STACK_USE_UART)
putsUART(IPDigit);
#endif
#ifdef USE_LCD
for(j = 0; j < strlen((char*)IPDigit); j++)
{
LCDText[LCDPos++] = IPDigit[j];
}
if(i == sizeof(IP_ADDR)-1)
break;
LCDText[LCDPos++] = '.';
#else
if(i == sizeof(IP_ADDR)-1)
break;
#endif
#if defined(STACK_USE_UART)
while(BusyUART());
WriteUART('.');
#endif
}
#ifdef USE_LCD
if(LCDPos < 32)
LCDText[LCDPos] = 0;
LCDUpdate();
#endif
}
Yes.. convert from IP_ADDR to string..
Actually, mine is from the NODE_INFO, but the IP_ADDR value can be extracted from there..
Thanks..
I wonder, what does the statement "printf("%u.%u.%u.%u", IPVal.v[0], IPVal.v[1], IPVal.v[2], IPVal.v[3]);" used for..? is it to print to LCD..?
Oh yeah.. Thanks..I don't know; it's commented out in the original code (in other words, I just copied and pasted the code; I didn't comment that line out). However, in the uC code I've written, that would end up going to the serial port (which I tend to use as a debug console if it's not needed for something else). I doubt very much it would be to print to the LCD; if it were, then what is the point of the rest of the function?
Torben
The printf function in most compiler libraries is used to output a string of text to the "standard output" device. In the early days of computing it was typically the users console device which could have been a teleprinter or a glass teletype. The code below the commented function call must be an attempt to duplicate the function in some sense.
I see the included code makes use of the uitoa(...,...) function. I'm sure it is derived from the simpler itoa() function. Again check your compiler libraries to see what functions it has. If there is nothing there then try to score a copy of the "The Standard C Library" by P.J. Plauger. A steal at $5.49 used on amazon
Amazon.com: The Standard C Library: P. J. Plauger: Books
/* this default version should not do anything. it is entirely a
placeholder symbol. To keep code size at a minimum, it is declared
without a return value or parameters. The caller will still clean up
the stack frame correctly.
When using the _H_USER stream, the function will be implemented in
application code with the prototype:
int _user_putc (char c);
*/
void
_user_putc (void)
{
}