Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: LED Wiz - talking to Unreal3  (Read 1756 times)

0 Members and 1 Guest are viewing this topic.

FritzStudio

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:August 23, 2008, 12:42:12 am
LED Wiz - talking to Unreal3
« on: August 18, 2008, 12:01:08 am »
Hi all,

I'm am trying to get a demo i've made in unreal3 engine to send commands to LEDWiz, but it seems that it cant talk to the OS Clipboard, so my initial idea of using it that way is shot.

Are there any other methods that you guys can think of that would allow the LEDWiz to hear commands from that engine or other apps?

thanks for your time!
Mike

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: LED Wiz - talking to Unreal3
« Reply #1 on: August 18, 2008, 12:11:06 am »
With MikeQ's LEDWiz.dll you can pretty much use any language to communicate to the LEDWiz. So it's really a matter of how you will get the Unreal engine talking to your app.

You can get the library with some sample source from here

If you need any help let me know, it sounds like it should be a pretty simple thing to do.

FritzStudio

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:August 23, 2008, 12:42:12 am
Re: LED Wiz - talking to Unreal3
« Reply #2 on: August 18, 2008, 12:50:48 am »
Thanks for your quick response!

I just grabbed the source and fired it up in C#, was a bit stumped, but i need to spend more time with it.

If you have a copy of Unreal3 Tournament, I'd love to send you my scene, I can explain everything that is going on, its all set up in Kismet, the Visual scripting language inside of Unreal3.

I'm betting there are several ways to go about this, this is part of my confusion :) 

I'll look into LEDWiz.dll, as it does seem pretty perfect for my needs


Mike

FritzStudio

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:August 23, 2008, 12:42:12 am
Re: LED Wiz - talking to Unreal3
« Reply #3 on: August 18, 2008, 02:08:23 pm »
its looking like Unreal doesnt like clipboards, as i've been contacted by some coders that have tried and offered up their examples that they describe as hacks.

Its been suggested that I go the TCPLink route. I've found a page describing setting up a client/server relationship that sends out external messages, in his case he just kicks out "Hello World"..  but i could easily see that being calls for the LEDWIz.

this make any sense?

FritzStudio

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:August 23, 2008, 12:42:12 am
Re: LED Wiz - talking to Unreal3
« Reply #4 on: August 18, 2008, 02:08:58 pm »

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: LED Wiz - talking to Unreal3
« Reply #5 on: August 18, 2008, 06:59:03 pm »
That is very simple to do then, you just need to set up a TCP Client in C# and listen for messages from the Unreal Engine on a local port (Eg. 127.0.0.1:666). There is a simple example here

The packets for the LEDWiz are fairly simple, so you need to implement two commands (SPA and PBA). These are explained in detail in the readme.txt included in the SDK archive. But in basic terms SPA turns LED's on and off, and PBA sets the intensity or brightness of LED's (a value between 0 to 49)

So the packets may look like this (and sending the data in "ASCII" packets would work fine, but it would obviously be faster if done with binary instead. But for simplicity sake I will show it in ASCII.

"SBA:LEDWizId,Bank0,Bank1,Bank2,Bank3,PulseSpeed"

To turn all LED's on LEDWiz Id 0 (Let's assume you only have one LEDWiz so Id will always be zero)

"SBA:0,255,255,255,255,2"

To turn all LED's off

"SBA:0,0,0,0,0,2"

Those numbers are just binary values that represent the state of the LED's in a bank. There are 4 banks each with 8 LED's (Total of 32). If you open up Windows Calculater (with scientific mode turned on), enter "255" then select "Bin" it will show 8 bits turned on (11111111) meaning turn on all LED's for that bank. Say we only want every second LED lit in the first bank. (01010101) type that in Calculator in Bin mode then select Dec for decimal. That is "85", so the command will look like this.

"SBA:0,85,0,0,0,2"

So in other words you need to use binary operations to turn LED's on and off.

Here is a function that simplfies the process of setting the bits. It's a function that can recieve an array of 32 bools  with one for each LED (true or false for on and off) and pack them into the 4 integer banks to send to the LEDWiz.

Code: [Select]
public void SetLEDState(int id, bool[] state, int pulseSpeed)
{
int i = 0;
uint[] bank = { 0, 0, 0, 0 };

for (; i < state.Length && i < 8; i++)
if (state[i]) bank[0] |= (uint)(1 << i);
for (; i < state.Length && i < 16; i++)
if (state[i]) bank[1] |= (uint)(1 << (i - 8));
for (; i < state.Length && i < 24; i++)
if (state[i]) bank[2] |= (uint)(1 << (i - 16));
for (; i < state.Length; i++)
if (state[i]) bank[3] |= (uint)(1 << (i - 24));

if(id < NumDevices)
LWZ_SBA(DeviceHandles[id], bank[0], bank[1], bank[2], bank[3], pulseSpeed);
}

Next you have the PBA command which accepts 32 values each a value from 1 to 49 to set the brightness of each LED using PWM. A value of zero will turn it off.

A PBA packet could look like this

"PBA:LEDWizId,32 Brightness Values,PulseSpeed"

So to set all the LED's to full brightness a packet may look like this

"PBA:0,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,0"

Obviously using ASCII to send the data will be rather slow, but sending the above in binary instead will only take 35 bytes instead of 103 bytes using ASCII like above.

FritzStudio

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 12
  • Last login:August 23, 2008, 12:42:12 am
Re: LED Wiz - talking to Unreal3
« Reply #6 on: August 19, 2008, 01:50:41 am »
thank you so much

(processing)