{"id":20441,"date":"2023-07-28T16:27:06","date_gmt":"2023-07-28T09:27:06","guid":{"rendered":"https:\/\/www.makeriot2020.com\/?p=20441"},"modified":"2023-07-28T16:27:16","modified_gmt":"2023-07-28T09:27:16","slug":"the-emergency-mouse-a-project-born-out-of-necessity","status":"publish","type":"post","link":"https:\/\/www.makeriot2020.com\/index.php\/2023\/07\/28\/the-emergency-mouse-a-project-born-out-of-necessity\/","title":{"rendered":"&#8220;The Emergency Mouse&#8221; &#8211; A project born out of necessity"},"content":{"rendered":"\n<p>Imagine You are working on a project late on a Friday evening and suddenly your mouse stops working&#8230; You can not scroll, and the right-side button won&#8217;t respond to your clicks&#8230; At the same time, you have a project design that has got to get finished&#8230; and the shops are all closed already&#8230; <\/p>\n\n\n\n<p>These were the circumstances that led to the birth of &#8220;The Emergency Mouse&#8221; &#8211; A project born out of necessity. How did I solve my problem?<br><br>Having access to a lot of electronic modules saved the day. As a maker, I always have various modules and gadgets lying around, and on this unfortunate evening, I remember that the RP2040 has USB HID support. Combine that with a simple Analog Joystick module, a rotary encoder and some push buttons, add about 30 minutes worth of browsing the internet, struggling along with a broken mouse &#8211; we have to give the old one credit, it had a very long and hard life, and I finally found some example code that did not just jiggle the mouse pointer or do something equally silly&#8230; <\/p>\n\n\n\n<p>The only problem with all of that was that the code was for CircuitPython&#8230; I generally dislike using Python on a Microcontroller, as I believe it is better suited for the computer, but, I am warming up to the idea&#8230; slowly&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The initial fix &#8211; a mess of wires on a breadboard<\/h2>\n\n\n\n<p>I quickly grabbed a RaspBerry Pi Pico out of a box, plugged it into a breadboard, loaded Circuitpyth and fired up the example code I got on the internet&#8230; While promising, It did not exactly do what I wanted&#8230; so a few minutes later, after some coding, I had a moving pointer, controlled by the small thumb joystick module, and with the center button as a &#8220;right button&#8221;&#8230; <br><br>So far so good&#8230; I can work more easily, but still did not have scrolling&#8230; so lets hit the datasheets and documentation on the Adafruit Website (not sponsored) and add a rotary encoder&#8230; works well, add more buttons, etc etc&#8230; <br><br>Eventually it was all done, and about 1 hour has passed, but we were left with a huge ugly mess on a breadboard, and a lot of unused GPIO pins.. So this Pico must go&#8230; it can be used for something more useful later&#8230; <br><br>Then my eye fell on a SEEED Studio XIAO RP2040 module, almost begging to be used&#8230; This is smaller, more compact&#8230; lets try that &#8230; <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"545\" height=\"403\" data-src=\"http:\/\/makeriot2020.com\/wp-content\/uploads\/2023\/07\/359672798_181949358210014_6870040927341044796_n.png\" alt=\"\" class=\"wp-image-20448 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2023\/07\/359672798_181949358210014_6870040927341044796_n.png 545w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2023\/07\/359672798_181949358210014_6870040927341044796_n-300x222.png 300w\" data-sizes=\"(max-width: 545px) 85vw, 545px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 545px; --smush-placeholder-aspect-ratio: 545\/403;\" \/><figcaption class=\"wp-element-caption\">Initial breadboard version, here shown with the SEEED Studio XIAO RP2040<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What functions did this &#8220;mouse&#8221; have<\/h2>\n\n\n\n<p>After changing to the XIAO RP2040, things went very quick&#8230; <\/p>\n\n\n\n<p>I added two buttons for scrolling up and down, simulating a mouse wheel,<br>but kept the encoder&#8230; which, while VERY awkward to use at this stage, definitely had potential in the long run&#8230; <br><br>I also added another button to take over the function of a right button, while the center button on the joystick became left&#8230; <\/p>\n\n\n\n<p>Disaster averted, with only about 2 hours wasted, I returned to my project and managed to get it finished using the &#8220;improvised-mouse-on-the-breadboard&#8221; contraption&#8230;<br><br>That night, while lying in bed, trying to get to fall asleep, the possibilities of this &#8220;contraption-on-the-breadboard&#8221; would not let me go&#8230; I am fairly old-school, and during the late 80&#8217;s and early 90&#8217;s owned quite a few &#8220;roller-ball&#8221; mouse devices&#8230; these later became trackballs, and being excessively overpriced, was promptly removed from my environment &#8211; the old ones did not last very long, and the new ones were, as I said, overly expensive&#8230; <br><br>I did however never forget the ease of use that first &#8220;rollerball mouse&#8221; gave me all that years ago, using only my thumb to move it around etc etc&#8230;<\/p>\n\n\n\n<p>This idea would have to be investigated, and turned into a PCB&#8230; with that, I finally drifted off to sleep&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The PCB design<\/h2>\n\n\n\n<p>The next morning came, and due to reasons unknown, as well as being lazy, I decided not to leave the house, and go buy a new mouse. lets try online&#8230; No, they are crazy &#8211; I am not paying that for a mouse! <\/p>\n\n\n\n<p>All the time using the &#8220;contraption-on-the-breadboard&#8221;. So this thing started growing on me&#8230; lets design a PCB <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"557\" height=\"403\" data-src=\"http:\/\/makeriot2020.com\/wp-content\/uploads\/2023\/07\/359560470_1147520759984217_6363018481416469634_n.png\" alt=\"\" class=\"wp-image-20446 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2023\/07\/359560470_1147520759984217_6363018481416469634_n.png 557w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2023\/07\/359560470_1147520759984217_6363018481416469634_n-300x217.png 300w\" data-sizes=\"(max-width: 557px) 85vw, 557px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 557px; --smush-placeholder-aspect-ratio: 557\/403;\" \/><figcaption class=\"wp-element-caption\">The Initial PCB design<\/figcaption><\/figure>\n\n\n\n<p>After a few hours spent on deciding on optimal layout, I came up with this&#8230; <br>It was still a bit unrefined, but definitely had potential&#8230; It lacked a dedicated center button, and those momentary push-buttons requires a lot of force to use&#8230; but as a prototype, why not&#8230; <br><br>Let&#8217;s get this manufactured.<br><br>For this build, since I used a SEEED Studio module, I decided to send it to SEEED for manufacturing&#8230; no need to get components from various places, as they should have all in stock&#8230; <\/p>\n\n\n\n<p>Seeed Studio&#8217;s Fusion service seamlessly marries convenience with full-feature capabilities in one simple platform. Whether you are prototyping or looking for a mass production partner or based on open source product customization requirements and other design manufacturing services, Seeed Studio Fusion service is catered to your needs starting with a simple online platform. <a href=\"https:\/\/www.seeedstudio.com\/fusion.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.seeedstudio.com\/fusion.html<\/a><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The PCB arrives from the factory<\/h2>\n\n\n\n<p>During the entire time that it took for the PCB to be manufactured and assembled, I was still using this &#8220;homemade mouse&#8221; &#8211; I started calling it a mouse now&#8230; and it was still on the breadboard&#8230; I never did bother to buy a new mouse, yet.. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"716\" height=\"403\" data-src=\"http:\/\/makeriot2020.com\/wp-content\/uploads\/2023\/07\/362322165_233432946195105_8199579043671644050_n.jpg\" alt=\"\" class=\"wp-image-20445 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2023\/07\/362322165_233432946195105_8199579043671644050_n.jpg 716w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2023\/07\/362322165_233432946195105_8199579043671644050_n-300x169.jpg 300w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 716px; --smush-placeholder-aspect-ratio: 716\/403;\" \/><\/figure>\n\n\n\n<p><br>The PCB Arrived today, and apart from a few small soldering issues, looked great&#8230; I still had to do a bit of assembly on my own, as there was an issue with the components I wanted being out of stock.. I have plenty in stock of my own, so opted to do manual assembly&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"298\" height=\"222\" data-src=\"http:\/\/makeriot2020.com\/wp-content\/uploads\/2023\/07\/362414229_309449838207611_8615384677215303182_n-e1690534761968.jpg\" alt=\"\" class=\"wp-image-20444 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 298px; --smush-placeholder-aspect-ratio: 298\/222;\" \/><\/figure>\n\n\n\n<p><br>The completed PCB now only needed a joystick, and some firmware&#8230; <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"158\" height=\"280\" data-src=\"http:\/\/makeriot2020.com\/wp-content\/uploads\/2023\/07\/362657268_295470062994838_5573510808685017426_n.jpeg\" alt=\"\" class=\"wp-image-20443 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 158px; --smush-placeholder-aspect-ratio: 158\/280;\" \/><\/figure>\n\n\n\n<p><br>After adding a few button caps, and mounting everything to a piece of acrylic plate, I had a working prototype&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Firmware<\/h2>\n\n\n\n<p>As mentioned above, the device runs on CircuitPyton. As Such, there are quite a lot of &#8220;examples&#8221; on the internet, showing you how to do many USB HID &#8220;mouse&#8221; like things, but generally being completely useless&#8230; <br><br>I have thus spent quite a lot of time up to now, writing and refining my own version of the firmware, that is actually useful and does actually work.<br><br>It has the following features:<br>X-Y axis control of the mouse pointer via a thumb joystick, with a left click function on the center joystick button, as well as a dedicated &#8220;left&#8221; button.<br><br>A dedicated &#8220;right&#8221; button<br>A &#8220;virtual center&#8221; button made up of simultaneously pressing left and right<\/p>\n\n\n\n<p>Up and down scrolling either using the rotary encoder as a &#8220;mouse wheel&#8221; or via dedicated up and down pushbuttons.<br><br>A dedicated Reset button &#8211; this is necessary, as I can not seem to get the device to initialise correctly at computer bootup.<br><br>Various software functions, like changing the pointer acceleration by pressing the center button on the rotary encoder<br><br>and most importantly, hiding the Circuitpyton drive, only showing it when I actually need access to the code in this device&#8230; <br><br>Various statuses are indicated using the NeoPixel on the XIAO, making it easy to see in what state the device is operating.<br><br>As such, I shall NOT be releasing the firmware at this moment, as it is still far from being perfect. It works, but it can be way better&#8230; <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"158\" height=\"280\" data-src=\"http:\/\/makeriot2020.com\/wp-content\/uploads\/2023\/07\/362647938_641315387959246_2387774553975598736_n.jpg\" alt=\"\" class=\"wp-image-20442 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 158px; --smush-placeholder-aspect-ratio: 158\/280;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary and next steps<\/h2>\n\n\n\n<p>Since its &#8220;birth&#8221; late on a Friday night, about 3 weeks ago, I have been using this device, in its various forms as my primary pointer device. It is growing on me more every day, and it is quite comfortable to use &#8211; If we ignore the fact that it is not in a suitable enclosure and that I am still making small changes to the firmware from time to time.<br><br>I am already planning the next revision, in which I shall replace the momentary push-buttons with proper microswitches, as well as try my hand at designing a proper enclosure.<br><br>If you are a 3D printing expert and want to collaborate with me on this, let&#8217;s talk&#8230; <br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine You are working on a project late on a Friday evening and suddenly your mouse stops working&#8230; You can not scroll, and the right-side button won&#8217;t respond to your clicks&#8230; At the same time, you have a project design that has got to get finished&#8230; and the shops are all closed already&#8230; These were &hellip; <a href=\"https:\/\/www.makeriot2020.com\/index.php\/2023\/07\/28\/the-emergency-mouse-a-project-born-out-of-necessity\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;&#8220;The Emergency Mouse&#8221; &#8211; A project born out of necessity&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":20443,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,44,139],"tags":[45,95],"class_list":["post-20441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-custom-pcb-design","category-electronics","category-rp2040","tag-electronics","tag-raspberry-pi-pico"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/20441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/comments?post=20441"}],"version-history":[{"count":0,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/20441\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media\/20443"}],"wp:attachment":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media?parent=20441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/categories?post=20441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/tags?post=20441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}