Dotto, part 11: the Elecrow CrowPanel 2.1, with a dial

On 29 November a round 2.1 inch board with a physical dial reached the desk. What it is, the four commits that made it run, the 20 pixels of glass that needed calibrating, and the input grammar that came out of the dial.

Part 10 ended with a list of things I couldn’t check on the 1.43 board. Three days later there is a different board on the desk: an Elecrow CrowPanel 2.1 inch, round, with a physical dial around the glass. The next part says why I’m not happy with it. This one covers what it took to make it run, which was less than I expected.

What it is

The commit that added it, c6bf993 on 29 November at 17:29, describes the hardware in one paragraph:

  • a round IPS panel, 480×480, with an ST7701S controller on an RGB bus, initialised over a 3-wire SPI;
  • a CST816 touch controller;
  • a PCF8574 I/O expander, which switches the panel’s power and reset and also carries the press of the dial;
  • the dial itself, read as a quadrature signal by the ESP32-S3’s pulse counter;
  • a PWM backlight.

No IMU, no battery, no audio. The input notes add that there is no vibration motor and no speaker either, so the screen is the only way Dotto can answer a gesture. The 1.43 had an IMU and a battery, so the sleep logic from part 10 gets a single still sample here instead of a real motion sensor.

Everything for this board lives in one file, esp/main/crow21.cpp, behind CONFIG_DOTTO_BOARD_CROW21. The files for the other boards compile nothing for it. The panel’s vertical sync pulse stands in for the tearing-effect line the AMOLED has. The commit message quotes 57 to 60 fps and 65 KB of internal RAM free. That can’t be compared with the 1.43’s 53 fps and 6.9 KB, which were measured on other screens at another point in the work. I quote them only to say it ran at once.

Two commits later: the size and the glass

The core had always drawn a 466×466 picture, the size of the AMOLED. On a 480×480 panel that left a 7 px ring around it, and the wave effects stopped short of the edge. Commit ad4e7f8 makes the size a property of the board: DOTTO_PX is 466 by default and 480 on this panel, and the hand-written 466s in the code became a variable. The simulator accepts it too. The 466 screens stayed identical, which the screen test confirms, and the board reports 59 fps.

The second problem was physical. The image looked shifted upward, because the glass sits about 20 px lower than the panel’s pixels. The commit that fixed it (eca2906) gives two confirmations: Elecrow’s own sample code subtracts 20 from the touch’s y coordinate, and my touches aimed at the centre arrived 15 to 20 px below it.

So the base offset is 20, and a calibration handles the rest. Hold the dial down while powering on and a test ring appears. Turn the dial to move it onto the edge of the glass, up and down first, then right and left, and a press saves the result as crow.dx and crow.dy for that unit. Yes, the unit needs its own calibration. The next part comes back to this.

One language for every input

Until now the interface was driven by a finger on a touch rim, a button and the simulator’s keys. The dial added one more source, and 392eab7 is where it stops being a special case. The dial, the touch rim, the simulator’s wheel and keys, and the test scripts all go through the same three calls in the core: rotate, press and release. The rules live in a new file, INPUT.md, and its central table is short:

GestureMeans, everywhere
Turn (one notch)The screen’s axis. Clockwise is always “next” or “more”
PressThe screen’s main action: open, confirm, start, play or pause
Hold 0.6 sBack one level
Keep holding, up to 1.5 sThe clock

Before this commit the dial lowered the light, the volume and the minutes, because only the touch rim turned the sign of the values. Now clockwise is “more” for every source. A few more rules came with it, and each exists because something went wrong without it:

  • from the clock, the first notch or a click opens the menu;
  • from asleep, the first gesture only wakes the screen: the press until its release, the rotation for 0.3 s;
  • a click during which the dial moved two notches or more does not count;
  • for 0.15 s after a screen opens, rotation is discarded, because the turn that follows a click is a reflex;
  • there is no double click, since it would delay every single click.

The texts depend on the board too: where a finger gets “tap to start”, a dial gets “press to start”, through hal::hasKnob().

Feedback without a motor

With no motor and no speaker, the answer to a gesture has to be on the glass, in the frame after the gesture. The input notes give three answers:

  • a notch is a tick on the rim that turns with the dial, 24 positions to a turn;
  • a click is a ring of dots that starts at the touch point (the centre, for the dial) and spreads. The old ripple lasted 1.4 s and stopped at a radius of 190 px, so on the clock it never reached the edge. The new one (8ce1267) reaches the glass in about 160 ms, is followed by an echo in the screen’s colour, and is gone in 0.8 s;
  • a hold draws an arc down the rim from 12 o’clock on both sides, starting at 0.2 s, and at 0.6 s the rim flashes.

What is not done

Two items on the list matter for the next part. First, the dial is read once per frame today. The plan is a task at 200 Hz, so that a press is recognised in 15 to 25 ms. Second, turning doesn’t yet move focus between the buttons of the choice screens, and a press there is still a tap on the centre. That is the P0 on the list.

So I’m judging the feel of a dial whose reading I haven’t finished.