Heavy My personal blog 2023-04-01T09:48:32+02:00 Heavy New Job Niclas It's been a while since last time I blogged. There have however been a lot of things happening during this time. <h1>New Job</h1> <p>It's been a while since last time I blogged. There have however been a lot of things happening during this time. Or really, one big thing that in turn have brought on a lot of new smaller things. The big thing is, I have a new job! 😄</p> <p>I did <a href="">briefly write about it on Mastodon</a> after my first day, but here it is again: I am now a systems developer/manager and basically &quot;senior&quot; person on the IT-team (being by far the oldest and most experienced) of a medium sized company.</p> <p>It's actually quite surprising to me how quickly this all happened.</p> <p><em>Sometimes I can't believe this is all really happening<br /> Sometimes I can't believe that I'm really sitting here<br /> Sometimes I tell myself, this is not my beautiful stapler<br /> Sometimes I tell myself, this is not my beautiful chair</em><sup>1</sup></p> <p>I heard that the company was looking to hire from a friend who works there, in a different department. I have for many years been self employed, running my own IT-consultancy company, but as the years have gone by I had been thinking more and more that it would be nice with the stability of actually being employed.</p> <p>So I put together my <em>Curriculum Vitae</em> and personal letter of application and e-mailed it on Friday evening. The following Monday I got a call asking if I could come in for an interview on Tuesday afternoon. Then on Wednesday I got another call asking how soon I could start working. The very next Monday was my first day.</p> <p>I have now completed two weeks. I basically had to hit the ground running on my first day, and has been going non-stop since. It's challenging and somewhat exhausting having to learn the systems and code-base while at the same time solving actual issues, but it also feels really good when I do manage to solve things, and every day I learn more and more making everything feel better.</p> <p>I also really like my co-worker, he's been great to me and I enjoy working with him.</p> <p>Anyway, that's about all I will say about this all right now.</p> <p>Rest assured though that I still have my own company, and I will keep supporting all my old projects and customers on my time off from the new work. It's even in my contract that I may keep doing this.</p> <p>I will also continue being chairman of the board on the housing association where I live, and keep doing all the accounting for it.</p> <p>Of course, working 8 to 5 at the office every day does not give me as much free time as before, especially when the above is added to it, but once I get more used to it all and get into new routines I will most likely make some time for a few fun personal projects and the odd blog post every now and then.</p> <hr> <p><em>1. Lyrics from &quot;Dog Eat Dog&quot; by &quot;Weird Al&quot; Yankovic – 1986</em></p> 2023-03-26T01:00:00+01:00 Using the new Raspberry Pi Debug Probe with Arduino IDE on an Apple Silicon M1 Mac Niclas I got a cryptic error about libusb library not loaded when trying to use the Debug Probe, I found a workaround … <h1>Using the new Raspberry Pi Debug Probe with Arduino IDE on an Apple Silicon M1 Mac</h1> <p><em>If you just want to know about the Arduino thing, scroll down a bit.</em></p> <p>If you follow <a href="">me on Mastodon</a> you might have seen that I recently bought the newly released Raspberry Pi Pico Debug Probe. It's a small little debug interface giving you an SWD connection for programming and debugging most ARM microcontrollers. It's of course mainly made for use with the <a href="">Raspberry Pi Pico</a> and other <a href="">RP2040</a>-based microcontroller boards, but it will happily work with just about anything else also.</p> <p>The SWD-interface is USB CMSIS-DAP compatible and works out of the box with OpenOCD by using parameter <code>-f interface/cmsis-dap.cfg</code>. It's capable of handling quite high speeds, depending on your wires and target device, although a reasonable value might be 5 MHz using parameter <code>-c "adapter speed 5000"</code>.</p> <p>It also has a serial interface with good old RS-232, except at 3.3 V logic levels, so it's really a &quot;2-in-1&quot; kind of thing. This is very handy if the device you are programming gives debug info on a serial port.</p> <h2>Works with Game and Watch Retro Go</h2> <p>The reason I got is was to see how well it would work with the new Game and Watch (which I have written about before). Quite well, it turns out, and at 12 USD it is more affordable than the official genuine STLink/V2 I was using before. Is is also much less of a gamble than the STLink clones, which may or may not work with the GnW.</p> <p>I paid the equivalent of 12.20 USD for it at my local electronics reseller, but the VAT and shipping bumped it to 18 USD equivalent. Unlike the real STLink, the Debug Probe is actually also in stock.</p> <p>It worked right out of the box for programming Retro Go on the GnW. All I had to do moving from using STLink to using the Debug Probe was <code>export ADAPTER=cmsis-dap</code> to tell the Make-script to use a standard CMSIS-DAP interface. Then it's just a matter of connecting the included cable to the D-connector on the Probe and on the GnW side the orange wire (clock) to GnW pin 5, the yellow (data) to GnW pin 2 and finally black (ground) to GnW pin 3.</p> <p><img src="/assets/blog/2023/2023-02-04-using-the-new-raspberry-pi-debug-probe-with-arduino-ide-on-an-m1-mac-1.jpg" alt="The Raspberry Pi Debug Probe connected to a Game and Watch by just plugging the included cable into the cable I previously made for the ST-Link" /></p> <h2>How we normally program a Raspberry Pi Pico microcontroller</h2> <p>But this blog entry was of course really ment to be about using the Debug Probe for programming the Pico, and using Arduino IDE.</p> <p>The normal way to program a Raspberry Pi Pico, or any other RP2040-based board, is to let it reboot into the bootloader. The bootloader will then make a pseudo mass storage device available on the USB-connector, and all you need to do is to copy a compiled .uf2-file with your program to it. It will read the file, flash it into its memory, and then reboot itself to start running the code.</p> <p>This works quite well, and if you are using the Arduino IDE together with the <a href="">&quot;Raspberry Pi Pico/RP2040&quot;</a> package by Earle F. Philhower, III, this will be done automatically when you push the Arduino IDE Upload button.</p> <p>The biggest downside with this is that to enter the bootloader, you either need to reset the Pico while holding down the BOOTSEL-button on it, or send a special command over the USB connection to make it reboot into the bootloader automatically.</p> <p>The problem with the first way is that there is no reset button, so you either need to <a href="">provide your own</a>, connecting a button between RUN (pin 30) and ground, or use an alternative RP2040-board that provides a button. If you don't have a reset-button you need to unplug the USB-cable and hold BOOTSEL while plugging it back in.</p> <p>The problem with the second way is that it requires you to use the included Pico SDK USB-stack, which provides the reset functionality, and you also need to make sure that the Pico have not crashed so it can actually reply to the USB-commands. This is usually not a problem, as you probably use the USB-stack anyway, but if your project have no need for the USB and you want to maximise the amount of available space for your program, you might not include it, and thus must resort to manually reset it every time you upload.</p> <h2>How we can do it with the Debug Probe instead</h2> <p>So, if we don't want to use USB, and also don't want to manually reset or unplug every time we upload, we can just use the SWD-interface. On the Pico, the SWD connection is provided on a separate 3-pin header labeled DEBUG. On the Pico H it has a JST-connector that can be plugged right into the Debug Probe with included cable, on the other models you need to solder a 2.54 mm pin-header yourself and connect using the included pinheader cable.</p> <p>Using SWD, which stands for Serial Wire Debug, we can at any moment take over the microcontroller, halt it, inspect memory, single step instructions and, of course, program the flash memory and reset it. All that no matter what state the controller is in, and irregardless of wether it uses USB or not.</p> <p>So this is where the Debug Probe comes in. It's a cheap SWD-interface that we can use for programming our Pico, or really any ARM-based microcontroller.</p> <p>To use the Debug Probe you would in many cases use a software called <a href="">OpenOCD</a> (Open On-Chip Debugger). It is an open source command line utility that can work with a large number of debug interfaces.</p> <p>There are several guides for OpenOCD on the internet, but for macOS, the easiest way to get it is to first install <a href="">Homebrew</a>, a package manager for macOS, and then install it with the command <code>brew install openocd</code> in the Terminal.</p> <p>It will be installed to <code>/opt/homebrew/bin/openocd</code> and if you want to use it easily from the Terminal you need to make sure you add the <code>/opt/homebrew/bin/</code>directory to the path. Either do this manually every time with <code>export PATH="/opt/homebrew/bin:$PATH"</code> or see the Homebrew documentation for how to add this to the startup files for your shell.</p> <p>Then you could easily program a Pico, though the Debug Probe, using the command <code>openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "program NameOfMyProgram.elf verify reset exit"</code>.</p> <p>More instructions on this is in the <a href="">Debug Probe documentation</a>.</p> <p>This requires you to first have compiled your program to an .elf-file.</p> <p><img src="/assets/blog/2023/2023-02-04-using-the-new-raspberry-pi-debug-probe-with-arduino-ide-on-an-m1-mac-2.jpg" alt="The Raspberry Pi Debug Probe connected to a Raspberry Pi Pico H with the included JST to JST cable" /></p> <h2>Works with Arduino IDE … sort of</h2> <p><em>Note that I am using Arduino IDE 2.0.4 and &quot;Raspberry Pi Pico/RP2040&quot; package version 2.7.3. Future versions may differ or not even need this fix.</em></p> <p>So how do we make the .elf-file with our actual program?</p> <p>There are many ways to do that, but one of them is to use the Arduino IDE. Some people don't like Arduino IDE and would rather use PlatformIO or just raw GCC and makefiles, but the Arduino IDE is an easy way to get started.</p> <p>The Arduino IDE tries to hide a lot of the complexity, and for most purposes it works quite well. For our quick tests here we will just use the Blink example sketch. Open it by File menu, Examples, 01.Basic, Blink. This will blink the LED on the Pico when we have programmed it.</p> <p>To use Arduino IDE with any RP2040 or Pico board, we first need to install the <a href="">&quot;Raspberry Pi Pico/RP2040&quot;</a> package by Earle F. Philhower, III. I am using version 2.7.3 here.</p> <p>Install by opening Arduino IDE preferences dialog and paste the URL <code></code> in &quot;Additional boards manager URLs&quot;-field. If you have anything else there already, just click the little button to the right of the field and enter the URL on a new line in the big box.</p> <p>Then you can just select &quot;Raspberry Pi Pico&quot; as your board in the board menu.</p> <p>As I wrote earlier, if you just use the Arduino IDE to program a Pico, it will compile to a .uf2-file, send a USB-command to the Pico to enter bootloader, wait until the mass storage device is mounted, and then copy the file.</p> <p>The Pico will immediately reboot and the Mac will respond to that with a message saying that we did not properly eject the disk. In this case that is ok, just ignore and close that notice.</p> <p>But what if we want to use the Debug Probe to program the Pico though the SWD-connection?</p> <p>Easy, just find &quot;Upload Method&quot; in the tools menu and select &quot;Picoprobe (CMSIS-DAP)&quot; instead of &quot;Default (UF2)&quot;.</p> <p>Now if you push upload, Arduino IDE will compile your code to an .elf-file and then invoke a bundled OpenOCD to program the Pico over SWD using a CMSIS-DAP interface (which the Debug Probe is).</p> <p>Except it it does not work. If you use an Apple Silicon M1 Mac, as I do, you will get a cryptic error:</p> <pre><code>dyld[64204]: Library not loaded: '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' Referenced from: '/Users/niclas/Library/Arduino15/packages/rp2040/tools/pqt-openocd/1.5.0-b-c7bab52/bin/openocd' Reason: tried: '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)</code></pre> <p><em>(I have not actually tested this on an Intel Mac, so I don't know if it would actually work there. I assume the error is because the bundled OpenOCD is compiled for Intel and libusb is not in the right place because of that. If you had an Intel Mac and installed libusb with Homebrew it would indeed be in /usr/local/ but it is not for Apple Silicon. This might be fixable by installing the Intel-version of Homebrew (you can run it in parallel with the Apple Silicon version) and install libusb there, but I did not test that.)</em></p> <p>Let's fix this issue with a little workaround.</p> <h2>How to make the Arduino IDE work with the M1 Mac for Pico Debug Probe programming</h2> <p>What we need to do is to use our own OpenOCD instead of the one that is included in the Arduino boards package.</p> <p>Step one is to install OpenOCD using Homebrew. If you have not already installed Homebrew, do so as per <a href="">the instructions on their page</a>. Then do <code>brew install openocd</code> in the Terminal. If you are correctly running the Apple Silicon version of Homebrew, this will install OpenOCD in <code>/opt/homebrew/bin/openocd</code>. For Intel-macs this will instead be in <code>/usr/local/bin/openocd</code>.</p> <p>This version of OpenOCD will work properly, but it does not know what a &quot;picoprobe&quot;-interface is, which the bundled one do. However, that matters not as it does know what a &quot;cmsis-dap&quot;-interface is. Therefore, be sure to select CMSIS-DAP later, and not just Picoprobe.</p> <p>Now we need to tell Arduino IDE to use our own OpenOCD.</p> <p>To do this, first quit Arduino IDE, then open a Finder window. Open the &quot;Go&quot;-menu on the menu bar and hold &quot;option&quot; on the keyboard. You will se &quot;Library&quot; suddenly appearing in the list of places you can open. Click it. <em>(Quick tip: Hit shift + command + . (period) in Finder to show all hidden files, including the Library folder)</em></p> <p>In the Library folder you will hopefully find a folder called &quot;Arduino15&quot;. Then inside that keep going to &quot;packages/rp2040/hardware/rp2040/2.7.3&quot;. There you will find a file called &quot;platform.txt&quot;. Double-click to open it in Textedit and scroll down to the bottom.</p> <p>Look for the line that says:</p> <p><code>tools.picoprobe_cmsis_dap.cmd={}</code></p> <p>Change it to say:</p> <p><code>tools.picoprobe_cmsis_dap.cmd=/opt/homebrew/</code></p> <p>What we do here is to change the command path to be the location for our Homebrew-installed openocd instead of the bundled one.</p> <p>Save the file and close Textedit.</p> <p>Start Arduino IDE again.</p> <p>Load up a sketch (for testing the Blink in basic-examples will work fine)</p> <p>Set &quot;Board&quot; to &quot;Raspberry Pi Pico&quot;.</p> <p>If you are using the USB-port of the Pico for anything, set &quot;Port&quot; to the USB-port of the Pico you are programming, not the port of the Debug Probe. If you are unsure which is which, unplug the Debug Probe USB-cable and there should only be one &quot;usbmodem####&quot; to choose from.</p> <p>If you are not using the USB-port of the Pico, don't select any port. Note that if not using the USB-port of the Pico you will need to power it by some other means (or just plug the USB-cable to a phone charger), the Debug Probe does not supply power to the target.</p> <p>Set &quot;Upload Method&quot; to &quot;Picoprobe (CMSIS-DAP)&quot;.</p> <p>Click the Upload-button.</p> <p><em><strong>Note:</strong> If you set Port to the &quot;usbmodem###&quot; port of the <strong>Debug Probe</strong> and then accidentally have Upload Method set to &quot;Default (UF2)&quot; you will overwrite the firmware in the Debug Probe with your program instead of programming the Pico as you intended. It will then need to be restored by downloading the Debug Probe firmware UF2-file from the Raspberry Pi GitHub and reprogram it by holding BOOTSEL-button while connecting the Debug Probe to the USB-port and copying the .uf2-file to the mass storage device that shows up in finder. Please be careful.</em></p> <p>In the Output you will see the Homebrew version of OpenOCD running, connecting to the CMSIS-DAP interface of the Debug Probe, flashing the .elf-file to the Pico and doing a reset. This will always work, wether the Pico is connected by USB to anything or not, all that is needed it that the Pico is connected to the SWD and have power.</p> <p>That's all for now. Have fun! If you find anything wrong or have any questions, <a href="">I am available on Mastodon</a>.</p> 2023-03-04T01:00:00+01:00 Was It Really Better Before? Niclas I recently came across someone writing how the Nokia phones of old were completely indestructible and lasted for eternity, compared to the junk we have today, but was it actually so? <h1>Was It Really Better Before?</h1> <p>I recently came across someone writing how the Nokia phones of old were completely indestructible and lasted for eternity, in contrast to the phones we use today that break if you look at them in the wrong way. More specifically the complaint was that today you need to replace the phone every two to four years just to keep it working without slowing down, despite doing the exact same thing you have always done.</p> <p>But was it actually so good in the old days?</p> <p>I started thinking back to my own history with phones. I'm old enough to remember when GSM and digital mobile communication was a new thing promising way better call quality than the old analog NMT system we used here.</p> <h2>The GH337</h2> <p>My first own phone was probably in 1997. The first pre-paid SIM-card had just been released here, and I got a second hand Ericsson GH337 from my brother. I don't know how old it was then, but the model was released in 1995 or so, so no more than two years old probably.</p> <p>It was a pretty nice phone. The shell had been changed to an after-market one with nicer colours, the antenna had been replaced with a shorter one and you could change the little ring at the base of the antenna to different colours. As I recall there were actually gold rings for these phones for people who wanted to display their wealth. The display was text only, 3 x 12 characters, it had basically no features what so ever. It could <em>not</em> send text messages, only receive them. I was still quite happy just having a phone though. I bought a prepaid SIM card, and the number I got then is actually still the phone number I have today.</p> <p>This phone, while not even having a calculator, did have one feature that phones today don't, and that people today like to complain loudly about. It did have removable battery. It did not have a headphone jack though, so it was quite ahead of its time like that. 😆</p> <p>I had several batteries for it, and a separate charger for charging them. Thing is, the battery life was downright lousy. The batteries were NiMH (Nickel-metal Hydride) and even with a brand new battery the phone was not specified for more than 25 hours of standby. And that decreased a lot if you actually used it for calling.</p> <p>There were two different sizes of batteries, a slim and a thick. I believe I had a few of both and probably bought a few new ones during the time I had the phone. A problem with NiMH back then was that they just didn't offer that many charge cycles, and with the low standby I had to charge the batteries daily so they just wore out.</p> <p>I still loved the phone and even managed to hook it up to a serial cable to change some memory locations in it to activate a few hidden features. But it wasn't much more than that, a phone. I could call (at great expense) if I ever needed, or, more often, be called by others.</p> <p>I used this phone until 1999 as I remember, so it got maybe two years of use by me, and maybe one year of use by someone else before me. By 1999 technology had advanced quite a bit though, and I upgraded to a Siemens S25.</p> <h2>The Next One</h2> <p>The Siemens S25 was a technical marvel. Released in 1999, a whole year before the legendary Nokia 3310, it was slightly smaller than the old Ericsson, a bit more rounded, it had Lithium battery and a display that could actually display three colours (badly). It had IrDA infrared communication for my Palm Pilot and supported circuit switched data (meaning you pay per the minute to dial up to the internet). It did have a primitive WAP-browser, but it was a version that was never used here, and thus did not work.</p> <p>A very nice phone in so many ways, yet, technology at this time was moving incredibly fast, and phone manufacturers started innovating and making up new features. It seemed for a time like there was a new cool phone released every single month.</p> <h2>Every Two Years</h2> <p>In 2001 I changed phone again. Yes, just two years later. This time for the Siemens S45. Now things were getting advanced for real. The screen was black and white, but had a lot more pixels than the Nokias. It had new fangled GPRS packet data, meaning you no longer had to pay by the minute for internet and it had a WAP-browser that worked quite well. Does anyone remember WAP pages? It was an XML-based way of making simple web pages specifically for phones. I think very few people used it much, but there were actually a lot of fun services available. I even made WAP-pages of my own, and for some businesses.</p> <p>The nicest thing about it though was that GPRS was actually free! My carrier introduced GPRS data as a sort of &quot;beta&quot; at first. They set the price at some outrageous sum per megabyte, but then said that during the testing period it would be free for all. Not that many people used it, and their testing period lasted for over a year as I recall.</p> <p>This solved a big problem for me. I was still living with my parents, and our only internet was though dial up modem. Of course, this was pay per minute, and not only did I occupy the phone line every single night, but the phone bills were quite high. My parents were not very happy with that.</p> <p>But this little phone had free internet using GPRS. I could just buy an RS232 serial cable, plug the phone into the computer and dial up to it like it was a modem. Speeds were comparable to modem speeds at 6 kByte per second or so. Only downside was that I could not charge the phone at the same time I was using the serial-cable, so I was limited to around six hours of being connected before the battery died. At which point it was usually time to go to sleep anyway.</p> <h2>More Phones</h2> <p>Anyway, thing is, even this fantastic little phone was quite soon outdated. My next one was the Sony Ericsson T610 released in 2003, again, just two years later. This one had larger full colour display, faster GPRS, a crappy camera, downloadable games written for the Mophun virtual machine and an actual web-browser with support for some but definitely not all HTML and CSS (no javascript).</p> <p>Two years later, again, I was given my first &quot;smart&quot; phone by my boss at my then work. It was one he had got for himself but couldn't really figure out how to use fully, a Sony Ericsson P800. It ran Symbian UIQ, had resistive touch screen with stylus and could run primitive apps. There were of course no app store or anything, you had to download things on the computer and transfer to the memory card. It was pretty neat though.</p> <p>Then in 2007, another two years later, the very same year the iPhone was released, I bought the successor, the Sony Ericsson P1i. It was pretty much the same as the P800, but more compact and the keyboard did not fold out. It was slow and annoying and I never liked it nearly as well as the P800, but the P800 was just worn out at this point, and quite ancient.</p> <p>So, yeah, the first half of the naughties was a time of very fast development for phones. I changed my phone every two years or thereabouts, but I knew several people who got new phones way more often than that. There were just so many different models and new innovations coming out all the time. Cameras, better screens, music players, gimmicky ways of folding them, games, apps. Month by month, more and more things found their way into even cheaper phones.</p> <p>I am of course a very &quot;tech&quot; person. There may very well have been many people who got the Nokia 3310 in 2001 and then used that phone until 2010 or so. As long as all they ever did was call, text message and playing Snake. No downloadable games. No camera. No colour screens. No music (except monotonic ring tones).</p> <h2>The Future Arrived</h2> <p>Apple released the iPhone 3G in the summer of 2008, the first one to be sold outside of USA.</p> <p>It was just one year after I had gotten the P1i, but I really wanted the iPhone so much. I was still locked down in a two year contract for my old phone, and the iPhone was at that time exclusive to a different carrier anyway, so I actually got a separate subscription just for it, and carried two phones for a while. Luckily I had a salary that could cover it, and the phone subscriptions are actually relatively cheap here compared to many other countries.</p> <p>Of course, that iPhone 3G was not fast, and it lacked a lot of what we take for granted in a phone today, but it had the brand new App Store and it clearly showed where things were heading. I had an app that played a &quot;mooo&quot; sound and showed a picture of a cow when you turned the phone around. Yeah. 😁</p> <p>The very next year I upgraded to a 3Gs, because it was just so much faster and more usable. Again, being in the middle of my contract, I paid cash for that phone, blowing a large chunk of my savings, but for me it was worth it. I realise I'm quite privileged being able to somehow almost always get the things I want, even though I did have to make sacrifices.</p> <p>But then that was it. No more new phones for me.</p> <p>You know how long that iPhone 3Gs lasted me? Until 2015. That's right. <em>Five and a half years</em>.</p> <p>Maybe I'm the weird one. Well I know I'm the weird one, but I had never before had a phone that lasted me that long, and that was usable the whole time. I did change the battery once or twice, and I did also replace the dock connector with one from a broken donor phone I was given.</p> <p>I replaced the 3Gs with a second hand iPhone 5C in 2015. The 5C was one year old when I bought it, and I used it until 2019 when I bought a brand new first generation iPhone SE to replace it, so that was only four years.</p> <p>Last year the SE was replaced with the 13 mini, yes, that was just three and a half years later, but the 13 mini being the last &quot;mini&quot; iPhone to be made and me not liking large phones weighed in to the decision. Plus all the advances in cameras and face ID just working so much better than touch ID for me.</p> <p>I have no plans to replace the 13 mini until it is at least four or five years old now.</p> <h2>Rounding Up</h2> <p>So, yes, going back to the original thing I was reacting to, many people these days do replace their phones every two to four years. And while I never managed to crack a screen, despite dropping both my 5C and SE a few times, they are probably a bit more sensitive than the plastic phones of old.</p> <p>But it was not really that much better in the old days. Even back then phones were not <em>actually</em> indestructible, and batteries did wear out. Anyone who says that the old Nokias (I never actually had a Nokia myself, but still) lasted for years and years probably don't actually remember what time spans we are talking about, because those phones were pretty obsolete within a year.</p> <p>Yes, sure, if all you ever did was to call and text they were still fine, but the big thing is that our usage patterns are always changing as new technologies emerge.</p> <p>You could argue that you still &quot;<em>do the same </em>'scrolling of social media'<em> that you did ten years ago, so why are the manufacturers making it so that the ten year old phones no longer work?</em>&quot;, but that is ignoring the fact that your social media back then was not a constant stream of live high resolution video, videos that use filters and overlays that require outrageously fast GPUs to make, nor were the games fully immersive high FPS 3D worlds.</p> <p>I think the advances in technology drives development of new services and software that shapes our usage of our phones, and the new things simply require the newer phones. Of course, the manufacturers are more than willing to sell you a new phone every year, because they make money on that, but that's just the same as it was back when the Nokia 3310 was the hottest new phone you could buy. Sucks to be the one with the bulkier 3110 or 3210, when your friends get the sleek 3310 with their fancy replaceable colour shells and ringtones that you also had to buy. Nothing has really changed in this regard.</p> <p>Yes, in many ways it's a bad development, phones get more and more expensive as they get more powerful. Software get more wasteful because the phones are more powerful. Manufacturers are struggling to sell more and more of them in a market where everyone already have one, so they need to come up with faster, newer and better things. Foldable phones are the lastest high end thing now.</p> <p>On the other hand, there have never been phones as capable and affordable as there are now. Yes, the &quot;flagships&quot; cost months of salary, but you can find plenty of cheap phones that are still quite good. They do tend to not last as long however, and are generally not even worth repairing when they inevitably break, and of course, having margins that thin means the people actually assembling them don't get much pay.</p> <p>This all is of course not really a good direction if we want a more sustainable society, I know, but it's really nothing new either.</p> <p>I'm not saying anything is good now. I'm just saying it wasn't good before either.</p> 2023-03-02T01:00:00+01:00 Picking My Dreams of a Larger Memory Niclas I had a weird dream again. Could we put a larger RAM chip in the Game and Watch? <h1>Picking My Dreams</h1> <p>I had a weird dream again. That is nothing unusual for me in itself, but what <em>was</em> unusual was that the <a href="">LockPickingLawyer</a> made an appearance shortly before I woke up.</p> <p>Of course, I don't actually know what he looks like, so my brain solved that by simply placing me in his eyes. I could hear the voice and see the hands but that was all. He was going through a bunch of very weirdly shaped padlocks with bluetooth functionality, using simple keys to show how they didn't lock properly, and then throwing them into a big pile in the corner of the room.</p> <p>There was some sort of reason for the locks being there, and there was a lot more going on before he appeared, but most of it I have already forgotten.</p> <h2>Game and Watch Again</h2> <p>Still have not managed to write much more about how to hack the Game and Watch. I have however spent a lot of time thinking about further things to do with it. First of all, a headphone socket. I spent way too much time looking at different sockets on Digikey, taking measurements and trying to figure out the best way to fit it. Thinking about small 3D-printed pieces of plastic and stuff. But it has not left the &quot;thinking&quot; state yet. Not sure it ever will. I can't really justify spending any more money on them right now.</p> <p>I have already successfully changed the flash chip in both the Mario and the Zelda GnW to 64 Mbyte, and made a <a href="">quick very sped up video showing the process</a>. I have also played a lot of Flashback for MegaDrive (Genesis), but I am now stuck right at the start of level 4: Earth. I just can't seem to manage to handle the polices, the orbs and the little robot thing that all appear at the same time. There might be some trick to it that I can't figure out, maybe I should check a walkthrough.</p> <h2>A Larger Memory</h2> <p>Another idea I have for the Game and Watch that I will probably not actually do is to replace the flash chip with a RAM-chip. 8 Mbyte or so of PSRAM are available with the same pin out as the flash chip.</p> <p>This would of course limit the device to the 256 kbyte flash inside the microcontroller, but thing is that some clever people have managed to wire in a microSD-card to it. There is however not yet any Retro Go fork that take advantage of the SD-card as very few people have done the mod. The downside of SD-cards also is that files need to be loaded from the file system and put in RAM, and the GnW only have 1 Mbyte of RAM in the microcontroller, limiting what game ROMs could be loaded and how much memory an emulated system could have.</p> <p>When just using the normal flash chip in the GnW as normal, it can be directly addressed, so both program code and game data is always there without copying to RAM (although with slower speeds than reading from the RAM), making the limited RAM in the controller not as big an issue (unless the ROMs are compressed, this is why larger game ROMs can't be compressed).</p> <p>However, just replacing the flash chip with a RAM chip would mean data or code could be loaded from files on the SD-card and put in the RAM-chip for use.</p> <p>It's an idea. I don't know if anyone else had the same idea. I probably won't actually try it though, as I don't really have the time nor the money to spend on it at the moment.</p> <p>In any case, that's all I have for you today. If you have any questions or comments about this, <a href="">please put them on mastodon</a>.</p> 2023-03-01T01:00:00+01:00 Offloading Niclas I'm not sure I'm doing this correctly … <h1>Offloading</h1> <p><em>This has been posted without my usual proofreading and editing.</em></p> <p>So, I started blogging because of <a href="">the &quot;100 Days To Offload&quot; thing</a>. Basically, it's a challenge to publish 100 blog posts in one year. I have now managed eleven (twelve counting this one) entries since January 22, which was pretty much one month ago. Since more or less half of them were all in the first week it's pretty clear that I will not make 100 posts before 365 days are up.</p> <p>But you know what? I don't really care. The &quot;challenge&quot; still pushed me to actually start a blog again, and even just doing one post was kind of a win for me.</p> <p>That said, I'm not sure I'm doing it right. I'm supposed to be &quot;offloading&quot;, am I not? Yet, the things I am writing are not really doing that. Or are they? They tend to be way too long, and I spend way to much time editing and spellchecking. Like, hours. It's just not possible to fit this into any kind of regular daily schedule, as it's not really a &quot;take 10 minutes to offload what is happening and get on with the day&quot; kind of thing.</p> <p>I guess one reason for that is that my life is just too boring. Yes, you heard it right, on an average day, nothing interesting happens here. And the things I do that might be remotely interesting to others are things that I would always (subconsciously?) try to describe in quite a bit of depth.</p> <h2>Draw two circles. Draw the rest of the damn Owl.</h2> <p>Maybe it's just me that feel like I want to make sure I explain everything in detail. I could of course just write &quot;Hey, I made this cool thing. Ok bye!&quot;, but that doesn't feel right. I am currently in the middle of writing a thing about the new Game and Watch—my recent obsession—about how to install Retro Go on it and <a href="">replace the flash memory chip</a>. But it just balloons out to basically a step by step tutorial.</p> <p>I'm not sure that actually belongs in a &quot;daily blog&quot;, but should rather go in some &quot;tutorials and guides&quot; thing. But if I do that I would probably feel bad if people try to follow them and I missed something that makes it impossible to do properly by just following the guide. That's always a problem writing guides. How detailed should it be? What background knowledge requirements should there be to follow it? Do I need to explain how to open the &quot;terminal&quot; and enter commands? Do I need to tell people how Git works? Do I need to tell them how to install Home-brew on their mac? How do I avoid getting too detailed and making the reader think that I think they are stupid? And am I responsible for errors caused by me not explaining things well enough? Instructions unclear … kind of thing.</p> <p>So it's <em>not</em> actually very offloading.</p> <p>Many years ago I wrote a very detailed step by step guide for how to build a specific patched version of OpenWRT for an old very tiny single board computer with an x86 compatible SOC and a tiny amount of RAM and Flash. It was relatively well received on the forum where people tinkering with this board were hanging out, but it didn't take very long until changes in packages and whatnots outside of my control made my instructions completely fail to build properly, and people who tried to use my guide got very disappointed. I had to take it down.</p> <p>That is the kind of things that will happen when you rely on things on the internet. And to avoid people being disappointed a lot of time then needs to be spent trying to update the instructions. But what if you have moved on and no longer use that thing or have any interest in it?</p> <p>So maybe I shouldn't write those things. But I still kind of enjoy—in a way—that somewhere, just maybe, there is someone who will read it and get what they need to try it and maybe learn something new, without having to do <em>all</em> the research that I did.</p> <p>Anyway. Not sure where I am going with this. I'm just dumping some random thoughts. Offloading?</p> <p>But it's Friday evening and there is a bag of cheap—although still 50% more expansive than they were a year ago—crisp here, so I think it's time to call it a night.</p> <p>Right after I go &quot;offload&quot; the contents of the tumble dryer. Which is, in itself, not something that is really worth blogging about.</p> <p>Now, if I made that dryer connect to the Wifi with an ESP32 and send data over MQTT to NodeRed running on a Raspberry Pi to send me messages to my phone about the progress of the drying, there would be something to blog about. And it would take me at least a week write it.</p> 2023-02-24T01:00:00+01:00 Further Adventures Gaming and Watching (part 1) Niclas How I made a nice little cable to reprogram my new 2020 Game and Watch … <h1>Further Adventures Gaming and Watching (part 1)</h1> <p>Som weeks ago i <a href="/blog/2023/2023-01-25-gaming-and-watching">wrote about my adventures with the new Nintendo Game and Watch with Colour Screen</a> and how I reflashed it. If you have not already read that, you might want to, as it provides some background info. Since then I have done a lot more to make the process of flashing easier and make the Game and Watch better.</p> <h2>A Solid Connection</h2> <p>The first thing to fix was a better way of connecting the <a href="">ST-link V2 programmer</a> to the debug port of the Game and Watch. The hook leads were neither convenient nor practical, and very prone to say click and go flying out of the hole they were supposed to make connection with.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-2.jpg" alt="Spring hook clip things connecting to the debug port" /></p> <p>The spacing of the connector in the Game and Watch is 1.27 mm. This is exactly half of the more common 2.54 mm pinheaders, and very tiny. For you Imperial people out there, 1.27 mm is exactly equal to 6/10th poppyseed.</p> <p>Even though 1.27 mm is not as common as 2.54 mm, pin-headers and sockets are still available. I ordered some from Digikey and received them two days later.</p> <p>I soldered a socket header to the debug port. This placement means I need to open the back every time I want to connect the programmer, but for now I didn't want to make any holes in the case for external connectors.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-3.jpg" alt="A header has been soldered in" /></p> <p>The receptacle part done, I needed a wire to connect it to the ST-link programmer. Standard ribbon cable conveniently enough also has a spacing of 1.27 mm, so we can just use that and solder it to a pin-header that fit our receptacle. Ribbon cables always come in even number of wires, but I wanted five. That's easy enough to fix though, they can just be separated. Then i stripped off a millimeter or so of insulation on one end and clumsily soldered it to a pin-header. It's very easy to melt the plastic in the pin-header, making them crooked, so it helps if the pins are inserted in a socket to hold them in place.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-4.jpg" alt="A pin-header has been soldered to a ribbon cable" /></p> <p>The other end of the ribbon we connect to a normal 2.54 mm 2x10 pin IDC-connector <em>(Insulation-displacement connector-connector)</em>. These connectors are specifically made for these kind of ribbon cables, but we have special requirements on the pin positions we put the wires in, so putting it together is a little tricky. The connectors have small forks that cut through the insulation of the wires and make contact. We just need to put the right wire at the right position and gently push it down using our fingernails. When everything is in the right position, we put the cap on the connector and press it with a pair of pliers to make sure the connections are good. Then we measure with a multimeter to make sure it did not accidentally make connections between the wires.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-5.jpg" alt="The ribbon is being connected to the IDC connector" /></p> <p>Please make sure the key on the connector, the small bit of plastic that prevents if from going in the wrong way, is on the right side. I did not make that sure and had to remove the wires, turn the connector 180 degrees and do it all again. Fun.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-6.jpg" alt="Cable plugged in to the Game and Watch" /> <img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-7.jpg" alt="Cable plugged in to the Game and Watch and the ST-link programmer" /></p> <p>When plugging in, the red wire is pin one, and the little golden triangle indicates pin one.</p> <p>For reference, the connections between the Game and Watch and the ST-link are:</p> <table> <thead> <tr> <th>GnW pin</th> <th>ST-link v2 pin</th> <th>Note</th> </tr> </thead> <tbody> <tr> <td>1 - NRST</td> <td>15 - NRST</td> <td>Reset (closest to golden triangle)</td> </tr> <tr> <td>2 - SWDIO</td> <td>7 - TMS_SWDIO</td> <td>Data</td> </tr> <tr> <td>3 - GND</td> <td>8 - GND</td> <td>Ground</td> </tr> <tr> <td>4 - VDD 1.8 V OUT</td> <td>2 - VAPP</td> <td>Target VDD,<br>do <strong>not</strong> connect to power source</td> </tr> <tr> <td>5 - SWCLK</td> <td>9 - TCK_SWCLK</td> <td>Clock</td> </tr> <tr> <td>6 - Zelda only</td> <td>N/C</td> <td>Not connected</td> </tr> <tr> <td>7 - Zelda only</td> <td>N/C</td> <td>Not connected</td> </tr> </tbody> </table> <p>Please note that the VDD-pin on the Game and Watch is outputting 1.8 V. This is the voltage the GnW microcontroller uses. Do not connect this line to any other voltage, you will make things broken if you do. It is connected to the VAPP-pin on the <em>original</em> ST-link v2, which is an <em>input</em> pin that is used to make sure the other pins operate at the correct voltage.</p> <p>If your interface is not an original ST-link (there are many clones, and they look very similar and can be difficult to tell apart from the real ones) it does likely not have this functionality, and you may get problems when flashing. Also please verify that your non original ST-link does not output voltage on the VAPP-pin. If it does, do not connect that pin.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-10.jpg" alt="A real ST-link to the left, a fake clone to the right" /></p> <p>The photo above is a clone I bought two years ago and an original I bought last month. Note that there may be differences in appearance to the ones I have depending on when and where they were made. One major difference between mine are that the year/week on the back is printed in blue as part of the label on the clone, but on the original it has been printer in black at a later time. The only way to be sure what you will get though is to buy from a reputable seller.</p> <p>A real ST-link will measure the voltage on the VAPP-pin and you can read it on the screen when using OpenOCD software to flash the Game and Watch. It should say 1.8-ish volt.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-9.jpg" alt="The pins on the ST-link and how they are numbered" /></p> <p>For more info about the pinout, please se the <a href="">ST-link data sheet</a>. If the ST-link is being helt with the ST-logo the right way up, the key of the 20 pin IDC-connector will be pointing down, and the pin 1 will be to the bottom left.</p> <p><img src="/assets/blog/2023/2023-02-19-further-adventures-gaming-and-watching-8.jpg" alt="The Game and Watch is showing progress display as Retro Go is being installed" /></p> <h2>To Be Continued</h2> <p>This was supposed to just be a little blog entry, but I realise it's basically turning into a tutorial. Anyway, I'm out of time for now, so I will continue next time.</p> <p>In the next episode we will do some more soldering to replace the flash chip. stay tuned. 😁</p> 2023-02-19T01:00:00+01:00 Time Marches On Niclas The Sensor Watch is a really cool upgrade for any F-91W watch … <h1>Time Marches On</h1> <p><em>This has been posted without my usual proofreading and editing. Expect their to be misstakes. 😉</em></p> <h2>Laptop Time</h2> <p>Sunday night. I grabbed the MacBook and headed to bed.</p> <p>It read 27% on the battery indication. That's nice, I thought, when did I last use it? Turns out it was two weeks ago, when I used it to <a href="/blog/2023/2023-01-29-sunday-wind-down">write a blog post</a> in bed. As I wrote back then, it was at 50% when I started that text, and I did spend some hours writing. And then two weeks of sleep with no charging. Pretty good battery life, yes.</p> <p>Anyway, I have plugged the charger in now.</p> <h2>Time Moves Slowly When You're Sick</h2> <p>Haven't written anything in a week now. I will at least partially blame that on being sick.</p> <p>Don't worry, It's Not Lupus. Most likely just a normal cold. I have also swab-tested my nose three times in the last five days just to be sure.</p> <p>It started already on Wednesday with a pretty sore throat. It was worse by Thursday morning, gradually worsening further during the day. I could still sit at my desk and work (I work from home) without too much difficulty, but needless to say I cancelled a meeting I had that afternoon. As evening rolled around my nose was not happy at all, though.</p> <p>Friday was much worse, the cough started and my nose was constantly dripping and generally non functional for all the usual things a nose should do. I decided to not get any work done.</p> <h2>Package in Time</h2> <p>The FedEx-driver called me around 11:30, saying they had a package for me. Hearing my voice they asked me if I was sick and quickly agreed to go up the stairs and just leave the package outside my apartment door. Very kind of them.</p> <p>It was the <a href="">Sensor Watch board</a> I had ordered on CrowdSupply a week prio. CrowdSupply is a crowd funding site, except it's good. It's focused on electronic boards and things for makers and the like, and they help the creators to make sure projects are actually realistic and can ship. They also take care of distribution and things like that. Many neat project there.</p> <h2>Sensing Time</h2> <p>The Sensor Watch project was launched already a year ago, and shipped to the backers at the end of last year. The really neat thing about CrowdSupply though is that once a project ships they will usually stock the product and you can just order it and know you will get it right away.</p> <p>The Sensor Watch is in stock right now. I ordered Friday a week ago, and exactly one week later the package arrived.</p> <p>The Sensor Watch board is a replacement circuit board that goes inside a Casio F-91W or A158W watch. The F-91W is a classic watch that has been in production for over 30 years. It's compact, stylish, durable and reasonably priced. Do be aware of fakes though.</p> <p>I do happen to have an F-91W, which I do use. It's awesome. With the Sensor Watch board inside though, it's even more awesome.</p> <p>Everything else is kept original, including the watch display. It's impossible to see that anything is different with the watch. That is, until you start pushing the mode button.</p> <h2>Firmware Time</h2> <p>The Sensor Watch board contains an ARM Cortex M0+ microcontroller. It has 256 kB flash memory and 32 kB of RAM, as well as 8 kB EEPROM storage. It can run at up to 32 MHz. It's also very low power, and the watch will achieve battery life of over one year on the CR2016 coin cell.</p> <p>The specs might not sound like that much, but it's still very decent for anything you would want a watch to do. It even has full speed USB-connection, even though you need to disassemble the watch to plug it in.</p> <p>And plug it in you want to do. The main strength of the watch is that you can adapt it to do whatever you like. There are a few ready made firmware images that can be easily programmed to it, but it's after you <code>git clone</code> the <a href="">GitHub repository</a> and start compiling your own firmware that it really shines.</p> <p>It's relatively easy to get going, even if you don't know too much about about programming. If you can find the terminal / command prompt on your computer, edit files and <a href="">follow instructions</a> you can probably get it working …</p> <p>… is what I would write if the instructions were a bit more complete. As it is right now you still need to figure some things out. There are also no instructions for Windows, only Linux and macOS. But everything is currently being very actively developed, and things will improve.</p> <p><em>(Future Niclas here, not feeling as sick any more: I realise that what I wrote here about the documentation might sound a bit negative, but that was not really my intention. There is actually <strong>a lot</strong> of good information on the docs site. It's just a bit sparse, for now, about compiling the firmware. It's definitely enough to figure it out, but I'm sure there will be more detailed step by step instructions in the future. As I said, it's still very much in active development, with code being pushd to the repository every single day.)</em></p> <p>There is also a <a href="">Discord server</a> (I'm sure this link will stop working any time) where you can get help.</p> <p>By the way, am I the only one who things Discords are a less than ideal way for documenting things? It's good for chat and sharing things <em>now</em>, but relying on it for things that should be available <em>later</em> has always seemed like a bad idea to me. &quot;Just scroll up to find it&quot; it is not really optimal. But, anyway, it's mostly chat between a lot of people developing parts of the firmware, so once things settle down I'm sure proper documentation will be written for all parts of it.</p> <p><em>(Future Niclas again: This is not a dig at this project specifically. Yes, for now some things are a bit hidden in the threads of the Discord, but that's mostly because they are just not 100% ready yet. They are litterally working on the code as I write this, so it's quite understandable that a lot of things will be in the developer discussions and not yet documentet. I did not mean anything negative about the Sensor Watch developers here.)</em></p> <h2>In Time</h2> <p>Anyway, yes, it's pretty neat. The &quot;operating system&quot; for the Watch is called Movement, and it has a large collection of <em>faces</em> that can be selected from and put in order to be cycled through with the mode button.</p> <p>You can have as many or as few as you like. There is plenty of storage in the watch for them.</p> <p>It's also relatively simple to make your own faces using the included template, <a href="">there are even instructions</a>. Or clone one of the existing ones and make changes to it.</p> <p>For testing there is a simulator. Basically the firmware is compiled with Emscripten to code that will run in a web browser.</p> <h2>On Time</h2> <p><a href="">Flashing (programming) the board is very easy</a>. Step one is to completely disassemble the watch. Ok, maybe not that easy then, but once the board is out and free (battery must be removed) you just plug it into a usb micro cable.</p> <p>It's quite neat really, how the actual circuit board slots right into the connector on the cable.</p> <p>Double-tap the small reset button. The LED on the board will pulse and the computer will see a mass storage device, a normal &quot;USB-memory&quot;. To flash a firmware, just drag the <code>watch.uf2</code> file that you just compiled or one that <a href="">you downloaded</a> to it. </p> <p>After happily blinking for a few seconds the board will reset itself, rudely breaking the USB-connection as it does so. Your computer will get annoyed by this and scold you for not properly ejecting the disk before unplugging it. Please pay no attention to this message. It's not your fault, and it's also, in this instance, completely safe.</p> <p>Then it's just a matter of putting the board back in the plastic frame, putting the battery on the board (there should be a small piece of double sided tape on the battery helping it say in place), snapping the metal part back over it all, and finally be able to see the display spring to life to test it.</p> <p>If it works, the module can be placed back inside the watch case (make sure the buttons are not pushed in) and the rubber sealing be carefully re-positioned, before the case back is screwed on again.</p> <p>Make sure you turn the screws backwards until you feel them fall down into their groove, before you screw them in. They fasten with basically no resistance. Do not over tighten.</p> <h2>Flex Time</h2> <p>Oh, I almost forgot. The reason it's called Sensor Watch is actually because the board have a small connector made for plugging in a flexible PCB (printed circuit board) with any sensor components you would like (and can fit). The idea is that anyone should be able to make a sensor board of their own if they want.</p> <p>Currently a temperature sensor is available. That board also have some test points for other signals, I2C, SPI, GPIO, that can be used to developing other sensors. Possible sensors include accelerometers and gyros for motion detection, barometers for altitude, magnetometers for compass and things similar to that.</p> <p>Space is very limited though, so it will be difficult to fit much more than one at a time.</p> <h2>Future Time</h2> <p>Anyway, all this was in the future, as I was there, feeling rather ill, holding package of shiny new toy. But runny nose be damned I was going to try it out as soon as possible.</p> <p>As afternoon rolled around I had gathered strength and blown my nose enough that I was ready to do it. It was a bit fiddly, and being sick did not make it easier, but it worked out all right. I flashed the board with a stock firmware with temperature sensor support and proceeded to take the watch apart. I even <a href="">posted photos on Mastodon</a>.</p> <p>I was quite happy with it, then I left the watch on my desk and went to bed. My cold got worse, pain in my nose and face, headache, constant coughing, blocked nose, and I was not able to sleep much during the night.</p> <p>Saturday was the worst, though I did manage to sleep for a few hours before noon.</p> <p>And the night between Saturday and Sunday? That was also the worst.</p> <p>The next few hours on early Sunday morning I didn't like at all.</p> <p>Then I actually managed to sleep some more, and was actually starting to feel better.</p> <p>Gradually things improved and by Sunday evening I could actually sit at the desk properly without having to go wash my nose every 10 minutes. I managed to read up enough to build a new firmware with the features I wanted, took the watch apart again and flashed it.</p> <h2>Exact Time</h2> <p>One of the things I added to the firmware was a rather new development for setting the time more precisely.</p> <p>You set the time as usual, then go into a special settings face where you can adjust the time plus/minus in increments of 25 ms until the seconds tick exactly in sync with a more accurate clock, like <a href=""></a>. When they are in sync, the correction is set.</p> <p>The idea now is that eventually the watch will drift away a little, as the crystal (a vibrating quartz crystal is used to keep the time, yes, I'm aware that sounds just like magic) is not perfect. When that happens, you go back and make the adjustment again. This time, the watch knows how long it has been since the first correction, and it will calculate a drift to adjust the timing with. Thus it will correct for the inaccuracy in the crystal.</p> <p>Just repeat this once more a few months later and you will have a hideously exact watch. I do believe I read something about using the temperature sensor for doing temperature compensation on the crystal too.</p> <p>I like to keep all my clocks in sync 😄.</p> <h2>Back in Time</h2> <p>Anyway, I'm back where I began this entry. In bed, with laptop, now at 100% charge. The time is approaching 3 AM again. My nose is actually relatively clear and I can mostly breathe through it.</p> <p>The end of this week did not turn out how it was planned at all, but you know, it could be worse. It could be raining.</p> <p>I usually spend way to much time proof reading and correcting these things. I don't feel like doing that now. So if anything seems weird, or you know, more weird than usual, or the spelling is of, that's entirely my fault.</p> <p>Good night.</p> 2023-02-13T01:00:00+01:00 No Longer Justified and Ancient Niclas I have changed the text alignment here to start instead of justify. I'm still quite ancient though … <h1>No Longer Justified and Ancient</h1> <p>I have changed the <em>text alignment</em> here to <code>start</code> instead of <code>justify</code>. I'm still quite ancient though. That's all I wanted to say.</p> <h2>Still no Master Plan</h2> <p>Still not sure what to put here. The first few entries wrote themselves kind of. I just had something I felt like writing about and then I did. But that doesn't happen every day, apparently.</p> <h2>All Bound for Mastodon Land</h2> <p>Mastodon is pretty nice, so far it's a steady flow of things to read, not as much as I used to have on the old place, in the before times, but the quality is good. And I am posting <em>a lot</em> more, and that's quite nice too.</p> <p>People seem to really like the <a href="">Griffin Powermate thing</a> I posted. 😅 It's at 53 favourites and 12 boosts right now. Just goes to show that people like things that are old, well made, stylish, <em>and</em> useful, and get happy if their shiny thing can actually be used with their modern computer.</p> <p>There is of course a lot of old hardware that's just impossible to use these days—I should know, I have most of them—but not that much of it that is as useful or intuitive as a knob, and not that much that keeps so well due to an all-metal construction. </p> <p>I posted a link to my instructions on the <a href="">BetterTouchTool forum</a> also. People there also seem to like it. 🙃</p> <p>So that's it then, my 15 minutes of fame. Now I can go back to being boring again.</p> <p>An interesting observation: Adjusting the volume in macOS with the Powermate controlling the &quot;small steps&quot; is <em>a lot</em> more laggy and sluggish when using the AirPods than when just using the computers own audio output. I guess that's because the volume is actually adjusted by the AirPods themselves, so a command need to be sent over bluetooth to them, and possibly a reply coming back. For every. single. small. step. adjustment. And there are <em>a lot</em> of small step adjustments done when turning the wheel.</p> <h2>Rocking to the Rhythm in their Ice Cube App</h2> <p>Still have not tested <a href="">Ice Cubes for Mastodon</a>. Still have not updated to iOS 16 or macOS 13. The latter is the reason for the former. I should get around to it some day. But I worry it will break my perfectly working setup 🫤.</p> <p>I'm using <a href="">Toot!</a> still. Seems to be the one that suits me best at the moment. It's not perfect, but I still like it. Worth every money I paid for it.</p> <p>In other software non-news, still using <a href="">Sublime Text</a> for coding, but I use <a href="">CotEditor</a> to write these posts in markdown. Spellchecking works better there, as it's the macOS standard. And I need spellchecking. 😬</p> <p>CotEditor have an annoying bug while writing Markdown though. The section selector flickers slightly every time I stop typing for a few seconds. It's very annoying, as it usually sits right there in my peripheral vision and just blips every time I stop typing for more than one second.</p> <p>I should probably check if there is an issue for it already, and possibly report it if not.</p> <p>On the other hand, if I stop typing for too long my brain might start working.</p> <h2>It's 3 A.M. Eternal</h2> <p>I wonder why I never seem to be able to sleep at any kind of sensible hour. And why is it so easy to sleep in the mornings?</p> <p>Also, if Instagram send me one more push notification about reels I should be checking out, I'm uninstalling the app. Sorry to the three people I have on Instagram messaging, we can probably find some other communication channel.</p> <p>Is Flickr still a thing by the way? I have <a href="">an outrageous amount of photos</a> on Flickr. Not really worth looking at. Too many of them are from a PLASMA JET concert. No, not those plasmajets, the Japanese one. What, there's more than one? Yes, it's death metal. No, I don't remember which members were in it at the time. No I will not explain. Actually, I couldn't even if I wanted. Moving on.</p> <h2>You got it, You got it</h2> <p>My old friend <a href="">Martin tooted</a> that I should have my own YouTube channel about &quot;old and/or quirky tech&quot;. I think there are quite a few of those already—I'm subscribed to several—so I don't really see what I could bring to the scene. If it's one thing I'm bad at it's doing regular things to a schedule. And if it's one thing I am good at it's missing deadlines. And I don't even <em>like</em> the very angst inducing whooshing sound they make as they fly by.</p> <p>I am also far too shy to ever be successful. I bought a fancy looking microphone some time back. I still haven't talked into it for fear of hearing my own voice. And fear of the neighbours hearing me. I mean, they will think I'm even crazier than they already think I am. Not that that is a bad thing, but still.</p> <p>But for what it's worth, I <em>do</em> have <a href="">a Youtube channel</a> already. Since 2006 in fact. It even used to be monetised back before they changed the rules about minimum subs and watch time. No, it never earned any money. And there are no serious videos on it.</p> <p>And I see now that Youtube have automatically converted my short videos to &quot;shorts&quot;. Thanks a lot for that Youtube, I really <em>love</em> how my videos now <em>continuously</em> loops as people try to locate the <em>hidden description</em> with important information and context.</p> <p>My <a href="">most popular video</a> have 21,710 views.</p> <p>That actually surprise me. It's just showing me controlling an RTI (Road and Traffic Information) LCD-screen from my Volvo S80 with an Arduino. It's a pretty cool screen really, it's motorised and comes up from the dash when the system activates. Many people wanted to use it to show other things though.</p> <p>That was 11 years ago. I was doing a lot of hacking on that car, sniffing the CAN-bus, documenting diagnostic commands, controlling the screen so I could hook my original Nintendo 8-bit to it. I used to be rather active on an old Volvo forum back then, and I documented everything I did on the forum. I just used Youtube to host small videos for the people on the forum to see.</p> <p>That forum is now gone, and so is all the useful info I wrote and all the discussions with other people there. They say the internet never forgets? Shows what they know. The internet is a huge amnesia-machine, it only cares about the &quot;new shiny&quot;. Bitrot is a real thing, and the Langoliers eat anything that is left.</p> <p>Before I used Youtube I actually used <a href="">Google Videos</a>. Does anyone even remember that anymore? They closed it <em>(of course they did)</em> for new uploads in 2009, because Google bought Youtube. They later closed it down completely and all my videos were automatically migrated to my Youtube channel, but unlisted, and I never made them public.</p> <p>I see now that two years ago Youtube changed all unlisted videos uploaded before 2017 to private. I should change that back to unlisted.</p> <p>Here you go, <a href="">this is a link to what I believe is the first video I uploaded to Google Videos</a>. I'm in the video. My brother is commenting behind the camera.</p> <p>It was migrated to to Youtube on November 1, 2012, but it's a lot older than that. It's been unlisted/private ever since, and right now it sits at one view. And that is me. I watched it. (Ok, two views now as I had to confirm it works again) And now you can too! Using that <a href="">super secret special link</a>, only for the Justified people who read this far. My special gift to you. Thank you! 😍</p> <p>Unfortunately, unlike some other videos uploaded in 2005, my video didn't net me $1.65 billion just a year later. Because I uploaded it to Google—for free—instead of making my own video platform and later selling the whole company to them. Easy mistake to make.</p> <p>Anyway, mentos and lemon soda? <em>Not</em> impressive. 😆</p> <h2>Last Train (Do You Wanna Ride?)</h2> <p>Yes, I completely derailed here. Anyway, Youtube-channel: Totally Exists. Prospect of getting new videos up there any time soon? Outlook Not So Good.</p> <p>But one should never say never, so they say. Who are They? Who knows. Doctor Who (Hey!) The Tardis. You What?! (You What?!) Exterminate! Posh, Posh, Posh, Loads of money.</p> <p>I'm probably getting quite tired. I should really stop now. But that has never stopped me before.</p> <p>And since you're here, <a href="">have another video</a>. This one is actually public, I made it 10 years ago. The music was totally used without permission or credits, but it's <a href=";t=1016s">Worm Riders from Panzer Dragoon Orta OST</a>. I should probably update the description to mention that. Also, it's a good soundtrack. Give it a listen if you like. Especially <a href=";t=887s">Ancient Weapon 1</a> (Yes, there is a remix of it called <a href="">More Than a Weapon</a>, totally worth a listen also).</p> <p>Should ye ever find yeself with yon OG XBOX, and ye olde fire-button-mashing-thumb is up for it, do give the game a try also.</p> <p>I'm just old, am I not?</p> <p>Good night.</p> 2023-02-06T01:00:00+01:00 I Kind of Expected This Niclas One and a half week ago I rediscovered website RSS-feeds through NetNewsWire, and I wrote about that. I also found out that NetNewsWire could read tweets. Today I had to update that blog entry after the news that free API-access to Tweets will be removed … <h1>I Kind of Expected This</h1> <p>One and a half week ago I rediscovered website RSS-feeds through NetNewsWire, and <a href="/blog/2023/2023-01-24-the-joys-of-syndication">I wrote about that</a>. I also found out that NetNewsWire could read tweets. Today I had to update that blog entry after the news that free API-access to Tweets will be removed.</p> <p>After Tweetbot was banned, I stopped reading tweets. It was just too annoying to keep up with them through the website and most sensible people had already moved to Mastodon.</p> <p>Then I found out that NetNewsWire could read tweet-feeds, which was quite neat. I could keep up with the few things that still were left over there, such as weather and power grid updates and some others who for one reason or other were still there.</p> <p><img src="/assets/blog/2023/2023-02-03-i-kind-of-expected-this-1.png" alt="Two screenshots from NetNewsWire showing feeds from the power grid corporation about service interrupptions and similar and the Atmospheric, Geophysical and Astronomical Services Administration showing weather information" /></p> <p>But I always suspected that would not last for long. And it turns out it didn't.</p> <p>There are no actual RSS-feeds for these things, there has not been for a long time, so everything was through the API. And now that API will not be available any more, without paying for it.</p> <p>NetNewsWire <a href="">has already made the announcement</a> that, due to the removal of the free API, they will be removing the integration in the next update of the app.</p> <p>So that's it then, my last connection to the the &quot;Blue Birdsite&quot; has been cut. 🙂</p> <p>This is of course also very bad for all the good bots and services that used the API to post their updates. I do wonder it the power grid and weather updates I was following did it though API or if someone manually copy-pasted them in the Web interface?</p> 2023-02-03T01:00:00+01:00 Touch of Power Niclas Back in 2001 or so, Griffin Technology released the PowerMate. Here's how you can get it working on a modern Mac in 2023 … <h1>Touch of Power</h1> <p><em>If you are impatient and just want to get the Powermate working on your Mac, scroll down to <a href="#thecode">the code</a></em></p> <h2>Our story so far</h2> <p>Back in 2001 or so, Griffin Technology released the PowerMate. It's basically just a jog wheel with a USB-connector, but it's also quite stylish, machined from a solid piece of <del>steel</del> aluminium with a slightly brushed finish. Inside the semi-translucent base sits a single blue LED—none of that RGB that is so popular these days—that can pulse smoothly to indicate things.</p> <p>There was a bluetooth version released in 2014, but I never had that one.</p> <p>The PowerMate is more or less just a glorified volume knob for your desktop, but it can be much more. As I recall, the software allowed you to map the rotating and pushing actions to anything you wanted, and you could use AppleScript to make it even more advanced.</p> <p>Fast forward 20 odd years and that old software of course does not work any more. I believe there have been some developments, but I never found anything that seemed to work well.</p> <p>But at it's core it's still just a USB low speed HID-device. It should be compatible with anything that can understand the simple values it sends.</p> <p><img src="/assets/blog/2023/2023-02-02-touch-of-power-1.jpg" alt="Photo of the Griffin Powermate. The base is illuminated by a nice blue light." /></p> <h2>The Better Tool</h2> <p><a href="">BetterTouchTool by folivora.AI GmbH</a> is a wonderful little application for macOS. If there is an input devices on a mac, BTT can most likely do something with it. It does not do much at all right after you install it, it requires a lot of configuration, but that is also the apps main strength. It can really do more or less anything, and it has been constantly developed for many years now. It costs 10 dollar for two years of updates, or 22 dollar for lifetime, but it should probably cost a lot more than that.</p> <h2>Combining them</h2> <p>BTT version 4 was released a few days ago, with support for &quot;Generic Devices&quot;. This immediately caught my attention. It allows you to look at the reports coming in from any HID-device on the system and use JavaScript to act on the raw bytes. It's still a bit rough around the edges, but it works. 😊</p> <p>First thing I thought about was the PowerMate. I managed to find it in an old box, plugged it in to my M1 Mac Mini, followed the simple steps in the (for now) a bit limited <a href="">documentation</a> and <em>boom</em>. I got data coming in as I turned the knob.</p> <p>The Powermate sends six bytes in every report, I do not know the mening of all of them, but the only ones we need to use are index 0 and 1.</p> <p><img src="/assets/blog/2023/2023-02-02-touch-of-power-2.png" alt="Screenshot showing the six bytes as received by BetterTouchTool Analyzer" /></p> <ul> <li> <p>Index 0 have the value 0 or 1 depending on wether the button is held down or not. When the state changes index 1 will always be 0, even if the knob is spinning while we push or release the button. A value other than 0 for index 1 while index 0 is 1 means the knob is being held down and turned at the same time.</p> </li> <li> <p>Index 1 have a value corresponding to how far the knob has been turned since the last report. It is signed, positive numbers for turning right, negative for turning left. Spinning the knob as fast as I can I have observed values up to ±7 here. You do need to spin quite fast to get anything other than 1 though.</p> </li> </ul> <p>Spinning the knob at a steady pace will cause repeated identical reports with the same value for movement. Originally it was not possible to get these repeat messages to the script, but version 4.006 added a function that can be called to tell BTT we want the next report also, even if it's the same. This solved that problem. 😄</p> <h2>The code <a name="thecode"></a></h2> <p>To do this yourself with BTT 4.006, open the BTT configuration and choose &quot;Generic Devices (work in progress)&quot;.</p> <ul> <li>Click + at the bottom to add a new trigger.</li> <li>Choose &quot;Generic Device &amp; Input Analyzer&quot;.</li> <li>Under the tab &quot;Target Device&quot;, find the Griffin Powermate in the &quot;See all connected HID Devices&quot; dropdown. This will fill out all necessary values like Vendor and Product ID.</li> <li>Go to the &quot;Analyzer&quot; tab and paste the triggers we want to define in the &quot;Provided Triggers&quot; input box.</li> </ul> <pre><code>buttonpress buttonrelease left leftpressed right rightpressed</code></pre> <ul> <li>Then click the &quot;Parse Device Input/Output&quot; button. This will open a new window.</li> <li>Give the PowerMate a little spin. If everything is ok so far, you should see reports coming in. If not, try closing the window and open it again. I found it can sometimes be a little flaky.</li> <li>Click on the values in index 0 and index 1 in the report under &quot;Current Input Data&quot;, to monitor them for changes. When turning or pushing the knob there will now be messages in &quot;History Of Monitored Changes&quot;.</li> <li>Paste the following script in the provided space to the left.</li> </ul> <pre><code>// Input Analyser script for Griffin PowerMate // Select index 0 and 1 in report 0 for monitoring function analyzeDeviceInput(targetDevice, reportID, reportDataHex) { let reportBuffer = buffer.Buffer.from(reportDataHex, 'hex'), // Index 0 is button state. 1 = press, 0 = release. button = reportBuffer.readUInt8(0), // Index 1 is amount of movement since last report. // Signed value, positive for right, negative for left. // Spinning really fast I have observed a value up to +/- 7, // lets assume it will never be larger than 9. movement = reportBuffer.readInt8(1); if ( movement &lt; 0 ) { if ( button == 0 ) { log('left ' + movement); // We should probably repeat the trigger "movement" times ... // but that would be too many triggers :) bttTriggerDeviceTrigger(targetDevice, 'left'); } else { log('left ' + movement + ' pressed'); bttTriggerDeviceTrigger(targetDevice, 'leftpressed'); } // If we are spinning we want the next report even if it's the same bttGetNextEvenWithoutChange(targetDevice, reportID); } else if( movement &gt; 0) { if ( button == 0 ) { log('right ' + movement); bttTriggerDeviceTrigger(targetDevice, 'right'); } else { log('right ' + movement + ' pressed'); bttTriggerDeviceTrigger(targetDevice, 'rightpressed'); } bttGetNextEvenWithoutChange(targetDevice, reportID); } // When button state change index 1 is always 0, even if knob is spinning. else if ( button === 1 &amp;&amp; movement === 0 ) { log('button press'); bttTriggerDeviceTrigger(targetDevice, 'buttonpress'); } else if ( button === 0 &amp;&amp; movement === 0 ) { log('button release'); bttTriggerDeviceTrigger(targetDevice, 'buttonrelease'); } }</code></pre> <ul> <li>Give the knob a turn again and check that things are written in the log.</li> <li>Close the window.</li> <li>Add more triggers with the + button, this time select the &quot;Griffin Powermate&quot;-triggers in the trigger selector, and add any actions you want to them.</li> </ul> <p><img src="/assets/blog/2023/2023-02-02-touch-of-power-3.png" alt="Screenshot showing the triggers added to BetterTouchTool Analyzer" /></p> <p>I have found that you sometimes need to restart BetterTouchTool for script changes to take affect in the actual actions, even if it works in the analyser window. Just select Restart in BTTs menu and it should be fine.</p> <p>Please note that this only receives data from the Powermate. It does not control the LED, though that should be possible as soon as I figure out the values to send to the device.</p> <h2>Further developments</h2> <p>I am currently experimenting with storing a position value in a &quot;global&quot; variable, increasing and decreasing this value by the amount of movement in the reports. Then sending a trigger every time it has passed over an even 10 ticks. This allows you to make corse movement, which would be a lot better for some types of input. It's not quite finished yet, will post more later. I'm not sure if it's allowed to use a global variable like that, but it works in the Analyzer at least. Update: Andreas Hegenberg <a href="">have confirmed</a> that that global variables are fine to use.</p> <h2>Disclaimer</h2> <p>I am in no way affiliated or sponsored by neither folivora.AI GmbH nor Griffin Technology. I just enjoy their products. I do not make any claims of usability or correctness of any code or instructions released here. Code and instructions may contain bugs or be incorrect. Software might change in the future making this obsolete. You are free to use the code presented here any way you like. If you get this working yourself, why not <a href="">Toot me on Mastodon</a>?</p> 2023-02-02T01:00:00+01:00