1/* 2 Print.h - Base class that provides print() and println() 3 Copyright (c) 2008 David A. Mellis. All right reserved. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18*/ 19 20#ifndef Print_h 21#define Print_h 22 23#include <inttypes.h> 24#include <stdio.h> // for size_t 25 26#include "WString.h" 27 28#define DEC 10 29#define HEX 16 30#define OCT 8 31#define BIN 2 32#define BYTE 0 33 34class Print 35{ 36 private: 37 void printNumber(unsigned long, uint8_t); 38 void printFloat(double, uint8_t); 39 public: 40 virtual void write(uint8_t) = 0; 41 virtual void write(const char *str); 42 virtual void write(const uint8_t *buffer, size_t size); 43 44 void print(const String &); 45 void print(const char[]); 46 void print(char, int = BYTE); 47 void print(unsigned char, int = BYTE); 48 void print(int, int = DEC); 49 void print(unsigned int, int = DEC); 50 void print(long, int = DEC); 51 void print(unsigned long, int = DEC); 52 void print(double, int = 2); 53 54 void println(const String &s); 55 void println(const char[]); 56 void println(char, int = BYTE); 57 void println(unsigned char, int = BYTE); 58 void println(int, int = DEC); 59 void println(unsigned int, int = DEC); 60 void println(long, int = DEC); 61 void println(unsigned long, int = DEC); 62 void println(double, int = 2); 63 void println(void); 64}; 65 66#endif 67