Convert autostart_atmillis to ShortTimer

Saves 34 bytes of flash and 1 byte of SRAM
This commit is contained in:
Guðni Már Gilbert 2021-08-26 20:49:19 +00:00
parent 762a5db125
commit a1abd094dd
2 changed files with 3 additions and 4 deletions

View File

@ -25,7 +25,6 @@ CardReader::CardReader()
cardOK = false; cardOK = false;
saving = false; saving = false;
logging = false; logging = false;
autostart_atmillis=0;
workDirDepth = 0; workDirDepth = 0;
file_subcall_ctr=0; file_subcall_ctr=0;
memset(workDirParents, 0, sizeof(workDirParents)); memset(workDirParents, 0, sizeof(workDirParents));
@ -39,7 +38,7 @@ CardReader::CardReader()
WRITE(SDPOWER,HIGH); WRITE(SDPOWER,HIGH);
#endif //SDPOWER #endif //SDPOWER
autostart_atmillis=_millis()+5000; autostart_atmillis.start(); // reset timer
} }
char *createFilename(char *buffer,const dir_t &p) //buffer>12characters char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
@ -619,7 +618,7 @@ void CardReader::checkautostart(bool force)
{ {
if(!autostart_stilltocheck) if(!autostart_stilltocheck)
return; return;
if(autostart_atmillis<_millis()) if(autostart_atmillis.expired(5000))
return; return;
} }
autostart_stilltocheck=false; autostart_stilltocheck=false;

View File

@ -130,7 +130,7 @@ private:
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH]; char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
uint32_t filesize; uint32_t filesize;
//int16_t n; //int16_t n;
unsigned long autostart_atmillis; ShortTimer autostart_atmillis;
uint32_t sdpos ; uint32_t sdpos ;
bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.