Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Print.h 2.5KB

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