Since PBP does not allow structures(at least I'm not aware of such), we have to be a little creative. This is purely conceptual, UNTESTED code.
Code:NoOfStructures: con 8 ' How many channels (1 struct per channel) StructureSize: con 10 'each is a 10 bytes long structure Ton: con 0 ; len 2b ; declare storage for a word Toff: con 2 ; len 2b Ron: con 4 ; len 2b Roff: con 6 ; len 2b Trigger: con 8 ; len 1b Reset: con 9 ; len 1b ' clear out as many eeprom bytes as we need to save data EEbase Data 0(NoOfStructures*StructureSize) ' This is where we bring out our structure to RAM Information: var byte[StructureSize] ' space for 1 structure Count: var byte ' temporary use counter gr0: var byte ' 8channels*10bytes = 80 max gr1: var byte ' Read the settings for channel gr0 from eeprom GetSettings: gr0 = gr0*SizeOfStructure for count = 0 to StructureSize-1 Read gr0+count, Information+count next return ' Put the settings for channel gr0 back to eeprom PutSettings: gr0 = gr0*SizeOfStructure for count = 0 to StructureSize-1 Write gr0+count, Information+count next return ' Accessing the elements of the structure My_Ton = Information[Ton] My_Toff = Information[Toff] ..... and so on




Bookmarks