My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SdFile.cpp 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Arduino SdFat Library
  2. * Copyright (C) 2009 by William Greiman
  3. *
  4. * This file is part of the Arduino SdFat Library
  5. *
  6. * This Library is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This Library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Arduino SdFat Library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Marlin.h"
  21. #include "SdFile.h"
  22. /** Create a file object and open it in the current working directory.
  23. *
  24. * \param[in] path A path with a valid 8.3 DOS name for a file to be opened.
  25. *
  26. * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive
  27. * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t).
  28. */
  29. SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) {
  30. }
  31. //------------------------------------------------------------------------------
  32. /** Write data to an open file.
  33. *
  34. * \note Data is moved to the cache but may not be written to the
  35. * storage device until sync() is called.
  36. *
  37. * \param[in] buf Pointer to the location of the data to be written.
  38. *
  39. * \param[in] nbyte Number of bytes to write.
  40. *
  41. * \return For success write() returns the number of bytes written, always
  42. * \a nbyte. If an error occurs, write() returns -1. Possible errors
  43. * include write() is called before a file has been opened, write is called
  44. * for a read-only file, device is full, a corrupt file system or an I/O error.
  45. *
  46. */
  47. int16_t SdFile::write(const void* buf, uint16_t nbyte) {
  48. return SdBaseFile::write(buf, nbyte);
  49. }
  50. #warning F_CPU
  51. //------------------------------------------------------------------------------
  52. /** Write a byte to a file. Required by the Arduino Print class.
  53. * \param[in] b the byte to be written.
  54. * Use writeError to check for errors.
  55. */
  56. #if ARDUINO >= 100
  57. size_t SdFile::write(uint8_t b)
  58. #else
  59. void SdFile::write(uint8_t b)
  60. #endif
  61. {
  62. SdBaseFile::write(&b, 1);
  63. }
  64. //------------------------------------------------------------------------------
  65. /** Write a string to a file. Used by the Arduino Print class.
  66. * \param[in] str Pointer to the string.
  67. * Use writeError to check for errors.
  68. */
  69. void SdFile::write(const char* str) {
  70. SdBaseFile::write(str, strlen(str));
  71. }
  72. //------------------------------------------------------------------------------
  73. /** Write a PROGMEM string to a file.
  74. * \param[in] str Pointer to the PROGMEM string.
  75. * Use writeError to check for errors.
  76. */
  77. void SdFile::write_P(PGM_P str) {
  78. for (uint8_t c; (c = pgm_read_byte(str)); str++) write(c);
  79. }
  80. //------------------------------------------------------------------------------
  81. /** Write a PROGMEM string followed by CR/LF to a file.
  82. * \param[in] str Pointer to the PROGMEM string.
  83. * Use writeError to check for errors.
  84. */
  85. void SdFile::writeln_P(PGM_P str) {
  86. write_P(str);
  87. write_P(PSTR("\r\n"));
  88. }