Code: Select all
' fbtermg.bas
'
' October 23, 2017
'
#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
Using fb
#endif
Dim e As EVENT
Dim Shared As String Key,title,titlecon,titledis,event1,blank1,buffer
Dim Shared As String titleport,port1,port2,port3,port4,port5,p
Dim Shared As String titlebaud,baud1,baud2,baud3,baud4,baud5,b
Dim Shared As Long res, x, y, buttons, column, row
Dim Shared As Integer title1
Dim Shared As Double t
Dim Shared As Double flag
Screen 20 ' 1024x768
WindowTitle "FBtermG Program"
Declare Sub Connect()
Declare Sub Disconnect()
Declare Sub CommBox()
Declare Sub CommBoxB()
Declare Sub PortBox()
Declare Sub PortBox1()
Declare Sub PortBox2()
Declare Sub PortBox3()
Declare Sub PortBox4()
Declare Sub PortBox5()
Declare Sub BaudBox()
Declare Sub BaudBox1()
Declare Sub BaudBox2()
Declare Sub BaudBox3()
Declare Sub BaudBox4()
Declare Sub BaudBox5()
Declare Sub BlankOut()
Declare Sub TextCursor(ByRef flag As Double)
Connect()
PortBox()
BaudBox()
color 0,0
locate 1,1
Do
res = GetMouse(x, y, ,buttons) ' Start mouse
Key = InKey ' Start keyboard
TextCursor(flag) ' Start cursor
If(ScreenEvent(@e)) Then
Select Case e.Type
Case EVENT_KEY_PRESS
If(e.scancode = SC_ESCAPE) Then ' Esc key to end program.
Close
End
End If
Case EVENT_WINDOW_CLOSE ' Close window
Close
End
End Select
End If
' Mouse over connect/disconnect
If x > 5 And x <= 88 And y > 1 And y <= 18 And buttons And 1 Then
Sleep 200,1
if title1 = 0 then
Disconnect()
CommBox()
Open Com p & b & ",n,8,1,cs0,ds0,cd0,rs" As #1
View Print 2 to 47
elseif title1 = 1 then
Connect()
Close
CommBoxB()
End If
End If
' Mouse over Port
If x > 93 And x <= 261 And y > 1 And y <= 18 And buttons And 1 Then
PortBox1()
PortBox2()
PortBox3()
PortBox4()
PortBox5()
End If
' Mouse over portbox1
If x > 157 And x <= 261 And y > 18 And y <= 35 And buttons And 1 Then
PortBox()
port1 = "/dev/ttyAMA0:"
Draw String (159,2),port1,4
p = port1
BlankOut()
End If
' Mouse over portbox2
If x > 157 And x <= 261 And y > 36 And y <= 73 And buttons And 1 Then
PortBox()
port2 = "/dev/ttyUSB0:"
Draw String (159,2),port2,4
p = port2
BlankOut()
End If
' Mouse over portbox3
If x > 157 And x <= 261 And y > 52 And y <= 68 And buttons And 1 Then
PortBox()
port3 = "/dev/ttyUSB1:"
Draw String (159,2),port3,4
p = port3
BlankOut()
End If
' Mouse over portbox4
If x > 157 And x <= 261 And y > 68 And y <= 84 And buttons And 1 Then
PortBox()
port4 = "/dev/ttyUSB2:"
Draw String (159,2),port4,4
p = port4
BlankOut()
End If
' Mouse over portbox5
If x > 157 And x <= 261 And y > 80 And y <= 96 And buttons And 1 Then
PortBox()
port5 = "/dev/ttyUSB3:"
Draw String (159,2),port5,4
p = port5
BlankOut()
End If
' Mouse over BAUD
If x > 262 And x <= 382 And y > 1 And y <= 18 And buttons And 1 Then
BaudBox1()
BaudBox2()
BaudBox3()
BaudBox4()
BaudBox5()
End If
' Mouse over baudbox1
If x > 300 And x <= 382 And y > 18 And y <= 35 And buttons And 1 Then
BaudBox()
baud1 = "9600"
Draw String (316,2),baud1,4
b = baud1
BlankOut()
End If
' Mouse over baudbox2
If x > 300 And x <= 382 And y > 36 And y <= 48 And buttons And 1 Then
BaudBox()
baud2 = "19200"
Draw String (316,2),baud2,4
b = baud2
BlankOut()
End If
' Mouse over baudbox3
If x > 300 And x <= 382 And y > 52 And y <= 68 And buttons And 1 Then
BaudBox()
baud3 = "38400"
Draw String (316,2),baud3,4
b = baud3
BlankOut()
End If
' Mouse over baudbox4
If x > 300 And x <= 382 And y > 68 And y <= 84 And buttons And 1 Then
BaudBox()
baud4 = "57600"
Draw String (316,2),baud4,4
b =baud4
BlankOut()
End If
' Mouse over baudbox5
If x > 300 And x <= 382 And y > 80 And y <= 96 And buttons And 1 Then
BaudBox()
baud5 = "115200"
Draw String (316,2),baud5,4
b = baud5
BlankOut()
End If
If Key <> "" Then
If Key = Chr(13) Then
Print Chr(13)
Else
print Key;
End If
End If
While LOC(1) > 0
buffer = Input(LOC(1),#1)
Print buffer;
Wend
Sleep 1
Loop
Close
End
''''''''''''''''''''''''''''''
' Menu item Connect
Sub Connect()
titlecon = "Connect"
Draw "BM 8,1" ' Start point x,y
Draw "C2" ' Set color
Draw "R85 D15 L85 U15" ' Size of box
Draw "BM +1,1" ' Move to inside of box
Draw "P 7,2" ' Flood fill up to border
Draw String (9,2),titlecon,2
title1 = 0
End Sub
' Menu item Disconnect
Sub Disconnect()
titledis = "Disconnect"
Draw "BM 8,1" ' Start point x,y
Draw "C2" ' Set color
Draw "R85 D15 L85 U15" ' Size of box
Draw "BM +1,1" ' Move to inside of box
Draw "P 7,2" ' Flood fill up to border
Draw String (9,2),titledis,4
title1 = 1
End Sub
' Window for serial comms, open
Sub CommBox()
'Draw "BM 0,34"
'Draw "C2"
'Draw "R900 D700 L900 U700"
'Draw "BM +1,1"
'Draw "P 7,2"
line (1,18) - (900,740), 7, BF 'Create filled box
locate 2,1
color 0,7
End Sub
' Window for serial comms, close
Sub CommBoxB()
'Draw "BM 0,34"
'Draw "C0"
'Draw "R900 D700 L900 U700"
'Draw "BM +1,1"
'Draw "P 0,0"
Locate 2,1
color 0,0
line (1,18) - (900,740), 0, BF 'Blank filled box
End Sub
Sub PortBox()
titleport = "Port -"
Draw "BM 93,1"
Draw "C2"
'Draw "R85 D15 L85 U15"
Draw "R168 D15 L168 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (96,2),titleport,4
End Sub
Sub PortBox1()
port1 = "/dev/ttyAMA0:"
Draw "BM 157,16"
Draw "C2"
Draw "R104 D15 L104 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (159,18),port1,4
End Sub
Sub PortBox2()
port2 = "/dev/ttyUSB0:"
Draw "BM 157,32"
Draw "C2"
Draw "R104 D15 L104 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (159,34),port2,4
End Sub
Sub PortBox3()
port3 = "/dev/ttyUSB1"
Draw "BM 157,48"
Draw "C2"
Draw "R104 D15 L104 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (159,50),port3,4
End Sub
Sub PortBox4()
port4 = "/dev/ttyUSB2"
Draw "BM 157,64"
Draw "C2"
Draw "R104 D15 L104 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (159,66),port4,4
End Sub
Sub PortBox5()
port5 = "/dev/ttyUSB3"
Draw "BM 157,80"
Draw "C2"
Draw "R104 D15 L104 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (159,82),port5,4
End Sub
Sub BaudBox()
titlebaud = "BAUD -"
Draw "BM 262,1"
Draw "C2"
Draw "R120 D15 L120 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (264,2),titlebaud,4
End Sub
Sub BaudBox1()
baud1 = "9600"
Draw "BM 300,16"
Draw "C2"
Draw "R82 D15 L82 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (316,18),baud1,4
End Sub
Sub BaudBox2()
baud2 = "19200"
Draw "BM 300,32"
Draw "C2"
Draw "R82 D15 L82 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (316,34),baud2,4
End Sub
Sub BaudBox3()
baud3 = "38400"
Draw "BM 300,48"
Draw "C2"
Draw "R82 D15 L82 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (316,50),baud3,4
End Sub
Sub BaudBox4()
baud4 = "57600"
Draw "BM 300,64"
Draw "C2"
Draw "R82 D15 L82 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (316,66),baud4,4
End Sub
Sub BaudBox5()
baud5 = "115200"
Draw "BM 300,80"
Draw "C2"
Draw "R82 D15 L82 U15"
Draw "BM +1,1"
Draw "P 7,2"
Draw String (316,82),baud5,4
End Sub
Sub BlankOut()
Locate 2,1
color 0,0
line (1,18) - (900,740), 0, BF 'Blank filled box
End Sub
' Cursor display
Sub TextCursor(ByRef flag As Double)
column = Pos
row = CsrLin
If Timer - t > .5 Then
flag = Not(flag)
If flag Then Print "_" Else Print " ";
Locate row,column
t = Timer
End If
End Sub