Go to Post I blame FIRST for being the best thing that has happened to me. - vivek16 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2004, 00:05
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Programming joysticks

here they are in binary, decimal, and hex forms...

Neutral: 001011xx 44 0x2C
Up Left: 111111xx 252 0xFC
Up: 111111xx 252 0xFC
Up Right: 111111xx 252 0xFC
Left: 011000xx 96 0x60
Right: 110010xx 200 0xCB
Down Left: 101001xx 164 0xA4
Down: 100101xx 148 0x94
Down Right: 110101xx 212 0xD4
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)

Last edited by deltacoder1020 : 16-02-2004 at 00:08.
  #2   Spotlight this post!  
Unread 16-02-2004, 00:17
Guest
 
Posts: n/a
Re: Programming joysticks

Here's a diagram that gives the full range of values and the value to test with AND is bold.

252-255*252-255*252-255
*96-99***44-47**200-203
164-167*148-151*212-215
  #3   Spotlight this post!  
Unread 16-02-2004, 00:20
Robert Hafner's Avatar
Robert Hafner Robert Hafner is offline
FIRST Alumni
no team
 
Join Date: Mar 2003
Rookie Year: 2000
Location: Springfield. MA
Posts: 34
Robert Hafner is on a distinguished road
Send a message via AIM to Robert Hafner Send a message via MSN to Robert Hafner Send a message via Yahoo to Robert Hafner
Re: Programming joysticks

Because the last bits are unreliable (from what i've read), how will this affect the program? Should I stick with a general area? example:

Code:
if (p1_wheel >= 42 && p1_wheel <= 46)
    // I am neutral
if (p1_wheel >= 250 && p1_wheel <= 254)
     // I am upperleft;
  #4   Spotlight this post!  
Unread 16-02-2004, 00:30
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Programming joysticks

your previous code with the bitwise AND (&) should work fine - just use the hex or decimal codes I posted above (because you AND it with the original constant, the lower bits don't matter, and thus it will be true for the entire range).
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #5   Spotlight this post!  
Unread 16-02-2004, 22:39
Robert Hafner's Avatar
Robert Hafner Robert Hafner is offline
FIRST Alumni
no team
 
Join Date: Mar 2003
Rookie Year: 2000
Location: Springfield. MA
Posts: 34
Robert Hafner is on a distinguished road
Send a message via AIM to Robert Hafner Send a message via MSN to Robert Hafner Send a message via Yahoo to Robert Hafner
Re: Programming joysticks

at the risk of sounding dumb, how does the AND thing work, and what do I need to do with it?
  #6   Spotlight this post!  
Unread 17-02-2004, 00:06
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Programming joysticks

Code:
if( (p1_wheel & 0xC0) == 0xC0 )
"&" is the "bitwise AND" operator. that means that it looks at individual bits of a value, and does an AND operation. AND is defined as follows: true if both inputs are true, otherwise false. a logic table:

0, 0 = 0
1, 0 = 0
0, 1 = 0
1, 1 = 1

so as you can see, it will only return 1's in the places where both numbers have ones. thus, it will only return all of the bits of one value if the same bits are 1's in the other value. the if statement essentially checks to see that all of the bits that are 1 in 0xC0 are also 1 in p1_wheel. replace 0xC0 with whatever "bitmask" (set of bits) you want to test as being 1.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Compatition Angela06 Programming 30 08-04-2005 23:12
Could use some help with joysticks . . . archiver 2001 5 23-06-2002 23:36
Pneumatics electrical wiring and programming archiver 2001 1 23-06-2002 23:10
Calibrating speed controllers and joysticks thedillybar Technical Discussion 4 11-02-2002 13:24
pbasic programming punarhero Programming 4 21-01-2002 23:32


All times are GMT -5. The time now is 05:31.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi