//--------------------------------------------------------------------------------------------------------------------------------------------------------:
//-- fixed "systemUnits" in source code ---------
//#define  NDRIVESETTINGSUNITS_SYSTEM_NONE  -2
//#define  NDRIVESETTINGSUNITS_SYSTEM_ALL   -1
//#define  NDRIVESETTINGSUNITS_SYSTEM_RAW    0
//#define  NDRIVESETTINGSUNITS_SYSTEM_OSCI   1
//
//-- example "systemUnits" user extensions ------
//SYSTEM_PERCENT                             2
//SYSTEM_SI                                  3
//SYSTEM_HEX                                 4


//
//the optional units for editRead editWrite items is specified by using the "units" field
//- in regid definitions for all occurrances
//- in page definition files for individual override
//
//the actual units applied are selected at runtime by the global variable "systemUnits"
//



//--------------------------------------------------------------------------------------------------------------------------------------------------------:
// variables
// ~~~~~~~~~
//  fixed               speed:      speedRPMmax             updates from 0xCE on connection or change to 0xC8 or 0x59
//                      current:    iDevice                 updates from 0xC6 on connection
//                      current:    current200percent       updates from 0xD9 on connection    { 0xD9 =fn(0xC6, 0xEE) }
//
//  extra (required)    speed:      nMax                    updates from 0xCE in Feedback_include.csv
//                      current:    Adc200                  updates from 0xD9 in Feedback_include.csv
//


//--------------------------------------------------------------------------------------------------------------------------------------------------------:
// special case (has precedence)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// oscilloscope:        units check box takes     system=1,
//                                      otherwise system=0
//
// osciunits=speed      system=0
//                      system=1  unitsName=RPM  decimals=0    conversion="(raw*speedRPMmax)/32767.0"
// osciunits=current    system=0
//                      system=1  unitsName=A    decimals=2    conversion="(raw*iDevice*2.0*sqrt2)/current200percent/10.0"
//
//




units=speedUnit_a       system=0     text=%      decimals=1    fromRaw="(x*100.0)/32767.0"    toRaw="(x*32767.0)/100.0"
units=speedUnit_a       system=1     text=%      decimals=0    fromRaw="(x*100.0)/32767.0"    toRaw="(x*32767.0)/100.0"
units=speedUnit_a       system=2     text=RPM    decimals=0    fromRaw="(x*nMax)/32767.0"     toRaw="(x*32767.0)/nMax"
units=torqueUnit_a      system=0     text=%      decimals=1    fromRaw="(x*150.0)/32767.0"    toRaw="(x*32767.0)/150.0"



units=units_RAW         system=-1

units=speedUnit_RPM     system=-1    text=RPM          inFieldText=" R"   decimals=0   fromRaw="(x*nMax)/32767.0"      toRaw="(x*32767.0)/nMax"
units=currentUnit_AMP   system=-1    text=A            inFieldText=" A"   decimals=1   fromRaw="(x*iDevice*2)/Adc200"  toRaw="(x*Adc200)/(iDevice*2)"

units=speedUnit         system=0
units=speedUnit         system=1     text=RPM          inFieldText=" R"   decimals=0   fromRaw="(x*nMax)/32767.0"      toRaw="(x*32767.0)/nMax"
units=speedUnit         system=2     text=%            inFieldText=" %"   decimals=1   fromRaw="(x*100.0)/32767.0"     toRaw="(x*32767.0)/100.0"
units=speedUnit         system=3     text=RPM          inFieldText=" R"   decimals=0   fromRaw="(x*nMax)/32767.0"      toRaw="(x*32767.0)/nMax"
units=speedUnit         system=4     text=hex  isHex=3

units=currentUnit       system=0
units=currentUnit       system=1     text=A            inFieldText=" A"   decimals=1   fromRaw="(x*iDevice*2*1.414)/Adc200"  toRaw="(x*Adc200)/(iDevice*2*1.414)"
units=currentUnit       system=2     text=%            inFieldText=" %"   decimals=1   fromRaw="(x*100.0)/32767.0"     toRaw="(x*32767.0)/100.0"
units=currentUnit       system=4     text=hex  isHex=3
units=currentUnit       system=-1    text=A            inFieldText=" A"   decimals=1   fromRaw="(x*iDevice*2)/Adc200"  toRaw="(x*Adc200)/(iDevice*2)"

units=torqueUnit        system=0     text=tqraw
units=torqueUnit        system=1;2   text=tq%          inFieldText=" %"   decimals=1   fromRaw="(x*150.0)/32767.0"     toRaw="(x*32767.0)/150.0"
units=torqueUnit        system=4     text=hex  isHex=3
units=torqueUnit        system=-1    text=tq?                             decimals=1   fromRaw="(x*150.0)/32767.0"     toRaw="(x*32767.0)/150.0"

units=posUnit           system=1;2   text=%            inFieldText=" %"   decimals=1   fromRaw="(x*150.0)/32767.0"     toRaw="(x*32767.0)/150.0"

units=tempUnit          system=1;2   text=%            inFieldText=" %"   decimals=1   fromRaw="(x*150.0)/32767.0"     toRaw="(x*32767.0)/150.0"

units=voltUnit          system=1;2   text=%            inFieldText=" %"   decimals=1   fromRaw="(x*150.0)/32767.0"     toRaw="(x*32767.0)/150.0"

units=timeUnit          system=1;2   text=%            inFieldText=" %"   decimals=1   fromRaw="(x*150.0)/32767.0"     toRaw="(x*32767.0)/150.0"



//--------------------------------------------------------------------------------------------------------------------------------------------------------:

units=unsigned16        system=-1    text=u16               fromRaw="(x<0)*65536+x"
units=signed16          system=-1    text=i16               fromRaw="(x)"
units=hex16             system=-1    text=h16    isHex=3    fromRaw="x & 0xFFFF"

units=decimal           system=-1    text=dec
units=hex               system=-1    text=hex    isHex=3

units=bit0              system=-1    text=b0                fromRaw="(x>>0)  &   0x01"
units=bit1              system=-1    text=b1                fromRaw="(x>>1)  &   0x01"
units=bit2              system=-1    text=b2                fromRaw="(x>>2)  &   0x01"
units=bit3              system=-1    text=b3                fromRaw="(x>>3)  &   0x01"
units=bit4              system=-1    text=b4                fromRaw="(x>>4)  &   0x01"
units=bit5              system=-1    text=b5                fromRaw="(x>>5)  &   0x01"
units=bit6              system=-1    text=b6                fromRaw="(x>>6)  &   0x01"
units=bit7              system=-1    text=b7                fromRaw="(x>>7)  &   0x01"
units=bit8              system=-1    text=b8                fromRaw="(x>>8)  &   0x01"
units=bit9              system=-1    text=b9                fromRaw="(x>>9)  &   0x01"
units=bit10             system=-1    text=b10               fromRaw="(x>>10) &   0x01"
units=bit11             system=-1    text=b11               fromRaw="(x>>11) &   0x01"
units=bit12             system=-1    text=b12               fromRaw="(x>>12) &   0x01"
units=bit13             system=-1    text=b13               fromRaw="(x>>13) &   0x01"
units=bit14             system=-1    text=b14               fromRaw="(x>>14) &   0x01"
units=bit15             system=-1    text=b15               fromRaw="(x>>15) &   0x01"

units=nibble0           system=-1    text=n0     isHex=3    fromRaw="(x>>0)  &   0x0f"
units=nibble1           system=-1    text=n1     isHex=3    fromRaw="(x>>4)  &   0x0f"
units=nibble2           system=-1    text=n2     isHex=3    fromRaw="(x>>8)  &   0x0f"
units=nibble3           system=-1    text=n3     isHex=3    fromRaw="(x>>12) &   0x0f"

units=byte0             system=-1    text=by0    isHex=3    fromRaw="(x>>0)  & 0x00ff"
units=byte1             system=-1    text=by1    isHex=3    fromRaw="(x>>8)  & 0x00ff"


//-----------   combination lists   ---------------------------------------

unitsList=bits16List    bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7,bit8,bit9,bit10,bit11,bit12,bit13,bit14,bit15
unitsList=nibbles16List nibble0,nibble1,nibble2,nibble3
unitsList=bytes16List   byte0,byte1
unitsList=hex16List     decimal,hex
unitsList=map16List     decimal,hex,bits16List,nibbles16List,bytes16List

// usage: units=map16List unitsLow=map16List unitsHigh=map16List

//--------------------------------------------------------------------------------------------------------------------------------------------------------:
