PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Committer:
spinal
Date:
Wed Oct 18 14:47:54 2017 +0000
Revision:
15:0bbe8f6fae32
Parent:
9:754a7af30890
direct lcd stuff used by sensitive

Who changed what in which revision?

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