OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [library/] [demos/] [timer] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#!/bin/sh
2
# the next line restarts using wish \
3
exec wish "$0" "$@"
4
 
5
# timer --
6
# This script generates a counter with start and stop buttons.
7
#
8
# SCCS: @(#) timer 1.6 96/02/16 10:49:20
9
 
10
label .counter -text 0.00 -relief raised -width 10
11
button .start -text Start -command {
12
    if $stopped {
13
        set stopped 0
14
        tick
15
    }
16
}
17
button .stop -text Stop -command {set stopped 1}
18
pack .counter -side bottom -fill both
19
pack .start -side left -fill both -expand yes
20
pack .stop -side right -fill both -expand yes
21
 
22
set seconds 0
23
set hundredths 0
24
set stopped 1
25
 
26
proc tick {} {
27
    global seconds hundredths stopped
28
    if $stopped return
29
    after 50 tick
30
    set hundredths [expr $hundredths+5]
31
    if {$hundredths >= 100} {
32
        set hundredths 0
33
        set seconds [expr $seconds+1]
34
    }
35
    .counter config -text [format "%d.%02d" $seconds $hundredths]
36
}
37
 
38
bind .  {destroy .}
39
bind .  {destroy .}
40
focus .

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.