Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | // -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*- |
2 | // |
||
3 | // Copyright (c) 2010 Michael Smith. All rights reserved. |
||
4 | // |
||
5 | // This is free software; you can redistribute it and/or modify it under |
||
6 | // the terms of the GNU Lesser General Public License as published by the |
||
7 | // Free Software Foundation; either version 2.1 of the License, or (at |
||
8 | // your option) any later version. |
||
9 | // |
||
10 | |||
11 | // |
||
12 | // Enhancements to the Arduino Stream class. |
||
13 | // |
||
14 | |||
15 | #include <limits.h> |
||
16 | #include "BetterStream.h" |
||
17 | |||
18 | // Stream extensions//////////////////////////////////////////////////////////// |
||
19 | |||
20 | void |
||
21 | BetterStream::print_P(const prog_char_t *s) |
||
22 | { |
||
23 | char c; |
||
24 | |||
25 | while ('\0' != (c = pgm_read_byte((const prog_char *)s++))) |
||
26 | write(c); |
||
27 | } |
||
28 | |||
29 | void |
||
30 | BetterStream::println_P(const prog_char_t *s) |
||
31 | { |
||
32 | print_P(s); |
||
33 | println(); |
||
34 | } |
||
35 | |||
36 | void |
||
37 | BetterStream::printf(const char *fmt, ...) |
||
38 | { |
||
39 | va_list ap; |
||
40 | |||
41 | va_start(ap, fmt); |
||
42 | _vprintf(0, fmt, ap); |
||
43 | va_end(ap); |
||
44 | } |
||
45 | |||
46 | void |
||
47 | BetterStream::_printf_P(const prog_char *fmt, ...) |
||
48 | { |
||
49 | va_list ap; |
||
50 | |||
51 | va_start(ap, fmt); |
||
52 | _vprintf(1, fmt, ap); |
||
53 | va_end(ap); |
||
54 | } |
||
55 | |||
56 | int |
||
57 | BetterStream::txspace(void) |
||
58 | { |
||
59 | // by default claim that there is always space in transmit buffer |
||
60 | return(INT_MAX); |
||
61 | } |