Last active
September 11, 2018 19:51
-
-
Save arkag/dfc4170bfa99193d70895e43d1e08253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void flash_rgb (void) { | |
switch(current_state) { | |
case always_on: | |
set_color(underglow, false); | |
return; | |
case flash_begin: | |
timer_one = timer_read(); | |
current_state = flash_off; | |
case flash_off: | |
timer_two = timer_read(); | |
elapsed = timer_two - timer_one; | |
if (elapsed >= LED_FLASH_DELAY) { | |
set_color(hsv_none, false); | |
timer_one = timer_read(); | |
current_state = flash_on; | |
} | |
return; | |
case flash_on: | |
timer_two = timer_read(); | |
elapsed = timer_two - timer_one; | |
if (elapsed >= LED_FLASH_DELAY) { | |
set_color(flash_color, false); | |
timer_one = timer_read(); | |
if (loop) { | |
current_state = flash_off; | |
} else if (num_extra_flashes_off > 0) { | |
current_state = flash_off; | |
num_extra_flashes_off--; | |
} else { | |
current_state = always_on; | |
} | |
} | |
return; | |
} | |
} | |
void set_os (uint8_t os, bool update) { | |
current_os = os; | |
if (update) { | |
eeprom_update_byte(EECONFIG_USERSPACE, current_os); | |
} | |
switch (os) { | |
case OS_MAC: | |
set_unicode_input_mode(UC_OSX); | |
underglow = (Color){ 300, 255, 255 }; | |
mod_primary_mask = MOD_GUI_MASK; | |
break; | |
case OS_WIN: | |
set_unicode_input_mode(UC_WINC); | |
underglow = (Color){ 180, 255, 255 }; | |
mod_primary_mask = MOD_CTL_MASK; | |
break; | |
case OS_NIX: | |
set_unicode_input_mode(UC_LNX); | |
underglow = (Color){ 60, 255, 255 }; | |
mod_primary_mask = MOD_CTL_MASK; | |
break; | |
default: | |
underglow = (Color){ 0, 0, 255 }; | |
mod_primary_mask = MOD_CTL_MASK; | |
} | |
set_color(underglow, update); | |
flash_color = underglow; | |
current_state = flash_begin; | |
num_extra_flashes_off = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment