From d1fd5a555f73889d3869761f826dfa4ce3c766c6 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 27 Jan 2021 14:12:11 +0100 Subject: [PATCH] Clean up gfReset() --- Firmware/SdFile.cpp | 13 ++++--------- Firmware/SdFile.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Firmware/SdFile.cpp b/Firmware/SdFile.cpp index b3dfefe9..5739f45f 100644 --- a/Firmware/SdFile.cpp +++ b/Firmware/SdFile.cpp @@ -34,10 +34,10 @@ SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) { //size=100B bool SdFile::openFilteredGcode(SdBaseFile* dirFile, const char* path){ if( open(dirFile, path, O_READ) ){ - gfReset(0,0); // compute the block to start with if( ! gfComputeNextFileBlock() ) return false; + gfReset(); return true; } else { return false; @@ -50,20 +50,15 @@ bool SdFile::seekSetFilteredGcode(uint32_t pos){ // SERIAL_PROTOCOLLN(pos); if(! seekSet(pos) )return false; if(! gfComputeNextFileBlock() )return false; - gfCachePBegin = vol_->cache()->data; - // reset cache read ptr to its begin - gfCacheP = gfCachePBegin + gfOffset; + gfReset(); return true; } //size=50B -void SdFile::gfReset(uint32_t blk, uint16_t ofs){ - // @@TODO clean up - gfBlock = blk; - gfOffset = ofs; +void SdFile::gfReset(){ gfCachePBegin = vol_->cache()->data; // reset cache read ptr to its begin - gfCacheP = gfCachePBegin; + gfCacheP = gfCachePBegin + gfOffset; } //FORCE_INLINE const uint8_t * find_endl(const uint8_t *p){ diff --git a/Firmware/SdFile.h b/Firmware/SdFile.h index b4c91a7e..a801a228 100644 --- a/Firmware/SdFile.h +++ b/Firmware/SdFile.h @@ -39,7 +39,7 @@ class SdFile : public SdBaseFile/*, public Print*/ { const uint8_t *gfCacheP; uint32_t gfBlock; // remember the current file block to be kept in cache - due to reuse of the memory, the block may fall out a must be read back uint16_t gfOffset; - void gfReset(uint32_t blk, uint16_t ofs); + void gfReset(); bool gfEnsureBlock(); bool gfComputeNextFileBlock(); void gfUpdateCurrentPosition(uint16_t inc);