Næþ'n Lasseter
/
DMX
DMX DeBUG clone source code
memory.c@0:64cb39e64128, 2011-12-06 (annotated)
- Committer:
- User_4574
- Date:
- Tue Dec 06 22:31:21 2011 +0000
- Revision:
- 0:64cb39e64128
DRAFT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
User_4574 | 0:64cb39e64128 | 1 | #include "mbed.h" |
User_4574 | 0:64cb39e64128 | 2 | #include "iface.h" |
User_4574 | 0:64cb39e64128 | 3 | #include "memory.h" |
User_4574 | 0:64cb39e64128 | 4 | |
User_4574 | 0:64cb39e64128 | 5 | LocalFileSystem local("local"); |
User_4574 | 0:64cb39e64128 | 6 | |
User_4574 | 0:64cb39e64128 | 7 | extern int channelPointer; |
User_4574 | 0:64cb39e64128 | 8 | extern char* channelData; |
User_4574 | 0:64cb39e64128 | 9 | |
User_4574 | 0:64cb39e64128 | 10 | void saveMemory() { |
User_4574 | 0:64cb39e64128 | 11 | int chan; |
User_4574 | 0:64cb39e64128 | 12 | FILE* mem = fopen("/local/memory.txt", "w"); |
User_4574 | 0:64cb39e64128 | 13 | for(chan = 0; chan < CHANNELCOUNT; chan++) |
User_4574 | 0:64cb39e64128 | 14 | if(channelData[chan]) |
User_4574 | 0:64cb39e64128 | 15 | fprintf(mem, "%03d %03hhd\r\n", chan, channelData[chan]); |
User_4574 | 0:64cb39e64128 | 16 | fclose(mem); |
User_4574 | 0:64cb39e64128 | 17 | } |
User_4574 | 0:64cb39e64128 | 18 | |
User_4574 | 0:64cb39e64128 | 19 | void loadMemory() { |
User_4574 | 0:64cb39e64128 | 20 | int chan; |
User_4574 | 0:64cb39e64128 | 21 | char val; |
User_4574 | 0:64cb39e64128 | 22 | for(chan = 0; chan < CHANNELCOUNT; chan++) channelData[channelPointer] = 0; |
User_4574 | 0:64cb39e64128 | 23 | FILE* mem = fopen("/local/memory.txt", "r"); |
User_4574 | 0:64cb39e64128 | 24 | while(fscanf(mem, "%d %hhd ", &chan, &val) != EOF) channelData[chan] = val; |
User_4574 | 0:64cb39e64128 | 25 | fclose(mem); |
User_4574 | 0:64cb39e64128 | 26 | channelPointer = 0; |
User_4574 | 0:64cb39e64128 | 27 | } |