コード例 #1
0
ファイル: rgblight.c プロジェクト: Xyverz/qmk_firmware
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
  if (!rgblight_config.enable) {
    return;
  }
  if (mode < RGBLIGHT_MODE_STATIC_LIGHT) {
    rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
  } else if (mode > RGBLIGHT_MODES) {
    rgblight_config.mode = RGBLIGHT_MODES;
  } else {
    rgblight_config.mode = mode;
  }
  RGBLIGHT_SPLIT_SET_CHANGE_MODE;
  if (write_to_eeprom) {
    eeconfig_update_rgblight(rgblight_config.raw);
    xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
  } else {
    xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode);
  }
  if( is_static_effect(rgblight_config.mode) ) {
#ifdef RGBLIGHT_USE_TIMER
      rgblight_timer_disable();
#endif
  } else {
#ifdef RGBLIGHT_USE_TIMER
      rgblight_timer_enable();
#endif
  }
#ifdef RGBLIGHT_USE_TIMER
    animation_status.restart = true;
#endif
  rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
コード例 #2
0
ファイル: rgb_stuff.c プロジェクト: UnderSampled/qmk_firmware
uint32_t default_layer_state_set_rgb(uint32_t state) {
#ifdef RGBLIGHT_ENABLE
  if (userspace_config.rgb_layer_change) {
    rgblight_config_t temp_rgblight_config = rgblight_config;
    switch (biton32(state)) {
      case _COLEMAK:
        temp_rgblight_config.hue = 300;
        temp_rgblight_config.val = 255;
        temp_rgblight_config.sat = 255;
        temp_rgblight_config.mode = 1;
        break;
      case _DVORAK:
        temp_rgblight_config.hue = 150;
        temp_rgblight_config.val = 255;
        temp_rgblight_config.sat = 255;
        temp_rgblight_config.mode = 1;
      case _WORKMAN:
        temp_rgblight_config.hue = 43;
        temp_rgblight_config.val = 218;
        temp_rgblight_config.sat = 218;
        temp_rgblight_config.mode = 1;
      default:
        temp_rgblight_config.hue = 180;
        temp_rgblight_config.val = 255;
        temp_rgblight_config.sat = 255;
        temp_rgblight_config.mode = 1;
    }
    if (temp_rgblight_config.raw != eeconfig_read_rgblight()) {
      xprintf("rgblight set default layer hsv [EEPROM]: %u,%u,%u,%u\n", temp_rgblight_config.hue, temp_rgblight_config.sat, temp_rgblight_config.val, temp_rgblight_config.mode);
      eeconfig_update_rgblight(temp_rgblight_config.raw);
    }
  }
#endif // RGBLIGHT_ENABLE
  return state;
}
コード例 #3
0
ファイル: rgblight.c プロジェクト: chrischambers/qmk_firmware
void rgblight_mode(uint8_t mode) {
  if (!rgblight_config.enable) {
    return;
  }
  if (mode < 1) {
    rgblight_config.mode = 1;
  } else if (mode > RGBLIGHT_MODES) {
    rgblight_config.mode = RGBLIGHT_MODES;
  } else {
    rgblight_config.mode = mode;
  }
  eeconfig_update_rgblight(rgblight_config.raw);
  xprintf("rgblight mode: %u\n", rgblight_config.mode);
  if (rgblight_config.mode == 1) {
    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_disable();
    #endif
  } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 23) {
    // MODE 2-5, breathing
    // MODE 6-8, rainbow mood
    // MODE 9-14, rainbow swirl
    // MODE 15-20, snake
    // MODE 21-23, knight

    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_enable();
    #endif
  }
  rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
コード例 #4
0
ファイル: rgblight.c プロジェクト: ScrelliCopter/qmk_firmware
void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
  if (rgblight_config.enable) {
    if (rgblight_config.mode == 1) {
      // same static color
      rgblight_sethsv_noeeprom(hue, sat, val);
    } else {
      // all LEDs in same color
      if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
        // breathing mode, ignore the change of val, use in memory value instead
        val = rgblight_config.val;
      } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) {
        // rainbow mood and rainbow swirl, ignore the change of hue
        hue = rgblight_config.hue;
      } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) {
        // static gradient
        uint16_t _hue;
        int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1;
        uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]);
        for (uint8_t i = 0; i < RGBLED_NUM; i++) {
          _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360;
          dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range);
          sethsv(_hue, sat, val, (LED_TYPE *)&led[i]);
        }
        rgblight_set();
      }
    }
    rgblight_config.hue = hue;
    rgblight_config.sat = sat;
    rgblight_config.val = val;
    eeconfig_update_rgblight(rgblight_config.raw);
    xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
  }
}
コード例 #5
0
ファイル: rgblight.c プロジェクト: adiabatic/qmk_firmware
void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
  if (rgblight_config.enable) {
    if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
      // same static color
      LED_TYPE tmp_led;
      sethsv(hue, sat, val, &tmp_led);
      rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
    } else {
      // all LEDs in same color
      if ( 1 == 0 ) { //dummy
      }
#ifdef RGBLIGHT_EFFECT_BREATHING
      else if (rgblight_config.mode >= RGBLIGHT_MODE_BREATHING &&
          rgblight_config.mode <= RGBLIGHT_MODE_BREATHING_end) {
        // breathing mode, ignore the change of val, use in memory value instead
        val = rgblight_config.val;
      }
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
      else if (rgblight_config.mode >= RGBLIGHT_MODE_RAINBOW_MOOD &&
                  rgblight_config.mode <= RGBLIGHT_MODE_RAINBOW_MOOD_end) {
        // rainbow mood, ignore the change of hue
        hue = rgblight_config.hue;
      }
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
      else if (rgblight_config.mode >= RGBLIGHT_MODE_RAINBOW_SWIRL &&
               rgblight_config.mode <= RGBLIGHT_MODE_RAINBOW_SWIRL_end) {
        // rainbow swirl, ignore the change of hue
        hue = rgblight_config.hue;
      }
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
      else if (rgblight_config.mode >= RGBLIGHT_MODE_STATIC_GRADIENT &&
               rgblight_config.mode <= RGBLIGHT_MODE_STATIC_GRADIENT_end) {
        // static gradient
        uint16_t _hue;
        int8_t direction = ((rgblight_config.mode - RGBLIGHT_MODE_STATIC_GRADIENT) % 2) ? -1 : 1;
        uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - RGBLIGHT_MODE_STATIC_GRADIENT) / 2]);
        for (uint8_t i = 0; i < RGBLED_NUM; i++) {
          _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360;
          dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range);
          sethsv(_hue, sat, val, (LED_TYPE *)&led[i]);
        }
        rgblight_set();
      }
#endif
    }
    rgblight_config.hue = hue;
    rgblight_config.sat = sat;
    rgblight_config.val = val;
    if (write_to_eeprom) {
      eeconfig_update_rgblight(rgblight_config.raw);
      xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
    } else {
      xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
    }
  }
}
コード例 #6
0
ファイル: rgblight.c プロジェクト: chrischambers/qmk_firmware
void eeconfig_update_rgblight_default(void) {
  dprintf("eeconfig_update_rgblight_default\n");
  rgblight_config.enable = 1;
  rgblight_config.mode = 1;
  rgblight_config.hue = 0;
  rgblight_config.sat = 255;
  rgblight_config.val = 255;
  eeconfig_update_rgblight(rgblight_config.raw);
}
コード例 #7
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
void rgblight_disable(void) {
  rgblight_config.enable = 0;
  eeconfig_update_rgblight(rgblight_config.raw);
  xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
  #ifdef RGBLIGHT_ANIMATIONS
    rgblight_timer_disable();
  #endif
  wait_ms(50);
  rgblight_set();
}
コード例 #8
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
void eeconfig_update_rgblight_default(void) {
  //dprintf("eeconfig_update_rgblight_default\n");
  rgblight_config.enable = 1;
  rgblight_config.mode = 1;
  rgblight_config.hue = 0;
  rgblight_config.sat = 255;
  rgblight_config.val = RGBLIGHT_LIMIT_VAL;
  rgblight_config.speed = 0;
  eeconfig_update_rgblight(rgblight_config.raw);
}
コード例 #9
0
ファイル: rgblight.c プロジェクト: Xyverz/qmk_firmware
void rgblight_disable(void) {
  rgblight_config.enable = 0;
  eeconfig_update_rgblight(rgblight_config.raw);
  xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
#ifdef RGBLIGHT_USE_TIMER
      rgblight_timer_disable();
#endif
  RGBLIGHT_SPLIT_SET_CHANGE_MODE;
  wait_ms(50);
  rgblight_set();
}
コード例 #10
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
void rgblight_update_dword(uint32_t dword) {
  rgblight_config.raw = dword;
  eeconfig_update_rgblight(rgblight_config.raw);
  if (rgblight_config.enable)
    rgblight_mode(rgblight_config.mode);
  else {
    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_disable();
    #endif
      rgblight_set();
  }
}
コード例 #11
0
ファイル: rgblight.c プロジェクト: chrischambers/qmk_firmware
void rgblight_toggle(void) {
  rgblight_config.enable ^= 1;
  eeconfig_update_rgblight(rgblight_config.raw);
  xprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable);
  if (rgblight_config.enable) {
    rgblight_mode(rgblight_config.mode);
  } else {
    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_disable();
    #endif
    _delay_ms(50);
    rgblight_set();
  }
}
コード例 #12
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
  if (!rgblight_config.enable) {
    return;
  }
  if (mode < 1) {
    rgblight_config.mode = 1;
  } else if (mode > RGBLIGHT_MODES) {
    rgblight_config.mode = RGBLIGHT_MODES;
  } else {
    rgblight_config.mode = mode;
  }
  if (write_to_eeprom) {
    eeconfig_update_rgblight(rgblight_config.raw);
    xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
  } else {
    xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode);
  }
  if (rgblight_config.mode == 1) {
    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_disable();
    #endif
  } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) ||
	     rgblight_config.mode == 35 ) {
    // MODE 2-5, breathing
    // MODE 6-8, rainbow mood
    // MODE 9-14, rainbow swirl
    // MODE 15-20, snake
    // MODE 21-23, knight
    // MODE 24, xmas
    // MODE 35  RGB test

    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_enable();
    #endif
  } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) {
    // MODE 25-34, static gradient

    #ifdef RGBLIGHT_ANIMATIONS
      rgblight_timer_disable();
    #endif
  }
  rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
コード例 #13
0
ファイル: rgblight.c プロジェクト: chrischambers/qmk_firmware
void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
  if (rgblight_config.enable) {
    if (rgblight_config.mode == 1) {
      // same static color
      rgblight_sethsv_noeeprom(hue, sat, val);
    } else {
      // all LEDs in same color
      if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
        // breathing mode, ignore the change of val, use in memory value instead
        val = rgblight_config.val;
      } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) {
        // rainbow mood and rainbow swirl, ignore the change of hue
        hue = rgblight_config.hue;
      }
    }
    rgblight_config.hue = hue;
    rgblight_config.sat = sat;
    rgblight_config.val = val;
    eeconfig_update_rgblight(rgblight_config.raw);
    xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
  }
}
コード例 #14
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
void rgblight_decrease_speed(void) {
    rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 );
    eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
}
コード例 #15
0
ファイル: rgblight.c プロジェクト: chrischambers/qmk_firmware
void rgblight_enable(void) {
  rgblight_config.enable = 1;
  eeconfig_update_rgblight(rgblight_config.raw);
  xprintf("rgblight enable: rgblight_config.enable = %u\n", rgblight_config.enable);
  rgblight_mode(rgblight_config.mode);
}
コード例 #16
0
ファイル: rgblight.c プロジェクト: Xyverz/qmk_firmware
void rgblight_decrease_speed(void) {
    rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 );
    //RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED??
    eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
}