Limit the Uno RAM change to flash-stored Serial messages

Keep only the eight F() wrappers in shield_sdlog so RAM improvements can be reviewed one at a time. Defer the other memory changes. This step saves 90 bytes on Uno, leaving 83 bytes; compilation passes but runtime SD logging still needs more RAM.

Co-authored-by: Limor Fried <ladyada@users.noreply.github.com>
This commit is contained in:
ladyadaandLimor Fried committed 2026-09-15 10:17:23 -04:00
1 parent 957153e23c
commit 7c76916d9f
5 files changed
+100 -172

No files matched your search

+7 -9
View File
@@ -74,8 +74,6 @@ void error(uint8_t errno) {
}
}
// Keep SD initialization buffers off the stack once logging starts.
void setup() __attribute__((noinline));
void setup() {
// for Leonardos, if you want to debug SD issues, uncomment this line
// to see serial output
@@ -95,8 +93,8 @@ void setup() {
Serial.println(F("Card init. failed!"));
error(2);
}
char filename[12];
strcpy_P(filename, PSTR("GPSLOG00.TXT"));
char filename[15];
strcpy(filename, "GPSLOG00.TXT");
for (uint8_t i = 0; i < 100; i++) {
filename[6] = '0' + i/10;
filename[7] = '0' + i%10;
@@ -119,16 +117,16 @@ void setup() {
GPS.begin(9600);
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
GPS.sendCommand(F(PMTK_SET_NMEA_OUTPUT_RMCGGA));
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
// uncomment this line to turn on only the "minimum recommended" data
//GPS.sendCommand(F(PMTK_SET_NMEA_OUTPUT_RMCONLY));
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
// For logging data, we don't suggest using anything but either RMC only or RMC+GGA
// to keep the log files at a reasonable size
// Set the update rate
GPS.sendCommand(F(PMTK_SET_NMEA_UPDATE_1HZ)); // 100 millihertz (once every 10 seconds), 1Hz or 5Hz update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 100 millihertz (once every 10 seconds), 1Hz or 5Hz update rate
// Turn off updates on antenna status, if the firmware permits it
GPS.sendCommand(F(PGCMD_NOANTENNA));
GPS.sendCommand(PGCMD_NOANTENNA);
// the nice thing about this code is you can have a timer0 interrupt go off
// every 1 millisecond, and read data from the GPS for you. that makes the
@@ -206,7 +204,7 @@ void loop() {
uint8_t stringsize = strlen(stringptr);
if (stringsize != logfile.write((uint8_t *)stringptr, stringsize)) //write the string to the SD file
error(4);
if (strstr_P(stringptr, PSTR("RMC")) || strstr_P(stringptr, PSTR("GGA"))) logfile.flush();
if (strstr(stringptr, "RMC") || strstr(stringptr, "GGA")) logfile.flush();
Serial.println();
}
}