static void applyLock(uint8_t *lock){ if(*lock == LOCK_WILL_SET){ *lock = LOCK_IS_SET; blinkOnce(50); _delay_ms(50); blinkOnce(100); }else if(*lock == LOCK_WILL_NOT_SET){ *lock = LOCK_NOT_SET; blinkOnce(100); } }
void VUMeter::blink(int index, int speed,int times){ //blink one leds for a few times(default is once) //speed is the delay time for both on and off for(int i=0;i<times;i++){ blinkOnce(index,speed,speed); } }
static void countQuickSwapEnabled(void){ if(enabledQuickSwapCount && ++_quickSwapCount > quickSwapCountMax){ if(enabledQuickSwapCount == COUNT_TYPE_QUICKSWAP_ALT_GUI){ blinkOnce(50); if((quickSwapMode & QUICKSWAP_ALT_GUI) == QUICKSWAP_ALT_GUI){ quickSwapMode &= ~QUICKSWAP_ALT_GUI; }else{ quickSwapMode |= QUICKSWAP_ALT_GUI; _delay_ms(50); blinkOnce(100); } } eeprom_write_byte((uint8_t *)EEPROM_QUICK_SWAP, quickSwapMode); enabledQuickSwapCount = 0; } }
void VUMeter::scrollLeft(int speed,int startIndex){ //leds will turn on one at a time, //each for the duration of speed in milliseconds, //start with the startIndex counting from right, //go towards left clear(); for(int i=pinCount-1-startIndex;i>-1;i--){ blinkOnce(i,speed,0); } }
void VUMeter::scrollRight(int speed,int startIndex){ //leds will turn on one at a time, //each for the duration of speed in milliseconds, //start with the startIndex counting from left, //go towards right clear(); for(int i=0+startIndex;i<pinCount;i++){ blinkOnce(i,speed,0); } }
static void applyQuickSwap(void) { static uint8_t prevModifier = 0; if(getDownBufferAt(0) > 0){ enabledQuickSwapCount = 0; return; } uint8_t gModi = getModifierDownBuffer(); if(gModi != prevModifier) { if(gModi == (MODI_RSHIFT|MODI_LALT|MODI_LGUI) || gModi == (MODI_RSHIFT|MODI_RALT|MODI_RGUI) || gModi == (MODI_RSHIFT|MODI_LALT|MODI_RGUI) || gModi == (MODI_RSHIFT|MODI_LALT|MODI_LGUI)){ // ALT + GUI + R SHIFT _quickSwapCount = 0; enabledQuickSwapCount = COUNT_TYPE_QUICKSWAP_ALT_GUI; }else{ enabledQuickSwapCount = 0; } prevModifier = gModi; } //} //static void countQuickSwapEnabled(void){ if(enabledQuickSwapCount && ++_quickSwapCount > quickSwapCountMax){ if(enabledQuickSwapCount == COUNT_TYPE_QUICKSWAP_ALT_GUI){ blinkOnce(50); if((quickSwapMode & QUICKSWAP_ALT_GUI) == QUICKSWAP_ALT_GUI){ quickSwapMode &= ~QUICKSWAP_ALT_GUI; }else{ quickSwapMode |= QUICKSWAP_ALT_GUI; _delay_ms(50); blinkOnce(100); } } eeprom_update_byte((uint8_t *)EEPROM_QUICK_SWAP, quickSwapMode); enabledQuickSwapCount = 0; } }
static void writeLEDMode(void) { // LED 모드 저장, 너무많은 eeprom접근을 막기위해 일정 간격으로 저장한다. const int countMAX = 1000; if (ledStateCount > 0 && ++ledStateCount == countMAX) { // DEBUG_PRINT(("writeLEDMode : mode %d, br %d \n", _fullLEDMode, _ledBrightnessMax)); ledStateCount = 0; if (_fullLEDMode != _fullLEDMode_saved) { _fullLEDMode_saved = _fullLEDMode; eeprom_update_byte((uint8_t *) EEPROM_LED_MODE, _fullLEDMode); // 1바이트 11번지 쓰기 } // brightness if (_ledBrightnessMax_saved != _ledBrightnessMax) { _ledBrightnessMax_saved = _ledBrightnessMax; eeprom_update_byte((uint8_t *) EEPROM_LED_BRIGHTNESS, _ledBrightnessMax); // 1바이트 9번지 쓰기 } blinkOnce(50); } }
// 키를 누르거나 땔때 FN 및 LED등 을 컨트롤한다. bool applyFN(uint8_t xKeyidx, uint8_t xCol, uint8_t xRow, bool xIsDown) { // DEBUG_PRINT(("applyFN : %d xIsDown : %d\n", xKeyidx, xIsDown)); applyKeyDownForFullLED(xKeyidx, xCol, xRow, xIsDown); if(isFnKey(xKeyidx)) return false; setDualAction(xKeyidx, xIsDown); // 듀얼액션 키의 기본 키를 가져온다. xKeyidx = getDualActionDefaultKey(xKeyidx); if(isFnKey(xKeyidx)) return false; if(xIsDown) { if((xKeyidx == KEY_BEYOND_FN || xKeyidx == KEY_BEYOND_FN3) || (_isExtraFNDown && xKeyidx == BEYOND_FN_CANCEL_KEY)){ // beyond_fn을 활성화; if( xKeyidx == BEYOND_FN_CANCEL_KEY ) { // 취소만 가능한 키 _beyondFnIndex = false; }else{ if(_beyondFnIndex == 0){ if(xKeyidx == KEY_BEYOND_FN){ _beyondFnIndex = LAYER_FN2; }else{ _beyondFnIndex = LAYER_FN3; } }else{ if(xKeyidx == KEY_BEYOND_FN){ if(_beyondFnIndex == LAYER_FN2){ _beyondFnIndex = LAYER_NORMAL; }else{ _beyondFnIndex = LAYER_FN2; } }else if(xKeyidx == KEY_BEYOND_FN3){ if(_beyondFnIndex == LAYER_FN3){ _beyondFnIndex = LAYER_NORMAL; }else{ _beyondFnIndex = LAYER_FN3; } } } } #ifndef DISABLE_FN2_TOGGLE_LED_BLINK if(isBeyondFnLedEnabled() == false){ if(_beyondFnIndex == 0){ blinkOnce(100); }else{ blinkOnce(100); _delay_ms(80); blinkOnce(70); } } #endif if(isBeyondFnLedEnabled()){ setLed(LED_STATE_NUM, isBeyondFN()); } return 0; }else if(_isQuickMacroDown && isEepromMacroKey(xKeyidx)){ _quickMacroIndex = xKeyidx - KEY_MAC1; _isReadyQuickMacro = true; return 0; }else if(xKeyidx == EXTRA_FN){ _isExtraFNDown = true; }else if((_isExtraFNDown && xKeyidx == LED_KEY)){ uint8_t gModi = getModifierDownBuffer(); if(gModi == 0x02 || gModi == 0x20){ changeFullLedState(FULL_LED_MODE2); }else{ changeFullLedState(FULL_LED_MODE1); } return 0; }else if(xKeyidx == KEY_LED){ changeFullLedState(FULL_LED_MODE1); return 0; }else if(xKeyidx == KEY_LED2){ changeFullLedState(FULL_LED_MODE2); return 0; }else if(xKeyidx == KEY_LED_UP){ uint8_t gModi = getModifierDownBuffer(); if(gModi == 0x02 || gModi == 0x20){ increaseLedBrightness(FULL_LED_MODE2); }else{ increaseLedBrightness(FULL_LED_MODE1); } return 0; }else if(xKeyidx == KEY_LED_DOWN){ uint8_t gModi = getModifierDownBuffer(); if(gModi == 0x02 || gModi == 0x20){ reduceLedBrightness(FULL_LED_MODE2); }else{ reduceLedBrightness(FULL_LED_MODE1); } return 0; }else if(xKeyidx == KEY_LED_ON_OFF){ _ledOff ^= true; if(_ledOff == false){ turnOnLedAll(); }else{ turnOffLedAll(); } }else if(xKeyidx == KEY_QUICK_MACRO){ if(isQuickMacro()){ stopQuickMacro(); }else{ _isQuickMacroDown = true; } return 0; } }else{ // up if(xKeyidx == KEY_BEYOND_FN){ // beyond_fn return 0; }else if(xKeyidx == EXTRA_FN){ _isExtraFNDown = false; }else if(xKeyidx == KEY_QUICK_MACRO){ _isQuickMacroDown = false; return 0; } } return 1; }