Exemple #1
0
void rgblight_init(void) {
  debug_enable = 1; // Debug ON!
  dprintf("rgblight_init called.\n");
  dprintf("rgblight_init start!\n");
  if (!eeconfig_is_enabled()) {
    dprintf("rgblight_init eeconfig is not enabled.\n");
    eeconfig_init();
    eeconfig_update_rgblight_default();
  }
  rgblight_config.raw = eeconfig_read_rgblight();
  if (!rgblight_config.mode) {
    dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
    eeconfig_update_rgblight_default();
    rgblight_config.raw = eeconfig_read_rgblight();
  }
  eeconfig_debug_rgblight(); // display current eeprom values

  #ifdef RGBLIGHT_ANIMATIONS
    rgblight_timer_init(); // setup the timer
  #endif

  if (rgblight_config.enable) {
    rgblight_mode_noeeprom(rgblight_config.mode);
  }
}
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;
}
Exemple #3
0
void rgblight_init(void) {
  /* if already initialized, don't do it again.
     If you must do it again, extern this and set to false, first.
     This is a dirty, dirty hack until proper hooks can be added for keyboard startup. */
  if (is_rgblight_initialized) { return; }

  debug_enable = 1; // Debug ON!
  dprintf("rgblight_init called.\n");
  dprintf("rgblight_init start!\n");
  if (!eeconfig_is_enabled()) {
    dprintf("rgblight_init eeconfig is not enabled.\n");
    eeconfig_init();
    eeconfig_update_rgblight_default();
  }
  rgblight_config.raw = eeconfig_read_rgblight();
  RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
  if (!rgblight_config.mode) {
    dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
    eeconfig_update_rgblight_default();
    rgblight_config.raw = eeconfig_read_rgblight();
  }
  rgblight_check_config();

  eeconfig_debug_rgblight(); // display current eeprom values

#ifdef RGBLIGHT_USE_TIMER
    rgblight_timer_init(); // setup the timer
#endif

  if (rgblight_config.enable) {
    rgblight_mode_noeeprom(rgblight_config.mode);
  }

  is_rgblight_initialized = true;

}