sanguino/cores/arduino/Print.h

Fri, 17 Nov 2017 10:13:31 +0100

author
mdd
date
Fri, 17 Nov 2017 10:13:31 +0100
changeset 3
770b218a4931
parent 2
b373b0288715
permissions
-rw-r--r--

proper configuration, homing and planner optimization

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

mercurial