Scott Hanselman

Showing Video on an Optimus Mini Three

February 6, '07 Comments [13] Posted in Coding4Fun | Programming | Reviews | Screencasts | Tools
Sponsored By

I got frustrated with MSBUILD today so I took a lunch break to clear my mind and decided to play with my Optimus Mini Three (user's manual). The hardware is really lovely. Sincerely. Each key is 96x96 24-bit color and very bright.

However, while their software configurator is pretty as heck, their Plugin Model is stuck in the world of VTables and is largely unusable for the general hacker out there. If you want to write a plugin, you do it in C++ and implement a Create() method and export it. There are three pure virtual methods that a plugin writer needs to implement, GetInfo, Paint, and OnKeyDown. My preferred software environment is managed. Full stop. I'm not going to apologize for preferring it. I was a bad-ass in C++ back in the day, but I fully recognize that those days are over, and I'm not going to write another lpcszcbFoo* again.

I'm pretty disappointed that I'd need to do all that unmanaged dancing. That said, if you, dear reader, would like to dance, I'd like an unmanaged shim in C++ that forwards these three calls to a parallel C# managed interface. Any takers? Give me a call. I'm sure we could work on it together and give it back to the company so their plugin model wouldn't suck so much. It'd really make the device take off, I think. I'd love to do a Continuous Integration widget.

Anyway, while they are a USB device, as with all good (read: usable/hackable) USB devices they are really a "Prolific USB-Serial" Device so they are addressable via a virtual COM port and they have a well defined spec. So instead of a plugin, this is currently a command line app. I suspect it'd be pretty easy to make it a Tray App and basically rewrite their config app in .NET.

They also include a C# sample that pushes bitmaps to the buttons as byte[] arrays. I used the existing IVideoSource libraries from the brilliant Andrew Kirillov (he worked on the motion detection baby article for Coding4Fun with me) and captured each frame from the AVI and resized it to 96x96 before pushing it to the Mini Three.

The SendToButton method takes a .NET Bitmap and a button number apart and sends it as an array that's 96x96x3 (3 for R,G,B). It calls the Optimus C-style library via PInvoke calls.

public unsafe static void SendToButton(int button, Bitmap i)
    byte[] bmpBytes = null;
    BitmapData bData = i.LockBits(new Rectangle(new Point(), i.Size), 
ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
        // number of bytes in the bitmap
        int byteCount = bData.Stride * i.Height;
        bmpBytes = new byte[byteCount];
        // Copy the locked bytes from memory
        Marshal.Copy(bData.Scan0, bmpBytes, 0, byteCount);
    // don't forget to unlock the bitmap!!
    IOptimusMini.ShowPictureBlocking(button, bmpBytes);

Here's a fantastically poor video taken with a cell phone camera that shows an AVI of a plane landing on the second mini-three button. The frame rate is crap, but it'll do. I've also got the Mini Three showing my infant son's internet "cradle cam" via a secure MJPEG stream as well. I think I'll do a Vista Side Show driver at some point as well.

Video: Video on an Optimus Mini Three. I'll do a more complete Coding4Fun Article soon.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Wednesday, 07 February 2007 01:11:17 UTC
I haven't convinced the wife I need one of these yet... I'm assuming there's a user-mode process that hosts the plugin code and bridges the stuff to a kmode USB driver (or via the virtual serial interface)? Can't imagine they're using UMDF yet. I've got a few minutes, I'll see what I can whip up.
Matt Davis
Wednesday, 07 February 2007 02:20:14 UTC
You've got mail...
Matt Davis
Wednesday, 07 February 2007 02:37:17 UTC
Have you got yours to work with Vista yet? Mine found a driver for it, but the apps don't seem to connect to it...
Erv Walter
Wednesday, 07 February 2007 02:49:57 UTC
Bah.. it looks like I got beat.. But I sent you some code also.
Wednesday, 07 February 2007 10:12:29 UTC
About plug-ins... we want to add some to our .net app, but don't want to reinvent the wheel. Can anyone recommend a nice, light-weight example to follow?
John Hatton
Wednesday, 07 February 2007 19:28:14 UTC
I see you found another use for your lovely book. :-D


that's pretty cool!
Wednesday, 07 February 2007 19:32:11 UTC
oh, btw, you made it on engadget

Wednesday, 07 February 2007 20:00:32 UTC
Good god, man, how do you find the time to do this stuff? Especially with a child.

Pretty sweet, though.
Wednesday, 07 February 2007 20:01:59 UTC
Dude, it was 15 min at lunch...honest.
Wednesday, 07 February 2007 20:45:00 UTC
"About plug-ins... we want to add some to our .net app, but don't want to reinvent the wheel. Can anyone recommend a nice, light-weight example to follow?"

Great example at dnrTV:

Once you have that figured out, there's more information about Providers in .NET at:
Wednesday, 07 February 2007 21:32:39 UTC
You've been dugg...
Scott Dougherty
Friday, 09 February 2007 08:44:06 UTC
In russian news site you are called "american hacker". This is funny :-).
Link for the history -
Thursday, 15 March 2007 00:20:51 UTC
My boss just handed me one of these button pads and told me to make it do something cool. I'm inspired with the things you are making it do. I am big into home automation and I'm looking to develop my own plugins for this thing. I don't know any C programing... can I do any customization with python or perl?

One idea for a useful app for me would be to make the 2 buttons on the left and right scroll through a list of possible A/V sources, and when the middle button is pressed it sends a signal to my home automation controller to set that source on the tv.
I also use switchers and scalers in these home automation systems. If I could somehow take a downscaled composite feed from my switcher and send that image into one of the buttons, it would be extremely slick.

Any links to source code I can tinker around with would be greatly appreciated.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.