• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

BetterStream.cpp

Go to the documentation of this file.
00001 // -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*-
00002 //
00003 //      Copyright (c) 2010 Michael Smith. All rights reserved.
00004 //
00005 // This is free software; you can redistribute it and/or modify it under
00006 // the terms of the GNU Lesser General Public License as published by the
00007 // Free Software Foundation; either version 2.1 of the License, or (at
00008 // your option) any later version.
00009 //
00010 
00011 //
00012 // Enhancements to the Arduino Stream class.
00013 //
00014 
00015 #include "BetterStream.h"
00016 
00017 // Stream extensions////////////////////////////////////////////////////////////
00018 
00019 void
00020 BetterStream::print_P(const prog_char *s)
00021 {
00022         char    c;
00023 
00024         while ('\0' != (c = pgm_read_byte(s++)))
00025                 write(c);
00026 }
00027 
00028 void
00029 BetterStream::println_P(const char *s)
00030 {
00031         print_P(s);
00032         println();
00033 }
00034 
00035 void
00036 BetterStream::printf(const char *fmt, ...)
00037 {
00038         va_list ap;
00039 
00040         va_start(ap, fmt);
00041         _vprintf(0, fmt, ap);
00042         va_end(ap);
00043 }
00044 
00045 void
00046 BetterStream::printf_P(const char *fmt, ...)
00047 {
00048         va_list ap;
00049 
00050         va_start(ap, fmt);
00051         _vprintf(1, fmt, ap);
00052         va_end(ap);
00053 }
00054 

Generated for ArduPilot Libraries by doxygen