Category Archives: Uncategorized

Imagine if the roles were reversed

My tax refund finally came through today, 4½ months after filing. By far, this is the longest it has ever taken. Even though I file by mail with printed forms, somewhere around 3-4 weeks is more typical.

If I owed money, do you think the IRS would tolerate such a lengthy delay without at least tacking on some penalties? Didn’t think so.

Fuck Joe Biden.

Solid advice

Hate them back:

I’m a big believer in giving back to people what they give to others. Think of it as a twist on the Golden Rule: if someone is a bad person to others, even if it isn’t you, treat them accordingly. Someone who is a bad person to people who aren’t you will eventually get around to you because it’s who they are at their core. That’s how I see Democrats, particularly Joe Biden. Jill too, but she’s such a non-entity without him she barely deserves a mention. If you are not with them, not one of them., they hate you, they really do. Return the favor.

Fuck Joe Biden.

Generate QR codes for Zebra EPL printers

I have a Zebra LP2844 at home that was originally purchased to print shipping labels, though I’ve used it from time to time for other types of labels. Recently, I had a need to produce labels that include QR codes. The LP2844 is a fairly old printer; its page-description language, EPL, knows nothing about QR codes. (Newer printers with newer languages have a feature to just drop a specified QR code anywhere on the label you want it.)

It does have the ability to print arbitrary bitmapped graphics, and the format of the bitmapped image data is similar to a PBM file without the header. We can therefore abuse the NetPBM tools to produce image data the printer understands:

#!/usr/bin/env bash

# generate a QR code and render it as an EPL fragment
# params: x y max_size "QR code contents" [qrencode options]

x=$1; shift
y=$1; shift
max_size=$1; shift
msg=`echo $1 | sed "s/\"/\\\\\"/g"`; shift
size=$(qrencode -t PNG -s 1 -m 0 -o - $* "$msg" | pngtopnm | pnmfile | sed "s/^.*raw, //;s/ .*//")
mul=$(expr $max_size / $size)
width=$(expr \( $size \* $mul + 7 \) / 8)
echo -n GW$x,$y,$width,$(expr $size \* $mul),
qrencode -t PNG -s $mul -m 0 -o - $* "$msg" | pngtopnm | pgmtopbm -thresh | pnminvert | tail -n +3
echo ""

The first two arguments to the script are the coordinates where you want the QR code to be placed. The third is the maximum size (in printer pixels, which are 1/203″ for most Zebra printers) of the code. The fourth is the content of the QR code. Any additional arguments are passed to qrencode (such as -i to ignore case).

Something like this will crank out a QR code suitable for a 1″ label:

(echo N; make-qr-epl 10 10 180 "This is a test"; echo P) | lpr -Plp2844_raw

The intent is that you could call this within a script that puts together a more complex label layout and sends it to the printer.

If you wanted to be able to send arbitrary bitmapped images to your label printer, it wouldn’t be much of an exercise to rip out the calls to qrencode and replace them with a different image source.

Fuck Joe Biden.

Gentoo + Raspberry Pi Pico SDK + VSCodium: getting it all working

The standard instructions for getting the Raspberry Pi Pico SDK up and running mostly work on Gentoo Linux, but there are a few exceptions (especially with regard to setting up the needed ARM cross-compiler). This is a summary of what I figured out over the course of a couple of hours on a Sunday morning, adding the needed components to my system to get the provided “blinky” example to compile without errors. (I don’t yet have a Raspberry Pi Pico to test with, but they’re on order from Sparkfun and will probably arrive sometime this week.)

Install the ARM Cross-Compiler

This is the biggest divergence from the published directions. Gentoo has a system called crossdev that makes building cross-compilers ridiculously easy. If you don’t already have it enabled (I already had AVR, ARM, and RISC-V cross-compilers for other purposes, though the ARM compilers I already had were for cross-compiling for Gentoo on Raspberry Pi SBCs, not the Raspberry Pi Pico), go get it. Even if you’re running Gentoo Linux on a Raspberry Pi SBC, you’ll need this for the Pico:

sudo emerge crossdev

Then, to build the necessary cross-compiler, do this…-s4 ensures that we get a C++ compiler as well as a C compiler:

sudo crossdev -s4 --target arm-none-eabi

Install the Raspberry Pi Pico SDK

This pretty much goes by the book. You’ll need Git installed…if you haven’t done that already, go take care of that. Then, get the SDK:

cd ~ && mkdir pico && cd pico
git clone -b master https://github.com/raspberrypi/pico-sdk
(cd pico-sdk && git submodule update --init)
git clone -b master https://github.com/raspberrypi/pico-examples
git clone -b master https://github.com/raspberrypi/pico-extras
git clone -b master https://github.com/raspberrypi/pico-playground
cat <<EOF >>~/.bashrc
PICO_SDK_PATH=`pwd`/pico-sdk
PICO_EXAMPLES_PATH=`pwd`/pico-examples
PICO_EXTRAS_PATH=`pwd`/pico-extras
PICO_PLAYGROUND_PATH=`pwd`/pico-playground
EOF

Log out and back in before continuing to make sure the new variables are in your environment.

Install VSCodium

VSCodium is the fully-open-source version of Visual Studio Code. Mainly it lacks the telemetry code that phones home to Microsoft with your usage. There is of course an ebuild in Portage, but before we install it, there’s a fix I like to apply that helps with plugin availability (in particular, it gets PlatformIO up and running in VSCodium). The following will do both:

sudo wget https://alfter.us/wp-content/uploads/2022/04/vscodium-marketplace.patch -O /etc/portage/patches/app-editors/vscodium/vscodium-marketplace.patch
sudo emerge vscodium

Configure VSCodium

There are a couple of extensions you’ll want to grab to better integrate Pico SDK projects into VSCodium:

  • C/C++ IntelliSense
  • CMake
  • CMake Tools
  • Cortex-Debug

Try It Out

Start VSCodium from a shell prompt (the needed environment variables may or may not show up if you launch it from some desktop facility). We’ll start with the provided examples:

nohup vscodium ~/pico/pico-examples &

If everything’s set up right, you’ll get some messages from cmake in the output window and a few options to select at the bottom of the window:

Where it says “CMake: [Debug]: Ready,” you can click to choose between different build options: debug, release, etc. To the right of that, you pick the compiler to use…whatever the exact version is, it should have “arm-none-eabi” as part of the name. To the right of that is the “Build” button, and right next to build, you can click where it says “[all]” to pick one of the examples to build. Click on it, select “blink”, then click “Build.” After a short time (maybe a second on the Ryzen 7 3800X I’m running), the output window should say the build is complete with no errors. ~/pico/pico-examples/build/blink/blink.uf2 is the file that you’d then transfer into a Raspberry Pi Pico for execution.