mirror of
https://github.com/brmlab/brmscope.git
synced 2025-06-07 17:34:06 +02:00
BrmScope INIT COMMIT
This commit is contained in:
commit
b6af2e5206
9 changed files with 681 additions and 0 deletions
2
.directory
Normal file
2
.directory
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Icon=./.icon.png
|
BIN
.icon.png
Normal file
BIN
.icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
19
.project
Normal file
19
.project
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Gambas Project File 2.0
|
||||||
|
# Compiled with Gambas 2.21.0
|
||||||
|
Title=DUINOCNC
|
||||||
|
Startup=FMain
|
||||||
|
Version=0.0.2
|
||||||
|
Library=gb.qt
|
||||||
|
Library=gb.form
|
||||||
|
Library=gb.net
|
||||||
|
Library=gb.qt.ext
|
||||||
|
TabSize=2
|
||||||
|
SourcePath=/home/tomsuch/Desktop
|
||||||
|
Maintainer=brmlab
|
||||||
|
Address=brmlab@brmlab.cz
|
||||||
|
Url=www.brmlab.cz
|
||||||
|
License=General Public Licence
|
||||||
|
Systems=suse
|
||||||
|
Menus=System/Monitor
|
||||||
|
Categories=Brmlab;Monitor;System
|
||||||
|
Groups=Amusements/Games/Other
|
23
.settings
Normal file
23
.settings
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[Breakpoints]
|
||||||
|
Count=0
|
||||||
|
|
||||||
|
[DebugWindow]
|
||||||
|
Count=0
|
||||||
|
|
||||||
|
[FFind]
|
||||||
|
SearchIn="Module"
|
||||||
|
CaseSensitive=False
|
||||||
|
SearchWord=False
|
||||||
|
SearchComment=False
|
||||||
|
SearchString=True
|
||||||
|
|
||||||
|
[OpenFile]
|
||||||
|
File[1]="FMain.form"
|
||||||
|
File[2]="FMain.class:141.0"
|
||||||
|
Active=2
|
||||||
|
File[3]="Joystick.class:0.0"
|
||||||
|
Count=3
|
||||||
|
|
||||||
|
[Watches]
|
||||||
|
Count=0
|
||||||
|
|
3
CHANGELOG
Normal file
3
CHANGELOG
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
* Tue Aug 09 2011 brmlab <brmlab@brmlab.cz> 0.0
|
||||||
|
- Initial release
|
||||||
|
|
BIN
DUINOCNC.gambas
Executable file
BIN
DUINOCNC.gambas
Executable file
Binary file not shown.
392
FMain.class
Normal file
392
FMain.class
Normal file
|
@ -0,0 +1,392 @@
|
||||||
|
' Gambas class file
|
||||||
|
PUBLIC Motor_A_Dir AS Integer
|
||||||
|
PUBLIC Motor_B_Dir AS Integer
|
||||||
|
PUBLIC Motor_C_Dir AS Integer
|
||||||
|
PUBLIC Step_IDX AS Integer
|
||||||
|
PUBLIC Step_COUNT AS Boolean
|
||||||
|
PUBLIC Step_WDT AS Boolean
|
||||||
|
|
||||||
|
PUBLIC js AS Joystick
|
||||||
|
|
||||||
|
PUBLIC joy_x AS Integer
|
||||||
|
PUBLIC joy_y AS Integer
|
||||||
|
PUBLIC joy_s AS Integer
|
||||||
|
|
||||||
|
PUBLIC joy_bt_up AS Integer
|
||||||
|
PUBLIC joy_bt_down AS Integer
|
||||||
|
|
||||||
|
|
||||||
|
PUBLIC SUB _new()
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB js_StickMove(num AS Integer, pos AS Integer)
|
||||||
|
TextBox9.Text = num
|
||||||
|
TextBox10.Text = pos
|
||||||
|
|
||||||
|
IF num = 0 THEN joy_x = pos
|
||||||
|
IF num = 1 THEN joy_y = pos
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Form_Open()
|
||||||
|
|
||||||
|
Motor_A_Dir = 0
|
||||||
|
Motor_B_Dir = 0
|
||||||
|
Motor_C_Dir = 0
|
||||||
|
|
||||||
|
Button8.Enabled = FALSE
|
||||||
|
Button10.Enabled = FALSE
|
||||||
|
Button12.Enabled = FALSE
|
||||||
|
|
||||||
|
Step_IDX = 0
|
||||||
|
Step_COUNT = FALSE
|
||||||
|
Step_WDT = FALSE
|
||||||
|
js = NEW Joystick("/dev/input/js0") AS "js"
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button1_Click()
|
||||||
|
|
||||||
|
SerialPort1.PortName = "/dev/ttyUSB0"
|
||||||
|
SerialPort1.Speed = 115200
|
||||||
|
SerialPort1.FlowControl = FALSE
|
||||||
|
SerialPort1.Open
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
PUBLIC SUB js_ButtonPress(num AS Integer)
|
||||||
|
|
||||||
|
' check the corresponding checkbox
|
||||||
|
IF num = 2 THEN joy_bt_up = 1
|
||||||
|
IF num = 3 THEN joy_bt_down = 1
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB js_ButtonRelease(num AS Integer)
|
||||||
|
|
||||||
|
' uncheck the corresponding checkbox
|
||||||
|
IF num = 2 THEN joy_bt_up = 0
|
||||||
|
IF num = 3 THEN joy_bt_down = 0
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
PUBLIC SUB Button2_Click()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Timer1.Enabled = TRUE
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button3_Click()
|
||||||
|
WRITE #SerialPort1, Chr$(TextBox1.Text)
|
||||||
|
Timer1.Delay = TextBox2.Text
|
||||||
|
Timer1.Enabled = FALSE
|
||||||
|
WRITE #SerialPort1, Chr$(110)
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Timer1_Timer()
|
||||||
|
|
||||||
|
IF CheckBox4.Value = TRUE THEN
|
||||||
|
Step_IDX = Step_IDX + 1
|
||||||
|
ELSE
|
||||||
|
Step_IDX = 0
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IF CheckBox1.Value = TRUE THEN
|
||||||
|
IF Motor_A_Dir = 0 THEN WRITE #SerialPort1, Chr$(4)
|
||||||
|
IF Motor_A_Dir = 1 THEN WRITE #SerialPort1, Chr$(5)
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF CheckBox2.Value = TRUE THEN
|
||||||
|
IF Motor_B_Dir = 0 THEN WRITE #SerialPort1, Chr$(6)
|
||||||
|
IF Motor_B_Dir = 1 THEN WRITE #SerialPort1, Chr$(7)
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF CheckBox3.Value = TRUE THEN
|
||||||
|
IF Motor_C_Dir = 0 THEN WRITE #SerialPort1, Chr$(8)
|
||||||
|
IF Motor_C_Dir = 1 THEN WRITE #SerialPort1, Chr$(9)
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF Step_IDX > 0 AND Step_IDX = TextBox3.Text THEN
|
||||||
|
Timer1.Enabled = FALSE
|
||||||
|
Step_IDX = 0
|
||||||
|
CheckBox4.Value = FALSE
|
||||||
|
Step_WDT = FALSE
|
||||||
|
WRITE #SerialPort1, Chr$(110)
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
TextBox4.Text = Step_IDX
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button4_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(TextBox1.Text)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button5_Click()
|
||||||
|
|
||||||
|
Timer1.Delay = TextBox2.Text
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button6_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(110)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button7_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(111)
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button9_Click()
|
||||||
|
|
||||||
|
Button9.Enabled = FALSE
|
||||||
|
Button8.Enabled = TRUE
|
||||||
|
Motor_A_Dir = 1
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button8_Click()
|
||||||
|
|
||||||
|
Button9.Enabled = TRUE
|
||||||
|
Button8.Enabled = FALSE
|
||||||
|
Motor_A_Dir = 0
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button11_Click()
|
||||||
|
|
||||||
|
Button11.Enabled = FALSE
|
||||||
|
Button10.Enabled = TRUE
|
||||||
|
Motor_B_Dir = 1
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button13_Click()
|
||||||
|
|
||||||
|
Button13.Enabled = FALSE
|
||||||
|
Button12.Enabled = TRUE
|
||||||
|
Motor_C_Dir = 1
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button10_Click()
|
||||||
|
|
||||||
|
Button11.Enabled = TRUE
|
||||||
|
Button10.Enabled = FALSE
|
||||||
|
Motor_B_Dir = 0
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button12_Click()
|
||||||
|
|
||||||
|
Button13.Enabled = TRUE
|
||||||
|
Button12.Enabled = FALSE
|
||||||
|
Motor_C_Dir = 0
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button14_Click()
|
||||||
|
DIM linc AS Integer
|
||||||
|
DIM lin AS String
|
||||||
|
|
||||||
|
DIM arr_strings AS String[]
|
||||||
|
|
||||||
|
arr_strings = Split(File.LOAD("/home/tomsuch/set-1.cnc"), "\n")
|
||||||
|
|
||||||
|
FOR EACH lin IN arr_strings
|
||||||
|
linc = linc + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TextBox6.Text = linc
|
||||||
|
' lin
|
||||||
|
TextBox5.Text = lin
|
||||||
|
|
||||||
|
|
||||||
|
IF Mid(lin, 1, 1) = "*" THEN
|
||||||
|
TextBox8.Text = Mid(lin, 2, 40)
|
||||||
|
ELSE
|
||||||
|
|
||||||
|
IF lin <> "" THEN
|
||||||
|
|
||||||
|
TextBox1.Text = Val((Mid(lin, 7, 3)))
|
||||||
|
TextBox2.Text = Val((Mid(lin, 11, 3)))
|
||||||
|
TextBox7.text = Val((Mid(lin, 1, 5)))
|
||||||
|
|
||||||
|
Button4_Click
|
||||||
|
Button5_Click
|
||||||
|
|
||||||
|
|
||||||
|
TextBox3.Text = Val((Mid(lin, 22, 4)))
|
||||||
|
|
||||||
|
IF Mid(lin, 15, 1) = 1 THEN CheckBox1.Value = TRUE
|
||||||
|
IF Mid(lin, 15, 1) = 0 THEN CheckBox1.Value = FALSE
|
||||||
|
|
||||||
|
IF Mid(lin, 16, 1) = 1 THEN Button9_Click
|
||||||
|
IF Mid(lin, 16, 1) = 0 THEN Button8_Click
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IF Mid(lin, 17, 1) = 1 THEN CheckBox2.Value = TRUE
|
||||||
|
IF Mid(lin, 17, 1) = 0 THEN CheckBox2.Value = FALSE
|
||||||
|
|
||||||
|
IF Mid(lin, 18, 1) = 1 THEN Button11_Click
|
||||||
|
IF Mid(lin, 18, 1) = 0 THEN Button10_Click
|
||||||
|
|
||||||
|
|
||||||
|
IF Mid(lin, 19, 1) = 1 THEN CheckBox3.Value = TRUE
|
||||||
|
IF Mid(lin, 19, 1) = 0 THEN CheckBox3.Value = FALSE
|
||||||
|
|
||||||
|
IF Mid(lin, 20, 1) = 1 THEN Button13_Click
|
||||||
|
IF Mid(lin, 20, 1) = 0 THEN Button12_Click
|
||||||
|
|
||||||
|
|
||||||
|
CheckBox4.Value = TRUE
|
||||||
|
Step_WDT = TRUE
|
||||||
|
Timer1.Enabled = TRUE
|
||||||
|
WHILE Step_WDT = TRUE
|
||||||
|
WAIT
|
||||||
|
WEND
|
||||||
|
ENDIF
|
||||||
|
ENDIF
|
||||||
|
NEXT
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB TextBox5_KeyPress()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Timer2_Timer()
|
||||||
|
|
||||||
|
TextBox13.Text = joy_bt_up
|
||||||
|
TextBox14.Text = joy_bt_down
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TextBox11.Text = joy_x
|
||||||
|
TextBox12.Text = joy_y
|
||||||
|
|
||||||
|
IF joy_y < 0 THEN
|
||||||
|
Button12_Click
|
||||||
|
CheckBox3.Value = TRUE
|
||||||
|
TextBox3.text = 1
|
||||||
|
'' CheckBox4.Value = TRUE
|
||||||
|
''Timer1.Enabled = TRUE
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF joy_y > 0 THEN
|
||||||
|
Button13_Click
|
||||||
|
CheckBox3.Value = TRUE
|
||||||
|
TextBox3.text = 1
|
||||||
|
'' CheckBox4.Value = TRUE
|
||||||
|
''Timer1.Enabled = TRUE
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF joy_x < 0 THEN
|
||||||
|
Button10_Click
|
||||||
|
CheckBox2.Value = TRUE
|
||||||
|
TextBox3.text = 1
|
||||||
|
'' CheckBox4.Value = TRUE
|
||||||
|
''Timer1.Enabled = TRUE
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF joy_x > 0 THEN
|
||||||
|
Button11_Click
|
||||||
|
CheckBox2.Value = TRUE
|
||||||
|
TextBox3.text = 1
|
||||||
|
'' CheckBox4.Value = TRUE
|
||||||
|
''Timer1.Enabled = TRUE
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF joy_bt_up = 1 THEN
|
||||||
|
Button8_Click
|
||||||
|
CheckBox1.Value = TRUE
|
||||||
|
TextBox3.text = 1
|
||||||
|
'' CheckBox4.Value = TRUE
|
||||||
|
''Timer1.Enabled = TRUE
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF joy_bt_down = 1 THEN
|
||||||
|
Button9_Click
|
||||||
|
CheckBox1.Value = TRUE
|
||||||
|
TextBox3.text = 1
|
||||||
|
'' CheckBox4.Value = TRUE
|
||||||
|
''Timer1.Enabled = TRUE
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF joy_bt_up = 0 AND IF joy_bt_down = 0 THEN CheckBox1.Value = FALSE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IF joy_x = 0 THEN CheckBox2.Value = FALSE
|
||||||
|
IF joy_y = 0 THEN CheckBox3.Value = FALSE
|
||||||
|
|
||||||
|
IF joy_x = 0 AND joy_y = 0 AND joy_bt_down = 0 AND joy_bt_up = 0 THEN Button6_Click
|
||||||
|
|
||||||
|
' joy_x = 0
|
||||||
|
'joy_y = 0
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button15_Click()
|
||||||
|
|
||||||
|
Timer2.Enabled = TRUE
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button16_Click()
|
||||||
|
|
||||||
|
Timer2.Enabled = FALSE
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button17_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(112)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button18_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(113)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button19_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(114)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button20_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(115)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Button21_Click()
|
||||||
|
|
||||||
|
WRITE #SerialPort1, Chr$(116)
|
||||||
|
|
||||||
|
END
|
180
FMain.form
Normal file
180
FMain.form
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
# Gambas Form File 2.0
|
||||||
|
|
||||||
|
{ Form Form
|
||||||
|
MoveScaled(0,0,114,47)
|
||||||
|
Text = ("")
|
||||||
|
{ Button1 Button
|
||||||
|
MoveScaled(3,4,25,7)
|
||||||
|
Text = ("CONNECT")
|
||||||
|
}
|
||||||
|
{ SerialPort1 #SerialPort
|
||||||
|
#X = 686
|
||||||
|
#Y = 161
|
||||||
|
}
|
||||||
|
{ Timer1 #Timer
|
||||||
|
#X = 728
|
||||||
|
#Y = 161
|
||||||
|
Delay = 100
|
||||||
|
}
|
||||||
|
{ Button2 Button
|
||||||
|
MoveScaled(95,4,17,3)
|
||||||
|
Text = ("START")
|
||||||
|
}
|
||||||
|
{ Button3 Button
|
||||||
|
MoveScaled(95,8,17,3)
|
||||||
|
Text = ("STOP")
|
||||||
|
}
|
||||||
|
{ TextBox1 TextBox
|
||||||
|
MoveScaled(34,4,24,3)
|
||||||
|
Text = ("30")
|
||||||
|
}
|
||||||
|
{ Button4 Button
|
||||||
|
MoveScaled(60,4,34,3)
|
||||||
|
Text = ("CAS KROKU (20-100)")
|
||||||
|
}
|
||||||
|
{ TextBox2 TextBox
|
||||||
|
MoveScaled(34,8,24,3)
|
||||||
|
Text = ("15")
|
||||||
|
}
|
||||||
|
{ Button5 Button
|
||||||
|
MoveScaled(60,8,34,3)
|
||||||
|
Text = ("CAS CIKLU (1-200) ")
|
||||||
|
}
|
||||||
|
{ Button6 Button
|
||||||
|
MoveScaled(95,12,17,2)
|
||||||
|
Text = ("ODBRZDIT")
|
||||||
|
}
|
||||||
|
{ Button7 Button
|
||||||
|
MoveScaled(95,16,17,3)
|
||||||
|
Text = ("ZABRZDIT")
|
||||||
|
}
|
||||||
|
{ CheckBox1 CheckBox
|
||||||
|
MoveScaled(70,17,14,3)
|
||||||
|
Text = ("MOTOR A")
|
||||||
|
}
|
||||||
|
{ CheckBox2 CheckBox
|
||||||
|
MoveScaled(70,21,14,3)
|
||||||
|
Text = ("MOTOR B")
|
||||||
|
}
|
||||||
|
{ CheckBox3 CheckBox
|
||||||
|
MoveScaled(70,25,14,3)
|
||||||
|
Text = ("MOTOR C")
|
||||||
|
}
|
||||||
|
{ Button8 Button
|
||||||
|
MoveScaled(60,16,8,3)
|
||||||
|
Text = ("<<<")
|
||||||
|
}
|
||||||
|
{ Button9 Button
|
||||||
|
MoveScaled(85,16,9,2)
|
||||||
|
Text = (">>>")
|
||||||
|
}
|
||||||
|
{ Button10 Button
|
||||||
|
MoveScaled(60,21,8,3)
|
||||||
|
Text = ("<<<")
|
||||||
|
}
|
||||||
|
{ Button11 Button
|
||||||
|
MoveScaled(85,21,9,3)
|
||||||
|
Text = (">>>")
|
||||||
|
}
|
||||||
|
{ Button12 Button
|
||||||
|
MoveScaled(60,26,8,3)
|
||||||
|
Text = ("<<<")
|
||||||
|
}
|
||||||
|
{ Button13 Button
|
||||||
|
MoveScaled(85,26,9,3)
|
||||||
|
Text = (">>>")
|
||||||
|
}
|
||||||
|
{ TextBox3 TextBox
|
||||||
|
MoveScaled(3,21,15,3)
|
||||||
|
Text = ("500")
|
||||||
|
}
|
||||||
|
{ TextBox4 TextBox
|
||||||
|
MoveScaled(19,21,15,3)
|
||||||
|
Text = ("")
|
||||||
|
}
|
||||||
|
{ CheckBox4 CheckBox
|
||||||
|
MoveScaled(43,22,14,2)
|
||||||
|
Text = ("STEP COUNT")
|
||||||
|
}
|
||||||
|
{ Button14 Button
|
||||||
|
MoveScaled(3,26,55,3)
|
||||||
|
Text = ("OPEN + START SET")
|
||||||
|
}
|
||||||
|
{ TextBox5 TextBox
|
||||||
|
MoveScaled(26,17,32,3)
|
||||||
|
Text = ("SET COMMANDS")
|
||||||
|
Alignment = Align.Center
|
||||||
|
}
|
||||||
|
{ TextBox6 TextBox
|
||||||
|
MoveScaled(3,17,10,3)
|
||||||
|
Text = ("SET LINES")
|
||||||
|
Alignment = Align.Center
|
||||||
|
}
|
||||||
|
{ TextBox7 TextBox
|
||||||
|
MoveScaled(14,17,11,3)
|
||||||
|
Text = ("SET STEPS")
|
||||||
|
Alignment = Align.Center
|
||||||
|
}
|
||||||
|
{ TextBox8 TextBox
|
||||||
|
MoveScaled(3,13,55,3)
|
||||||
|
Text = (" -- SET INFO --")
|
||||||
|
Alignment = Align.Center
|
||||||
|
}
|
||||||
|
{ TextBox9 TextBox
|
||||||
|
MoveScaled(3,30,11,3)
|
||||||
|
Text = ("TextBox9")
|
||||||
|
}
|
||||||
|
{ TextBox10 TextBox
|
||||||
|
MoveScaled(15,30,11,3)
|
||||||
|
Text = ("TextBox10")
|
||||||
|
}
|
||||||
|
{ TextBox11 TextBox
|
||||||
|
MoveScaled(27,30,11,3)
|
||||||
|
Text = ("TextBox11")
|
||||||
|
}
|
||||||
|
{ TextBox12 TextBox
|
||||||
|
MoveScaled(39,30,11,3)
|
||||||
|
Text = ("TextBox12")
|
||||||
|
}
|
||||||
|
{ Timer2 #Timer
|
||||||
|
#X = 728
|
||||||
|
#Y = 203
|
||||||
|
Delay = 30
|
||||||
|
}
|
||||||
|
{ Button15 Button
|
||||||
|
MoveScaled(60,30,16,3)
|
||||||
|
Text = ("JOY START")
|
||||||
|
}
|
||||||
|
{ Button16 Button
|
||||||
|
MoveScaled(78,30,16,3)
|
||||||
|
Text = ("JOY STOP")
|
||||||
|
}
|
||||||
|
{ TextBox13 TextBox
|
||||||
|
MoveScaled(3,34,23,3)
|
||||||
|
Text = ("TextBox13")
|
||||||
|
}
|
||||||
|
{ TextBox14 TextBox
|
||||||
|
MoveScaled(27,34,23,3)
|
||||||
|
Text = ("TextBox14")
|
||||||
|
}
|
||||||
|
{ Button17 Button
|
||||||
|
MoveScaled(60,35,16,3)
|
||||||
|
Text = ("SERVO +")
|
||||||
|
}
|
||||||
|
{ Button18 Button
|
||||||
|
MoveScaled(78,35,16,3)
|
||||||
|
Text = ("SERVO -")
|
||||||
|
}
|
||||||
|
{ Button19 Button
|
||||||
|
MoveScaled(60,40,9,3)
|
||||||
|
Text = ("Servo 0")
|
||||||
|
}
|
||||||
|
{ Button20 Button
|
||||||
|
MoveScaled(71,40,11,3)
|
||||||
|
Text = ("Servo 90")
|
||||||
|
}
|
||||||
|
{ Button21 Button
|
||||||
|
MoveScaled(84,40,10,3)
|
||||||
|
Text = ("Servo 180")
|
||||||
|
}
|
||||||
|
}
|
62
Joystick.class
Normal file
62
Joystick.class
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
' Gambas class file
|
||||||
|
|
||||||
|
' Joystick.class - represents a HID game device containing
|
||||||
|
' one or more joysticks and buttons
|
||||||
|
'
|
||||||
|
' Copyright 2008 Rob Kudla, Binara, Inc. <rpm@kudla.org>
|
||||||
|
'
|
||||||
|
' This program is free software; you can redistribute it and/or modify
|
||||||
|
' it under the terms of the GNU General Public License version 2 as
|
||||||
|
' published by the Free Software Foundation.
|
||||||
|
|
||||||
|
PRIVATE jsdev AS Process
|
||||||
|
|
||||||
|
PUBLIC SUB _new(OPTIONAL device AS String)
|
||||||
|
|
||||||
|
IF device = "" THEN device = "/dev/input/js0"
|
||||||
|
' the interpreter dies when we try to read from /dev/input/js0 as a file
|
||||||
|
' saying "invalid argument", so we have to run cat
|
||||||
|
jsdev = EXEC ["cat", device] FOR READ AS "Device"
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Close()
|
||||||
|
|
||||||
|
' kill the cat process if it's still going
|
||||||
|
TRY jsdev.Kill
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
PUBLIC SUB Device_Read()
|
||||||
|
|
||||||
|
DIM stamp AS Integer
|
||||||
|
DIM value AS Short
|
||||||
|
DIM myevent AS Byte
|
||||||
|
DIM number AS Byte
|
||||||
|
DIM test AS String
|
||||||
|
|
||||||
|
' each joystick event produces 8 bytes
|
||||||
|
READ #jsdev, stamp, 4 ' 4 bytes
|
||||||
|
READ #jsdev, value, 2 ' 2 bytes
|
||||||
|
READ #jsdev, myevent, 1 ' 1 byte
|
||||||
|
READ #jsdev, number, 1 ' 1 byte
|
||||||
|
|
||||||
|
IF myevent AND 1 THEN ' button
|
||||||
|
IF value THEN ' pressed
|
||||||
|
PRINT "Got button press"
|
||||||
|
RAISE ButtonPress(number)
|
||||||
|
ELSE ' released
|
||||||
|
PRINT "Got button release"
|
||||||
|
RAISE ButtonRelease(number)
|
||||||
|
ENDIF
|
||||||
|
ELSE IF myevent AND 2 THEN ' joystick axis
|
||||||
|
RAISE StickMove(number, value)
|
||||||
|
ELSE
|
||||||
|
PRINT "Unhandled event: myevent is " & myevent
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
EVENT ButtonPress(ButtonNum AS Integer)
|
||||||
|
EVENT ButtonRelease(ButtonNum AS Integer)
|
||||||
|
EVENT StickMove(Axis AS Integer, Position AS Integer)
|
Loading…
Add table
Add a link
Reference in a new issue