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);
    try
    {
        // 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!!
    finally
    {
        i.UnlockBits(bData);
    }
    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

How to change the width of the text insertion cursor

February 6, '07 Comments [9] Posted in Musings
Sponsored By

I got this question today:

Do you know how to change the icon used for the blinking insertion point in VStudio?  I’d like to make it a little more visible…

Here's how to change the width for that little "i-bar." Go to Control Panel | Accessibility, then to the Display Tab, and move the Width Slider to the right.

The accessibility stuff in Windows is very nice. I say that as someone who used to have VERY bad eyes and then got Lasik'ed by a machine running Windows 98.

Have you been LASIK'ed? How'd it go?

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

Isabel Hanselman

February 6, '07 Comments [9] Posted in Musings
Sponsored By

We were up for 38 hours straight this weekend, with many of those house spent in the hospital waiting room. Why you ask? We were waiting for the chance to meet my brother and his wife's first child, Isabel. She was 8 pounds, 5.5 oz (!) and 21 inches long. Born the old fashioned way at 2:42pm on a brisk Sunday afternoon after about 21 hours of labor.

Isabel has some hearty lungs on her and has seen fit to alert the entire hospital floor to her arrival. She'll live on a farm in the Willamette valley with a load of different animals including two Nigerian Dwarf goats that I suspect she'll be riding bareback within the year. More importantly she'll have her own pony and two loving parents. 

Z was shocked to find he wasn't the youngest Hanselman any longer, and as such no longer the Center of The World. We suspect that his ego will recover from this offense and he and his new cousin will become fast friends.

We all wish Josh and his wife Megan the very best. Since Mo and I have an extensive experience spanning nearly 14 months of childrearing, they can expect all sorts of unsolicited advice in the coming eighteen years.

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

Free Refactor for ASP.NET Software from the makers of CodeRush

February 5, '07 Comments [4] Posted in Tools
Sponsored By

I'm a huge CodeRush fan, as you may know. CodeRush take a while to really grok, and some folks don't want to spend $250 on it. They also offer just Refactor! Pro for $99 with 75 refactorings (CodeRush includes these, plus the underlying engine) for those who really just want the refactorings.

If you don't use either of these, and you want a FREE Refactoring tool for ASP.NET, run, don't walk over to the Refactor! for ASP.NET (Beta) and check it out.

(Note that the ASP.NET refactorings in this tool are included in the Refactor! Pro updates, so don't install this tool if you already have Refactor Pro.)

I loves me some free tools.

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

Asking Permission of your Docking Stations

February 5, '07 Comments [26] Posted in Musings
Sponsored By

For years I've avoided Docking Stations Port Replicators. Early on, they at least made sense, because they had a bunch of ports that your laptop didn't already have. Now, other than more USB ports and the occasional DVI port, most Docking Stations seem like Port Duplicators. Sure, folks argue that you don't have to plugin multiple cords, but I don't personally find it all that difficult to plug in the monitor and one USB hub.

Anyway, the real point here is this - Has docking/undocking ever worked in Windows? The only docking station I've ever used that hasn't sucked egregiously has been the Toshiba MultiDock II Docking StationIt's for the Portege m200/205 Tablet PC and is not only a docking station, but also a stand that expects you to use the laptop screen as the primary monitor. The docking station experience in Vista with this laptop, so far, seems to be fine. No errors, no troubles, although for some reason when I'm docked I can't go into standby.

However, things aren't so rosy on the Windows XP SP2 totally fresh install side. I just got a Lenovo ThinkPad T60p. A fine laptop indeed. It also happened to come with a Docking Station. The station has lock-and-key on the top with two buttons marked "1" and "2" that I'm apparently supposed to press in order. When I press the first one I get a message telling me that:

"You cannot eject your computer because of of the devices in the docking station, "Docking Station," cannot be stopped because of an unknown error. Since this device is still being used, do not remove the computer."

Sometimes I'll get the same error except it'll say "USB Printing Support" - and I'm not printing.

On the other hand, when I plug my new T60p into the docking station, it just reboots. no blue screen, no How's your Father, just black screen, then BIOs. I'm not going to use the docking station anymore. Sigh.

From my point of view, I need my Docking Station to understand this. When I pressed the Undock button, that wasn't a request. I'm not asking your permission, Docking Station, if I can take my computer with me. Understand this, Mr. Station, I'm taking the computer with me, and I'm taking it now. The fact that I pressed the button at all was a kindness - a heads up, if you will - to you. If you choose to do something about it, cool, do what you have to do and shut down what you need to shut down, but if you have a problem doing that, you should error on the side of "I guess he's not coming back" not on the side of "Don't Leave!"

Seems to me the design of the Undocking experience is sub-par at best, similar to the "Unplugging a Device" experience. Much of the device related errors are like this. When an anonymous dialog tells me that a Device can't do something, why doesn't it tell me WHY not, and offer some suggestions about how I can move forward? If you're going to put up a roadblock, as a designer, always offer a detour sign so I can continue the journey.

Does your docking station experience suck as well?

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

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