Arduino Core API Library besed on mbed platform.
Dependents: WeeESP8266 ESP8266_moj
Print.h
00001 /* 00002 Print.h - Base class that provides print() and println() 00003 Copyright (c) 2008 David A. Mellis. All right reserved. 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef __ARDUINOAPI_PRINT_H__ 00021 #define __ARDUINOAPI_PRINT_H__ 00022 #ifdef __cplusplus 00023 00024 #include <inttypes.h> 00025 #include <stdio.h> // for size_t 00026 00027 #include "WString.h" 00028 00029 00030 #define DEC 10 00031 #define HEX 16 00032 #define OCT 8 00033 #define BIN 2 00034 00035 class Print 00036 { 00037 private: 00038 int write_error; 00039 size_t printNumber(unsigned long, uint8_t); 00040 size_t printFloat(double, uint8_t); 00041 protected: 00042 void setWriteError(int err = 1) { write_error = err; } 00043 public: 00044 Print() : write_error(0) {} 00045 00046 int getWriteError() { return write_error; } 00047 void clearWriteError() { setWriteError(0); } 00048 00049 virtual size_t write(uint8_t) = 0; 00050 size_t write(const char *str) { 00051 if (str == NULL) return 0; 00052 return write((const uint8_t *)str, strlen(str)); 00053 } 00054 virtual size_t write(const uint8_t *buffer, size_t size); 00055 00056 size_t print(const String &); 00057 size_t print(const char[]); 00058 size_t print(char); 00059 size_t print(unsigned char, int = DEC); 00060 size_t print(int, int = DEC); 00061 size_t print(unsigned int, int = DEC); 00062 size_t print(long, int = DEC); 00063 size_t print(unsigned long, int = DEC); 00064 size_t print(double, int = 2); 00065 00066 size_t println(const String &s); 00067 size_t println(const char[]); 00068 size_t println(char); 00069 size_t println(unsigned char, int = DEC); 00070 size_t println(int, int = DEC); 00071 size_t println(unsigned int, int = DEC); 00072 size_t println(long, int = DEC); 00073 size_t println(unsigned long, int = DEC); 00074 size_t println(double, int = 2); 00075 size_t println(void); 00076 }; 00077 #endif // __cplusplus 00078 #endif /* #ifndef __ARDUINOAPI_PRINT_H__ */
Generated on Mon Jul 25 2022 12:21:32 by 1.7.2