top of page

COLORCLOCK

What time is it?

Amber o'clock-ish (?)

WSL 2 cannot interface with the serial ports on my PC and it makes me sad. Because that means I can't use WSL for the one use case I reallllly want it for: programming an Arduino.


It's been about a year and a half since last looking at the code base for my ColorClock project and I finally have the mental capacity to continue work on this endeavor. In one of my previous posts I shared my excitement over using the Arduino Command Line Interface because it enabled me to code and upload my programs all in a single terminal window. But, I should mention that all of my Arduino development up until this point has been on a MacBook i.e. a UNIX environment.


This past weekend I tried to recreate this development environment on my newly remodeled Windows gaming tower. I was super excited about the prospect of getting to use Windows Subsystem for Linux (WSL) and no longer needing to use Cygwin or some other Linux emulator-like-thing.


It took me hours to just to get compiling again - between dealing with Git issues, installing the toolchain, tracking and installing library files, and relearning how to interact with Arduino CLI. My efforts felt worth something for a tiny while because I got it to compile on the command line 🥳 But then... the internet rained on my parade 😭


I read somewhere that WSL doesn't play nice with the serial ports, but I was not deterred. Surely SOMEONE has been able to get WSL to communicate through serial? I was determined to find a way.


I learned about a third party program, USBIPD that would allow WSL to see my serial ports. And this was confirmed! I performed the commands on the PowerShell side (e.g. bind, attach) and then I saw my Arduino on the WSL side using lsusb!! But when when it was time to run the upload command my console spits out a no communication error.


I felt defeated. Fine. Windows. YOU WIN.


It crossed my mind to use keep using my old development environment, but that was using my 10 year old Macbook - which I love, but I have a new computer and I want to use it!


I proceeded to use VS Code with the Arduino plugin, had trouble, got it to work with PlatformIO, which worked but created so much overhead I went back to the Arduino extension and FINALLY got it to work.


To be fair, I like VS Code. The more I learn about it the more I like it. The Vim plugin is actually quite good (I can use my own .vimrc file) and the Python debugger is pretty sweet.


Honestly, I'm just happy to be working on a fun project again.



References



“It doesn’t matter how slow you progress so as long as you never stop.” I think my grad school advisor shared this with me. Maybe that wasn’t the really the quote. And maybe it wasn’t my advisor. But you get the gist 😉


ColorClock is progressing. Sllloooooowwwwwllllllyyyy. At some point during the pandemic time warp (a year ago… maybe two?), I finished coding the software prototype in Processing3. It was a window with a black background and a solid circle that changed color according to the system time. In the last year I’ve been porting that code to hardware (Arduino) so that I can fabricate an actual RGB LED wall piece or sculpture.




The Software Prototype This video demonstrates how the color changes over time. The cycle length displayed here is ~6 seconds. The current design is for the final piece to have a cycle length of 24 hours; the audience will not perceive a color change if the piece is viewed for a short time period.

A month or two ago I had to start over because I realized that I was converting code but barely testing it beyond making sure that the project built properly - and then at some point it stopped compiling 😬 And even though I was using version control, I couldn’t figure out the last commit with a known good build 😩 Though this is a personal project, it was crazy to reflect on similar challenges I have experienced in my work life.

🐰


Soooooooo…

🐰


Since then, I have added a debug class for serial monitor print statements, refactored the project to be completely object oriented, and started using branches and pull requests for my repository even though I’m the only developer.

🐰


This past week I also started exploring how to unit test portions of the code without running it on actual hardware. The Arduino language is basically C++ so I just made a small driver function where I include my classes that don’t have any Arduino dependencies. I’m proud of myself for the forethought I put in to the architecture so that I can build software only tests without needing to modify the code I’m testing 🤓



Hardware Prototyping Progress This is the state of the hardware prototype at the time of writing. The alphanumeric display will be hidden from view in the final piece. While testing the color changing capabilities, I realized that the Arduino board I'm using only has two pulse width modulation I/O pins so I can only cycle through colors that are combinations of two primary colors, like red and green, red and blue, or green and blue.

I’m actually kind of stuck at the moment - the contents of my RGB <-> HSV color conversion functions seem to be working, but not when the class definitions are included in a different file 🤷‍♀️ I’m going to stare at the code a bit more and possibly call in some reinforcements 🧑‍💻

Once upon a time I was intimidated by the command line. Today, I get annoyed when I can't use Vim.

🐰

Progress is happening. In 2014, prior to becoming a software engineer, I started programming ColorClock using Processing to map the system time to a colored eclipse displayed on my computer screen. Six years later, in 2020, I dabbled in this project a little more to entertain myself during the early months of the pandemic. I cringed at my previous work as I refactored the code into functions. And today, I’m refactoring further, making the code more modular and porting it into C++ / Arduino.

🐰


Since I picked up ColorClock again about a month ago (May 2022), I have been coding at work using Vim because it improves my workflow. My fingers never have to leave the keys so it's easier for me to become deeply immersed in the task at hand. But the Arduino IDE does not have a Vim extension. Going back to this coding environment was painful 😣


🐰


The time had come to explore the Arduino Command Line Interface (CLI). I was holding back because though I had become proficient in command line computing, a part of me felt intimidated again.


🐰


Despite my hesitation to explore the Arduino CLI, the drive to improve my development workflow motivated me to just RTFM. And so I did. And now I'm done with the Arduino IDE. Because the Arduino CLI is working 🌻beautifully🌻


🐰

This past weekend I found my flow again. Now I can code, compile, and upload my program to the Arduino board without ever letting my fingers leave the keyboard 🥳





Glossary

CLI - command line interface


IDE - integrated development environment


RTFM - read the friendly manual


Vim - a command line text editor with a steep learning curve that makes many people upset and can drastically improve your workflow if you are committed to practice

bottom of page