Hello,
I’m looking at adding the xbrat gun code to my hexapod. In doing so, I’ve stripped (from what I can tell) are all the elements needed to get it to work. I’m new to embedded programing and would like to get someone experienced to double check my thoughts/comments on each line and perhaps answer my questions.
;This sets the constants
RGUNP con p16
RGswP con p17
LGUNP con p18
LGswP con p19
;Set var type
RSwitch var bit
PrevRSW var bit
LSwitch var bit
PrevLSW var bit
;Not sure what in# represents, is this an input pin?
RSwitch = in17
LSwitch = in19
;set constant
BUTTON_DOWN con 0
BUTTON_UP con 1
;I shouldn’t need this if I’m not using a servo to move the gun?
if PrevRSW = 0 AND RSwitch = 1 then
hservo [RGUNP-7000\0]
else
PrevRSW = RSwitch
endif
;I shouldn’t need this if I’m not using a servo to move the gun (same as above)?
if PrevLSW = 0 AND LSwitch = 1 then
hservo [LGUNP-7000\0]
else
PrevLSW = LSwitch
endif
;Read incoming bits to perform some action
IF (DualShock(2).bit3 = 0) THEN ;R1 Button test
hservo [RGUNP\7000\0] ;Shouldn’t need this as it moves the servro, correct?
PrevRSW = BUTTON_UP ;Does this trigger to switch to fire?
ENDIF
IF (DualShock(2).bit2 = 0) THEN ;L1 Button test
hservo [LGUNP\7000\0] ;Same as above
PrevLSW = BUTTON_UP
ENDIF