Set of Files to enable some Arduino examples.
Dependents: TFT_Touch_botao_v1 TFT_Touch_exemplo5_git_touch TESTE_1 TFT_Touch_exemplo6_git_touch_button_3_
Print.h@2:81364824d56a, 2021-05-11 (annotated)
- Committer:
- davidprentice
- Date:
- Tue May 11 16:24:13 2021 +0000
- Revision:
- 2:81364824d56a
- Parent:
- 0:5952bbaff1c6
add includes, typedef byte
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
davidprentice | 0:5952bbaff1c6 | 1 | /* |
davidprentice | 0:5952bbaff1c6 | 2 | Print.h - Base class that provides print() and println() |
davidprentice | 0:5952bbaff1c6 | 3 | Copyright (c) 2008 David A. Mellis. All right reserved. |
davidprentice | 0:5952bbaff1c6 | 4 | |
davidprentice | 0:5952bbaff1c6 | 5 | This library is free software; you can redistribute it and/or |
davidprentice | 0:5952bbaff1c6 | 6 | modify it under the terms of the GNU Lesser General Public |
davidprentice | 0:5952bbaff1c6 | 7 | License as published by the Free Software Foundation; either |
davidprentice | 0:5952bbaff1c6 | 8 | version 2.1 of the License, or (at your option) any later version. |
davidprentice | 0:5952bbaff1c6 | 9 | |
davidprentice | 0:5952bbaff1c6 | 10 | This library is distributed in the hope that it will be useful, |
davidprentice | 0:5952bbaff1c6 | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
davidprentice | 0:5952bbaff1c6 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
davidprentice | 0:5952bbaff1c6 | 13 | Lesser General Public License for more details. |
davidprentice | 0:5952bbaff1c6 | 14 | |
davidprentice | 0:5952bbaff1c6 | 15 | You should have received a copy of the GNU Lesser General Public |
davidprentice | 0:5952bbaff1c6 | 16 | License along with this library; if not, write to the Free Software |
davidprentice | 0:5952bbaff1c6 | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
davidprentice | 0:5952bbaff1c6 | 18 | */ |
davidprentice | 0:5952bbaff1c6 | 19 | |
davidprentice | 0:5952bbaff1c6 | 20 | #ifndef Print_h |
davidprentice | 0:5952bbaff1c6 | 21 | #define Print_h |
davidprentice | 0:5952bbaff1c6 | 22 | |
davidprentice | 0:5952bbaff1c6 | 23 | #include <stdint.h> |
davidprentice | 0:5952bbaff1c6 | 24 | #include <stdio.h> // for size_t |
davidprentice | 0:5952bbaff1c6 | 25 | #include <stdarg.h> // for printf |
davidprentice | 0:5952bbaff1c6 | 26 | |
davidprentice | 0:5952bbaff1c6 | 27 | #include "WString.h" |
davidprentice | 0:5952bbaff1c6 | 28 | //#include "Printable.h" |
davidprentice | 0:5952bbaff1c6 | 29 | |
davidprentice | 0:5952bbaff1c6 | 30 | #define DEC 10 |
davidprentice | 0:5952bbaff1c6 | 31 | #define HEX 16 |
davidprentice | 0:5952bbaff1c6 | 32 | #define OCT 8 |
davidprentice | 0:5952bbaff1c6 | 33 | #define BIN 2 |
davidprentice | 0:5952bbaff1c6 | 34 | |
davidprentice | 0:5952bbaff1c6 | 35 | // uncomment next line to support printing of 64 bit ints. |
davidprentice | 0:5952bbaff1c6 | 36 | #define SUPPORT_LONGLONG |
davidprentice | 0:5952bbaff1c6 | 37 | |
davidprentice | 0:5952bbaff1c6 | 38 | class Print { |
davidprentice | 0:5952bbaff1c6 | 39 | private: |
davidprentice | 0:5952bbaff1c6 | 40 | int write_error; |
davidprentice | 0:5952bbaff1c6 | 41 | size_t printNumber(unsigned long, uint8_t); |
davidprentice | 0:5952bbaff1c6 | 42 | #ifdef SUPPORT_LONGLONG |
davidprentice | 0:5952bbaff1c6 | 43 | void printLLNumber(uint64_t, uint8_t); |
davidprentice | 0:5952bbaff1c6 | 44 | #endif |
davidprentice | 0:5952bbaff1c6 | 45 | size_t printFloat(double, uint8_t); |
davidprentice | 0:5952bbaff1c6 | 46 | protected: |
davidprentice | 0:5952bbaff1c6 | 47 | void setWriteError(int err = 1) |
davidprentice | 0:5952bbaff1c6 | 48 | { |
davidprentice | 0:5952bbaff1c6 | 49 | write_error = err; |
davidprentice | 0:5952bbaff1c6 | 50 | } |
davidprentice | 0:5952bbaff1c6 | 51 | public: |
davidprentice | 0:5952bbaff1c6 | 52 | Print() : write_error(0) {} |
davidprentice | 0:5952bbaff1c6 | 53 | |
davidprentice | 0:5952bbaff1c6 | 54 | int getWriteError() |
davidprentice | 0:5952bbaff1c6 | 55 | { |
davidprentice | 0:5952bbaff1c6 | 56 | return write_error; |
davidprentice | 0:5952bbaff1c6 | 57 | } |
davidprentice | 0:5952bbaff1c6 | 58 | void clearWriteError() |
davidprentice | 0:5952bbaff1c6 | 59 | { |
davidprentice | 0:5952bbaff1c6 | 60 | setWriteError(0); |
davidprentice | 0:5952bbaff1c6 | 61 | } |
davidprentice | 0:5952bbaff1c6 | 62 | |
davidprentice | 0:5952bbaff1c6 | 63 | virtual size_t write(uint8_t) = 0; |
davidprentice | 0:5952bbaff1c6 | 64 | size_t write(const char *str) |
davidprentice | 0:5952bbaff1c6 | 65 | { |
davidprentice | 0:5952bbaff1c6 | 66 | if (str == NULL) { |
davidprentice | 0:5952bbaff1c6 | 67 | return 0; |
davidprentice | 0:5952bbaff1c6 | 68 | } |
davidprentice | 0:5952bbaff1c6 | 69 | return write((const uint8_t *)str, strlen(str)); |
davidprentice | 0:5952bbaff1c6 | 70 | } |
davidprentice | 0:5952bbaff1c6 | 71 | virtual size_t write(const uint8_t *buffer, size_t size); |
davidprentice | 0:5952bbaff1c6 | 72 | size_t write(const char *buffer, size_t size) |
davidprentice | 0:5952bbaff1c6 | 73 | { |
davidprentice | 0:5952bbaff1c6 | 74 | return write((const uint8_t *)buffer, size); |
davidprentice | 0:5952bbaff1c6 | 75 | } |
davidprentice | 0:5952bbaff1c6 | 76 | |
davidprentice | 0:5952bbaff1c6 | 77 | size_t print(const __FlashStringHelper *); //.kbv |
davidprentice | 0:5952bbaff1c6 | 78 | size_t print(const String &); //.kbv |
davidprentice | 0:5952bbaff1c6 | 79 | size_t print(const char []); |
davidprentice | 0:5952bbaff1c6 | 80 | size_t print(char); |
davidprentice | 0:5952bbaff1c6 | 81 | size_t print(unsigned char, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 82 | size_t print(int, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 83 | size_t print(unsigned int, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 84 | size_t print(long, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 85 | size_t print(unsigned long, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 86 | size_t print(double, int = 2); |
davidprentice | 0:5952bbaff1c6 | 87 | //size_t print(const Printable &); |
davidprentice | 0:5952bbaff1c6 | 88 | |
davidprentice | 0:5952bbaff1c6 | 89 | size_t println(const __FlashStringHelper *); //.kbv |
davidprentice | 0:5952bbaff1c6 | 90 | size_t println(const String &s); //.kbv |
davidprentice | 0:5952bbaff1c6 | 91 | size_t println(const char[]); |
davidprentice | 0:5952bbaff1c6 | 92 | size_t println(char); |
davidprentice | 0:5952bbaff1c6 | 93 | size_t println(unsigned char, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 94 | size_t println(int, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 95 | size_t println(unsigned int, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 96 | size_t println(long, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 97 | size_t println(unsigned long, int = DEC); |
davidprentice | 0:5952bbaff1c6 | 98 | size_t println(double, int = 2); |
davidprentice | 0:5952bbaff1c6 | 99 | //size_t println(const Printable &); |
davidprentice | 0:5952bbaff1c6 | 100 | size_t println(void); |
davidprentice | 0:5952bbaff1c6 | 101 | #ifdef SUPPORT_LONGLONG |
davidprentice | 0:5952bbaff1c6 | 102 | void println(int64_t, uint8_t = DEC); |
davidprentice | 0:5952bbaff1c6 | 103 | void print(int64_t, uint8_t = DEC); |
davidprentice | 0:5952bbaff1c6 | 104 | void println(uint64_t, uint8_t = DEC); |
davidprentice | 0:5952bbaff1c6 | 105 | void print(uint64_t, uint8_t = DEC); |
davidprentice | 0:5952bbaff1c6 | 106 | #endif |
davidprentice | 0:5952bbaff1c6 | 107 | |
davidprentice | 0:5952bbaff1c6 | 108 | int printf(const char *format, ...); |
davidprentice | 0:5952bbaff1c6 | 109 | //int printf(const __FlashStringHelper *format, ...); |
davidprentice | 0:5952bbaff1c6 | 110 | }; |
davidprentice | 0:5952bbaff1c6 | 111 | |
davidprentice | 0:5952bbaff1c6 | 112 | #endif |