Motion Control Updates
This commit is contained in:
parent
471d018bfe
commit
cc1bdaa82f
5 changed files with 132 additions and 41 deletions
33
serial.cpp
33
serial.cpp
|
|
@ -38,7 +38,7 @@ void Serial::putChar(const char c)
|
|||
UDR0 = c;
|
||||
}
|
||||
|
||||
void Serial::putString(const char* in, const unsigned int length)
|
||||
void Serial::write(const char* in, const unsigned int length)
|
||||
{
|
||||
for(unsigned int i = 0; i < length && in[i] != '\0'; i++)
|
||||
{
|
||||
|
|
@ -46,7 +46,7 @@ void Serial::putString(const char* in, const unsigned int length)
|
|||
}
|
||||
}
|
||||
|
||||
void Serial::putString(const char in[])
|
||||
void Serial::write(const char in[])
|
||||
{
|
||||
for(unsigned int i = 0; i < strlen(in); i++)
|
||||
{
|
||||
|
|
@ -54,6 +54,35 @@ void Serial::putString(const char in[])
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Serial::write(int32_t in)
|
||||
{
|
||||
if(in == 0)
|
||||
{
|
||||
putChar('0');
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag = false;
|
||||
char str[64] = { 0 };
|
||||
int16_t i = 62;
|
||||
if (in < 0)
|
||||
{
|
||||
flag = true;
|
||||
in = abs(in);
|
||||
}
|
||||
|
||||
while (in != 0 && i > 0)
|
||||
{
|
||||
str[i--] = (in % 10) + '0';
|
||||
in /= 10;
|
||||
}
|
||||
|
||||
if (flag) str[i--] = '-';
|
||||
write(str + i + 1, 64-(i+1));
|
||||
}
|
||||
}
|
||||
|
||||
bool Serial::dataIsWaiting()
|
||||
{
|
||||
return (interruptIndex > _rxIndex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue