rmick / LTTO_Library

Arduino library for the LTTO/LTX/LTAR Lasertag system (Lazertag)
13 stars 2 forks source link

LTX Grab&Go Team Games not reading team correctly #5

Open rmcmullanLB opened 3 years ago

rmcmullanLB commented 3 years ago

When I use an LTX in grab&go team mode (the switch on the tagger, unhosted team mode, or TTAG) and set it to team 1, readTeamID() returns team 0, player 2. When I set it to solo, it reads Team 0, player 1. Set to team 2, it returns Team 0, Player 3. Based on https://wiki.lazerswarm.com/wiki/2:3_Packed_Team_and_Player_Number This makes sense since unhosted team 1 uses 00001, while solo uses 00000, team 2 is 00010.

And if it were reading it as a hosted game, team would be in the first two digits instead of the last 2.

Is there a way to indicate that the game is unhosted team?

rmick commented 3 years ago

let me have a look into this over the next week or two and I will get back to you.

rmcmullanLB commented 3 years ago

Thanks. I put together this Google Sheet summarizing the different protocols, in case that's helpful: https://docs.google.com/spreadsheets/d/1xpZ0SXhO8nzwAiPHMphC0OclXuiXqwamKYJo7ee3Yac/edit?usp=sharing

On Wed, May 19, 2021 at 4:02 AM Richie Mickan @.***> wrote:

let me have a look into this over the next week or two and I will get back to you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rmick/LTTO_Library/issues/5#issuecomment-843993015, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW277IZPWRTUQDVBEDLYCTTOOLEPANCNFSM44ZYCKUQ .

rmick commented 3 years ago

Good find. I will add the logic to fix this in the next week or two.

Meanwhile you can work it out in your code.

Add this line to setup bool grabAndGoGame = false;

Add this in the relevant part of your loop if (ltto.readTeamID() == 0) { grabAndGoGame = true; teamID = ltto.readPlayerID(); // The playerID is used as the TeamID in G&G games }

I think that should work, but I have not actually tested it.

N.B. It is impossible to tell whether a game is Solo or Teams, as the tag contains the same data for both.

rmick commented 3 years ago

I have upload a fix. Please download the new version and test, then let me know if it works.

NB. Please make a backup copy of the old library, just in case I broke something else in the background. :-)

rmcmullanLB commented 3 years ago

Thanks for trying. I downloaded and replaced the LTTO library, then recompiled and loaded my Arduino nano with the sketch including LTTO.h and tested with an LTX set to different grab&go games. I get the same behavior on the serial monitor (ltto.readTeamID() gives Team 0, Player 2 when set to Grab&Go Team 1.

On Thu, May 20, 2021 at 12:52 AM Richie Mickan @.***> wrote:

I have upload a fix. Please download the new version and test, then let me know if it works.

NB. Please make a backup copy of the old library, just in case I broke something else in the background. :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rmick/LTTO_Library/issues/5#issuecomment-844825618, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW277IY7ULAEIUZDVOSCDTTOS5U5ANCNFSM44ZYCKUQ .

rmick commented 3 years ago

Try again please.

I had forgotten to actually upload the changes to github :-)

rmcmullanLB commented 3 years ago

Here's the error message I got:

C:\Users\rmcmu\Documents\Arduino\libraries\LTTO_Library-master\ProcessIR.cpp: In member function 'void LTTO::ProcessTag()':

C:\Users\rmcmu\Documents\Arduino\libraries\LTTO_Library-master\ProcessIR.cpp:20:26: error: 'struct LTTO::irMessage' has no member named 'isGrabAndGoGame' decodedIRmessage.isGrabAndGoGame = true; ^~~~~~~ C:\Users\rmcmu\Documents\Arduino\libraries\LTTO_Library-master\ProcessIR.cpp:23:26: error: 'struct LTTO::irMessage' has no member named 'player'; did you mean 'playerID'? decodedIRmessage.player = 0; ^~ playerID

I'm going to take a look at irMessage to see if I see anything.

On Sat, May 22, 2021 at 5:57 PM Richie Mickan @.***> wrote:

Try again please.

I had forgotten to actually upload the changes to github :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rmick/LTTO_Library/issues/5#issuecomment-846483445, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW277LOPOKYVJHWTL5TVQTTPBHJPANCNFSM44ZYCKUQ .

rmcmullanLB commented 3 years ago

I got it working. I updated ProcessIR.cpp, line 23, decodedIRmessage.playerID = 0; (added the ID after player)

LTTO.h, line 116 At the bottom of this structure, I added: bool isGrabAndGoGame;

That did the trick and now it works like a charm. I tried Grab and Go team 1, 2, and solo and they all worked as expected.

Thanks for cracking this open.

On Sat, May 22, 2021 at 7:09 PM Ryan McMullan @.***> wrote:

Here's the error message I got:

C:\Users\rmcmu\Documents\Arduino\libraries\LTTO_Library-master\ProcessIR.cpp: In member function 'void LTTO::ProcessTag()':

C:\Users\rmcmu\Documents\Arduino\libraries\LTTO_Library-master\ProcessIR.cpp:20:26: error: 'struct LTTO::irMessage' has no member named 'isGrabAndGoGame' decodedIRmessage.isGrabAndGoGame = true; ^~~~~~~ C:\Users\rmcmu\Documents\Arduino\libraries\LTTO_Library-master\ProcessIR.cpp:23:26: error: 'struct LTTO::irMessage' has no member named 'player'; did you mean 'playerID'? decodedIRmessage.player = 0; ^~ playerID

I'm going to take a look at irMessage to see if I see anything.

On Sat, May 22, 2021 at 5:57 PM Richie Mickan @.***> wrote:

Try again please.

I had forgotten to actually upload the changes to github :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rmick/LTTO_Library/issues/5#issuecomment-846483445, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW277LOPOKYVJHWTL5TVQTTPBHJPANCNFSM44ZYCKUQ .

rmick commented 3 years ago

Thanks for fixing the stupid errors.

Editing a library is tricky, you cannot do it in the Arduino editor (it cleverly locks you out to prevent beginners accidentally breaking a library). I use XCode to edit the library, and it cannot compilte Arduino code, so I did not spot the missing ID on playerID. It also does not have a SaveAll button, so I had forgotten to save the changes in LTTO.h

All fixed and uploaded now :-)

rmick commented 3 years ago

One more question.

What should happen with Hostile Zones in Grab and Go games. You will have noticed the unused IF statement that detects if the tag was sent by a hostile zone. I was thinking that maybe a PlayerID of 255 or similar. Alternatively I could add another bool into the decodedIRmessage called hostileZone.

What do you think is best.