Check-in [a2782097ce]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Correct several bugs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:a2782097cecd6b35054e97272682d800da51365b1e802f62cdc4884b85d5cca5
User & Date: gwlester 2018-02-08 05:50:36
Context
2018-02-09
22:38
General configration section of dIMU class and Multisenor example working. check-in: cbe12efdf4 user: gwlester tags: trunk
2018-02-08
05:50
Correct several bugs. check-in: a2782097ce user: gwlester tags: trunk
2018-02-07
21:53
Reorganize prohect directories. check-in: 1ae81b7c1b user: gwlester tags: trunk
Changes

Changes to examples/Multisensor_Example.tcl.

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
787
788
789
790
791
792
793
794
795
796
797
798
799

800




801
802
803
804
805
806
807
808
809
810
811
812
813
##
## It utilizes the low leve bno055 package.
##

lappend atuo_path [file dirname [info script]] [pwd]
::tcl::tm::path add [file dirname [info script]] [pwd]

#package require dimu
proc dimu {args} {return}

##
## These bytes set the full scale range of the gyroscope.
## it is important to define full_scale_range.  Values are:
##      0x00 - 250 dps.  Full scale range.
##      0x10 - 500 dps.  Full scale range.
##      0x30 - 2000 dps.  Full scale range.
................................................................................
        amg             "Accelerometer, Gyroscope and Magnetometer Only"
        imu             "Inertial Measurement Unit"
        compass         "Compass"
        m4g             "Magnet for Gyroscope"
        ndof_fmc_off    "9 Degrees of Freedom -- Fast Magnetometer Calibration Off"
        ndof            "9 Degrees of Freedom -- Fast Magnetometer Calibration On"
    }
    power,map,labelframe {
        normal          "Normal"
        low             "Low"
        suspend         "Suspend"
    }
}

foreach key [array names UI "*,map,label"] {
................................................................................

proc LoadCurrentConfiguration {} {
    global UI
    global Configuration
    global CurrentValue
    
    foreach optionValue [$CurrentValue(handle) configure] {
        lassign $optionalValue option default value
        ##
        ## Remove the leading -
        ##
        set index [string range $option 1 end]
        if {[info exists UI($index,map,label)]} {

            set value $UI($index,map,label)




        }
        set Configuration($index) $value
    }
}

##
## Main Body
##
set CurrentValue(handle) [dimu new]
LoadCurrentConfiguration
CreateGui
trace add variable Configuration write ConfigurationChange
trace add variable ::Configuration(operation) write ChangeMode







|
<







 







|







 







|





>
|
>
>
>
>













16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
...
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
##
## It utilizes the low leve bno055 package.
##

lappend atuo_path [file dirname [info script]] [pwd]
::tcl::tm::path add [file dirname [info script]] [pwd]

package require dimu


##
## These bytes set the full scale range of the gyroscope.
## it is important to define full_scale_range.  Values are:
##      0x00 - 250 dps.  Full scale range.
##      0x10 - 500 dps.  Full scale range.
##      0x30 - 2000 dps.  Full scale range.
................................................................................
        amg             "Accelerometer, Gyroscope and Magnetometer Only"
        imu             "Inertial Measurement Unit"
        compass         "Compass"
        m4g             "Magnet for Gyroscope"
        ndof_fmc_off    "9 Degrees of Freedom -- Fast Magnetometer Calibration Off"
        ndof            "9 Degrees of Freedom -- Fast Magnetometer Calibration On"
    }
    power,map,label     {
        normal          "Normal"
        low             "Low"
        suspend         "Suspend"
    }
}

foreach key [array names UI "*,map,label"] {
................................................................................

proc LoadCurrentConfiguration {} {
    global UI
    global Configuration
    global CurrentValue
    
    foreach optionValue [$CurrentValue(handle) configure] {
        lassign $optionValue option default value
        ##
        ## Remove the leading -
        ##
        set index [string range $option 1 end]
        if {[info exists UI($index,map,label)]} {
            try {
                set value [dict get $UI($index,map,label) $value]
            } on error {errMsg errInfo} {
                puts "Error: $errMsg"
                puts "Error on $index for '$value'"
            }
        }
        set Configuration($index) $value
    }
}

##
## Main Body
##
set CurrentValue(handle) [dimu new]
LoadCurrentConfiguration
CreateGui
trace add variable Configuration write ConfigurationChange
trace add variable ::Configuration(operation) write ChangeMode

Changes to src/bno055/bno055.tcl.

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
...
548
549
550
551
552
553
554
555

556
557
558
559
560
561
562
563
        gyr,units       {0 0x3b b 1:1}
        eul,units       {0 0x3b b 2:2}
        temp,units      {0 0x3b b 4:4}
        format,opt      {0 0x3b b 7:7}
        operMode        {0 0x3d b 3:0}
        powerMode       {0 0x3e b 1:0}
        runSelfTest     {0 0x3f b 0:0}
        sytemReset      {0 0x3f b 5:5}
        resetInt        {0 0x3f b 6:6}
        clockSource     {0 0x3f b 7:7}
        tempSource      {0 0x40 b 1:0}
        remap,x,value   {0 0x41 b 1:0}
        remap,y,value   {0 0x41 b 3:2}
        remap,z,value   {0 0x41 b 5:4}
        remap,x,sign    {0 0x42 b 0:0}
................................................................................
    SymDef ACC_SLEEP_MODE EVENT 0
    SymDef ACC_SLEEP_MODE EQUIDISTANT 1
    set value 0
    foreach item {0.5MS 0.5MS 0.5MS 0.5MS 0.5MS 0.5MS 1MS 2MS 4MS 6MS 10MS 25MS 50MS 100MS 500MS 1000MS} {
        SymDef ACC_SLEEP_DURR $item $value
        incr value
    }
    set value 1
    foreach item {4MS 5MS 8MS 10MS 15MS 20MS 40MS} {
        SymDef GRY_AUTOSLP_DURR $item $value
        incr value
    }
    set value 0
    foreach item {4MS 5MS 8MS 10MS 15MS 18MS 20MS} {
        SymDef GRY_SLEEP_DURR $item $value
        incr value
................................................................................
        }

        return $result
    }

    proc validateHandle {handle} {
        foreach register {main,chipId acc,chipId mag,chipId gyro,chipId} expectedValue {0xa0 0xfb 0x32 0x0f} {
            if {[readRegister $handle $register] != $expectedValue} {

                throw [list NOTBNO055 $handle] "The handle, '$handle', does not refrence a bno055"
            }
        }
    }


    namespace ensemble create -subcommands {
        getValue







|







 







|
|







 







|
>
|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
        gyr,units       {0 0x3b b 1:1}
        eul,units       {0 0x3b b 2:2}
        temp,units      {0 0x3b b 4:4}
        format,opt      {0 0x3b b 7:7}
        operMode        {0 0x3d b 3:0}
        powerMode       {0 0x3e b 1:0}
        runSelfTest     {0 0x3f b 0:0}
        systemReset     {0 0x3f b 5:5}
        resetInt        {0 0x3f b 6:6}
        clockSource     {0 0x3f b 7:7}
        tempSource      {0 0x40 b 1:0}
        remap,x,value   {0 0x41 b 1:0}
        remap,y,value   {0 0x41 b 3:2}
        remap,z,value   {0 0x41 b 5:4}
        remap,x,sign    {0 0x42 b 0:0}
................................................................................
    SymDef ACC_SLEEP_MODE EVENT 0
    SymDef ACC_SLEEP_MODE EQUIDISTANT 1
    set value 0
    foreach item {0.5MS 0.5MS 0.5MS 0.5MS 0.5MS 0.5MS 1MS 2MS 4MS 6MS 10MS 25MS 50MS 100MS 500MS 1000MS} {
        SymDef ACC_SLEEP_DURR $item $value
        incr value
    }
    set value 0
    foreach item {"Not Allowed" 4MS 5MS 8MS 10MS 15MS 20MS 40MS} {
        SymDef GRY_AUTOSLP_DURR $item $value
        incr value
    }
    set value 0
    foreach item {4MS 5MS 8MS 10MS 15MS 18MS 20MS} {
        SymDef GRY_SLEEP_DURR $item $value
        incr value
................................................................................
        }

        return $result
    }

    proc validateHandle {handle} {
        foreach register {main,chipId acc,chipId mag,chipId gyro,chipId} expectedValue {0xa0 0xfb 0x32 0x0f} {
            set receivedValue [readRegister $handle $register]
            if {$receivedValue != $expectedValue} {
                throw [list NOTBNO055 $handle] "The handle, '$handle', does not refrence a bno055. For register $register expected '$expectedValue' but received '$receivedValue'"
            }
        }
    }


    namespace ensemble create -subcommands {
        getValue

Changes to src/dimu/dimu.tcl.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135



136
137
138
139
140
141
142
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
	self method init {} {
		variable HardwiredSettings
		variable ConfigurationRegisters
		variable OptionDef

		set OptionDef {
            -bus        	{-default 1}
			-power          {-register pwrMode -allowed {normal low suspend} -type PWR_MODE}
			-operation		{-register operMode -immediate yes -allowed {configmode acconly magonly gyroonly accmag accgyro maggyro amg imu compass m4g ndof_fmc_off ndof} -type OPER_MODE}
            -gryorange		{-register gyr,range -allowed {2000dps 1000dps 500dps 250dps 125dps} -type GRY_RANGE}
            -gryobandwidth	{-register gyr,bandwidth -allowed {523hz 230hz 116hz 64hz 47hz 32hz 23hz 12hz} -type GRY_BANDWIDTH}
            -gyropowermode	{-register gyr,pwrMode -allowed {normal fast_up deep_suspend suspend advanced_powersave} -type GRY_POWER_MODE}
			-gyrounits		{-register gry,units -allowed {dps rps} -type GRY_UNIT}
			-gryoautosleep	{-register gyr,autoSlpDur -allowed {4MS 5MS 8MS 10MS 15MS 20MS 40MS} -type GRY_AUTOSLP_DURR}
			-gryosleep		{-register gyr,sleepDur -allowed {4MS 5MS 8MS 10MS 15MS 18MS 20MS} -type GRY_SLEEP_DURR}
			-gryoawake		{-register gyr,am,durr -allowed {8samples 16samples 32samples 64samples} -type GYR_AWAKE_DURR}
			-gryoslope		{-register gyr,am,slope}
			-gryoxoffset	{-register gyr,x,offset}
			-gryoyoffset	{-register gyr,y,offset}
			-gryozoffset	{-register gyr,z,offset}
................................................................................
		}

		set HardwiredSettings {
			address 0x28
		}

        set ConfigurationRegisters {
            main,chipId
            acc,chipId
            mag,chipId
            gyro,chipId
            sw,rev
            bl,rev
            mag,cab,status
            acc,cab,status
            gyr,cab,status
            sys,cab,status
            acc,selftest
            mag,selftest
            gyr,selftest
            mcu,selftest
            sys,clk,status
            sys,status
            sys,error
            acc,units
            gyr,units
            eul,units
            temp,units
            format,opt
            operMode
            powerMode
            clockSource
            tempSource
            remap,x,value
            remap,y,value
            remap,z,value
            remap,x,sign
            remap,y,sign
            remap,z,sign
            acc,x,offset
            acc,y,offset
            acc,z,offset
            mag,x,offset
            mag,y,offset
            mag,z,offset
            gyr,x,offset
            gyr,y,offset
            gyr,z,offset
            acc,radius
            mag,radius
            acc,range
            acc,bandwidth
            acc,pwrMode
            mag,rate
            mag,operMode
            mag,pwrMode
            gyr,range
            gyr,bandwidth
            gyr,pwrMode
            acc,sleepMode
            acc,sleepDur
            gyr,am,intMask
            gyr,hiR,intMask
            acc,hiG,intMask
            acc,am,intMask
            acc,nm,intMask
            gyr,am,intEnab
            gyr,hiR,intEnab
            acc,hiG,intEnab
            acc,am,intEnab
            acc,nm,intEnab
            acc,am,thresh
            acc,am,dur
            acc,an,x
            acc,an,y
            acc,an,z
            acc,hi,x
            acc,hi,y
            acc,hi,z
            acc,hi,thresh
            acc,hi,durr
            acc,nm,thresh
            acc,smnm,enab
            acc,smnm,durr
            gyr,am,x,enab
            gyr,am,y,enab
            gyr,am,z,enab
            gyr,hr,x,enab
            gyr,hr,y,enab
            gyr,hr,z,enab
            gyr,am,filter
            gyr,hr,filter
            gyr,hr,x,thres
            gyr,hr,x,hyst
            gyr,hr,x,durr
            gyr,hr,y,thres
            gyr,hr,y,hyst
            gyr,hr,y,durr
            gyr,hr,z,thres
            gyr,hr,z,hyst
            gyr,hr,z,durr
            gyr,am,slope
            gyr,am,durr
            uniqueId



        }

		::oo::objdefine [self] deletemethod init
		

	}

................................................................................

        if {[dict exists $instanceInfo options $option]} {
            return [dict get $instanceInfo options $option]
        } elseif {[dict exists $instanceInfo legalOption $option]} {
			set optionDict [dict get $OptionDef $option]
			set register [dict get $optionDict -register]
			set value [dict get $currentConfiguration $register]
			if {[dict exists $OptionDef -type]} {
				set type [dict get $OptionDef -type]
				set value [bno055 getSymbol $type $value]
			}
			return $value
        } else {
            set legalOptions [dict keys [dict get $instanceInfo legalOption]]
            throw [list TK LOOKUP OPTION $option] "unknown option \"$option\" -- legal options are: [join $legalOptions {,}]"
        }
    }
................................................................................
        set argLen [llength $args]
        if {$argLen == 0} {
			set returnList {}
			foreach option [lsort -dictionary [dict keys [dict get $instanceInfo legalOption]]] {
				##
				## Order is optionName defaultValue currentValue
				##
				if {[dict exists $instanceInfo options]} {
					set itemList [list $option [dict get $instanceInfo defaults $option] [dict get $instanceInfo options $option]]
				} else {
					set optionDict [dict get $OptionDef $option]
					set register [dict get $optionDict -register]
					set value [dict get $currentConfiguration $register]
					if {[dict exists $OptionDef -type]} {
						set type [dict get $OptionDef -type]
						set value [bno055 getSymbol $type $value]
					}
					set itemList [list $option {} $value]
				}

				lappend returnList $itemList
			}
            return $returnList







|




|







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>







 







|
|
|







 







|





|
|
|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
...
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
	self method init {} {
		variable HardwiredSettings
		variable ConfigurationRegisters
		variable OptionDef

		set OptionDef {
            -bus        	{-default 1}
			-power          {-register powerMode -allowed {normal low suspend} -type PWR_MODE}
			-operation		{-register operMode -immediate yes -allowed {configmode acconly magonly gyroonly accmag accgyro maggyro amg imu compass m4g ndof_fmc_off ndof} -type OPER_MODE}
            -gryorange		{-register gyr,range -allowed {2000dps 1000dps 500dps 250dps 125dps} -type GRY_RANGE}
            -gryobandwidth	{-register gyr,bandwidth -allowed {523hz 230hz 116hz 64hz 47hz 32hz 23hz 12hz} -type GRY_BANDWIDTH}
            -gyropowermode	{-register gyr,pwrMode -allowed {normal fast_up deep_suspend suspend advanced_powersave} -type GRY_POWER_MODE}
			-gyrounits		{-register gyr,units -allowed {dps rps} -type GRY_UNIT}
			-gryoautosleep	{-register gyr,autoSlpDur -allowed {4MS 5MS 8MS 10MS 15MS 20MS 40MS} -type GRY_AUTOSLP_DURR}
			-gryosleep		{-register gyr,sleepDur -allowed {4MS 5MS 8MS 10MS 15MS 18MS 20MS} -type GRY_SLEEP_DURR}
			-gryoawake		{-register gyr,am,durr -allowed {8samples 16samples 32samples 64samples} -type GYR_AWAKE_DURR}
			-gryoslope		{-register gyr,am,slope}
			-gryoxoffset	{-register gyr,x,offset}
			-gryoyoffset	{-register gyr,y,offset}
			-gryozoffset	{-register gyr,z,offset}
................................................................................
		}

		set HardwiredSettings {
			address 0x28
		}

        set ConfigurationRegisters {
			acc,am,dur
			acc,am,intEnab
			acc,am,intMask
			acc,am,thresh
			acc,an,x
			acc,an,y
			acc,an,z
			acc,bandwidth
			acc,cab,status
			acc,chipId
			acc,hi,durr
			acc,hi,thresh
			acc,hi,x
			acc,hi,y
			acc,hi,z
			acc,hiG,intEnab
			acc,hiG,intMask
			acc,nm,intEnab
			acc,nm,intMask
			acc,nm,thresh
			acc,pwrMode
			acc,radius
			acc,range
			acc,selftest
			acc,sleepDur
			acc,sleepMode
			acc,smnm,durr
			acc,smnm,enab
			acc,units
			acc,x,offset
			acc,y,offset
			acc,z,offset
			bl,rev
			clockSource
			eul,units
			format,opt
			gyr,am,durr
			gyr,am,filter
			gyr,am,intEnab
			gyr,am,intMask
			gyr,am,slope
			gyr,am,x,enab
			gyr,am,y,enab
			gyr,am,z,enab
			gyr,autoSlpDur
			gyr,bandwidth
			gyr,cab,status
			gyr,hiR,intEnab
			gyr,hiR,intMask
			gyr,hr,filter
			gyr,hr,x,durr
			gyr,hr,x,enab
			gyr,hr,x,hyst
			gyr,hr,x,thres
			gyr,hr,y,durr
			gyr,hr,y,enab
			gyr,hr,y,hyst
			gyr,hr,y,thres
			gyr,hr,z,durr
			gyr,hr,z,enab
			gyr,hr,z,hyst
			gyr,hr,z,thres
			gyr,pwrMode
			gyr,range
			gyr,selftest
			gyr,units
			gyr,x,offset
			gyr,y,offset
			gyr,z,offset
			gyr,sleepDur
			gyr,units
			gyro,chipId
			mag,cab,status
			mag,chipId
			mag,operMode
			mag,pwrMode
			mag,radius
			mag,rate
			mag,selftest
			mag,x,offset
			mag,y,offset
			mag,z,offset
			main,chipId
			mcu,selftest
			operMode
			powerMode
			remap,x,sign
			remap,x,value
			remap,y,sign
			remap,y,value
			remap,z,sign
			remap,z,value
			sw,rev
			sys,cab,status
			sys,clk,status
			sys,error
			sys,status
			temp,units
			tempSource
			uniqueId
        }

		::oo::objdefine [self] deletemethod init
		

	}

................................................................................

        if {[dict exists $instanceInfo options $option]} {
            return [dict get $instanceInfo options $option]
        } elseif {[dict exists $instanceInfo legalOption $option]} {
			set optionDict [dict get $OptionDef $option]
			set register [dict get $optionDict -register]
			set value [dict get $currentConfiguration $register]
			if {[dict exists $optionDict -type]} {
				set type [dict get $optionDict -type]
				set value [string tolower [bno055 getShortSymbol $type $value]]
			}
			return $value
        } else {
            set legalOptions [dict keys [dict get $instanceInfo legalOption]]
            throw [list TK LOOKUP OPTION $option] "unknown option \"$option\" -- legal options are: [join $legalOptions {,}]"
        }
    }
................................................................................
        set argLen [llength $args]
        if {$argLen == 0} {
			set returnList {}
			foreach option [lsort -dictionary [dict keys [dict get $instanceInfo legalOption]]] {
				##
				## Order is optionName defaultValue currentValue
				##
				if {[dict exists $instanceInfo options $option]} {
					set itemList [list $option [dict get $instanceInfo defaults $option] [dict get $instanceInfo options $option]]
				} else {
					set optionDict [dict get $OptionDef $option]
					set register [dict get $optionDict -register]
					set value [dict get $currentConfiguration $register]
					if {[dict exists $optionDict -type]} {
						set type [dict get $optionDict -type]
						set value [string tolower [bno055 getShortSymbol $type $value]]
					}
					set itemList [list $option {} $value]
				}

				lappend returnList $itemList
			}
            return $returnList