My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

media_file_reader.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /************************
  2. * media_filereader.cpp *
  3. ************************/
  4. /****************************************************************************
  5. * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
  6. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  7. * *
  8. * This program is free software: you can redistribute it and/or modify *
  9. * it under the terms of the GNU General Public License as published by *
  10. * the Free Software Foundation, either version 3 of the License, or *
  11. * (at your option) any later version. *
  12. * *
  13. * This program is distributed in the hope that it will be useful, *
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU General Public License for more details. *
  17. * *
  18. * To view a copy of the GNU General Public License, go to the following *
  19. * location: <http://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "../compat.h"
  22. #if ENABLED(TOUCH_UI_FTDI_EVE)
  23. #include "media_file_reader.h"
  24. #if ENABLED(SDSUPPORT)
  25. bool MediaFileReader::open(const char* filename) {
  26. card.init(SPI_SPEED, SDSS);
  27. volume.init(&card);
  28. root.openRoot(&volume);
  29. return file.open(&root, filename, O_READ);
  30. }
  31. int16_t MediaFileReader::read(void *buff, size_t bytes) {
  32. return file.read(buff, bytes);
  33. }
  34. void MediaFileReader::close() {
  35. file.close();
  36. }
  37. uint32_t MediaFileReader::size() {
  38. return file.fileSize();
  39. }
  40. void MediaFileReader::rewind() {
  41. file.rewind();
  42. }
  43. int16_t MediaFileReader::read(void *obj, void *buff, size_t bytes) {
  44. return reinterpret_cast<MediaFileReader*>(obj)->read(buff, bytes);
  45. }
  46. #else
  47. bool MediaFileReader::open(const char*) {return -1;}
  48. int16_t MediaFileReader::read(void *, size_t) {return 0;}
  49. void MediaFileReader::close() {}
  50. uint32_t MediaFileReader::size() {return 0;}
  51. void MediaFileReader::rewind() {}
  52. int16_t MediaFileReader::read(void *, void *, size_t) {return 0;}
  53. #endif
  54. #endif // TOUCH_UI_FTDI_EVE