Version 3 of firmware looks quite different; this appears to be the code part I'll have to modify to get analog pins logged:
//Start recording incoming characters
while(escape_chars_received < setting_max_escape_character) {
uint8_t n = NewSerial.read(localBuffer, sizeof(localBuffer)); //Read characters from global buffer into the local buffer
if (n > 0) {
if (localBuffer[0] == setting_escape_character) {
escape_chars_received++;
//Scan the local buffer for esacape characters
for(checkedSpot = 1 ; checkedSpot < n ; checkedSpot++) {
if(localBuffer[checkedSpot] == setting_escape_character) {
escape_chars_received++;
//If n is greater than 3 there's a chance here where we receive three esc chars
// and then reset the variable: 26 26 26 A T + would not escape correctly
if(escape_chars_received == setting_max_escape_character) break;
}
else
escape_chars_received = 0;
}
}
file.write(localBuffer, n); //Record the buffer to the card
STAT1_PORT ^= (1<<STAT1); //Toggle the STAT1 LED each time we record the buffer
idleTime = 0; //We have characters so reset the idleTime
if(timeSinceLastRecord++ > maxLoops) { //This will force a sync approximately every second
timeSinceLastRecord = 0;
file.sync(); //Sync the card
}
}
else if(idleTime > MAX_IDLE_TIME_MSEC) { //If we haven't received any characters in 2s, goto sleep
file.sync(); //Sync the card before we go to sleep
STAT1_PORT &= ~(1<<STAT1); //Turn off stat LED to save power
power_timer0_disable(); //Shut down peripherals we don't need
power_spi_disable();
sleep_mode(); //Stop everything and go to sleep. Wake up if serial character received
power_spi_enable(); //After wake up, power up peripherals
power_timer0_enable();
escape_chars_received = 0; // Clear the esc flag as it has timed out
idleTime = 0; //A received character woke us up to reset the idleTime
}
else {
idleTime++;
delay(1); //Burn 1ms waiting for new characters coming in
}
}