Silicon Laboratories Stepper Machine Uživatelský manuál Strana 31

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 36
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 30
AN155
Rev. 1.1 31
putc(*string); // put character at pointer in buffer
string++; // increment pointer
}
}
//-----------------------------------------------------------------------------
unsigned int getuint(void) // get string and convert to int
{
char theChar;
unsigned int i;
i=0; // build value in i
theChar=getc(); // get next character
while( theChar<'0' || theChar>'9') // while not 0-9
theChar=getc();
while(theChar>='0' && theChar<='9') // while 0-9
{
theChar -= '0'; // convert from ASCII
i *= 10; // shift decimal point
i += theChar; // add next digit
theChar=getc();
}
return i; // return int value
}
//-----------------------------------------------------------------------------
void putuint(unsigned int i)
{
char string[7]; // string used to build output
char *sp; // string pointer
sp=string + 6; // build back to front
*sp=0; // insert null character
do
{
sp--; // predecrement pointer
*sp=i%10 + 0x30; // take modulus add 30
i/=10; // divide i by 10
} while (i); // while i not zero
// now output front to back
while (*sp) // while not null character
{
putc(*sp); // put character in buffer
sp++; // increment pointer
}
}
//-----------------------------------------------------------------------------
unsigned char getuchar () // same as getuint but returns uchar
{
char theChar;
unsigned char i;
i=0; // build value in i
theChar=getc(); // get next character
while( theChar<'0' || theChar>'9') // while not 0-9
theChar=getc();
while(theChar>='0' && theChar<='9') // while 0-9
{
theChar -= '0'; // convert from ASCII
i *= 10; // shift decimal point
i += theChar; // add next digit
theChar=getc();
Zobrazit stránku 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36

Komentáře k této Příručce

Žádné komentáře