Some updates on Stream and Print class.

This commit is contained in:
Cristian Maglie 2017-08-23 16:59:04 +02:00 committed by Cristian Maglie
parent 0ee62489c0
commit 3d51b54386
3 changed files with 11 additions and 3 deletions

View file

@ -238,14 +238,14 @@ size_t Print::printFloat(double number, uint8_t digits)
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print(".");
n += print('.');
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)remainder;
unsigned int toPrint = (unsigned int)(remainder);
n += print(toPrint);
remainder -= toPrint;
}

View file

@ -28,6 +28,9 @@
#define DEC 10
#define HEX 16
#define OCT 8
#ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar
#undef BIN
#endif
#define BIN 2
class Print
@ -54,6 +57,10 @@ class Print
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overriden by subclasses with buffering
virtual int availableForWrite() { return 0; }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
@ -78,6 +85,8 @@ class Print
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
virtual void flush() { /* Empty implementation for backward compatibility */ }
};
#endif

View file

@ -59,7 +59,6 @@ class Stream : public Print
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
virtual void flush() = 0;
Stream() {_timeout=1000;}