My apologies if this is old hat, but I've never run into it before...

Everybody knows those 4 digit 7 segment displays.

They have 4 common pins and 7 (+1 for the decimal point) segment pins.

Everything is arranged electrically in a little rectangle, 4 x 8 = 32 lightable thingies.

I found a trashed USB power bank on the highway.

It had a cute little 2.5 digit (188) LED display on it.

I thought that I'd salvage it.

I was amazed to see that it connected on only 5 pins.

I scratched my head.

If it were 2 rows and 3 columns, that would be 6 lightable thingies.

What they are doing is connecting between every pin and every other pin an LED.

Ok, but that would be 5 * 4, (then divided by 2 since polarity does matter) = 10 lightable thingies.

But! They have LEDs going in both directions between all the pins, 5 * 4 = 20 lightable thingies.

Since this is a 2.5 digit (without decimal points) we only need 16 lightable thingies.

So what we have is actually a square matrix (with the row drivers and the column drivers being the same).

It has a dimension of 5 * 5 (minus of course the 5 where the row and column is the same, i.e. the diagonal) = 20 active crosspoints.

Since we are only using 16 crosspoints, we could use the remaining 4 as pushbutton inputs (with an isolating diode).

Since we're driving LEDs and they need a resistor and there's no division between rows and columns, each of the 5 leads gets a resistor, 1/2 of the value we'd want.

The advantage to all this is that you only need 5 pins out of your uP.

The disadvantage is you have to do wacky bit bopping to determine the right segment.

Since builtin pullups on uPs are easy, I have the multiplexing work by grounding 1 of the 5 pins and either Hi-Z or VSS on the other pins.

Without reading any extra pushbuttons, a 4 phase refresh will do.

With pushbuttons you need 5 phases.

Of course, you could make this 16 (or 17) phase to make sure that the drop across the resistors is absolutely uniform.