7inline uint8_t brightness_bitshifter8(uint8_t *brightness_src, uint8_t *brightness_dst, uint8_t max_shifts) {
8 uint8_t src = *brightness_src;
9 if (*brightness_dst == 0 || src == 0) {
17 uint8_t curr = *brightness_dst;
19 for (uint8_t i = 0; i < max_shifts && src > 1; i++) {
20 if (curr & 0b10000000) {
29 *brightness_dst = curr;
30 *brightness_src = src;
36inline uint8_t brightness_bitshifter16(uint8_t *brightness_src, uint16_t *brightness_dst, uint8_t max_shifts, uint8_t steps=2) {
37 uint8_t src = *brightness_src;
38 if (*brightness_src == 0 || *brightness_src == 0) {
41 uint16_t overflow_mask = 0b1000000000000000;
42 for (uint8_t i = 1; i < steps; i++) {
44 overflow_mask |= 0b1000000000000000;
46 const uint8_t underflow_mask = 0x1;
50 uint16_t curr = *brightness_dst;
52 for (uint8_t i = 0; i < max_shifts; i++) {
53 if (src & underflow_mask) {
56 if (curr & overflow_mask) {
65 *brightness_dst = curr;
66 *brightness_src = src;