My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef _CMSIS_PRINT_H_
  20. #define _CMSIS_PRINT_H_
  21. #include <inttypes.h>
  22. #include <stdio.h> // for size_t
  23. #include <string.h>
  24. #include "Printable.h"
  25. #define DEC 10
  26. #define HEX 16
  27. #define OCT 8
  28. #define BIN 2
  29. class Print {
  30. private:
  31. int write_error;
  32. size_t printNumber(unsigned long, uint8_t);
  33. size_t printFloat(double, uint8_t);
  34. protected:
  35. void setWriteError(const int err = 1) { write_error = err; }
  36. public:
  37. Print() : write_error(0) {}
  38. virtual ~Print() {}
  39. int getWriteError() { return write_error; }
  40. void clearWriteError() { setWriteError(0); }
  41. virtual size_t write(uint8_t) = 0;
  42. size_t write(const char *str) {
  43. if (str == NULL) return 0;
  44. return write((const uint8_t *)str, strlen(str));
  45. }
  46. virtual size_t write(const uint8_t *buffer, size_t size);
  47. size_t write(const char *buffer, size_t size) {
  48. return write((const uint8_t *)buffer, size);
  49. }
  50. size_t print(const char[]);
  51. size_t print(char);
  52. size_t print(unsigned char, int = DEC);
  53. size_t print(int, int = DEC);
  54. size_t print(unsigned int, int = DEC);
  55. size_t print(long, int = DEC);
  56. size_t print(unsigned long, int = DEC);
  57. size_t print(double, int = 2);
  58. size_t print(const Printable&);
  59. size_t println(const char[]);
  60. size_t println(char);
  61. size_t println(unsigned char, int = DEC);
  62. size_t println(int, int = DEC);
  63. size_t println(unsigned int, int = DEC);
  64. size_t println(long, int = DEC);
  65. size_t println(unsigned long, int = DEC);
  66. size_t println(double, int = 2);
  67. size_t println(const Printable&);
  68. size_t println(void);
  69. virtual size_t printf(const char *argList, ...);
  70. };
  71. #endif // _CMSIS_PRINT_H_