Tuesday, April 26, 2011

The FrankenKindle - It's alive!

Every project needs a good name, and given the nature of this particular endeavor I can't think of anything that would top The FrankenKindle.  Now all I need is a theme song...

This week marked a huge milestone for the project.  The two large page turning buttons on the V.Reader device were used to control the page turn functionality of the Kindle 3.  And, wonder of wonders, it worked!

Here's a quick rundown of the components in the video (skip to the end to see the actual test).

(WARNING: Nerdspeak ahead.  Skip to the bottom if you value your sanity.  You've been warned...)

The V.Reader

We'll be using seven buttons in total from this device, although for this test only the two large arrow buttons on the front panel were used to turn individual pages.  They are simple dry-contact switches, which means that when they're activated it's basically the same as touching two wires together to make a connection.  Two wires were used per switch, and are routed back to the microcontroller on the breadboard.

The controller

For simplicity's sake I chose to use the Teensy++.  It's a USB-powered device based on an 8-bit AVR microcontroller, which allows easy connection to the PC for programming and also provides a convenient 5V supply to the rest of the circuit.  In addition, it is compatible with the Arduino environment which dramatically simplifies the programming phase. This particular unit is overkill for this application but we're hip-deep in the prototyping phase here so the emphasis is more on making it work than making it efficient.  That will come later.

The multiplexer

This is the multiplexer I chose, mainly because it's cheap, intended for digital signals, and has a breakout board already.  If multiplexers confuse you, just think of one of those old-school telephone operators sitting in front of a giant switchboard.  They take a jumper cable and connect two signals together so they can communicate.  That's exactly what happens here.


Let's look at the left-hand circuit for starters.  The short version is that pin 7 (called "1D") may be connected to any one of the four pins above it, pins 3, 4, 5 or 6 (1S4, 1S3, 1S2, or 1S1, respectively).  The signals IN1 and IN2 control which connection is made, and 1EN and 2EN enable it.  The EN signals allow the connection circuits to be handled independently, basically making this into a dual single-pole, quadruple-throw switch.  Each chip, then, should allow up to eight distinct connections to be made.

That's fantastic, except the breakout board supplied by SparkFun doesn't break out the 1EN and 2EN pins, so any connection made on one side of the chip is mirrored on the other.  1D and 2D are still distinct, but they cannot be controlled independently.  If 1D is connected to 1S3, then 2D must also be connected to 2S3.  This limits us to only four independent connections per chip, rather than eight.  (Yes, the two switch systems are electrically isolated, but since it is not possible to independently control them, half of the switch becomes useless for this application.)

Further, since I can't enable or disable the connection I must reserve one combination as a "home" and make sure it's not used.  The reason for this is simple - each connection simulates a key press event on the Kindle.  We must have a state where no keys are pressed, and the only way to do that with this chip as SparkFun sells it is to reserve one of the switch combinations and not connect it to the Kindle at all.  As such, out of eight possible connections we are only able to use three.

Fortunately I decided to buy spares, so I should have enough on hand to complete the first run of the FrankenKindle.  Eventually I'd like to make this project more user-friendly however, and this issue will need to be addressed.  It will likely require creating a custom PCB for the project.

The software

As detailed in a previous post, two hacks were used to improve the functionality of the Kindle for this application, Jailbreak and Launchpad.  When a key is pressed on the V.Reader, the Teensy sees that and uses the multiplexer to mimic pressing the specific key sequence to fire the Launchpad script, which will turn an individual page.  (Whew!)  This same procedure could be used without the software hack, but it would only be able to jump between chapters, not individual pages.

(This concludes the nerdspeak - welcome back!)

The test

Enough talk - here's a short video showing how it works.  Apologies for the horrible sound quality.

Tuesday, April 19, 2011

Successful keyboard test!

They say a picture is worth a thousand words.  I'm not sure who "they" are, and I imagine this word value is up for debate, but the idea is nice.

This video is 2:16, or 136 seconds in length.  At 25 frames per second (I have no idea if that's the case, but it's what Youtube recommends), that's 3400 words.  Don't worry, I won't put you through that.  I just want you to know how valuable this video really is...


Thanks to the great folks over at the Mobileread.com forums, it is now possible to remap hotkey combinations and individual keys to just about any function we could need.  In this case the 5-way Left and Right keys have been paired with the Shift key to allow them to turn individual pages.

One unexpected benefit of this technique is that the keys retain their original functionality if used without the Shift key.  That is, pressing the Right-side 5-way button will jump to the next chapter in the book.  But pressing Shift and then the Right-side 5-way button will advance only one page.

That's great, but the goal of this project was to be able to do this without using the Kindle's onboard keypad at all, instead using a custom keyboard with big cushy buttons.


This video shows a successful test of the system.  There are some very subtle timing issues that will need to be ironed out, and it now becomes clear that an intermediate controller will be required to handle the key sequencing.  This entire process should be transparent to the user; a single keystroke should advance a page. Fortunately there are a host of very simple controllers on the market that will be able to accomplish this task.

We've still got a long way to go, but this was an important milestone.  We've shown that the Kindle can be controlled externally, using whatever buttons we may find convenient.  Once the sequencing and timing issues are resolved, we can move on to actually building the custom keyboard using buttons harvested from the V.Reader.

See you next time!

Monday, April 18, 2011

Success!

I have not yet begun to void your warranties, BestBuy!

I thought my warranty shredding activities would be limited to popping off the rear case and tapping into the keypad's signal connectors.  Nope, it turns out the actual Kindle operating system needs a good dose of warranty-voiding hacks as well.  Fortunately the Great and Powerful Internet (henceforth known as the "GPI") came through once again.  Thanks to the aforementioned hacks (jailbreak, launchpad), I have successfully created hotkey sequences to allow the user to turn individual pages from the main keypad. 

The simple keystroke combination Shift + Right and Shift + Left (that's the left and right keys on the 5-way) will now allow the user to turn individual pages.  Interestingly enough, pressing the Right and Left buttons without first pressing shift retains their original function: jumping between chapters.

This is a huge success.  Proper documentation will follow in a later post, when I'm properly rested and have a chance to produce some decent pictures and maybe a demo video.  For now, it looks like the biggest hurdle so far has been overcome.

Thanks for reading!

Sunday, April 17, 2011

If Engineering were easy, anyone could do it!

No Engineering endeavor goes smoothly every step of the way, and this one seems no different.  After surprising success with the main keypad a couple weeks ago, it quickly became clear that the easy part was over.

It turns out that the main keypad and the individual page turn keys on the device edges use signals which are routed through two different connectors on the motherboard.  The 20-pin FFC (Flat Flex Cable) connector handles the main keypad signals, while the individual page turn keys on the edges are routed through two VERY small connectors, one 6-pin and the other merely 4. 

Pictures will follow in a later post.  For now though, the moral of the story is that tiny connectors are incredibly difficult to deal with.  The creation of a breakout board similar to that of the 20-pin main ribbon cable proved to be a spectacular failure.

So what alternatives do we have?  With the existing physical hack, we're only able to advance between chapters, not individual pages.  It seems clear that the physical keyboard alone won't be sufficient to complete this project.

Fast forward a few hours.  Some quality alone time with Google and more than a few newbie questions posted on www.mobileread.com and a possible solution is found.  Jailbreak the Kindle and install another software hack called Launchpad.  (Here is the page I used for the jailbreak operation, which pulls together information from a few different mobileread.com forum posts and presents it in a nice step-by-step instruction guide)  This should allow the keys to be mapped to just about any function we wish.  The idea will be to map the left and right keys on the 5-way to force them to turn pages, not chapters. 

So far the Kindle has been jailbroken and it's not (yet) a smoking ruin.  The road got a lot longer this week, but we're making good progress.

Stay tuned for pictures and detailed information about the software hacks. 

Sunday, April 3, 2011

Keyboard map complete!

This weekend's mini-project was simple - use a physical pushbutton like this to mimic the behavior of every key on the Kindle 3's main keypad.  The result?  Success!

Of course as we all know, every silver lining has a cloud.  It turns out that the D-Pad (called a "5-Way" in most Kindle documentation), while useful for menu navigation, cannot actually be used to turn a page. 

You read that right.  The Kindle offers pairs of oversized buttons on halfway up either side of the unit for turning pages but does not duplicate this functionality in the 5-Way connector they offer on the main keyboard.  These dedicated keys are routed to the motherboard through their own connectors.  It looks like I'll have to clone this second, much smaller connector as well.

Back to Mouser, and it looks like the smallest FFC (Flat Flex Cable) connector they've got has 6-pins, which matches nicely with one of the small connectors on the side of the Kindle.

The 6-pin page turning keypad connector
 marked by the upper-right arrow

Once the dedicated page turn keys are cloned, this phase of the project will be complete.  

Phase II begins with an organ transplant.  The main keypad from the V.Reader unit referenced in an earlier blog post will be removed and wired into an adaptor that will allow it to be used in place of the Kindle's own keypad.  This adaptor will also need to be created.

Phase III, hopefully the final phase, will be the creation of a simple stand for the assembly.  It will need to position the Kindle in such a way that the screen is easily visible, but will also need to present the custom replacement keyboard so my sister can use it.  Finally, the entire assembly will need to be physically secured to a desk or wheelchair tray to provide stability.

Thanks for reading!