I have some Dell 2407 monitors mounted on a decent swivel mount, which makes switching to landscape for the odd game, movie or webex really easy. Except that you need to fool around in the display control panel each time. The monitor has numerous USB ports, so I'd like to make a small dongle with a tilt switch, to install in one of the rear USB ports, so that it sends a signal (keypress of a strange key?) to the PC when the monitor goes from portrait to landscape or back. Windows already has APIs (I think) to programmatically change the orientation of the logical display, so a small bit of C# should resolve the software side.
I got a nice overview image in the Windows app, where you can click on the display that the hardware is attached to. I also got global hotkeys working, so you can actually twist the device and the screen changes! Pretty cool...
Next issue: the digispark board has one of those PCB-track USB plugs, and it's a little bit short, so in my actual monitor I think only the power lines are making contact (they're a bit longer). I also seem to be having problems with some hubs - even with a USB extension, it's hit or miss whether the 'keyboard' is detected, whereas it's fine plugged into a standalone powered hub. It's not clear if this is an issue with borderline spec USB from V-USB or another power/connector issue. The real answer is to make my own dongle, I guess.
Switched to Linux - now I can actually program the DigiSpark! The final result is a HID keyboard, so shouldn't have the same driver issues.
I have a test working now, with a digispark and tiltswitch producing keystrokes as I move it. Currently it sends 'a' and 'b' so I can see what's going on, but the final version will be something like Shift-Win-F9 and Shift-Win-F10.
The software side flips nicely when a dialog button is pressed - next steps there are:
Something to draw a diagram of the screen layout so you can pick which monitor to rotate visually.
Register global keyboard shortcuts for those two keys.
The Digisparks and tilt switches have arrived. I also got a working C# app to test the rotation part. Current issues:
The digispark driver won't load on Windows 10
The Windows EnumDisplayDevices() API call produces "interesting" output - it would be nice if the IDs matched up with those in the Displays control panel. Otherwise, I'd want an OSD 'identify' option like that control panel does - so how to figure out which displays match up to which areas of the desktop?
It's conceivable you'd want more than one of these things, so I'm thinking about adding a 1-wire chip, just to get the unique ID. DS18B20 temperature sensors are about $2 a pop (the simple 'serial number' chips aren't really much cheaper, and I already have some temperature sensors).
I ordered some digisparks from ebay, and a packet of ball-tilt switches.
From the HID reference, I'm going to try using F23 and F24 to signal position 1 and 2 respectively (depending the the orientation of the monitor's USB ports, that might be portrait/landscape or landscape/portrait): http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
I also found an existing digispark example for a V-USB based keyboard.