The Peggy 2 hardware– natively –only knows about on and off. However, the refresh rate is very high, so we can simulate multiple brightness levels by trading off refresh rate, and lighting some of the LEDs for only part of the time– quite convincingly to the eye. We show off this capability in a few of the demo programs, and also use it in the “Peggy 2 video” examples, where we let the Peggy 2 receive serial-streamed data with 16 levels of brightness. You might want to look at those examples as a starting point.
For PeggyDraw 2, we wanted to make it simple to use and able to draw a lot of frames (~250), so it’s single-level on/off. If we rewrote it to use 16 grayscale levels, that would requires four times as much memory (4 bits per LED), so only 1/4 as many frames could be stored in memory, or about 60 frames maximum. Perhaps 8 gray levels (3 bits per LED) would be a better choice, giving about 120 frames available.