Putting robotics at your service™

Free shipping on orders over $75

DIY Remote Control XBee controller for Robotics...

Print view Share :
Previous topicNext topic

Page 35 of 35 [ 511 posts ]

1 ... 31, 32, 33, 34, 35
Veteran ( offline )
Posts: 191
Posted: 2015-01-26 18:57 
works!


Taserin doesn't work so

Code:

;==============================================================================
; [CheckKeypad] function modified for serial Keypad
;
; Input Parameters:
;  FCheckModeChange: Should we do checks for mode change? Currently always true.
;
; Variables updated:
; keypress - the ascii value associated with that key.
;   rcv
;==============================================================================

fCheckModeChange var byte ; should we check for a mode change ?
CheckKeypad[fCheckModeChange]:



bPacket(0) = 0 ; assume no buttons pressed
bPacket(1) = 0
  keypress = " "
  CmdBtnsPrev = CmdBtns
  CmdBtns = 0
if fCheckModeChange then
fTModeChanged = FALSE
endif


serin cPAD_IN, cPAD_BAUD,5500,timeout, [keypress]

timeout:



;Read buttons - New version reads multiple keys as well are down.
if keypress = "1" then
bPacket(0).bit1 = 1
elseif  keypress = "2" 
bPacket(0).bit2 = 1
elseif  keypress = "3" 
   bPacket(0).bit3 = 1
elseif keypress = "A"
   bPacket(1).bit2 = 1
elseif  keypress = "4" 
   bPacket(0).bit4 = 1
elseif   keypress = "5"   
   bPacket(0).bit5 = 1
elseif  keypress = "6"
bPacket(0).bit6 = 1
elseif  keypress = "B"
bPacket(1).bit3 = 1
elseif  keypress = "7"   
   bPacket(0).bit7 = 1
elseif   keypress = "8"
   bPacket(1).bit0 = 1
elseif  keypress = "9" 
   bPacket(1).bit1 = 1
elseif  keypress = "C" 
   bPacket(1).bit4 = 1
elseif  keypress = "0" 
   bPacket(0).bit0 = 1
elseif  keypress = "F" 
   bPacket(1).bit7 = 1
elseif  keypress = "E"
   bPacket(1).bit6 = 1
elseif   keypress = "D"
   bPacket(1).bit5 = 1
elseif  keypress = "W"   
   CmdBtns.bit0 = 1
elseif   keypress = "X"
   CmdBtns.bit1 = 1
elseif   keypress = "Y"
   CmdBtns.bit2 = 1
elseif   keypress = "Z"
 CmdBtns.bit3 = 1
else
keypress=" "
endif

; Check to see if the state of the command buttons has changed.
if fCheckModeChange and (CmdBtns <> CmdBtnsPrev) then ;
if (CmdBtns & CMD_UP_MASK) and ((CmdBtnsPrev & CMD_UP_MASK) = 0) then
; CmD Up button has been pressed
if TransMode = TMODE_MAX then
TransMode = 0
else
TransMode = TransMode + 1
endif
fTModeChanged = TRUE
elseif (CmdBtns & CMD_DOWN_MASK) and ((CmdBtnsPrev & CMD_DOWN_MASK) = 0)
; CmD Down button has been pressed
if TransMode = 0 then
TransMode = TMODE_MAX
else
TransMode = TransMode - 1
endif
fTModeChanged = TRUE
endif

if fTModeChanged then
gosub ClearLCDDisplay
bTDataLast = 0xff ; make sure we will display something when it changes.
endif
endif

return



1 ... 31, 32, 33, 34, 35

All times are UTC - 5 hours [ DST ]. It is currently 2018-06-18 07:06