12
12
#include "rgb_led_status.h"
13
13
#include "samd21_pins.h"
14
14
15
+ uint8_t rgb_status_brightness = 255 ;
15
16
#ifdef MICROPY_HW_NEOPIXEL
16
17
static uint8_t status_neopixel_color [3 ];
17
18
static digitalio_digitalinout_obj_t status_neopixel ;
@@ -94,25 +95,26 @@ void new_status_color(uint32_t rgb) {
94
95
if (current_status_color == rgb ) {
95
96
return ;
96
97
}
97
- current_status_color = rgb ;
98
+ uint32_t rgb_adjusted = color_brightness (rgb , rgb_status_brightness );
99
+ current_status_color = rgb_adjusted ;
98
100
#endif
99
101
100
102
#ifdef MICROPY_HW_NEOPIXEL
101
103
if (neopixel_in_use ) {
102
104
return ;
103
105
}
104
- status_neopixel_color [0 ] = (rgb >> 8 ) & 0xff ;
105
- status_neopixel_color [1 ] = (rgb >> 16 ) & 0xff ;
106
- status_neopixel_color [2 ] = rgb & 0xff ;
106
+ status_neopixel_color [0 ] = (rgb_adjusted >> 8 ) & 0xff ;
107
+ status_neopixel_color [1 ] = (rgb_adjusted >> 16 ) & 0xff ;
108
+ status_neopixel_color [2 ] = rgb_adjusted & 0xff ;
107
109
common_hal_neopixel_write (& status_neopixel , status_neopixel_color , 3 );
108
110
#endif
109
111
#if defined(MICROPY_HW_APA102_MOSI ) && defined(MICROPY_HW_APA102_SCK )
110
112
if (apa102_mosi_in_use || apa102_sck_in_use ) {
111
113
return ;
112
114
}
113
- status_apa102_color [5 ] = rgb & 0xff ;
114
- status_apa102_color [6 ] = (rgb >> 8 ) & 0xff ;
115
- status_apa102_color [7 ] = (rgb >> 16 ) & 0xff ;
115
+ status_apa102_color [5 ] = rgb_adjusted & 0xff ;
116
+ status_apa102_color [6 ] = (rgb_adjusted >> 8 ) & 0xff ;
117
+ status_apa102_color [7 ] = (rgb_adjusted >> 16 ) & 0xff ;
116
118
117
119
#ifdef CIRCUITPY_BITBANG_APA102
118
120
shared_module_bitbangio_spi_write (& status_apa102 , status_apa102_color , 8 );
@@ -123,18 +125,22 @@ void new_status_color(uint32_t rgb) {
123
125
}
124
126
125
127
void temp_status_color (uint32_t rgb ) {
128
+ #if defined(MICROPY_HW_NEOPIXEL ) || (defined(MICROPY_HW_APA102_MOSI ) && defined(MICROPY_HW_APA102_SCK ))
129
+ uint32_t rgb_adjusted = rgb ;
130
+ rgb_adjusted = color_brightness (rgb , rgb_status_brightness );
131
+ #endif
126
132
#ifdef MICROPY_HW_NEOPIXEL
127
133
if (neopixel_in_use ) {
128
134
return ;
129
135
}
130
- uint8_t colors [3 ] = {(rgb >> 8 ) & 0xff , (rgb >> 16 ) & 0xff , rgb & 0xff };
136
+ uint8_t colors [3 ] = {(rgb_adjusted >> 8 ) & 0xff , (rgb_adjusted >> 16 ) & 0xff , rgb_adjusted & 0xff };
131
137
common_hal_neopixel_write (& status_neopixel , colors , 3 );
132
138
#endif
133
139
#if defined(MICROPY_HW_APA102_MOSI ) && defined(MICROPY_HW_APA102_SCK )
134
140
if (apa102_mosi_in_use || apa102_sck_in_use ) {
135
141
return ;
136
142
}
137
- uint8_t colors [12 ] = {0 , 0 , 0 , 0 , 0xff , rgb & 0xff , (rgb >> 8 ) & 0xff , (rgb >> 16 ) & 0xff , 0x0 , 0x0 , 0x0 , 0x0 };
143
+ uint8_t colors [12 ] = {0 , 0 , 0 , 0 , 0xff , rgb_adjusted & 0xff , (rgb_adjusted >> 8 ) & 0xff , (rgb_adjusted >> 16 ) & 0xff , 0x0 , 0x0 , 0x0 , 0x0 };
138
144
#ifdef CIRCUITPY_BITBANG_APA102
139
145
shared_module_bitbangio_spi_write (& status_apa102 , colors , 12 );
140
146
#else
@@ -166,3 +172,7 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness) {
166
172
return color ;
167
173
#endif
168
174
}
175
+
176
+ void set_rgb_status_brightness (uint8_t level ){
177
+ rgb_status_brightness = level ;
178
+ }
0 commit comments