My code.
Thanks
namespace FEZ_Domino_SD_test_godFather89_
{
public class Program
{
static Thread thread;
static bool running;
static string url = "http://api.thingspeak.com/update";
static string key = "<YourThingSpeakChannelKey>";
static AnalogIn thermometer;
static AnalogIn lightSensor;
static int temp;
static int light;
bool cardLoaded = true;
static int idx;
private static string path;
bool FileOpen = false;
public bool DebugMirror = true;
private static PersistentStorage pStore;
private static VolumeInfo pStoreI;
public static void Main()
{
bool ledState = false;
OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
pStore = new PersistentStorage("SD");
pStore.MountFileSystem();
pStoreI = VolumeInfo.GetVolumes()[0];
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
//path = rootDirectory + @ "\log " + ".csv";
path = rootDirectory + @ "\log" + ".txt";
// Initialize the eblocks
thermometer = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An2);
thermometer.SetLinearScale(-22, 56);
lightSensor = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An3);
lightSensor.SetLinearScale(0, 100);
FileStream fHandle = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
int offset = 0;
const int size = 4096; //4KB buffer
byte[] buffer = new byte[size];
Timer t = new Timer((o) =>
{
int v1 = 10;
int v2 = 20;
buffer[offset++] = (byte)((v1 >> (0 * 8)) & 0xFF);
buffer[offset++] = (byte)((v1 >> (1 * 8)) & 0xFF);
buffer[offset++] = (byte)((v1 >> (2 * 8)) & 0xFF);
buffer[offset++] = (byte)((v1 >> (3 * 8)) & 0xFF);
buffer[offset++] = (byte)((v2 >> (0 * 8)) & 0xFF);
buffer[offset++] = (byte)((v2 >> (1 * 8)) & 0xFF);
buffer[offset++] = (byte)((v2 >> (2 * 8)) & 0xFF);
buffer[offset++] = (byte)((v2 >> (3 * 8)) & 0xFF);
if (offset == size)
{
fHandle.Write(buffer, 0, size);
offset = 0;
}
}, null, 0, 10);
Thread.Sleep(Timeout.Infinite);
}
}
}