Clean up gfReset()

This commit is contained in:
D.R.racer 2021-01-27 14:12:11 +01:00
parent b2cf5b7b6c
commit d1fd5a555f
2 changed files with 5 additions and 10 deletions

View File

@ -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){

View File

@ -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);