Pages: [1]   Go Down
Author Topic: Sketch too big!!! First time this has happened to me.  (Read 328 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This little block of code:

Code:
//    if(recording && newReading)
//    {
//    if(strcmp(messageID, "GPGGA") == 0)
//      {
//        char filename[13];
//        sprintf(filename, "%s.txt", date);
//        if(!SD.exists(filename)) Serial.println("Making Directory");
//        File dataFile = SD.open(filename, FILE_WRITE);
//        
//        // if the file is available, write to it:
//        if (dataFile)
//        {
//          dataFile.print(latitude);
//          dataFile.print(",");
//          dataFile.print(longitude);
//          dataFile.print(",");
//          dataFile.println(satsUsed);
//          dataFile.close();
//        }  
//      }
//    }

takes my sketch from 27,444 bytes (just under the 28,672 byte limit for the leonardo) to over 33,000 bytes.  Is there a seriously trimmed down version of the SD library or perhaps the adafruit OLED display library that anyone knows about?
Logged

Arduino Uno;
Mega328

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8933
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sprintf() is large because it has to incorporate a scripting language.  Try using more primitive operations like strcpy().

Code:
       char filename[13];
        strcpy(filename, date);
        strcpy(filename + strlen(date), ".txt");
        if(!SD.exists(filename))
            Serial.println("Making Directory");
        File dataFile = SD.open(filename, FILE_WRITE);
« Last Edit: April 07, 2013, 03:50:07 pm by johnwasser » Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll give that a try....i use sprintf in a couple of places so maybe I can trim some fat there.
Logged

Arduino Uno;
Mega328

Pages: [1]   Go Up
Jump to: