My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Print.h 2.5KB

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