Go Down

Topic: Sketch too big!!! First time this has happened to me. (Read 399 times) previous topic - next topic

jerseyguy1996

This little block of code:

Code: [Select]
//    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?
Arduino Uno;
Mega328

johnwasser

#1
Apr 07, 2013, 10:48 pm Last Edit: Apr 07, 2013, 10:50 pm by johnwasser Reason: 1
sprintf() is large because it has to incorporate a scripting language.  Try using more primitive operations like strcpy().

Code: [Select]

       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);
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

jerseyguy1996

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy