PWM does not work due to the beat effect, however I do it.
This was to be expected but I did not expect it to be so bad, and be so PWM frequency independent. One can avoid it but it needs a very careful frequency tweak, which will not work other than a one-off.
The discovery that 25k Rset works great means that an analog solution exists, as a wide range current sink.
Just in case somebody finds this one day, the 3 software brightness bits produce the following currents in mA (6 digits showing 8, Rset=1.5k )
7
11
18
40
43
46
48
52
The DS reveals a weird relationship for the brightness setting bits:
0000: pulse width is 1/16
0001: pulse width is 2/16
0010: pulse width is 4/16
0011: pulse width is 10/16
0100: pulse width is 11/16
0101: pulse width is 12/16
0110: pulse width is 13/16
0111: pulse width is 14/16
So the chip's 3-bit brightness values 0-7 do not map linearly to increasing brightness (LED current) — there's a non-linear jump between values 2 and 3 (4/16 to 10/16), skipping 5/16, 6/16, 7/16, 8/16, 9/16 entirely.
I've spent a bit of time on this and it appears impossible to solve that gap with just one resistor being switched (i.e. two Rset values only).
So another reason to not use the software brightness, set it to 111, and drive the Rset pin from a wide range current sink. Or one of those programmable potentiometers but they aren't cheap.
Another way would be to have a R/2R/4R/8R etc network on Rset, switched from a shift register, preferably an open-drain one. That would need clock+data but there might be a cunning way to load it from the keypad scanning feature of the chip.
Unfortunately this 20 year old chip is still a very good solution, at a low price. There is not much else out there, apart from obscure chinese chips. The old MAX7219 / MAX6950 are 10x the price. Hmmm just found the AS1115 which is rather similar, 2x more, and is an obvious "improved copy of the STLED316 and gives 16 brightness levels
