-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_seven_seg.ks
76 lines (75 loc) · 1.71 KB
/
lib_seven_seg.ks
1
2
3
4
5
6
7
8
9
10
11
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
// This file is distributed under the terms of the MIT license, (c) the KSLib team
function seven_seg {
parameter
num,
col,
ln.
if num > -1 {
if num < 5 {
if num < 2 {
if num < 1 {
print "_" at (col+1,ln).
print "| |" at (col,ln+1).
print "|_|" at (col,ln+2).
} else {
print " " at (col+1,ln).
print " |" at (col,ln+1).
print " |" at (col,ln+2).
}
} else {
if num < 4 {
if num < 3 {
print "_" at (col+1,ln).
print " _|" at (col,ln+1).
print "|_ " at (col,ln+2).
} else {
print "_" at (col+1,ln).
print " _|" at (col,ln+1).
print " _|" at (col,ln+2).
}
} else {
print " " at (col+1,ln).
print "|_|" at (col,ln+1).
print " |" at (col,ln+2).
}
}
} else {
if num < 7 {
if num < 6 {
print "_" at (col+1,ln).
print "|_ " at (col,ln+1).
print " _|" at (col,ln+2).
} else {
print "_" at (col+1,ln).
print "|_ " at (col,ln+1).
print "|_|" at (col,ln+2).
}
} else {
if num < 9 {
if num < 8 {
print "_" at (col+1,ln).
print " |" at (col,ln+1).
print " |" at (col,ln+2).
} else {
print "_" at (col+1,ln).
print "|_|" at (col,ln+1).
print "|_|" at (col,ln+2).
}
} else {
print "_" at (col+1,ln).
print "|_|" at (col,ln+1).
print " |" at (col,ln+2).
}
}
}
// special cases
} else if num = "b" { //"b" = blank
print " " at (col+1,ln).
print " " at (col,ln+1).
print " " at (col,ln+2).
} else if num = "-" { //"-" = minus
print " " at (col+1,ln).
print " _ " at (col,ln+1).
print " " at (col,ln+2).
}// else if num = // add more special cases here.
}