Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: YATTT sd_map_test cPong SnowDemo ... more
PokittoLib
Library for programming Pokitto hardware
How to Use
- Import this library to online compiler (see button "import" on the right hand side
 - DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
 - Change My_settings.h according to your project
 - Start coding!
 
POKITTO_XTERNALS/Arduino/Print.h@68:61a4ccb0a4b6, 2019-04-05 (annotated)
- Committer:
 - Pokitto
 - Date:
 - Fri Apr 05 11:18:14 2019 +0000
 - Revision:
 - 68:61a4ccb0a4b6
 - Parent:
 - 8:754a7af30890
 
Pure polling method added for Buttons
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Pokitto | 8:754a7af30890 | 1 | /* | 
| Pokitto | 8:754a7af30890 | 2 | Print.h - Base class that provides print() and println() | 
| Pokitto | 8:754a7af30890 | 3 | Copyright (c) 2008 David A. Mellis. All right reserved. | 
| Pokitto | 8:754a7af30890 | 4 | |
| Pokitto | 8:754a7af30890 | 5 | This library is free software; you can redistribute it and/or | 
| Pokitto | 8:754a7af30890 | 6 | modify it under the terms of the GNU Lesser General Public | 
| Pokitto | 8:754a7af30890 | 7 | License as published by the Free Software Foundation; either | 
| Pokitto | 8:754a7af30890 | 8 | version 2.1 of the License, or (at your option) any later version. | 
| Pokitto | 8:754a7af30890 | 9 | |
| Pokitto | 8:754a7af30890 | 10 | This library is distributed in the hope that it will be useful, | 
| Pokitto | 8:754a7af30890 | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| Pokitto | 8:754a7af30890 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 
| Pokitto | 8:754a7af30890 | 13 | Lesser General Public License for more details. | 
| Pokitto | 8:754a7af30890 | 14 | |
| Pokitto | 8:754a7af30890 | 15 | You should have received a copy of the GNU Lesser General Public | 
| Pokitto | 8:754a7af30890 | 16 | License along with this library; if not, write to the Free Software | 
| Pokitto | 8:754a7af30890 | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 
| Pokitto | 8:754a7af30890 | 18 | */ | 
| Pokitto | 8:754a7af30890 | 19 | |
| Pokitto | 8:754a7af30890 | 20 | #ifndef Print_h | 
| Pokitto | 8:754a7af30890 | 21 | #define Print_h | 
| Pokitto | 8:754a7af30890 | 22 | |
| Pokitto | 8:754a7af30890 | 23 | #include <inttypes.h> | 
| Pokitto | 8:754a7af30890 | 24 | #include <stdio.h> // for size_t | 
| Pokitto | 8:754a7af30890 | 25 | |
| Pokitto | 8:754a7af30890 | 26 | #include "WString.h" | 
| Pokitto | 8:754a7af30890 | 27 | #include "Printable.h" | 
| Pokitto | 8:754a7af30890 | 28 | |
| Pokitto | 8:754a7af30890 | 29 | #define DEC 10 | 
| Pokitto | 8:754a7af30890 | 30 | #define HEX 16 | 
| Pokitto | 8:754a7af30890 | 31 | #define OCT 8 | 
| Pokitto | 8:754a7af30890 | 32 | #define BIN 2 | 
| Pokitto | 8:754a7af30890 | 33 | |
| Pokitto | 8:754a7af30890 | 34 | class Print | 
| Pokitto | 8:754a7af30890 | 35 | { | 
| Pokitto | 8:754a7af30890 | 36 | private: | 
| Pokitto | 8:754a7af30890 | 37 | int write_error; | 
| Pokitto | 8:754a7af30890 | 38 | size_t printNumber(unsigned long, uint8_t); | 
| Pokitto | 8:754a7af30890 | 39 | size_t printFloat(double, uint8_t); | 
| Pokitto | 8:754a7af30890 | 40 | protected: | 
| Pokitto | 8:754a7af30890 | 41 | void setWriteError(int err = 1) { write_error = err; } | 
| Pokitto | 8:754a7af30890 | 42 | public: | 
| Pokitto | 8:754a7af30890 | 43 | Print() : write_error(0) {} | 
| Pokitto | 8:754a7af30890 | 44 | |
| Pokitto | 8:754a7af30890 | 45 | int getWriteError() { return write_error; } | 
| Pokitto | 8:754a7af30890 | 46 | void clearWriteError() { setWriteError(0); } | 
| Pokitto | 8:754a7af30890 | 47 | |
| Pokitto | 8:754a7af30890 | 48 | virtual size_t write(uint8_t) = 0; | 
| Pokitto | 8:754a7af30890 | 49 | size_t write(const char *str) { | 
| Pokitto | 8:754a7af30890 | 50 | if (str == NULL) return 0; | 
| Pokitto | 8:754a7af30890 | 51 | return write((const uint8_t *)str, strlen(str)); | 
| Pokitto | 8:754a7af30890 | 52 | } | 
| Pokitto | 8:754a7af30890 | 53 | virtual size_t write(const uint8_t *buffer, size_t size); | 
| Pokitto | 8:754a7af30890 | 54 | |
| Pokitto | 8:754a7af30890 | 55 | size_t print(const __FlashStringHelper *); | 
| Pokitto | 8:754a7af30890 | 56 | size_t print(const String &); | 
| Pokitto | 8:754a7af30890 | 57 | size_t print(const char[]); | 
| Pokitto | 8:754a7af30890 | 58 | size_t print(char); | 
| Pokitto | 8:754a7af30890 | 59 | size_t print(unsigned char, int = DEC); | 
| Pokitto | 8:754a7af30890 | 60 | size_t print(int, int = DEC); | 
| Pokitto | 8:754a7af30890 | 61 | size_t print(unsigned int, int = DEC); | 
| Pokitto | 8:754a7af30890 | 62 | size_t print(long, int = DEC); | 
| Pokitto | 8:754a7af30890 | 63 | size_t print(unsigned long, int = DEC); | 
| Pokitto | 8:754a7af30890 | 64 | size_t print(double, int = 2); | 
| Pokitto | 8:754a7af30890 | 65 | size_t print(const Printable&); | 
| Pokitto | 8:754a7af30890 | 66 | |
| Pokitto | 8:754a7af30890 | 67 | size_t println(const __FlashStringHelper *); | 
| Pokitto | 8:754a7af30890 | 68 | size_t println(const String &s); | 
| Pokitto | 8:754a7af30890 | 69 | size_t println(const char[]); | 
| Pokitto | 8:754a7af30890 | 70 | size_t println(char); | 
| Pokitto | 8:754a7af30890 | 71 | size_t println(unsigned char, int = DEC); | 
| Pokitto | 8:754a7af30890 | 72 | size_t println(int, int = DEC); | 
| Pokitto | 8:754a7af30890 | 73 | size_t println(unsigned int, int = DEC); | 
| Pokitto | 8:754a7af30890 | 74 | size_t println(long, int = DEC); | 
| Pokitto | 8:754a7af30890 | 75 | size_t println(unsigned long, int = DEC); | 
| Pokitto | 8:754a7af30890 | 76 | size_t println(double, int = 2); | 
| Pokitto | 8:754a7af30890 | 77 | size_t println(const Printable&); | 
| Pokitto | 8:754a7af30890 | 78 | size_t println(void); | 
| Pokitto | 8:754a7af30890 | 79 | }; | 
| Pokitto | 8:754a7af30890 | 80 | |
| Pokitto | 8:754a7af30890 | 81 | #endif |