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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. Streaming.h - Arduino library for supporting the << streaming operator
  3. Copyright (c) 2010 Mikal Hart. All rights 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 ARDUINO_STREAMING
  17. #define ARDUINO_STREAMING
  18. //#include <WProgram.h>
  19. #define STREAMING_LIBRARY_VERSION 4
  20. // Generic template
  21. template<class T>
  22. inline Print &operator <<(Print &stream, T arg)
  23. { stream.print(arg); return stream; }
  24. struct _BASED
  25. {
  26. long val;
  27. int base;
  28. _BASED(long v, int b): val(v), base(b)
  29. {}
  30. };
  31. #define _HEX(a) _BASED(a, HEX)
  32. #define _DEC(a) _BASED(a, DEC)
  33. #define _OCT(a) _BASED(a, OCT)
  34. #define _BIN(a) _BASED(a, BIN)
  35. #define _BYTE(a) _BASED(a, BYTE)
  36. // Specialization for class _BASED
  37. // Thanks to Arduino forum user Ben Combee who suggested this
  38. // clever technique to allow for expressions like
  39. // Serial << _HEX(a);
  40. inline Print &operator <<(Print &obj, const _BASED &arg)
  41. { obj.print(arg.val, arg.base); return obj; }
  42. #if ARDUINO >= 18
  43. // Specialization for class _FLOAT
  44. // Thanks to Michael Margolis for suggesting a way
  45. // to accommodate Arduino 0018's floating point precision
  46. // feature like this:
  47. // Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
  48. struct _FLOAT
  49. {
  50. float val;
  51. int digits;
  52. _FLOAT(double v, int d): val(v), digits(d)
  53. {}
  54. };
  55. inline Print &operator <<(Print &obj, const _FLOAT &arg)
  56. { obj.print(arg.val, arg.digits); return obj; }
  57. #endif
  58. // Specialization for enum _EndLineCode
  59. // Thanks to Arduino forum user Paul V. who suggested this
  60. // clever technique to allow for expressions like
  61. // Serial << "Hello!" << endl;
  62. enum _EndLineCode { endl };
  63. inline Print &operator <<(Print &obj, _EndLineCode arg)
  64. { obj.println(); return obj; }
  65. #endif