Author Archives: Nick Poole

Contributing to the Arduino IDE

via SparkFun: Commerce Blog

Something I love about my job is that I never know what I'm going to be working on next. Anything from hardware layout to mechanical design, to firmware and software, everything is fair game. If I don't know how to do something, I'll try to pick it up. This has led me to learning bits and pieces of a lot of different skills. All of this is to say, when Nate asked me if I could add a new feature to the Arduino IDE, my first thought was, "Well, it's been a good run but nobody avoids Java forever."

A Lot of Legacy

Jokes aside, I was actually a little apprehensive. Not so much because of the Java — although it's never that much fun to install a new toolchain — but because the idea of contributing to such a large, ongoing project can be intimidating. The Arduino GitHub Repository contains over 7,000 commits in 87 releases over the span of 15 years... that's a lot of legacy! Somehow it's managed not to turn into a massive pile of spaghetti over that amount of time, which is a testament to the community around it. I'll get into the process around pull requests and code review here in a minute, but first let's talk about the new feature: Recently Used Boards!

One side effect of Arduino's tremendous success over the years is that the ecosystem of Arduino-compatible development boards has absolutely exploded. Combined with the addition of the Boards Manager, it's easier than ever to cram your "boards" menu with hundreds of board packages. For the average user this probably never becomes annoying, but in our line of work at SparkFun — constantly switching between development boards — we end up doing a lot of scrolling. The most recent version made small steps toward fixing this issue by splitting the boards into submenus. That definitely helps, but depending on your monitor resolution, scale factor, etc., a lot of boards still can't be located at a glance. Nate's idea for solving this? Do the same thing that we already do with sketches and keep track of the most recently used items in an easily accessible list.


I won't get too into the process of installing and configuring the Java toolchain. It's no more or less painful than any other development package. That said, one thing did trip me up for about a day so I feel obliged to mention it here: You cannot build Arduino with the 64-bit JDK, you have to use the 32-bit JDK (as of 1.8.13 anyway, I imagine this will change in the future).

So, anyway, how do I go about adding a new feature to an unfamiliar code base in an unfamiliar language? Step one for me is to basically mock it up. Find the menu structure in the source code — by searching the whole repo for the string "Tools" and then drilling down until I see "boards" — and add some menu items that look like what I want, even though they don't do anything when you click them. Once I know how menu items are represented in code, I can find out what actually happens when you click them and how to insert them into the menu programmatically.

So how do the board menus work in the Arduino IDE?

Basically all of the menus are periodically rebuilt at different points while the program is running - some on startup, some whenever certain pop-ups are opened, some after hitting compile, etc. All of this happens in app/src/processing/app/ The boards menu is rebuilt by a routine appropriately named rebuildBoardsMenu() first on startup and then again whenever the Boards Manager or Library Manager is opened. It was easy enough to add some menu items here for the mockup and it looked pretty good! So now I just had to solve two problems: 1) They were static and didn't actually reflect any sort of board history, and 2) they had no actions assigned to them, so clicking them did nothing.

To keep track of the board history I would need unique identifiers for each board and a place to store the list that would persist between sessions. The unique ID was easy, since these already exist as part of the board's profile and is used to refer to the board while building the menus. I can simply query the ID of a board whenever it's selected and save it to the "recent boards list" for reference when building the menu later. This list would be stored in the one file that holds all persistent data in the IDE: preferences.txt

The preferences file is interesting; it gets loaded into an object at the beginning of each session where a number of methods allow it to be read and modified and then at the end of a session, it's serialized back into the text file. Methods are provided for storing and retrieving strings and collections by arbitrary key names. Anything that persists between sessions or across windows is stored here, so things like the selected COM port, recent sketches and, of course, preferences. In fact, if you've been using Arduino for a while, you might want to check in on your preferences.txt file because while I was playing with it I found that the recent.sketches field doesn't seem to be managed in any way and is simply a record of ALL sketches that have been opened since installation (and therefore will grow indefinitely).

To keep track of the five most recently used boards, I found a function that gets called any time a board is selected (onBoardOrPortChange()) and added a short chunk of code to capture the selected board's ID. Then I check to see if preferences has a key called boards.recent. If it does, then I grab that list and check whether the current board is on it. If it is then I move it to the top of the list, if not then I append it to the top of the list. The list is then limited to five items and stored back into boards.recent.

Whenever the boards menu is rebuilt, so are all of the actions assigned to each menu item, as well as the custom menus assigned to each board (things like bootloader and processor selection submenus), which makes that a good time to grab these actions and copy them into new menu items. Unfortunately, this isn't a great time to build the "recent boardS" menu because — again — this only happens when the Boards Manager or Library Manager is opened and closed. We'll need to store these actions and then use them to build the menu later. Originally, the list containing these actions wasn't scoped outside of createBoardMenusAndCustomMenus() so I had to widen the scope of this and a few other variables. With this list in memory, however, we now have freedom to build our menu whenever we need to.

Back to our friend onBoardOrPortChange(), and we write a little chunk of code to create the new menu items and insert them into the menu... but wait, where in the menu? We can't hard code the menu index, because certain menu items will come and go depending on preferences so our target index is liable to change, but it will only change whenever the greater 'boards' menu is rebuilt, so in rebuildBoardsMenu() we pick a spot for our menu in line with the rest of the menu rebuild and take note of the index at that time.


  • During rebuildBoardsMenu(), check to see whether preferences has recent.boards. If so, insert separators and a menu label to denote the "Recently Used Boards" list and store the index of this section for the insertion of menu items later.
  • During createBoardMenusAndCustomMenus(...) create a collection of 'clone' menu items whose action is to click the original menu items. Reference them by boardId.
  • During onBoardOrPortChange() update the list of boardIds in recent.boards. This list is treated as a stack with new boards popping off the oldest member of the list. Then call rebuildRecentBoardsList() to remove previous menu items and insert new menu items using the collection generated during createBoardMenusAndCustomMenus(...).

screenshot of the Arduino IDE with the Board menu open and a new menu list labeled "Recently Used Boards"

The fruits of our labor

Contributing my Changes

Arduino's development policy is listed on the wiki and is a great place to start if you're thinking about joining the development effort or proposing changes. Once you've decided you're serious about contributing, check out the file for contributing rules and guidance on where to contribute to different efforts. Pay special attention to the section on Pull Requests, which outlines the requirements for making a useful PR. Most of these are good git-manners in general, and help to prevent the project becoming unsustainable under the weight of a thousand devs. Things like writing good commits, removing commented-out code, and addressing one bug fix or enhancement at a time help developers understand what you're trying to achieve and make code review go smoothly.

One key step that I neglected was to search the existing PRs to make sure I wasn't reinventing the wheel. There turned out to have been a PR at some point that addressed this idea but it lacked persistence between sessions, so I got lucky.

Once I forked the Arduino repo, made my changes in a new branch, and filed my pull request, a number of automated tests kicked off to ensure that the proposed code was still buildable and properly linted. Then I just waited for someone to review my code. Before long, I had a number of suggested tweaks in the comments and that's where it currently sits. I'm still making the proposed changes, but there seems to be interest in pulling the code, so hopefully you'll be able to find this feature in the next official release. In the meantime, if you want to take it for a test drive, you can download this file to replace the current 'pde.jar' in your arduino/lib/ directory.

screenshot of the Properties window for pde.jar showing a file location of "C:\Program Files (x86)\Arduino\lib"

My Windows install looks like this, if that helps you locate the file

Moral of the Story

Don't be afraid to contribute to big open source projects! The only way these tools get better for everyone is if everyone pitches in and helps. Have a great idea but don't have the chops to implement? Talk to folks in the forums - someone who has the skills might like your idea and help you out with the proposal! Hopefully, you'll all find this minor enhancement useful and I cannot wait to see what idea you have for the Arduino IDE.

Happy hacking!

comments | comment feed

Perspectives on Pride

via SparkFun: Commerce Blog

Note: As this is an ongoing cultural discussion and progress happens quickly and constantly, some terminology may fall in and out of favor. Please note that my choice in terminology such as LGBTQ+, Queer and Trans* come with only the best intentions and I apologize for any offense caused on present or future reading of this article. Thanks!

A stormtrooper poses for a photo with rainbow accents covering their armor.

Photo Courtesy of

This past weekend was an excellent weekend to be in Denver! Not only had Denver Comic Con flooded the streets with characters from a wide selection of pop culture properties, but Denver Pride was in full swing, celebrating love and spreading good vibes. I was celebrating from the costume floor at Comic Con with a handful of other past and present ‘funions, and I have to say that I can’t imagine a better intermingling of events. I’ve written before about how much overlap there is between LGBTQ+ culture and geek culture at large, and nowhere is that more clear than Denver Comic Con during Pride weekend.

Selfie in full Taako makeup. I'm wearing a very light foundation with pink blush across the bridge of my nose and fake freckles. Black winged eyeliner and electric pink underliner. My cheeks are lightly contoured to my beard. I'm wearing downward elf ears with earrings in them and a floppy, moss-colored wizard hat.

Hail and Well Met! A Taako Taaco Makeup Test the night before the con.

I cosplayed what I thought may be a slightly obscure character: an elven wizard named Taako from the fantasy adventure podcast The Adventure Zone — a character who happens to also be gay. On Saturday alone, I met no fewer than eight other Taakos of every possible description! People of every age, gender and sexual orientation, who had all spent hours making props and costume pieces to celebrate their favorite sassy wizard. It was… pretty cool.

I think it would be hard to argue that comic books and fantasy/sci-fi don’t have a huge influence on maker culture, or on the field of engineering. The worlds of fantasy and sci-fi, and the fandom surrounding them, leave an impression on people that shapes their work – even when that work has nothing to do with space marines or spellcasting, there’s a little bit of “geek” in it.

In that vein, it’s not unreasonable to think that as LGBT/queer folks, we also bring our culture to our work as well. To get a little more perspective on the intersection of queer identity and engineering/making, and how — if at all — Pride Month should be observed by companies like SparkFun, I asked a few friends (and long-time SparkFun customers) what they thought. Here’s what they had to say:

Why don’t you introduce yourselves?

C.S.: Hello fellow Sparkies! My name is C.S. - I grew up in Colorado, lived in Silicon Valley for a couple years, and currently live near Washington, D.C. I spend just about every waking second making something, be it for work, a crazy contraption for my parrots, or some new machine.

Gaston: I’m a retired electrical engineer and programmer. I worked for IBM for over 32 years. My career started out building robots and electrical test equipment as part of printed circuit board production, to writing software for the IBM PC Company, and finished as part of IBM’s Developer Support Team.

What kind of engineering or fabrication are you involved in? Is it professional, or a hobby, or a little of both?

C.S.: Professionally, I’m an electrical and software engineer. I designed and programmed industrial control systems for a number of years (I basically lived on the set of How It’s Made), but I now write drivers for embedded computing platforms.

At home, I’m in love with electromechanical machines. In the last couple years, I’ve built three separate CO2 laser cutters, a couple 3D printers, a CNC router and a bunch of other bits and bobs. I’m one of those crazy guys who makes machines for the sole purpose of making more machines.

Gaston: I enjoyed building electrical projects throughout my entire career, both at work and as a hobby. Believe it or not, I’ve made projects based on Raspberry Pi and Arduino within IBM as proof-of-concept devices for IBM’s Internet of Things and Cloud activities. Now that I’m retired, I hope to devote more of my time to my own hobby projects.

Have you noticed that people in your field treat you differently because you’re gay? Has that changed at all over the years?

C.S.: They used to. I used to deal with small things like folks giving me the evil eye and silent treatment, to more serious things like threats and actual physical harm.

I’m happy to say, however, that’s not really the case anymore. I’ve found that the vast majority of people don’t care about my sexuality, or are at least polite enough not to vocalize their distaste.

Comically enough, the biggest response I get nowadays are folks who maybe try a little too hard to be accepting. I’ll say something like, “My boyfriend and I went to the San Mateo Maker Faire last year….” and they’ll respond with something like, “I DIDN’T KNOW YOU WERE GAY!!!! I have a gay sibling/best friend/neighbor/chia pet!!!!!” and then proceed to tell me all about them. I can’t speak ill about anyone who tries like that - while I think it is somewhat funny given how frequently it happens, they are making a conscious effort to try to make me feel welcome. Can’t really complain about that.

Gaston: Yes, things have changed a lot for the better. It’s actually much better now. When I first started my career, I and everyone else who was gay that I knew at IBM was closeted. I didn’t know anyone else who was out at IBM. That’s just the way it was when I joined IBM in the early 80’s. Gradually, people began to come out, first in private to other gay employees, then to their managers, then to their co-workers. Honestly, the negative reactions were largely out-weighed by the positive reactions.

Coming out was a very positive experience for me at IBM. People learned that we were more alike than different. It actually helped strengthen the morale in our work groups. When you’re closeted, you are basically hiding an important part of yourself. People who are straight assume someone is not gay by default, and if one doesn’t do anything to correct that assumption, they can make a lot of careless mistakes and thoughtless remarks. Or perhaps they just wonder why one person never talks about their personal life. It’s unfair to both you and them.

When I first came out, a lot of people apologized for things they said, which honestly they never would have said or thought if they knew I was gay. A lot of people just didn’t know anyone who was gay until I came out at work, so their perceptions back in the early days of my career were pretty far off the mark. Plus, when someone is silent, that tends to be taken as an indication that they agree. So not speaking up caused many others to stay in the closet. Coming out helped others come out, and it helped change people’s perceptions and break down prejudices.

We hear all the time (and I’m sure you’ve heard) that bringing awareness to LGBT/queer issues and identities is “politicizing.” People may say that sexual orientation has nothing to do with engineering, so why bring it up? What are your feelings on that idea?

C.S.: There is bound to be at least one person reading this (who perhaps didn’t read this article and jumped straight to the comment section) who will say or think something along the lines of, “We shouldn’t bring sexuality or gender into engineering at all! What people do in bed has nothing to do with coding, wiring up LEDs, or [insert some geeky thing here].”

From the viewpoint of engineering being about numbers and equations and algorithms, there is a little bit of truth to that. Engineering at its surface is about taking things we’ve learned through scientific and mathematical rigor and applying them to solve a problem. If you were to look only through that lens, then yeah, there should be no mention of LGBTQQIA folk on any tech blog, site or article.

But, engineering isn’t just about formulas and math. It’s about people who come together over a common problem to solve it and improve the world in some goofy way or another. From that standpoint, it is extremely important for there to be awareness of LGBTQQIA folk in the workplace and in Maker communities. In order for folks to think clearly and be able to work with others, they need to feel a certain level of human respect and acceptance. Engineering isn’t done in a vacuum, it’s done as a community, and if people feel like they are not welcome, they won’t participate.

As an avid comment reader (for better or worse), the next common statement is something along the lines of, “If [they] really want to be treated equally, [they] shouldn’t be asking for special treatment.” In a perfect world, this type of commenter is 100% right. The most perfect state of equality is zero “special treatment” at all. The cruel reality is that the world isn’t perfect.

The reason it is important to recognize LGBTQQIA folk in STEM is the same reason it is important to recognize women and racial/ethnic minorities in STEM; we don’t want the best and brightest among us to fall the wayside because they didn’t think they’d be happy in a STEM career or that they didn’t think they belonged there. Engineering especially is viewed as an extremely conservative profession made up of stuffy, white, old guys who are so straight they make an arrow look bent - if a community or company is to thrive, they need to invite all walks. Again, if people feel like they are not welcome, they won’t contribute.

Gaston: I’ve heard that “you’re politicizing things” argument my whole career. It’s a standard put-down response to try and shut up someone who is coming out. My response has been that no one ever complains when a straight person talks about their personal life, including their spouse or children. But when a LGBTQ person shares their life, some people will immediately say that’s being political, immoral or demeaning.

Frankly, I’ve had to tell people bluntly I don’t care. If they think it’s political, then it’s their problem. Years ago, I remember people who would say it’s immoral or improper for IBM to recognize partners of LGBTQ along with other employee spouses at award events. IBM’s response was that they would recognize whomever the employee asked them to recognize. When I married my husband nine years ago, I sent wedding photos to everyone in my department. Someone asked me if it was a political act, and I just said no, I was just sharing a happy time in my life with everyone, like when that person had sent out baby pictures of his newborn daughter. I think he understood.

Another co-worker told me she hoped someday to see wedding photos like this for her son, who was gay as well. It is important to realize that there are more people validated by these actions than just other LGBTQ people themselves. There are many others who are allies and who know someone that is LGBTQ. I met people in IBM who were parents of LGBTQ children, and they were some of our strongest supporters when we were just coming out. They were always glad to see LGBTQ employees coming out. It gave them hope for their own kids.

There’s a lot of culture and shared experience among queer communities. Do you think that being gay impacts your work or your experience as an engineer and/or maker?

C.S.: This is a pretty massive question and the answer is going to be widely different for most people. For me, being openly gay allows me to open up a giant can of “I don’t give a f***” in my daily life. I get creative freedom with no apologies or shame.

While much of the world sees gay culture to mean “drag shows, glitter and gallons of lip gloss,” what gay culture boils down to is the idea that you are who you want to be. You don’t need to feel pressured to act a certain way or keep to some random societal rule. As a community, we were pushed aside so hard for so long that we decided to make our own rules: As long as you are kind to others, be yourself. If that means dressing in drag and showering crowds with glitter at a show, then go for it! That’s not to say that all gay men have a glitter addiction and dress in drag (trust me, we don’t), but we aren’t going to tell someone they shouldn’t because it doesn’t fit our bill.

This sentiment bleeds into engineering, believe it or not. There is a certain quality good engineers have where they are willing to think and test designs outside the box even though that box has been around four trillion years, has 20-foot-tall, steel-reinforced concrete walls and lead shielding. A good engineer knows enough to stick to some norms and completely obliterate the others. Progress does not come any other way.

Gaston: Absolutely. I think our personal experiences bring a lot to our work and shape who we are. That’s true for straight people as well as LGBTQ. I think my experiences have made me more creative and more willing to try new things. At the very least it’s helped me realize there’s more than one way of looking at things.

As we try to expand interest and opportunities in the field of engineering, do you think it’s important to focus on sexual and gender minorities in the same way we might focus on, say, women and racial minorities? Have you been involved in any of these efforts, and could you describe your involvement?

C.S.: Like I talked about before, I do think it is important to place a certain amount of focus on LGBTQQIA individuals in STEM, just like we do with women and racial/ethnic minorities.

I did try to organize outreach for the LGBT communities within my college of engineering many years ago, but I’m afraid I don’t know how far my efforts got. I know that a program was started a couple years after I got my degree, but not much else. I’ll have to follow up soon and see if the program is still up and running.

Gaston: I think it’s extremely important to focus on LGBTQ as well as other groups. Frankly, silence is often taken to imply disapproval, and in many places out-right, expressed disapproval from anti-gay groups can be quite high. The hardest part is not to internalize this hate and project it onto other situations, real or imagined. That’s why reaching out to diverse groups of people brings back great returns. It gives a positive message, and counteracts any preconceived notions.

When we first formed IBM’s LGBTQ diversity group, we made shirts (IBM approved) with the IBM logo and text that read, “IBM Gay and Lesbian Employee Alliance.” We were the first diversity group in IBM. This was before they were even called Diversity groups. I had several people stop me at work and ask if it was a joke. When I said no, the next response was, “Well I think it’s a great idea.” Our group was partly what we would now call a safe-space. But it was more than that. It was a place to network, to meet, even to socialize. It worked so well at IBM that IBM quickly expanded it to other groups.

Another important point, of which I’m quite proud, is that IBM expanded its anti-discrimination policy (IBM calls it their Respect for the Individual policy) to include LGBTQ employees, and they stuck by us. We had the complete support of our management and that was important. That was one reason I stayed with IBM so long. I had other offers from other companies over the years, but none had supported their LGBTQ employees like IBM.

IBM also started to market to LGBTQ audiences very early on, and the response was extremely positive. IBM not only got a lot of good will, but also a lot of business. I strongly believe that diversity marketing is a large net-positive for any company. We sponsored speakers at IBM social events, and we marched in the NC Pride parade carrying an IBM banner. That actually made the local news when we first did it back in the mid-90’s. All of our events were open to everyone in IBM and their guests. That’s an important point – open to everyone. One of the last things I was involved in was reverse mentoring; we made ourselves available to help managers that had questions or issues they wanted to discuss. It was actually quite effective, and probably helped defuse some situations before they occurred.

IBM Logo in rainbow colors

IBM’s Rainbow Diversity Logo

In a time when it seems to be both trendy and controversial to discuss LGBTQ rights, it sometimes seems that between the publicity and the backlash, the only people who benefit from corporate diversity initiatives are the companies themselves, and not necessarily the communities that they’re ostensibly “including.” I struggled to find a way for SparkFun to acknowledge Pride Month (after all, we have several queer/LGBTQ employees) without appearing disingenuous or exploitative. What do you think companies could do better in that respect?

C.S.: Yeah, I think this is a tricky subject myself. While I am sure there are a few companies that jump on the pro-LGBTQQIA bandwagon for financial reasons, I don’t think that is the case with most. I think that they recognized that a large chunk of the population was being subjected to a daily hell and decided to do what they could to try to help. While it may seem like ancient history, it wasn’t that long ago that LGBTQQIA folk were killed, beaten, disowned and shamed for simply being who they are. And while those hells are starting to diminish, it is still an issue in a lot of the world, and in the US.

As far as how to go about supporting the LGBTQQIA community, this is also tricky. There is no magical, perfect way to please everyone. For me, at least, just the public acknowledgment of our existence means a whole hell of a lot. When the It Gets Better Project took off a few years ago, I was absolutely BLOWN away that companies like Google, Microsoft, Apple and many, many others took part so publicly. I teared up a bit when I watched them. Why? Because even though I had come to accept myself in the years prior, there is something viscerally redeeming about being told you are a human being and you are valued without question.

Gaston: I’m really glad it’s trendy now. But there still are enough struggles and obstacles out there that reaching out to LGBTQ people is really important. Unfortunately, given today’s political state, it’s probably going to be just as important to reach out to women and other minority groups as well. One just can’t take anything for granted. Someone out there there is a LGBTQ SparkFun customer that’s going to be inspired to hear your story, Nick. It’s important and no more political than Nate telling customers he started out of his dorm room.

Maybe it’s because I remember the bad old days, but I’m really a tough guy to exploit. I don’t mind someone sticking a pride flag next to their logo. In fact I like it. I’ll buy two of that brand if I can. I remember Matt Shepard. I remember Don’t Ask, Don’t Tell. I remember people worried that they would get fired for having a pride sticker on their car. I remember the Aids Quilt in Washington, D.C. That’s actually when and where the first IBM LGBTQ meeting happened. Honestly, we’ve come too far to go back, and I’m not going to be intimidated anymore.

So hang in there, Nick. Tell your story, and be proud. Don’t let anyone tell you that you’re being disingenuous or exploitative. Be yourself. For every hater you see in the comments on your blog post, there’s 10 who loved it, and probably 100 who didn’t really think anything of it more than, “Oh, gee, okay, that’s cool.”

Personal statements are very relevant. At one time, if you Googled (or used Yahoo at that time) “Gay IBM” you’d come across a web page with my IBM coming-out story and links to about 10 others. That was our employee LGBTQ diversity page, and we made it public so that anyone who wished to join IBM knew that it was a great place for LGBTQ people to work. The key thing was that it was like other pages IBM did at that time – it was part of, with the same official IBM look and feel. So my advice for companies is to leverage their line of business knowledge to put their own personal touches on Pride. That connects most effectively with their LGBTQ customers and to their allies.

So please keep making pink breadboards, rainbow LED packs, a rainbow cloud-connected cloud and other Pride-related SparkFun products and projects (yeah I know, many groups can claim pink, but it’s interesting how many haters complained about SparkFun’s pink breadboard in the comments). Maybe ask your LGBTQ employees if they can share any Pride-themed projects, or heck, just slap a rainbow on it and call it a Pride version. You wouldn’t believe the response I got for a Rainbow Raspberry Pi enclosure I brought into work. Small things can make a big impact. It’s easy to be cynical now that Pride displays are more common in business, but please don’t let other’s cynicism get you down. Someone will see it and be happy.

comments | comment feed