Example #1
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void)
{
    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
        case FMU:
            ergodox_right_led_1_on();
        break;
        case PMQ:
            ergodox_right_led_2_on();
        break;
        case PMN:
            ergodox_right_led_3_on();
        break;
        default:
            if(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) {
                ergodox_led_all_set(LED_BRIGHTNESS_HI);
                ergodox_right_led_1_on();
            }
            else {
                ergodox_board_led_off();
            }
        break;
    }

};
Example #2
0
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
    ergodox_board_led_off();
    ergodox_right_led_1_on();
    ergodox_right_led_2_on();
    ergodox_right_led_3_on();
    ergodox_board_led_off();
    ergodox_right_led_1_on();
    ergodox_right_led_2_on();
    ergodox_right_led_3_on();
    ergodox_board_led_off();    
};
Example #3
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

  uint8_t layer = biton32(layer_state);

  ergodox_board_led_off();
  ergodox_right_led_1_off();
  ergodox_right_led_2_off();
  ergodox_right_led_3_off();
  switch (layer) {
    case 1:
      ergodox_right_led_1_on();
      break;
    case 2:
      ergodox_right_led_2_on();
      break;
#ifdef CFQ_USE_EXPEREMENTAL_LAYER
    case 3:
      ergodox_right_led_3_on();
      break;
#endif
    default:
      // none
      break;
  }

};
Example #4
0
void matrix_scan_keymap(void) {  // runs frequently to update info
  uint8_t modifiders = get_mods();

  if (!skip_leds) {
    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();

    // Since we're not using the LEDs here for layer indication anymore,
    // then lets use them for modifier indicators.  Shame we don't have 4...
    // Also, no "else", since we want to know each, independantly. 
    if (modifiders & MODS_SHIFT_MASK) {
      ergodox_right_led_2_on();
    }
    if (modifiders & MODS_CTRL_MASK) {
      ergodox_right_led_1_on();
    }
    if (modifiders & MODS_ALT_MASK) {
      ergodox_right_led_3_on();
    }

  }

};
Example #5
0
void dance_flsh_each(qk_tap_dance_state_t *state, void *user_data) {
    if (!skip_leds) {
        ergodox_board_led_off();
        ergodox_right_led_1_off();
        ergodox_right_led_2_off();
        ergodox_right_led_3_off();
        skip_leds = true;
    }
    switch (state->count) {
        case 1:
            ergodox_right_led_1_on();
            break;
        case 2:
            ergodox_right_led_2_on();
            break;
        case 3:
            ergodox_right_led_3_on();
            break;
        case 4:
            ergodox_right_led_1_off();
            _delay_ms(50);
            ergodox_right_led_2_off();
            _delay_ms(50);
            ergodox_right_led_3_off();

    }
}
Example #6
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
    case NUMBER:
    case SYMBOL:
    case BRACKETS:
        //case SHELL_LAYER:
        ergodox_right_led_2_on();
        break;
    case KEY_NAV:
    case KEY_SEL:
        ergodox_right_led_3_on();
        break;
    case SHORTCUTS:
        ergodox_right_led_2_on();
        ergodox_right_led_3_on();
        break;
    default:
        // none
        break;
    }
    return;
};
Example #7
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
      // TODO: Make this relevant to the ErgoDox EZ.
        case 1:
            ergodox_right_led_3_on();
            break;
        case 2:
            ergodox_right_led_2_on();
            break;
        case 3:
            ergodox_right_led_2_on();
            ergodox_right_led_3_on();
            break;
        default:
            // none
            break;
    }

    if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
        // if capslk is on, set led 1 on
        ergodox_right_led_1_on();
    } else {
        ergodox_right_led_1_off();
    }

};
Example #8
0
// Runs constantly in the background, in a loop.
void * matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
    case 1:
      ergodox_right_led_1_on();
      break;
    case 2:
      ergodox_right_led_2_on();
      break;
    case 3:
      ergodox_right_led_3_on();
      break;
    case 4:
      ergodox_right_led_1_on(); // TODO: Make a fourth layer
      ergodox_right_led_3_on();
      break;
    default:
      // none
      break;
    }

};
Example #9
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
    /* leds is a static array holding the current brightness of each of the
     * three keyboard LEDs. It's 4 long simply to avoid the ugliness of +1s and
     * -1s in the code below, and because wasting a byte really doesn't matter
     * that much (no, it *doesn't*, stop whinging!). Note that because it's
     * static it'll maintain state across invocations of this routine.
     */
    static uint8_t leds[4];
    uint8_t led;
    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();

    /* Loop over each LED/layer */
    for (led = 1; led <= 3; ++led) {
        /* If the current layer matches the current LED, increment its
         * brightness by 1 up to a maximum of 255. If the current layer doesn't
         * match, decrement its brightness by 1 down to a minimum of zero.
         */
        leds[led] += (layer == led) ?
            (leds[led] < 255 ? 1 : 0):
            (leds[led] > 0 ? -1 : 0);
        /* Set LED state according to the new brightness */
        if (leds[led]) {
            ergodox_right_led_on(led);
            ergodox_right_led_set(led, leds[led]);
        }
        else {
            ergodox_right_led_off(led);
        }
    }


};
Example #10
0
void matrix_scan_keymap(void) {  // runs frequently to update info
  uint8_t modifiers = get_mods();
  uint8_t led_usb_state = host_keyboard_leds();
  uint8_t one_shot = get_oneshot_mods();

  if (!skip_leds) {
    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();

    // Since we're not using the LEDs here for layer indication anymore,
    // then lets use them for modifier indicators.  Shame we don't have 4...
    // Also, no "else", since we want to know each, independently.
    if ( ( modifiers | one_shot ) & MOD_MASK_SHIFT || led_usb_state & (1<<USB_LED_CAPS_LOCK) ) {
      ergodox_right_led_2_on();
      ergodox_right_led_2_set( 50 );
    }
    if ( ( modifiers | one_shot ) & MOD_MASK_CTRL) {
      ergodox_right_led_1_on();
      ergodox_right_led_1_set( 10 );
    }
    if ( ( modifiers | one_shot ) & MOD_MASK_ALT) {
      ergodox_right_led_3_on();
      ergodox_right_led_3_set( 10 );
    }

  }

};
Example #11
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
      // TODO: Make this relevant to the ErgoDox EZ.
        case DVORAK:
            ergodox_right_led_1_on();
            break;
        case COLEMAK:
            ergodox_right_led_2_on();
            break;
        case QWERTY:
            ergodox_right_led_3_on();
            break;
        case FN:
            ergodox_led_all_on();
            break;
        default:
            // none
            break;
    }

};
Example #12
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
    static uint8_t state;

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();

    //reduce LED on time to 1/6th because LEDs are too strong
    if (++state < 6) return;
    state = 0;

    //bit 1: default layer 1 - QWERTY
    if (default_layer_state & (1UL << 1)) ergodox_right_led_1_on();

    uint8_t layer = biton32(layer_state);

    //layer 2 : Symbols (& Fs)
    //if (layer == 2) ergodox_right_led_2_on();

    //layer 3 : F-lock
    if (layer == 3) ergodox_right_led_2_on();

    //layer 4 : Num-lock
    if (layer == 4) ergodox_right_led_3_on();
};
Example #13
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
      // TODO: Make this relevant to the ErgoDox EZ.
        case 1:
            ergodox_right_led_1_on();
            break;
        case 2:
            ergodox_right_led_2_on();
            break;
        case 3:
            ergodox_right_led_3_on();
            break;
        case 4:
            ergodox_right_led_1_on();
            ergodox_right_led_2_on();
            break;
        default:
            // none
            break;
    }
};
Example #14
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();

    switch (td_led_override) {
    case 1:
        ergodox_right_led_1_on();
        break;
    case 2:
        ergodox_right_led_2_on();
        break;
    default:
        // Layer 1 and 2 are both overlay layers, so they could both be on. This
        // means we can't use the lazy check of checking for the first significant
        // bit.
        if (LAYER_ON(SYMB)) {
            ergodox_right_led_1_on();
        }
        if (LAYER_ON(NUMP)) {
            ergodox_right_led_2_on();
        }
    }
};
Example #15
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
        case 1:
            ergodox_right_led_3_on();
            break;
        case 2:
            ergodox_right_led_2_on();
            break;
        case 3:
            ergodox_right_led_1_on();
            ergodox_right_led_2_on();
            ergodox_right_led_3_on();
            break;
        default:
            // none
            break;
    }
    
    // Turn the caps lock led on
    if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
        ergodox_right_led_1_on();
    }

}
Example #16
0
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_on();
    ergodox_led_all_on();

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
   //    _delay_ms(45);

    switch (layer)
    {
    case _SYMBOLS:
      ergodox_right_led_1_on();
      break;
    case _MOUSE:
      ergodox_right_led_2_on();
      break;
    case _NUMPAD:
      ergodox_right_led_3_on();
      break;
    case _NAV:
      ergodox_right_led_1_on();
      ergodox_right_led_2_on();
      break;
    case _MACROS:
      //layer unused right now
      break;
    case _FUNCTION:
      //layer unused right nowex
      break;
    case _APPSWITCH:
      ergodox_right_led_2_on();
      ergodox_right_led_3_on();
      break;
    case _ONESHOT:
      ergodox_right_led_1_on();
      ergodox_right_led_2_on();
      ergodox_right_led_3_on();
      break;
    case _TEXTNAV:
      ergodox_right_led_1_on();
      ergodox_right_led_3_on();
      break;
    case _QWERTY_KIDS:
      ergodox_right_led_1_on();
      ergodox_right_led_2_on();
      ergodox_right_led_3_on();
      break;
    case _STREET_FIGHTER:
      ergodox_right_led_2_on();
      ergodox_right_led_3_on();
    default:
      break;
    }
};
Example #17
0
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
  // AFAICT, we don't have one of these
  ergodox_board_led_off();
#ifdef MOUSEKEY_ENABLE
  // mousekey: A bit faster by default, use accel keys for fine control
  mk_max_speed = 6;
  // Slightly slower mouse wheel speed than the default
  mk_wheel_max_speed = 4;
#endif
}
Example #18
0
// Runs constantly in the background, in a loop.
void * matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
        case SYMB:
            ergodox_right_led_1_on();
            break;
        case MDIA:
            ergodox_right_led_2_on();
            break;
        default:
            ergodox_board_led_off();
            break;
    }

};
Example #19
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

  uint8_t layer = biton32(layer_state);

  ergodox_board_led_off();
  ergodox_right_led_1_off();
  ergodox_right_led_2_off();
  ergodox_right_led_3_off();
  switch (layer) {
  case 1:
    ergodox_right_led_1_on();
    /* ergodox_left_led_1_on(); */
    break;
  case 2:
    ergodox_right_led_2_on();
    /* ergodox_left_led_2_on(); */
    break;
  case 3:
    ergodox_right_led_3_on();
    /* ergodox_left_led_3_on(); */
    break;
  case 4:
    ergodox_right_led_1_on();
    ergodox_right_led_2_on();
    /* ergodox_left_led_1_on(); */
    /* ergodox_left_led_2_on(); */
    break;
  case 5:
    ergodox_right_led_1_on();
    ergodox_right_led_3_on();
    /* ergodox_left_led_1_on(); */
    /* ergodox_left_led_3_on(); */
    break;
  case 6:
    ergodox_right_led_2_on();
    ergodox_right_led_3_on();
    /* ergodox_left_led_2_on(); */
    /* ergodox_left_led_3_on(); */
    break;
  case 7:
    ergodox_right_led_1_on();
    ergodox_right_led_2_on();
    ergodox_right_led_3_on();
    /* ergodox_left_led_1_on(); */
    /* ergodox_left_led_2_on(); */
    /* ergodox_left_led_3_on(); */
    break;
  default:
    break;
  }

};
Example #20
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    switch (layer) {
        case L1:
            ergodox_right_led_1_on();
            break;
        case L2:
            ergodox_right_led_2_on();
            break;
        case L3:
            ergodox_right_led_3_on();
            break;
        case L4:
            ergodox_right_led_1_on();
            ergodox_right_led_2_on();
            break;
        case L5:
            ergodox_right_led_1_on();
            ergodox_right_led_3_on();
            break;
        // case L6:
        //     ergodox_right_led_2_on();
        //     ergodox_right_led_3_on();
        //     break;
        // case L7:
        //     ergodox_right_led_1_on();
        //     ergodox_right_led_2_on();
        //     ergodox_right_led_3_on();
        //     break;
        default:
            ergodox_board_led_off();
            break;
    }
};
Example #21
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
    uint32_t layer0 = layer_state & (1UL << 0),
             layer1 = layer_state & (1UL << 1),
             layer2 = layer_state & (1UL << 2),
             layer3 = layer_state & (1UL << 3);    

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();

    if (layer1) ergodox_right_led_1_on();
    if (layer2) ergodox_right_led_2_on();
    if (layer3) ergodox_right_led_3_on();
};
Example #22
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    switch (layer) {
        case 1:
            ergodox_right_led_1_on();
            break;
        case 2:
            ergodox_right_led_2_on();
            break;
        default:
            // none
            break;
		   }
};
Example #23
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    // led 1: numeric layer
    if (layer_state & (1 << NUMR)) {
        ergodox_right_led_1_on();
    }
    // led 2: Dvorak layer
    if (default_layer_state == 1 << DVRK) {
        ergodox_right_led_2_on();
    }
    // led 3: caps lock
    if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
      ergodox_right_led_3_on();
    }

};
Example #24
0
/**
 * Runs constantly in the background, in a loop.
 */
void matrix_scan_user(void) {
  uint8_t layer = biton32(layer_state);

  ergodox_board_led_off();
  ergodox_led_lower_off();
  ergodox_led_raise_off();
  ergodox_led_adjust_off();

  switch (layer) {
    case _LOWER:
      ergodox_led_lower_on();
      break;
    case _RAISE:
      ergodox_led_raise_on();
      break;
    case _ADJUST:
      ergodox_led_adjust_on();
      break;
  }
};
Example #25
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {

  uint8_t layer = biton32(layer_state);

  ergodox_board_led_off();
  ergodox_right_led_1_off();
  ergodox_right_led_2_off();
  ergodox_right_led_3_off();
  switch (layer) {
    // TODO: Make this relevant to the ErgoDox EZ.
    case 1:
      ergodox_right_led_1_on();
      break;
    case 2:
      ergodox_right_led_2_on();
      break;
    default:
      // none
      break;
  }

  LEADER_DICTIONARY() {
    leading = false;
    leader_end();

    SEQ_ONE_KEY(KC_W) {
      register_code(KC_LALT);
      register_code(KC_F4);
      unregister_code(KC_F4);
      unregister_code(KC_LALT);
    }
    SEQ_ONE_KEY(KC_O) {
      register_code(KC_LCTL);
      register_code(KC_LSFT);
      register_code(KC_O);
      unregister_code(KC_O);
      unregister_code(KC_LSFT);
      unregister_code(KC_LCTL);
    }
  }
}
Example #26
0
void matrix_scan_user(void) {  // runs frequently to update info
    uint8_t modifiders = get_mods();
    uint8_t layer = biton32(layer_state);
    static bool has_layer_changed = true;

    if (!skip_leds) {
        ergodox_board_led_off();
        ergodox_right_led_1_off();
        ergodox_right_led_2_off();
        ergodox_right_led_3_off();
        
        // Since we're not using the LEDs here for layer indication anymore,
        // then lets use them for modifier indicators.  Shame we don't have 4...
        // Also, no "else", since we want to know each, independantly. 
        if ( modifiders & MODS_SHIFT_MASK) {
            ergodox_right_led_2_on();
        }
        if ( modifiders & MODS_CTRL_MASK) {
            ergodox_right_led_1_on();
        }
        if ( modifiders & MODS_ALT_MASK) {
            ergodox_right_led_3_on();
        }
        
    }
    if (layer != current_layer) {
        has_layer_changed = true;
        current_layer = layer;
    }
    // Check layer, and apply color if its changed since last check
    if (has_layer_changed) {
        uint8_t default_layer = 0;
        default_layer = eeconfig_read_default_layer();

        switch (layer) {
            case SYMB:
                rgblight_set_blue;
                rgblight_mode(2);
                break;
            case OVERWATCH:
                rgblight_set_orange;
                rgblight_mode(17);
                break;
            case DIABLO:
                rgblight_set_red;
                rgblight_mode(5);
                break;
            case MOUS:
                rgblight_set_urine;
                rgblight_mode(1);
                break;
            case 7:
                rgblight_sethsv (255,255,255);
                rgblight_mode(1);
                break;
            default:
                if (default_layer & (1UL << COLEMAK)) {
                    rgblight_set_green;
                }
                else if (default_layer & (1UL << DVORAK)) {
                    rgblight_set_magenta;
                }
                else if (default_layer & (1UL << WORKMAN)) {
                    rgblight_set_purple;
                }
                else {
                    rgblight_set_teal;
                }
                rgblight_mode(1);
                break;
        }
        has_layer_changed = false;
    }

    // Run Diablo 3 macro checking code.
    run_diablo_macro_check();
#ifdef LEADER_KEYS
    LEADER_DICTIONARY() {
        leading = false;
        leader_end();
        SEQ_ONE_KEY(KC_C) {
            SEND_STRING("Covecube");
        }
        SEQ_TWO_KEYS(KC_S, KC_D) {
            SEND_STRING("StableBit DrivePool");
        }
        SEQ_TWO_KEYS(KC_C, KC_D) {
            SEND_STRING("StableBit CloudDrive");
        }
Example #27
0
void matrix_scan_user(void) {

    uint8_t new_layer = biton32(layer_state);
    
    ergodox_board_led_off();
    ergodox_right_led_1_off();
    ergodox_right_led_2_off();
    ergodox_right_led_3_off();
    
#ifdef LAYER_UNDERGLOW_LIGHTING
    static uint8_t old_layer = 0;
    uint8_t modifiders = get_mods();
    
    if ( modifiders & MODS_SHIFT_MASK) {
            ergodox_right_led_1_on();
    }
    if ( modifiders & MODS_CTRL_MASK) {
            ergodox_right_led_2_on();
    }
    if ( modifiders & MODS_ALT_MASK) {
            ergodox_right_led_3_on();
    }
    
    if (old_layer != new_layer) {
        has_layer_changed = true; 
        old_layer = new_layer;
    }
    if (has_layer_changed) {
        switch (new_layer) {
            case 1:
                rgblight_set_red;
                break;
            case 2:
                rgblight_set_blue;
                break;
            case 3:
                rgblight_set_green;
                break;
            case 4:
                rgblight_set_yellow;
                break;
            case 5:
                rgblight_setrgb(0xFF, 0xFF, 0x00);
                break;
            case 6:
                rgblight_setrgb(0xFF, 0xFF, 0x00);
                break;
            case 7:
                rgblight_setrgb(0xFF, 0xFF, 0xFF);
                break;
            default:
                rgblight_set_teal;
                break;
        }
        has_layer_changed = false;
    }
    
#else    
    switch (new_layer) {
        case 1:
            ergodox_right_led_1_on();
            break;
        case 2:
            ergodox_right_led_2_on();
            break;
        case 3:
            ergodox_right_led_3_on();
            break;
        case 4:
            ergodox_right_led_1_on();
            ergodox_right_led_2_on();
            break;
        case 5:
            ergodox_right_led_1_on();
            ergodox_right_led_3_on();
            break;
        case 6:
            ergodox_right_led_2_on();
            ergodox_right_led_3_on();
            break;
        case 7:
            ergodox_right_led_1_on();
            ergodox_right_led_2_on();
            ergodox_right_led_3_on();
            break;
        default:
            break;
     }
#endif 
};
Example #28
0
uint8_t matrix_scan(void)
{
    if (mcp23018_status) { // if there was an error
        if (++mcp23018_reset_loop == 0) {
            // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
            // this will be approx bit more frequent than once per second
            print("trying to reset mcp23018\n");
            mcp23018_status = init_mcp23018();
            if (mcp23018_status) {
                print("left side not responding\n");
            } else {
                print("left side attached\n");
                ergodox_blink_all_leds();
            }
        }
    }

#ifdef DEBUG_MATRIX_FREQ
    matrix_scan_count++;

    uint32_t timer_now = timer_read32();
    if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
        print("matrix scan frequency: ");
        pdec(matrix_scan_count);
        print("\n");

        matrix_timer = timer_now;
        matrix_scan_count = 0;
    }
#endif

#ifdef KEYMAP_CUB
    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    ergodox_left_led_1_off();
    ergodox_left_led_2_off();
    ergodox_left_led_3_off();
    switch (layer) {
        case 1:
            // all
            ergodox_left_led_1_on();
            ergodox_left_led_2_on();
            ergodox_left_led_3_on();
            break;
        case 2:
            // blue
            ergodox_left_led_2_on();
            break;
        case 8:
            // blue and green
            ergodox_left_led_2_on();
            // break missed intentionally
        case 3:
            // green
            ergodox_left_led_3_on();
            break;
        case 6:
            ergodox_board_led_on();
            // break missed intentionally
        case 4:
        case 5:
        case 7:
            // red
            ergodox_left_led_1_on();
            break;
        default:
            // none
            break;
    }

    mcp23018_status = ergodox_left_leds_update();
#endif

#ifdef KEYMAP_SIMON
    uint8_t layer = biton32(layer_state);

    ergodox_board_led_off();
    switch (layer) {
        case 0:
// none

            break;
        default:
            ergodox_board_led_on();
            break;
    }
#endif

    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        matrix_row_t cols = read_cols(i);
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}
Example #29
0
// Runs whenever there is a layer state change.
uint32_t layer_state_set_user(uint32_t state) {
  ergodox_board_led_off();
  ergodox_right_led_1_off();
  ergodox_right_led_2_off();
  ergodox_right_led_3_off();

  uint8_t layer = biton32(state);
  switch (layer) {
      case 0:
        #ifdef RGBLIGHT_COLOR_LAYER_0
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
        #else
        #ifdef RGBLIGHT_ENABLE
          rgblight_init();
        #endif
        #endif
        break;
      case 1:
        ergodox_right_led_1_on();
        #ifdef RGBLIGHT_COLOR_LAYER_1
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1);
        #endif
        break;
      case 2:
        ergodox_right_led_2_on();
        #ifdef RGBLIGHT_COLOR_LAYER_2
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2);
        #endif
        break;
      case 3:
        ergodox_right_led_3_on();
        #ifdef RGBLIGHT_COLOR_LAYER_3
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3);
        #endif
        break;
      case 4:
        ergodox_right_led_1_on();
        ergodox_right_led_2_on();
        #ifdef RGBLIGHT_COLOR_LAYER_4
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4);
        #endif
        break;
      case 5:
        ergodox_right_led_1_on();
        ergodox_right_led_3_on();
        #ifdef RGBLIGHT_COLOR_LAYER_5
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5);
        #endif
        break;
      case 6:
        ergodox_right_led_2_on();
        ergodox_right_led_3_on();
        #ifdef RGBLIGHT_COLOR_LAYER_6
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
        #endif
        break;
      case 7:
        ergodox_right_led_1_on();
        ergodox_right_led_2_on();
        ergodox_right_led_3_on();
        #ifdef RGBLIGHT_COLOR_LAYER_7
          rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
        #endif
        break;
      default:
        break;
    }

  return state;
};