• I've played with this a bit more....

    echo(1);
    
    var fs=require("fs");
    
    fs.readdir();
    
    fs.appendFile("before.txt","testtext");
    
    setTimeout("lcd();",1000);
    
    setTimeout('fs.appendFile("after.txt","testtext");',5000);
    
    var g=0;
    
    function lcd() {
      g=require('PCD8544').connect(SPI2,C4,C5,A3, function(){g.clear();g.drawString('LCD OK',0,0);g.flip();});
    }
    
    

    In this case, before.txt will be created just fine, and the file will have the correct content, and fs.appendFile() returned success - great.

    But the call after lcd() will fail - the file after.txt is created, but is empty.

    A few other things I've found:

    If you try to call appendFile() after setting up the LCD, on the same file as you just wrote to before setting up the LCD, it will report success, but nothing is appended to the file.

    You mentioned that the the CS pin might get left on, which I take to mean that the pin is left grounded when it shouldn't be (it goes low to select that device, right?). I assumed that the CS pin for SD card was D2, and tried digitalWrite(D2,1); before the call to lcd(); - but it didn't make any difference. Of course, I'm not certain I was doing the right thing here anyway.

About

Avatar for DrAzzy @DrAzzy started