I must do a few jobs on R2 for FACTs, but when starting, I opened the Arduino IDE, got out the spare boards and my MEGA ADK was looking at me. I had ordered a PS3 Nav Controller and a good Bluetooth dongle a few weeks back, but hadn't looked at them. What could be the harm of booting up the example sketch and trying the PS3 controller library?
An hour or so later I had that running. But the library wouldn't work using the style of coding I had used before, so I was forced to adapt. I now have a much better grip on the timing approach. :) Should serve me well and I may well redo some of the droid code to refine the whole core.
A little over a week later I have the PS3 Dualshock3 and the PS3 Navigation controller working superbly, all coded up to send the droid script numbers and the stick values 50 times a second, while also outputting to the PC for debugging. I added a time-out to disconnect the pads after a set time of inactivity, and watching the output of the pad you could see the errors, so I added code to avoid the errors and disconnect if continues too long. Either controller can be used, and you can swap without touching the XBee box. The Dualshock is the same as my old PS2 setup and I have 32 script options and a couple of cool extras coded into the Nav code; hold L2 to change the drive type, and an extra step to protect the 2-3-2 command. Should be great for shows, going on patrol with the Nav and having the option of complete control via the Dualshock for really showing off. ;) I add an LED I could flash to represent the pad connection and show when buttons are pressed, then 6 more LEDs, 4 to represent the status that the old PS2 setup screen was used for, then a couple more, played with the code and got the 4 LEDs on the Dualshock working alongside 4 of the arduino LEDs. These Dualshock LEDs cause a delay of 0.47s when triggered, so after a lot of thought I decided that the only issue with that was drive control, either dome or feet, so I added some code to wait for 0.8s of no stick usage before flipping the LED, so if not moving the sticks the LED will change immediately, and if driving it waits. I also added automatic status changes when switching on the Nav, as that wont have some of the control options needed. Works like a charm. I made a little end shield for the Mega and added the LEDs there. So I now have an LED on the XBee/bluetooth setup for each of the following:
1. Leg Mode (on for 3 Leg, will default to 2 Leg i.e. off, if no droid connection)
2. Random Dome Motion
3. Random Sounds on/off (Also Left LED on Dualshock)
4. Speed Mode Fast is on, slow is off (2nd LED from the Left on the Dualshock, slow if Nav)
5. Feet Drive on/off (3rd LED from the Left on Dualshock, on if Nav)
6. Dome Drive on/off (4rd LED from the Left on Dualshock, on if Nav)
7. Pad Status LED, flash slow if off, boot flash and handshake flash, on if pad connected and 0.5s off when a script command is sent.
I have been planning a few upgrades for a while. The plan is to use the PS3 pads, and have an XBee/Bluetooth box with a touch screen, so you get the benefits of the pads but the range and reliability of the XBee. The screen will have the option to mount into the data door and the Nav into a pie panel, so the Nav can be presented by R2, and I can either have Bluetooth range or take the box out and use the better XBee range. :) Best of all worlds. Short term I will mount this in a box, with the LEDs in a line below the screen, and have an external battery, long term it would be great to shrink it and have the screen box a total of about 25mm thick, including the battery and Lipo charging circuits. :D
So i made a start looking at the screen. I have a 4.3" 4D Systems screen, I think i can use the current setup with the screen and have a total thickness not including battery of 33mm ish, so it wont be too bad. Just need to get a handle on the code for the screen and see about making an interface. :D I think I will try and get that working and so the pocket box code ideas will all be proven before i move onto the droid side. Here is a few shots of the setup so far:
I will be bringing this set-up to FACTS as a board droid, so i can test the Bluetooth range and stability in the worst possible conditions.
Really enjoying being back in the code and testing. But I have to put this aside and get R2 running, I will potter with the screen over the next few weeks and update you when I have some screenshots and video. :D