📄 #paddle.bas.txt
字号:
#paddle.bas
# Paddle for the mount
# by Bob Bond
#
bmax = 10
dim ba(bmax, 4)
bi = 1
draw -1
dim m$(3): dim mc$(3)
dim n$(4): dim nc$(4)
m$(1)="Guide" : mc$(1)="SSG"
m$(2)="8x" : mc$(2)="SSM"
m$(3)="32x" : mc$(3) ="SSF"
form lst 60,130,3,1,m$,1
n$(1)="Sidereal": nc$(1)="SST"
n$(2)="Lunar" : nc$(2)="SSL"
n$(3)="Solar" : nc$(3)="SSS"
n$(4)="Off" : nc$(4)="I"
form lst 110,130,4,1,n$,1
s$(0)="1":s$(1)="1"
button(60,20,40,30,"N")
button(10,50,40,30,"W")
button(110,50,40,30,"E")
button(60,80,40,30,"S")
last = 0
while 1
cur = fn pen(3)
if (cur <> last)
gosub myupdate()
last = fn pen(3)
endif
wend
end
# Button pressed...
sub myupdate()
call getbtn()
if b < 1 then goto 2000
cmd$ = mc$(val(s$(0)))
call send()
if b=1 then cmd$="MD+":goto 1000
if b=2 then cmd$="MR-":goto 1500
if b=3 then cmd$="MR+":goto 1500
if b=4 then cmd$="MD-":goto 1000
goto 2000
1000 call send()
while(fn pen(4)) : wend
cmd$="ID"
call send()
goto 2000
1500 call send()
while(fn pen(4)): wend
cmd$=nc$(val(s$(1)))
call send()
if (s$(1) <> "4")
cmd$="MR-"
call send()
endif
2000 return
3000 sub button(x, y, xl, yl, t$)
draw x, y, xl, yl, 5
tx = (xl-fn strw(t$, len(t$), 0))/2+x
ty = (yl-10)/2+y
draw t$, tx, ty
ba(bi, 1) = x
ba(bi, 2) = y
ba(bi, 3) = x+xl
ba(bi, 4) = y+ yl
bi = bi+1
return
4000 sub getbtn()
x = fn pen(1)
y = fn pen(2)
i = 1
b = -1
while (i < bi)
c = 0
if ba(i, 1) <= x then c = 1
if ba(i, 2) <= y then c = c+1
if ba(i, 3) >= x then c = c+1
if ba(i, 4) >= y then c = c+1
if (c = 4)
b = i
exit while
endif
i = i+1
wend
return
5000 sub send()
#draw cmd$+ " ", 60,150
#for i = 1 to 1000 : next i
#return
open "com1:", 9600 as #5
for i = 1 to len(cmd$)
co = asc(mid$(cmd$, i, 1))
put #5, co
next i
put #5, 13
ci$ = chr$(0)
draw 60, 150, 110, 10, -7
xi = 60
while(ci$ <> ">")
while (fn serial(5) < 1) : wend
ci$ = get$(#5, 1)
draw ci$, xi, 150
xi = xi+fn strw(ci$, 1, 0)
wend
close #5
return
run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -