I think that calculateAvgColor() function can be used here, but without tests or real LightPack hardware I can't be sure that all will work.
So I didn't touch this code yet.