That's correct (although G goes up to 63) - it's called 'RGB565' and is a standard way of packing RGB data into 16 bits.
If you just want an easy solution use
Oh, that's interesting...I never heard of RGB565 before - but good to know.
I need that conversion because of g.setPixel which expects a color value as its last argument.
I've just updated the docs, but it turns out that if you leave out the last argument it just defaults to using the foreground color so you can use setColor first if you need to.
I guess there should really be a 'toColor` function to make the process easier
I had some trouble generating a proper color value for g.setPixel. My current experiments have led to some weird results:
But the shifts look strange - can they be correct?