Adalight hack to cockpit info lights
Moderators: adafruit_support_bill, adafruit

Adalight hack to cockpit info lights

by TonyH on Thu Oct 17, 2013 3:12 pm

Hi,

I'm a "bit" of a fan of Mechwarrior online - and have been using the adalight set up for a while with great success.

http://www.youtube.com/watch?v=TchvJRBBtWU

However it struck me that I could use the adalight approach to give LED readouts on the in game HUD.
(in the video, for instance, you can see the yellow and red bars either side of the map move up and down, I thought it'd be cool to have an actual bank of LED's turn on and off.

So what I want to do is hack the adalight processing code, assign my own screen locations for sampling for each LED and then output that to the arduino using the existing serial comms.

Easy !! :D

err well maybe not... :cry:

I've been fiddling with the adalight processing code and going round in circles a bit. :? :shock:

I'm not sure what the best bit of code to fiddle with would achieve this best ? Anyone got any hints?
Am I better off writing something from scratch ? in which case any hints on how to get a single LED to light from a single sampling point?

Thanks in advance for any help.

T

ps apologies if this is in the wrong forum section.. just occurred to me that it might belong somewhere else as although it's a project with an arduino in it I don't need help with the arduino bit.
TonyH
 
Posts: 12
Joined: Sun Jan 15, 2012 12:32 pm

Re: Adalight hack to cockpit info lights

by pburgess on Fri Oct 18, 2013 12:27 pm

Hey there. Cool idea, I'd never thought of using the Adalight code for something like that.

Is this something you want working in addition to the ambient effect around the screen perimeter, or do you just need the HUD indicators? The code would be hacked up differently in each case.
User avatar
pburgess
 
Posts: 2535
Joined: Sun Oct 26, 2008 1:29 am

Re: Adalight hack to cockpit info lights

by TonyH on Sat Oct 19, 2013 2:40 am

Ooo... Errr...

That's a good question.

If you could manually assign the areas then I guess you could always manually assign the sampling points for the ambient effects?

You could always use another adalight rig for the ambient lights? (I've got 3 :-) ) and I'm trying to get the pi based adalight system featured in the blog working anyway (which would take over ambient effects).

I have tried using light pack, which allows you to choose where the sampling points are but it enforces a minimum sampling area which is too large.

Thanks for the help in advance.

Tony
TonyH
 
Posts: 12
Joined: Sun Jan 15, 2012 12:32 pm

Re: Adalight hack to cockpit info lights

by TonyH on Sat Oct 26, 2013 9:58 am

So I've had a bit of a fiddle and come up with a workaround to demonstrate proof of concept.

http://www.youtube.com/watch?v=G4RXGlLE1bo

Here you can see the different weapon states:

I've written a script in Autoit that creates a Gui window and then sets it's background colour to the colour of the weapon status indicators.

This gui window sits on my second window and then the adalight script is configured to scan that.

et voila - the gui changes colour with the game - the adalight scans the gui - the arduino sets the led colour.
Now I'm fully aware that the coding-cognoscenti amoungst you have now devloped the sort of twitch normally caused by someone dragging their fingers down a blackboard. This is a kludge, I know. But I wanted to see what it was like in principle. It's a horrible cpu hog and has wiped 25% of my frame rate off the game.

It's thrown something up already - the background of the indicators in game is semi transparent. I think I'll have to think long term about somesort of filtering on the values "what's the colour, is is mostly green? then send green"

T
TonyH
 
Posts: 12
Joined: Sun Jan 15, 2012 12:32 pm

Re: Adalight hack to cockpit info lights

by TonyH on Tue Oct 29, 2013 1:50 pm

So While I'm waiting for Phil's return to help with integrating this with adalight proper I'm attempting a different approach.
(and so people don't just think I'm sat here just flapping)

So...

What I'm going to try and do it based on the colour of a particular part of the screen - send a preset colour command to the rgb string on the arduino.

So far I've gotten a piece of code on the arduino that sets the colour of the leds to Red green or blue based on the incoming serial stream. and a piece of processing code that sends R or B over serial when I click a mouse button - and - well it kinda works!

I have flashing green and blue lights - not proper control yet. I think I need some sort of end bit output stream from processing.

T
TonyH
 
Posts: 12
Joined: Sun Jan 15, 2012 12:32 pm

Re: Adalight hack to cockpit info lights

by adafruit_support_mike on Tue Oct 29, 2013 3:54 pm

That's more an issue of transmission protocols than hardware, so you have plenty of room to experiment. There are lots of existing protocols with various amounts of reliability and error recovery.

For the short term, try doing a simple loopback test. Send some information from Processing to your Arduino, then have the Arduino send it back. It's been a while since I worked with Processing, but I recall issues where the serial buffer needed to be flushed every once in a while.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9189
Joined: Thu Feb 11, 2010 1:51 pm

Re: Adalight hack to cockpit info lights

by TonyH on Tue Oct 29, 2013 4:50 pm

That's kind of what I've been trying to do... thanks :D
TonyH
 
Posts: 12
Joined: Sun Jan 15, 2012 12:32 pm