source: rtos_arduino/trunk/arduino_lib/hardware/arduino/samd/cores/arduino/Print.h@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

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