Structured Array


Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,632

    Default Structured Array

    I have been working on an idea for structured arrays with named elements eg
    say i have a battery charger that can charge multiple batteries
    each battery has these properties voltage[byte] current[word] pwm_drive[word] current_limit[word] status[byte]
    thats 8 bytes per battery
    ;define structure batteries for pbp
    struct_items con 10 ;10 index size ie number of batteries
    struct_sz_of con 8 ;total 8 bytes / index

    ;elements byte offset of each element
    volts CON 0;byte
    amps CON 1;word
    drive CON 3;word
    climit con 5;word
    stat con 7;byte
    reserve our memory
    battery var byte[ struct_items*struct_sz_of ]
    some user commands
    USERCOMMAND "ARRAY_GET" ;{array,}index,element{,var}
    USERCOMMAND "ARRAY_PUT" ;index,element,DATA

    we now have some nice commands ,j=byte test=word a_index=byte
    array_get 2,DRIVE
    array_put 2,DRIVE,1234
    array_get 3,AMPS
    a_index=1
    array_get a_index,volts,j
    array_get a_index,drive,test
    even multiple arrays
    array_get battery,a_index,volts,j
    this is a work in progress ,whats lacking is a way to tell the usercommand the "size" of our elements as they are accessed .
    at present the macros are customised to suit
    Attached Files Attached Files

Similar Threads

  1. Copying Array to Array
    By vamtbrider in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th April 2010, 01:12
  2. Array and IF - THEN
    By Gusse in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 25th February 2010, 12:52
  3. Custom array of ports using array?
    By blainecf in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 18th June 2006, 01:43
  4. Array
    By ripmax in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th March 2006, 22:21
  5. Word array behaving like byte array.... wierd
    By forgie in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd August 2005, 15:43

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts