{"id":43,"date":"2022-10-28T02:27:46","date_gmt":"2022-10-28T02:27:46","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/fisheali\/?p=43"},"modified":"2022-10-28T02:34:33","modified_gmt":"2022-10-28T02:34:33","slug":"journey-with-johnny-five","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/fisheali\/2022\/10\/28\/journey-with-johnny-five\/","title":{"rendered":"journey with johnny-five"},"content":{"rendered":"\n<p>I am 5 months into a 6-month software engineering internship at Code.org. The latest project I completed was the migration of our main code-dot-org repo from using an outdated fork of the johnny-five package that hadn&#8217;t been touched since January 2018 to the latest release of its upstream. <\/p>\n\n\n\n<p>johnny-five is an open source, firmata protocol based, robotics programming framework! Its API documentation is available at: <a href=\"http:\/\/johnny-five.io\/api\/\">http:\/\/johnny-five.io\/api\/<\/a><\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" width=\"421px;\" height=\"109px;\" src=\"https:\/\/lh6.googleusercontent.com\/7wXgWXOsLqMSD_rwVu2VXFKHzB9jPc-dMUM9t5c058y-s0gIV91AuDxrpK3hb137zulryrG6QWTNBl_rYUIzQnMvTpZFc3phJOdZxScmLqc7rdLT_NlHWNTimBc9wN1doRvTeFAzibKBSfil0SVCrdN5c3cyyf8eiINazOOJqylW5FQgQXynasrxQ4I6\"><\/p>\n\n\n\n<p>It supports Code.org&#8217;s <a href=\"https:\/\/studio.code.org\/s\/csd6-2022\">Physical Computing module<\/a> that use the Adafruit Circuit Playground. <\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" width=\"207px;\" height=\"207px;\" src=\"https:\/\/lh5.googleusercontent.com\/qB1BrnD___RWpzSwpvzKzPv1aUvUj7xXA84Ufs8xVzKdgnoXgQU3_HytfsRXICBkK7CwKddUuG21wX6zzdyQJX7g_vNc_kZUi-u6pm-WEm3Vjq8nW_yZvusQHF7z6oFBfcMmBOCRs8bN8Ow7PLoXghGn4PeSGt84xGXHJGq6pmBZ2PzgftIW2Drw98r9\"><\/p>\n\n\n\n<p>Code.org has researched benefits of physical computing which include:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Inclusion of and engagement with girls and students from underrepresented groups in computing<\/li><li>social emotional learning<\/li><li>learning efficacy<\/li><li>real world applicability in a world of non-linear proliferation of devices<\/li><\/ul>\n\n\n\n<p>Here is a timeline of the Code.org johnny-five fork:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>March 2017: Forked mainline johnny-five to add first Code.org customization &#8211; Round scaled sensor values<\/li><li>January 2018: Last Code.org customization &#8211; Add RGB.pulse method (v0.1.1-cdo.2)<\/li><li>September 28 2022: Updated to latest release of mainline johnny-five (v2.1.0)<\/li><li>October 2022: Re-implemented 3 Code.org customizations<\/li><li>October 20, 2022: Released as v2.1.0-cdo.1\u00a0<\/li><li>October 27, 2022: Migration to updated johnny-five!<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"410\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.30.13-PM-1024x410.png\" alt=\"\" class=\"wp-image-53\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.30.13-PM-1024x410.png 1024w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.30.13-PM-300x120.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.30.13-PM-768x307.png 768w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.30.13-PM.png 1070w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It was time to upgrade because the version of serialport that the outdated johnny-five package was dependent on was causing pesky errors:<\/p>\n\n\n\n<p><img decoding=\"async\" width=\"752px;\" height=\"419px;\" src=\"https:\/\/lh3.googleusercontent.com\/MY7Y3-Bfl05UbOlcBJPiGnkSmywU1kax1pbPAlQpHgLYpWByAG0Sy_6iYwSdXpyL3hmJcc8oPoLfx15F4OvubXEp0zjQvHCA5WAvdEyfUsb1bBLzRJpy2AJ4oasD1iphrvDMzu2Ho3PAcSdW-3U1Utn7Onjqk7rfozBEdZtqNfs4KkG1TWJu5Fc8GQtg\"><\/p>\n\n\n\n<p>So the first task was to create a copy of the outdated johnny-five repo, name it johnny-five-deprecated and point all references in the main code-dot-org repo to  it. Then I updated johnny-five to the latest release of its upstream v2.1.0.<\/p>\n\n\n\n<p>I had to learn how to link the updated johnny-five locally with my local code-dot-org repo in order to develop and test Code.org customizations. The recommendation was to use <code>yarn link<\/code> or <code>npm link<\/code>, but neither worked. So then I read online about <code>yarn add<\/code> which adds a copy of the local repo as a node_module and that did the trick!<\/p>\n\n\n\n<p>Once I linked the two modules, I had build errors which required updates in webpack &#8211; fixing node dependencies and adding johnny-five to a list of packages that ship in ES6 and need to be transpiled for our purposes. A senior engineer to helped me with these updates.<\/p>\n\n\n\n<p>Once I was able to build and then run the code-dot-org dashboard locally, I could finally start adding customizations, the reason why we forked johnny-five in the first place! There were three customizations I re-implemented:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>A performance fix to use setTimeout fallback so pulse functions are not CPU hogs. <a href=\"https:\/\/github.com\/code-dot-org\/johnny-five\/pull\/13\">PR<\/a><\/li><li>Adding RGB pulse function. <a href=\"https:\/\/github.com\/code-dot-org\/johnny-five\/pull\/15\">PR<\/a><\/li><li>Rounding scaled sensor values. <a href=\"https:\/\/github.com\/code-dot-org\/johnny-five\/pull\/17\">PR<\/a> <\/li><\/ol>\n\n\n\n<p>Once these were implemented, I published to the <a href=\"https:\/\/www.npmjs.com\/package\/@code-dot-org\/johnny-five\">NPM registry<\/a> and added the latest release on GitHub.<\/p>\n\n\n\n<p>This was quite a challenging project overall, and I learned many lessons from it. The most important takeaway for me was that a good pull request tells a story. I relied upon notes and comments from Brad, a Code.org engineer who had done most of the prior work in johnny-five back in 2017-2018. His detailed notes guided me throughout the re-implementation process. I didn&#8217;t feel alone even though I was the only engineer assigned to this task.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.22.51-PM-1024x558.png\" alt=\"\" class=\"wp-image-48\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.22.51-PM-1024x558.png 1024w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.22.51-PM-300x164.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.22.51-PM-768x419.png 768w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.22.51-PM.png 1214w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I also appreciated that he included alternate paths he didn&#8217;t choose and explained why he didn&#8217;t choose certain options. <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Fantastic notes and comments &#8211; <a href=\"https:\/\/github.com\/code-dot-org\/johnny-five\/pull\/10\">Brad\u2019s RGB pulse PR<\/a>&nbsp;<\/li><li>Alternative paths not taken &#8211; <a href=\"https:\/\/github.com\/code-dot-org\/code-dot-org\/pull\/18655\">Brad\u2019s original shim solution<\/a> for pulse function being a CPU hog<\/li><\/ul>\n\n\n\n<p>Overall, my journey with johnny-five presented many roadblocks and challenges, but ultimately, we were able to migrate successfully. Along the way, I learned many lessons and I&#8217;m proud to have contributed to the maintenance and support of the Code.org Maker Kit module whose future is looking bright!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.25.02-PM.png\" alt=\"\" class=\"wp-image-49\" width=\"650\" height=\"586\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.25.02-PM.png 772w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.25.02-PM-300x270.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/6050\/files\/2022\/10\/Screen-Shot-2022-10-27-at-9.25.02-PM-768x692.png 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I am 5 months into a 6-month software engineering internship at Code.org. The latest project I completed was the migration of our main code-dot-org repo from using an outdated fork of the johnny-five package that hadn&#8217;t been touched since January 2018 to the latest release of its upstream. johnny-five is an open source, firmata protocol [&hellip;]<\/p>\n","protected":false},"author":12806,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/users\/12806"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":10,"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"predecessor-version":[{"id":56,"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/posts\/43\/revisions\/56"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/fisheali\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}