Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial GUI design. Still need to design the configuration tab. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: | 199f0f198cc122f6b59ce9323c5577d6ddc4836d21f9e9c39d5040a6f253a6d4 |
User & Date: | gwlester 2018-02-01 00:35:41 |
Context
2018-02-02
| ||
01:58 | Corrected typos. check-in: 519803a9b5 user: gwlester tags: trunk | |
2018-02-01
| ||
00:35 | Initial GUI design. Still need to design the configuration tab. check-in: 199f0f198c user: gwlester tags: trunk | |
2018-01-31
| ||
21:26 | Removed Komodo project. check-in: 14968c8081 user: gwlester tags: trunk | |
Changes
Changes to Multisensor_Example.tcl.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 .. 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 ... 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 ... 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 ... 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 ... 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
## ## 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. ................................................................................ } set i2cbus 1 set dIMUaddress 0x28 set range 2000dps set CurrentValue(x) {0} set CurrentValue(y) {0} set CurrentValue(z) {0} proc StartGyro {handle range} { global GyroValues ## ## Place the dIMU in configuration mode ## ................................................................................ return; } ## ## Gyro: gets a full axis reading, scaled to the full scale reading. Returns ## in degrees per second. ## proc GryoAxisGeading {axis oldValue} { global GyroValues set handle $GyroValues(handle) set intValue [bno055 readRegister $handle gyr,data,$axis] set digits $GyroValues(digits) set decimals $GyroValues(decimals) incr digits $decimals ................................................................................ set newValue [format "%${digits}.${decimals}f" [expr {$intValue / $GyroValues(divisor)}]] if {$newValue != $oldValue && abs($newValue - $oldValue) < $GyroValues(minChange)} { set newValue $oldValue } return $newValue } proc ClearHistory {} { global CurrentValue set CurrentValue(history) {} } proc ReadGyro {} { global GyroValues CurrentValue if {[info exists GyroValues(afterId)]} { after cancel $GyroValues(afterId) } set GyroValues(afterId) [after [expr {$GyroValues(rate) * 10}] ReadGyro] ## ## Read the GYROSCOPE ## set x [GryoAxisGeading x $CurrentValue(x)] set y [GryoAxisGeading y $CurrentValue(y)] set z [GryoAxisGeading z $CurrentValue(z)] if {$x != $CurrentValue(x) || $y != $CurrentValue(y) || $z != $CurrentValue(z) } { LogValues $x $y $z } ................................................................................ set CurrentValue(x) $x set CurrentValue(y) $y set CurrentValue(z) $z return } proc LogValues {x y z} { global GyroValues CurrentValue #if {[info exists GyroValues(logId)]} { # after cancel $GyroValues(logId) #} #set GyroValues(logId) [after [expr {$GyroValues(freq) * 100}] LogValues] set timeStamp [clock format [clock seconds]] .main.history.data insert {} end -values [list $timeStamp $x $y $z] } proc StartReading {} { global i2cbus dIMUaddress range GyroValues if {$dIMUaddress eq {}} { return ................................................................................ ttk::frame .main.prh .main add .main.prh -text {Pitch, Roll and Heading} CreateConfigurationFrame .main.configuration CreateGyroFrame .main.gyroscope CreateAccelerometerFrame .main.accelerometer CreateMagnetometerFrame .main.magnetometer CreateGravityFrame .main. CreateLinearAccelerationFrame .main. CreateQuaternionFrame .main. CreatePitchRollHeadingFrame .main. } proc CreateControlFrame {w} { ttk::label $w.busLbl \ -text {I2C Bus:} ttk::combobox $w.busCMB \ -textvariable ::i2cbus \ -values [list 1] \ -state readonly ttk::label $w.addrLbl \ ................................................................................ -width 6 \ -command StartReading ttk::button $w.buttons.stop \ -state disabled \ -text {Stop} \ -width 6 \ -command StopReading ttk::button $w.buttons.reset \ -text {Clear Log} \ -width 10 \ -command {.main.history.data delete [.main.history.data children {}]} $w.minChangeEnt set $::GyroValues(minChange) grid configure $w.busLbl $w.busCMB $w.addrLbl $w.addrEnt $w.rangeLbl $w.rangeCMB x -padx 2 -sticky ew grid configure $w.rateLbl1 $w.rateEnt $w.rateLbl2 x x x x -padx 2 -sticky ew grid configure $w.numDigitsLbl $w.numDigitsCMB $w.numDecimalsLbl $w.numDecimalsCMB x x x -padx 2 -sticky ew grid configure $w.minChangeLbl1 $w.minChangeEnt $w.minChangeLbl2 x x x x -padx 2 -sticky ew grid configure $w.buttons -columnspan 7 -sticky ew -pady 3 grid configure x $w.buttons.start x $w.buttons.stop x $w.buttons.reset x -sticky ew grid columnconfigure $w.buttons {0 2 4 6} -weight 1 grid columnconfigure $w 6 -weight 1 } proc CreateCurrentReadingsFrame {w} { ttk::label $w.xLabel \ -text {X:} ttk::entry $w.xValue \ -textvariable ::CurrentValue(x) \ -state readonly ttk::label $w.yLabel \ -text {Y:} ttk::entry $w.yValue \ -textvariable ::CurrentValue(y) \ -state readonly ttk::label $w.zLabel \ -text {Z:} ttk::entry $w.zValue \ -textvariable ::CurrentValue(z) \ -state readonly grid configure $w.xLabel $w.xValue $w.yLabel $w.yValue $w.zLabel $w.zValue x -sticky ew -padx 2 -pady 1 grid columnconfigure $w [list $w.xLabel $w.yLabel $w.zLabel] -uniform labels -weight 0 grid columnconfigure $w [list $w.xValue $w.yValue $w.zValue] -uniform values -weight 0 grid columnconfigure $w 6 -weight 1 } proc CreateHistoryFrame {w} { ttk::treeview $w.data \ -xscrollcommand [list $w.hsb set] \ -yscrollcommand [list $w.vsb set] \ -columns {timestamp xaxis yaxis zaxis} \ -displaycolumns {timestamp xaxis yaxis zaxis} \ -show headings \ -selectmode none ttk::scrollbar $w.vsb \ -orient vertical \ -command [list $w.data yview] ttk::scrollbar $w.hsb \ -orient horizontal \ -command [list $w.data xview] foreach column {timestamp xaxis yaxis zaxis} heading {"Time Stamp" "X Axis" "Y Axis" "Z Axis"} { $w.data column $column \ -anchor w \ -stretch yes $w.data heading $column \ -anchor center \ -text $heading } $w.data column timestamp \ -anchor e grid configure $w.data $w.vsb -sticky nsew grid configure $w.hsb -sticky ew grid columnconfigure $w $w.data -weight 1 grid rowconfigure $w $w.data -weight 1 } CreateGui |
| > | | | > | < < < < < < | | | | > | > > > | | | | | | < < < < | | | | | | | | | > > > > > > > > > > > > | > > | < < < > > > > > > > > > > > > > | > > | < < < < > > > > > > > > | > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 .. 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 ... 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 ... 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 ... 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 ... 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
## ## 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. ................................................................................ } set i2cbus 1 set dIMUaddress 0x28 set range 2000dps foreach type {gyroscope accelerometer magnetometer gravity linearAcceleration quaternion prh} { set CurrentValue($type,x) {0} set CurrentValue($type,y) {0} set CurrentValue($type,z) {0} } proc StartGyro {handle range} { global GyroValues ## ## Place the dIMU in configuration mode ## ................................................................................ return; } ## ## Gyro: gets a full axis reading, scaled to the full scale reading. Returns ## in degrees per second. ## proc GryoAxisReading {axis oldValue} { global GyroValues set handle $GyroValues(handle) set intValue [bno055 readRegister $handle gyr,data,$axis] set digits $GyroValues(digits) set decimals $GyroValues(decimals) incr digits $decimals ................................................................................ set newValue [format "%${digits}.${decimals}f" [expr {$intValue / $GyroValues(divisor)}]] if {$newValue != $oldValue && abs($newValue - $oldValue) < $GyroValues(minChange)} { set newValue $oldValue } return $newValue } proc ReadGyro {} { global GyroValues CurrentValue if {[info exists GyroValues(afterId)]} { after cancel $GyroValues(afterId) } set GyroValues(afterId) [after [expr {$GyroValues(rate) * 10}] ReadGyro] ## ## Read the GYROSCOPE ## set x [GryoAxisReading x $CurrentValue(x)] set y [GryoAxisReading y $CurrentValue(y)] set z [GryoAxisReading z $CurrentValue(z)] if {$x != $CurrentValue(x) || $y != $CurrentValue(y) || $z != $CurrentValue(z) } { LogValues $x $y $z } ................................................................................ set CurrentValue(x) $x set CurrentValue(y) $y set CurrentValue(z) $z return } proc LogValues {type} { variable WidgetData variable CurrentValue #if {[info exists GyroValues(logId)]} { # after cancel $GyroValues(logId) #} #set GyroValues(logId) [after [expr {$GyroValues(freq) * 100}] LogValues] set timeStamp [clock format [clock seconds]] set x $CurrentValue($type,x) set y $CurrentValue($type,y) set z $CurrentValue($type,z) $WidgetData($type,history) insert {} end -values [list $timeStamp $x $y $z] } proc StartReading {} { global i2cbus dIMUaddress range GyroValues if {$dIMUaddress eq {}} { return ................................................................................ ttk::frame .main.prh .main add .main.prh -text {Pitch, Roll and Heading} CreateConfigurationFrame .main.configuration CreateGyroFrame .main.gyroscope CreateAccelerometerFrame .main.accelerometer CreateMagnetometerFrame .main.magnetometer CreateGravityFrame .main.gravity CreateLinearAccelerationFrame .main.linearAcceleration CreateQuaternionFrame .main.quaternion CreatePitchRollHeadingFrame .main.prh } proc CreateConfigurationFrame {w} { ttk::label $w.busLbl \ -text {I2C Bus:} ttk::combobox $w.busCMB \ -textvariable ::i2cbus \ -values [list 1] \ -state readonly ttk::label $w.addrLbl \ ................................................................................ -width 6 \ -command StartReading ttk::button $w.buttons.stop \ -state disabled \ -text {Stop} \ -width 6 \ -command StopReading $w.minChangeEnt set $::GyroValues(minChange) grid configure $w.busLbl $w.busCMB $w.addrLbl $w.addrEnt $w.rangeLbl $w.rangeCMB x -padx 2 -sticky ew grid configure $w.rateLbl1 $w.rateEnt $w.rateLbl2 x x x x -padx 2 -sticky ew grid configure $w.numDigitsLbl $w.numDigitsCMB $w.numDecimalsLbl $w.numDecimalsCMB x x x -padx 2 -sticky ew grid configure $w.minChangeLbl1 $w.minChangeEnt $w.minChangeLbl2 x x x x -padx 2 -sticky ew grid configure $w.buttons -columnspan 7 -sticky ew -pady 3 grid configure x $w.buttons.start x $w.buttons.stop x -sticky ew grid columnconfigure $w.buttons {0 2 4} -weight 1 grid columnconfigure $w 4 -weight 1 } proc CreateGyroFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings gyroscope CreateHistoryFrame $w.history gyroscope grid columnconfigure $w 6 -weight 1 } proc CreateAccelerometerFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings accelerometer CreateHistoryFrame $w.history accelerometer grid columnconfigure $w 6 -weight 1 } proc CreateMagnetometerFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings magnetometer CreateHistoryFrame $w.history magnetometer grid columnconfigure $w 6 -weight 1 } proc CreateGravityFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings gravity CreateHistoryFrame $w.history gravity grid columnconfigure $w 6 -weight 1 } proc CreateLinearAccelerationFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings linearAcceleration CreateHistoryFrame $w.history linearAcceleration grid columnconfigure $w 6 -weight 1 } proc CreateQuaternionFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings quaternion CreateHistoryFrame $w.history quaternion grid columnconfigure $w 6 -weight 1 } proc CreatePitchRollHeadingFrame {w} { ttk::labelframe $w.readings \ -text {Current Readings} ttk::labelframe $w.history \ -text {Change History} grid configure $w.readings -sticky ew grid configure $w.history -sticky nsew grid rowconfigure $w $w.history -weight 1 grid columnconfigure $w $w.history -weight 1 CreateReadingsFrame $w.readings prh {roll pitch heading} {"Roll:" "Pitch:" "Heading:"} CreateHistoryFrame $w.history prh {timestamp roll pitch heading} {"Timestamp" "Roll" "Pitch" "Heading"} grid columnconfigure $w 6 -weight 1 } proc CreateHistoryFrame {w type {columns {timestamp xaxis yaxis zaxis}} {labels {"Time Stamp" "X Axis" "Y Axis" "Z Axis"}}} { variable WidgetData ttk::treeview $w.data \ -xscrollcommand [list $w.hsb set] \ -yscrollcommand [list $w.vsb set] \ -columns $columns \ -displaycolumns $columns \ -show headings \ -selectmode none ttk::scrollbar $w.vsb \ -orient vertical \ -command [list $w.data yview] ttk::scrollbar $w.hsb \ -orient horizontal \ -command [list $w.data xview] ttk::frame $w.buttons ttk::button $w.buttons.reset \ -text {Clear Log} \ -width 10 \ -command [format {%1$s delete [%1$s children {}]; LogValues %2$s} $w.data $type] set WidgetData($type,history) $w.data foreach column $columns heading $labels { $w.data column $column \ -anchor w \ -stretch yes $w.data heading $column \ -anchor center \ -text $heading } $w.data column timestamp \ -anchor e grid configure $w.data $w.vsb -sticky nsew grid configure $w.hsb -sticky ew grid configure $w.buttons - -sticky ew grid columnconfigure $w $w.data -weight 1 grid rowconfigure $w $w.data -weight 1 grid configure x $w.buttons.reset x -sticky ew grid columnconfigure $w.buttons {0 2} -weight 1 } proc CreateReadingsFrame {w type {columns {x y z}} {labels {"X:" "Y:" "Z:"}}} { lassign $columns x y z lassign $labels xl yl zl ttk::label $w.xLabel \ -text $xl ttk::entry $w.xValue \ -textvariable ::CurrentValue($type,$x) \ -state readonly ttk::label $w.yLabel \ -text $yl ttk::entry $w.yValue \ -textvariable ::CurrentValue($type,$y) \ -state readonly ttk::label $w.zLabel \ -text $zl ttk::entry $w.zValue \ -textvariable ::CurrentValue($type,$z) \ -state readonly grid configure $w.xLabel $w.xValue $w.yLabel $w.yValue $w.zLabel $w.zValue x -sticky ew -padx 2 -pady 1 grid columnconfigure $w [list $w.xLabel $w.yLabel $w.zLabel] -uniform labels -weight 0 grid columnconfigure $w [list $w.xValue $w.yValue $w.zValue] -uniform values -weight 0 } CreateGui |