[NXC] Mindsensors PSP-Nx Incorrect Constants

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

[NXC] Mindsensors PSP-Nx Incorrect Constants

Post by muntoo »

They should be:

Code: Select all

#define 	PSP_BTNSET2_SQUARE   0x80
#define 	PSP_BTNSET2_CROSS   0x40
#define 	PSP_BTNSET2_CIRCLE   0x20
#define 	PSP_BTNSET2_TRIANGLE   0x10
#define 	PSP_BTNSET2_R1   0x08
#define 	PSP_BTNSET2_L1   0x04
#define 	PSP_BTNSET2_R2   0x02
#define 	PSP_BTNSET2_L2   0x01
Possibly the same with PSP_BTNSET1_xxx.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by afanofosc »

This will be fixed in the next release. Thanks for reporting the problem.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by mattallen37 »

Before I learned how to use constants and bitwise operators/comparators, I designed my own set of code to determine what buttons are pressed. Here is the code that is more than just tried and true to work (used it in hundreds of programs).

Code: Select all

    ReadSensorMSPlayStation(PSP_Port, PSP_Addr, b1, b2, lx, ly, rx, ry);

    B2=b2*(-1)+255;
    if (B2>=128){squ =1;B2-=128;}else{squ =0;}
    if (B2>=64) {crs =1;B2-=64;} else{crs =0;}
    if (B2>=32) {cir =1;B2-=32;} else{cir =0;}
    if (B2>=16) {tri =1;B2-=16;} else{tri =0;}
    if (B2>=8)  {R1  =1;B2-=8;}  else{R1  =0;}
    if (B2>=4)  {L1  =1;B2-=4;}  else{L1  =0;}
    if (B2>=2)  {R2  =1;B2-=2;}  else{R2  =0;}
    if (B2>=1)  {L2  =1;B2-=1;}  else{L2  =0;}

    B1=b1*(-1)+255;
    if (B1>=128){lft =1;B1-=128;}else{lft =0;}
    if (B1>=64) {dwn =1;B1-=64;} else{dwn =0;}
    if (B1>=32) {rght=1;B1-=32;} else{rght=0;}
    if (B1>=16) {up  =1;B1-=16;} else{up  =0;}
    if (B1>=8)  {str =1;B1-=8;}  else{str =0;}
    if (B1>=4)  {sr  =1;B1-=4;}  else{sr  =0;}
    if (B1>=2)  {sl  =1;B1-=2;}  else{sl  =0;}
    if (B1>=1)  {sel =1;B1-=1;}  else{sel =0;}
Just because I have been using this for so long, and don't want to go back and change all my programs, I still haven't updated to a better method yet.

According to that, the constants should be like this for button set 1(based on doing *(-1)+255 which inverts all the bits like a NOT would do, like Muntoo must be doing).

Code: Select all

#define 	PSP_BTNSET1_LEFT   0x80
#define 	PSP_BTNSET1_DOWN   0x40
#define 	PSP_BTNSET1_RIGHT  0x20
#define 	PSP_BTNSET1_UP     0x10
#define 	PSP_BTNSET1_STR    0x08
#define 	PSP_BTNSET1_R3     0x04
#define 	PSP_BTNSET1_L3     0x02
#define 	PSP_BTNSET1_SEL    0x01
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by afanofosc »

What are STR and SEL? These two buttons aren't listed in the docs that I have from mindsensors.com.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by muntoo »

afanofosc wrote:What are STR and SEL?
Start and select buttons respectively. The mindsensors demo program didn't include them either, for some reason. They work OK, though.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by mattallen37 »

Muntoo is right. However, I though it was the l3 and r3 that were left out of the mindsensors docs... I guess I was probably wrong.

Anyhow, they should be included in the NXC and the mindsensors docs.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by mightor »

Matt,

Pop a mail to [email protected] and let them know about the omission in the docs :)

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by muntoo »

mattallen37 wrote:l3 and r3 that were left out of the mindsensors docs...
Those were missing too, IIRC. :)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Post by mattallen37 »

Xander,

I thought I had told Deepak, but maybe I forgot. He is away on vacation right now anyhow, but I'll (try to remember to) mention it in my next email.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests