Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions keyboards/ble_micro_pro/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_RGB_TEST
#define RGBLIGHT_EFFECT_ALTERNATING
#define RGBLIGHT_EFFECT_TWINKLE
/*== customize breathing effect ==*/
/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
#define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
Expand Down
4 changes: 3 additions & 1 deletion quantum/rgblight/rgblight.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,8 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
uint8_t frac(uint8_t n, uint8_t d) { return (uint16_t)255 * n / d; }
uint8_t scale(uint16_t v, uint8_t scale) { return (v * scale) >> 8; }

const uint8_t trigger = scale((uint16_t)0xFF * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2);

for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) {
TwinkleState *t = &(led_twinkle_state[i]);
HSV * c = &(t->hsv);
Expand All @@ -1372,7 +1374,7 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
t->life--;
uint8_t unscaled = frac(breathe_calc(frac(t->life, t->max_life)) - bottom, top - bottom);
c->v = scale(rgblight_config.val, unscaled);
} else if (rand() < scale((uint16_t)RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2)) {
} else if ((rand() % 0xFF) < trigger) {
// This LED is off, but was randomly selected to start brightening
if (random_color) {
c->h = rand() % 0xFF;
Expand Down