|
6 | 6 |
|
7 | 7 | namespace pimoroni {
|
8 | 8 |
|
9 |
| - |
10 |
| - |
11 |
| -Hub75::Hub75(uint width, uint height, Pixel *buffer, PanelType panel_type, bool inverted_stb) |
12 |
| - : width(width), height(height), panel_type(panel_type), inverted_stb(inverted_stb) |
| 9 | +Hub75::Hub75(uint width, uint height, Pixel *buffer, PanelType panel_type, bool inverted_stb, COLOR_ORDER color_order) |
| 10 | + : width(width), height(height), panel_type(panel_type), inverted_stb(inverted_stb), color_order(color_order) |
13 | 11 | {
|
14 | 12 | // Set up allllll the GPIO
|
15 | 13 | gpio_init(pin_r0); gpio_set_function(pin_r0, GPIO_FUNC_SIO); gpio_set_dir(pin_r0, true); gpio_put(pin_r0, 0);
|
@@ -60,7 +58,26 @@ void Hub75::set_color(uint x, uint y, Pixel c) {
|
60 | 58 | }
|
61 | 59 |
|
62 | 60 | void Hub75::set_pixel(uint x, uint y, uint8_t r, uint8_t g, uint8_t b) {
|
63 |
| - set_color(x, y, Pixel(r, g, b)); |
| 61 | + switch(color_order) { |
| 62 | + case COLOR_ORDER::RGB: |
| 63 | + set_color(x, y, Pixel(r, g, b)); |
| 64 | + break; |
| 65 | + case COLOR_ORDER::RBG: |
| 66 | + set_color(x, y, Pixel(r, b, g)); |
| 67 | + break; |
| 68 | + case COLOR_ORDER::GRB: |
| 69 | + set_color(x, y, Pixel(g, r, b)); |
| 70 | + break; |
| 71 | + case COLOR_ORDER::GBR: |
| 72 | + set_color(x, y, Pixel(g, b, r)); |
| 73 | + break; |
| 74 | + case COLOR_ORDER::BRG: |
| 75 | + set_color(x, y, Pixel(b, r, g)); |
| 76 | + break; |
| 77 | + case COLOR_ORDER::BGR: |
| 78 | + set_color(x, y, Pixel(b, g, r)); |
| 79 | + break; |
| 80 | + } |
64 | 81 | }
|
65 | 82 |
|
66 | 83 | void Hub75::FM6126A_write_register(uint16_t value, uint8_t position) {
|
|
0 commit comments