MCPcopy Create free account
hub / github.com/cbm80amiga/Arduino_ST7789_Fast / rgbWheel

Method rgbWheel

Arduino_ST7789_Fast.cpp:650–677  ·  view source on GitHub ↗

------------------------------------------------ Input a value 0 to 511 (85*6) to get a color value. The colours are a transition R - Y - G - C - B - M - R.

Source from the content-addressed store, hash-verified

648// Input a value 0 to 511 (85*6) to get a color value.
649// The colours are a transition R - Y - G - C - B - M - R.
650void Arduino_ST7789::rgbWheel(int idx, uint8_t *_r, uint8_t *_g, uint8_t *_b)
651{
652 idx &= 0x1ff;
653 if(idx < 85) { // R->Y
654 *_r = 255; *_g = idx * 3; *_b = 0;
655 return;
656 } else if(idx < 85*2) { // Y->G
657 idx -= 85*1;
658 *_r = 255 - idx * 3; *_g = 255; *_b = 0;
659 return;
660 } else if(idx < 85*3) { // G->C
661 idx -= 85*2;
662 *_r = 0; *_g = 255; *_b = idx * 3;
663 return;
664 } else if(idx < 85*4) { // C->B
665 idx -= 85*3;
666 *_r = 0; *_g = 255 - idx * 3; *_b = 255;
667 return;
668 } else if(idx < 85*5) { // B->M
669 idx -= 85*4;
670 *_r = idx * 3; *_g = 0; *_b = 255;
671 return;
672 } else { // M->R
673 idx -= 85*5;
674 *_r = 255; *_g = 0; *_b = 255 - idx * 3;
675 return;
676 }
677}
678
679uint16_t Arduino_ST7789::rgbWheel(int idx)
680{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected