Næþ'n Lasseter
/
DMX
DMX DeBUG clone source code
Diff: memory.c
- Revision:
- 0:64cb39e64128
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memory.c Tue Dec 06 22:31:21 2011 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "iface.h" +#include "memory.h" + +LocalFileSystem local("local"); + +extern int channelPointer; +extern char* channelData; + +void saveMemory() { + int chan; + FILE* mem = fopen("/local/memory.txt", "w"); + for(chan = 0; chan < CHANNELCOUNT; chan++) + if(channelData[chan]) + fprintf(mem, "%03d %03hhd\r\n", chan, channelData[chan]); + fclose(mem); +} + +void loadMemory() { + int chan; + char val; + for(chan = 0; chan < CHANNELCOUNT; chan++) channelData[channelPointer] = 0; + FILE* mem = fopen("/local/memory.txt", "r"); + while(fscanf(mem, "%d %hhd ", &chan, &val) != EOF) channelData[chan] = val; + fclose(mem); + channelPointer = 0; +} \ No newline at end of file