On Trump and taxes

According to the Epoch Times, Donald and Melania Trump reported negative income in four of the six years’ worth of tax returns that were dumped. I’m sure the usual scumbags will try to make something of this, but as long as all the “I”s are dotted and “T”s are crossed, I don’t see anything at all wrong with this:

Anyone may arrange his affairs so that his taxes shall be as low as possible; he is not bound to choose that pattern which best pays the treasury. There is not even a patriotic duty to increase one’s taxes. Over and over again the Courts have said that there is nothing sinister in so arranging affairs as to keep taxes as low as possible. Everyone does it, rich and poor alike and all do right, for nobody owes any public duty to pay more than the law demands.

– Learned Hand

LED Marquee, or scrolling text across multiple IS31FL3731 displays

I lost my first Tindie sale to misplaced email. By the time I discovered I’d had an order come in, it had already been refunded automatically. Determined to avoid a repeat, I figured that a display of some sort that could be updated with live order information from Tindie, H3 Hab Bazaar, and elsewhere would be useful for making sure orders are handled expeditiously.

For display elements, I wanted LED modules that aren’t too ridiculously large, and a single color would be sufficient. Adafruit has charlieplexed 16×9 LED matrix boards (such as this) that are just a mess of 0603 LEDs wired together appropriately. They’re meant to be used with this driver board, which provides an I2C interface. As many as four boards can be used together on one I2C bus; that’ll make a 64×9 display about eight inches wide and an inch tall. I2C allows use of something small and cheap like an ESP-01 module that also provides WiFi so the display can be reconfigured on the fly.

Here’s the prototype, with two of the display modules connected:

(It looks brighter in person than it does in the video. That said, I also have the brightness dialed way back from maximum. You can crank it bright enough that your eyes will bleed. :-) The blue LED on the ESP-01 is connected to GPIO2, which we’re using for the I2C clock…that’s why it’s lit up.)

It’s just a fixed string right now, with WiFi disabled. Adding the rest of the displays is a matter of soldering them together and daisy-chaining them with some cables. I intend to put the displays in a 3D-printed enclosure and hang it on the wall, with some code running on my home server to update the display periodically over WiFi.

Finding code that uses multiple Adafruit_GFX-compatible displays and treats them as one unit was a bit tricky. I thought it might combine the four 16×9 screens into a single 64×9 virtual screen, but it doesn’t. Instead, your code needs to divide the image across the four screens. Fortunately, Adafruit_GFX allows for graphics coordinates outside the range of the screen, which (1) facilitates smooth scrolling by allowing the same text to be written one pixel to the left at a time and (2) allows the same content to be written to multiple screens with different offsets so they end up showing a larger image. Here’s the code that runs the demo in the video shown above:

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_IS31FL3731.h>

#define NUM_SCREENS 2 
#define BRIGHTNESS 8

Adafruit_IS31FL3731 matrix0 = Adafruit_IS31FL3731();
Adafruit_IS31FL3731 matrix1 = Adafruit_IS31FL3731();
Adafruit_IS31FL3731 matrix2 = Adafruit_IS31FL3731();
Adafruit_IS31FL3731 matrix3 = Adafruit_IS31FL3731();

void setup() {
  // set up I2C
  Wire.pins(0,2); // SDA on GPIO0, SCL on GPIO2

  // connect to display(s)
  if (! matrix0.begin(0x74)) 
    while (1);
  #if NUM_SCREENS>=2
  if (! matrix1.begin(0x75)) 
    while (1);
  #if NUM_SCREENS>=3
  if (! matrix2.begin(0x76)) 
    while (1);
  #if NUM_SCREENS>=4
  if (! matrix3.begin(0x77)) 
    while (1);

void loop() {

  String msg="The quick brown fox jumps over the lazy dog.";

  msg="    "+msg+"    ";
  #if NUM_SCREENS>=2
  msg="    "+msg+"    ";
  #if NUM_SCREENS>=3
  msg="    "+msg+"    ";
  #if NUM_SCREENS>=4
  msg="    "+msg+"    ";

  for (int i=0; i<msg.length()-4*NUM_SCREENS; i++)
    String segment=msg.substring(i, i+4*NUM_SCREENS);
    for (int8_t x=0; x>-6; x--) {
      #if NUM_SCREENS>=2
      #if NUM_SCREENS>=3
      #if NUM_SCREENS>=4

I really wanted an array of Adafruit_IS31FL3731 instances that I could iterate through with loops, but I couldn’t get that to work, so instead the loops are unrolled with a bunch of #ifdefs to control how many are produced, based on the number of attached screens. At first I was running with one screen, but last night I got it running with two. I haven’t yet tested it, but three or four screens should work as well.

This code builds in PlatformIO, and I currently have it targeting the ESP-01 (which uses an ESP8266). Before I figured out how to enable I2C on the ESP-01, I had a single screen driven by an Arduino Nano, but I’ve seen posts elsewhere indicating that it might not have enough RAM to handle multiple screens.

Next task is to set up some sort of control interface (probably web-based) to allow content to be changed on the fly, and to knock together an enclosure so it’s more than just a bunch of boards and wires.

Fuck Joe Biden.

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.