Пример #1
0
void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
  if (debug_enable) {
    return;
  }
#endif

  struct CharacterMatrix matrix;

  matrix_clear(&matrix);
  matrix_write_P(&matrix, PSTR("TKC1800"));
  
  uint8_t layer = biton32(layer_state);

  char buf[40];
  snprintf(buf,sizeof(buf), "Undef-%d", layer);
  matrix_write_P(&matrix, PSTR("\nLayer: "));
  matrix_write(&matrix, layer_lookup[layer]);

  // Host Keyboard LED Status
  char led[40];
    snprintf(led, sizeof(led), "\n\n%s  %s  %s",
            (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : "       ",
            (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : "    ",
            (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : "    ");
  matrix_write(&matrix, led);
  matrix_update(&display, &matrix);
}
Пример #2
0
const char *read_host_led_state(void) {
  static char led_str[24];
  bool ext_status = get_enable_jp_extra_layer() && get_japanese_mode();
  strcpy(led_str, ext_status ? "EXT" : "   ");

  strcat(led_str, (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? " NMLK" : "     ");
  strcat(led_str, (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? " CAPS" : "    ");
  strcat(led_str, (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? " SCLK" : "     ");
  return led_str;
}
Пример #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 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;
    }

};
Пример #4
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 );
    }

  }

};
Пример #5
0
void hook_matrix_change(keyevent_t event)
{
    // 
  if (stay_connected){
    test_status = 0;
    last_press_timer = 0;

  }else{

    if (event.pressed)
    {

    if (!(PINB & (1<<4))) { // Battery powered.
        test_status = 1;
        last_press_timer = timer_read32();
    }
      else { // Plugged in, no need to disconnect Bluetooth if connected.
	test_status = 0;
	last_press_timer = 0;
      }  
    }

    if (second_test){
      dprintf("second test..\n");
      rn42_cts_lo();
      rn42_autoconnect();
      second_test = 0;
	    sleep_led_toggle();
      led_set(host_keyboard_leds());
    }
  }
}
Пример #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_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();
    }

}
Пример #7
0
static void print_status(void)
{

    print("\n\t- Status -\n");

    print_val_hex8(host_keyboard_leds());
    print_val_hex8(keyboard_protocol);
    print_val_hex8(keyboard_idle);
#ifdef NKRO_ENABLE
    print_val_hex8(keymap_config.nkro);
#endif
    print_val_hex32(timer_read32());

#ifdef PROTOCOL_PJRC
    print_val_hex8(UDCON);
    print_val_hex8(UDIEN);
    print_val_hex8(UDINT);
    print_val_hex8(usb_keyboard_leds);
    print_val_hex8(usb_keyboard_idle_count);
#endif

#ifdef PROTOCOL_PJRC
#   if USB_COUNT_SOF
    print_val_hex8(usbSofCount);
#   endif
#endif
	return;
}
Пример #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) {
      // 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();
    }

};
Пример #9
0
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
  uint8_t layer = biton32(layer_state);

  // Dim the LEDs as much as possible
  ergodox_led_all_set(0);

  // Show the active layer number as binary bits in the LEDs.
  // Note that LED1 is left-most, so bit1 -> LED3 and bit3 -> LED1
  if (layer & 0b001) {
    ergodox_right_led_3_on();
  } else {
    ergodox_right_led_3_off();
  }
  if (layer & 0b010) {
    ergodox_right_led_2_on();
  } else {
    ergodox_right_led_2_off();
  }

  // Show caps lock on the left most LED.
  // (Double-tap left shift to toggle caps lock)
  if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) {
    ergodox_right_led_1_on();
  } else {
    ergodox_right_led_1_off();
  }
}
Пример #10
0
void render_status(struct CharacterMatrix *matrix) {

  // Render to mode icon
  static char logo[][2][3] = {{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
  int mode_number = get_enable_kc_lang() ? 0 : 1;
  matrix_write(matrix, logo[mode_number][0]);
  matrix_write(matrix, "\n");
  matrix_write(matrix, logo[mode_number][1]);

  // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
  char buf[40];
  snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
  matrix_write_P(matrix, PSTR("\nLayer: "));
  switch (biton32(layer_state)) {
    case L_BASE:
      matrix_write_P(matrix,
          default_layer_state == 1UL<<_EDVORAK ? PSTR("EDVORAK") : PSTR("QWERTY")
          );
      break;
    case _EDVORAKJ1:
    case _EDVORAKJ2:
      matrix_write_P(matrix, PSTR("JP_EXT"));
      break;
    case _RAISE:
      matrix_write_P(matrix, PSTR("Raise"));
      break;
    case _LOWER:
      matrix_write_P(matrix, PSTR("Lower"));
      break;
    case _ADJUST:
      matrix_write_P(matrix, PSTR("Adjust"));
      break;
    default:
      matrix_write(matrix, buf);
  }

  // Host Keyboard LED Status
  char led[40];
  snprintf(led, sizeof(led), "\n%s %s %s %s",
      get_enable_jp_extra_layer() && get_japanese_mode() ? "EXT" : "   ",
      (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NMLK" : "    ",
      (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : "    ",
      (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : "    ");
  matrix_write(matrix, led);
}
Пример #11
0
static bool command_common(uint8_t code)
{
    static host_driver_t *host_driver = 0;
    switch (code) {
#ifdef SLEEP_LED_ENABLE
        case KC_Z:
            // test breathing sleep LED
            print("Sleep LED test\n");
            sleep_led_toggle();
            led_set(host_keyboard_leds());
            break;
#endif
#ifdef BOOTMAGIC_ENABLE
        case KC_E:
            print("eeconfig:\n");
            print_eeconfig();
            break;
#endif
#ifdef KEYBOARD_LOCK_ENABLE
        case KC_CAPSLOCK:
            if (host_get_driver()) {
                host_driver = host_get_driver();
                clear_keyboard();
                host_set_driver(0);
                print("Locked.\n");
            } else {
                host_set_driver(host_driver);
                print("Unlocked.\n");
            }
            break;
#endif
        case KC_H:
        case KC_SLASH: /* ? */
            command_common_help();
            break;
        case KC_C:
            debug_matrix   = false;
            debug_keyboard = false;
            debug_mouse    = false;
            debug_enable   = false;
            command_console_help();
            print("C> ");
            command_state = CONSOLE;
            break;
        case KC_PAUSE:
            clear_keyboard();
            print("\n\nbootloader... ");
            _delay_ms(1000);
            bootloader_jump(); // not return
            break;
        case KC_D:
            if (debug_enable) {
<<<<<<< HEAD
                print("\ndebug: off\n");
=======
                print("\ndebug: on\n");
>>>>>>> upstream/master
Пример #12
0
void render_status(struct CharacterMatrix *matrix) {

  // Render to mode icon
  static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
  if(keymap_config.swap_lalt_lgui==false){
    matrix_write(matrix, logo[0][0]);
    matrix_write_P(matrix, PSTR("\n"));
    matrix_write(matrix, logo[0][1]);
  }else{
    matrix_write(matrix, logo[1][0]);
    matrix_write_P(matrix, PSTR("\n"));
    matrix_write(matrix, logo[1][1]);
  }

  // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
  char buf[40];
  snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
  matrix_write_P(matrix, PSTR("\nMode: "));
    switch (layer_state) {
        case L_BASE:
           matrix_write_P(matrix, PSTR("Swan Match"));
           break;
        case L_RAISE:
           matrix_write_P(matrix, PSTR("Calculator"));
           break;
        case L_LOWER:
           matrix_write_P(matrix, PSTR("Cursor"));
           break;
        case L_ADJUST:
        case L_ADJUST_TRI:
           matrix_write_P(matrix, PSTR("Setting"));
           break;
        default:
           matrix_write(matrix, buf);
    }

  // Host Keyboard LED Status
  char led[40];
    snprintf(led, sizeof(led), "\n%s  %s  %s",
            (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : "       ",
            (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : "    ",
            (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : "    ");
  matrix_write(matrix, led);
}
Пример #13
0
void led_set_user(uint8_t usb_led) {
    // Turn LEDs On/Off for Caps Lock
    if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) {
        rgblight_enable_noeeprom();
        rgblight_sethsv_noeeprom(0, 0, 80);
    } else {
        rgblight_sethsv_noeeprom(0, 0, 80);
        rgblight_disable_noeeprom();
    }
}
Пример #14
0
const char *read_host_led_state(void)
{
  uint8_t leds = host_keyboard_leds();
  snprintf(host_led_state_str, sizeof(host_led_state_str), "NL:%s CL:%s SL:%s",
           (leds & (1 << USB_LED_NUM_LOCK)) ? "on" : "- ",
           (leds & (1 << USB_LED_CAPS_LOCK)) ? "on" : "- ",
           (leds & (1 << USB_LED_SCROLL_LOCK)) ? "on" : "- ");

  return host_led_state_str;
}
Пример #15
0
void hook_usb_suspend_loop(void) {
    serial_link_update();
    visualizer_update(default_layer_state, layer_state, host_keyboard_leds());
    /* Do this in the suspended state */
    suspend_power_down(); // on AVR this deep sleeps for 15ms
    /* Remote wakeup */
    if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
        send_remote_wakeup(&USB_DRIVER);
    }
}
Пример #16
0
void matrix_init_keymap(void) {
  // set Numlock LED to output and low
  DDRF |= (1 << 7);
  PORTF &= ~(1 << 7);


  if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) {
    register_code(KC_NUMLOCK);
    unregister_code(KC_NUMLOCK);
  }
}
Пример #17
0
void matrix_scan_indicator(void) {
  current_mod = get_mods();
  current_led = host_keyboard_leds();
  current_osm = get_oneshot_mods();

  set_rgb_indicators(current_mod, current_led, current_osm);

  last_mod = current_mod;
  last_led = current_led;
  last_osm = current_osm;

}
Пример #18
0
uint8_t matrix_scan(void)
{
    is_modified = false;

    uint8_t code;
    code = serial_recv();
    if (!code) return 0;

    debug_hex(code); debug(" ");

    switch (code) {
        case 0xFF:  // reset success: FF 04
            print("reset: ");
            _delay_ms(500);
            code = serial_recv();
            xprintf("%02X\n", code);
            if (code == 0x04) {
                // LED status
                led_set(host_keyboard_leds());
            }
            return 0;
        case 0xFE:  // layout: FE <layout>
            print("layout: ");
            _delay_ms(500);
            xprintf("%02X\n", serial_recv());
            return 0;
        case 0x7E:  // reset fail: 7E 01
            print("reset fail: ");
            _delay_ms(500);
            xprintf("%02X\n", serial_recv());
            return 0;
        case 0x7F:
            // all keys up
            for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
            return 0;
    }

    if (code&0x80) {
        // break code
        if (matrix_is_on(ROW(code), COL(code))) {
            matrix[ROW(code)] &= ~(1<<COL(code));
            is_modified = true;
        }
    } else {
        // make code
        if (!matrix_is_on(ROW(code), COL(code))) {
            matrix[ROW(code)] |=  (1<<COL(code));
            is_modified = true;
        }
    }
    return code;
}
Пример #19
0
void matrix_scan_keymap (void) {
  static uint8_t current_mods;
  static uint8_t current_host_leds;
  static uint8_t current_oneshot_mods;
  static bool has_status_changed = true;

  if ( current_mods != get_mods() || current_host_leds != host_keyboard_leds() || current_oneshot_mods != get_oneshot_mods()) {
    has_status_changed = true;
    current_mods = get_mods();
    current_host_leds = host_keyboard_leds();
    current_oneshot_mods = get_oneshot_mods();
  }
  if (has_status_changed) {
    has_status_changed = false;

    if (current_mods & MODS_SHIFT_MASK || current_host_leds & (1<<USB_LED_CAPS_LOCK) || current_oneshot_mods & MODS_SHIFT_MASK) {
      rgblight_sethsv_at(0, 255, 255, 5);
      rgblight_sethsv_at(0, 255, 255, 10);
    } else {
      rgblight_sethsv_default_helper(5);
      rgblight_sethsv_default_helper(10);
    }
    if (current_mods & MODS_CTRL_MASK || current_oneshot_mods & MODS_CTRL_MASK) {
      rgblight_sethsv_at(51, 255, 255, 6);
      rgblight_sethsv_at(51, 255, 255, 9);
    } else {
      rgblight_sethsv_default_helper(6);
      rgblight_sethsv_default_helper(9);
    }
    if (current_mods & MODS_GUI_MASK || current_oneshot_mods & MODS_GUI_MASK) {
      rgblight_sethsv_at(120, 255, 255, 7);
      rgblight_sethsv_at(120, 255, 255, 8);
    } else {
      rgblight_sethsv_default_helper(7);
      rgblight_sethsv_default_helper(8);

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

  ergodox_led_all_off();
  ergodox_led_all_set(LED_BRIGHTNESS_LO);

  switch (layer) {
  case BASE:
    current_layer = BASE;
    break;
  case KEYPAD:
    current_layer = KEYPAD;
    break;
  default:
    // none
    break;
  }

  // layer leds
  if (current_layer == KEYPAD) {
    ergodox_right_led_3_on();
  }

  // capslock
  if (host_keyboard_leds() & (3<<USB_LED_CAPS_LOCK)) {
    ergodox_right_led_1_on();
  }

  // Temporary leds

  // The function layer takes over other layers and we need to reflect that on the leds.
  // If the current layer is the BASE, we simply turn on the FN led, but if the current
  // layer is the KEYPAD, than we must turn it off before turning on the FN led.
  if (layer == FN && !has_oneshot_layer_timed_out()) {
    ergodox_right_led_3_off();
    ergodox_right_led_2_on();
  }

  // if the shifted is pressed I show the case led in a brighter color. This is nice to
  // differenciate the shift from the capslock.
  // Notice that I make sure that we're not using the shift on a chord shortcut (pressing
  // shift togather with other modifiers).
  if((keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) &&                                 // is shift pressed and there is no other
      !(keyboard_report->mods & (~MOD_BIT(KC_LSFT) & ~MOD_BIT(KC_RSFT)))) ||                           //    modifier being pressed as well
     (get_oneshot_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && !has_oneshot_mods_timed_out())) {  // or the one shot shift didn't timed out
    ergodox_right_led_1_set(LED_BRIGHTNESS_HI);
    ergodox_right_led_1_on();
  }
};
Пример #21
0
void matrix_init_user(void) {
    // set Numlock LED to output and low
    DDRF |= (1<<7);
    PORTF &= ~(1<<7);

#ifdef RGBLIGHT_ENABLE
    rgblight_enable();
    rgblight_set_teal;
    rgblight_mode(1);
#endif

    if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) ){
        register_code(KC_NUMLOCK);
        unregister_code(KC_NUMLOCK);
    }
}
Пример #22
0
uint8_t matrix_scan(void)
{
	uint8_t layer = biton32(layer_state);

	switch (layer) {
	case 0:
		all_led_off();
		break;
	case 1:
		if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) {
			all_led_off();
			caps_lock_led_on();
		}
		break;
	case 2:
		all_led_off();
		num_lock_led_on();
		break;
	default:
		break;
	}

    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select(i);
        uint8_t row = read(i);
        if (matrix_debouncing[i] != row) {
            matrix_debouncing[i] = row;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect();
    }

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

    return 1;
}
Пример #23
0
uint8_t matrix_scan(void)
{
    if (!debouncing) {
        uint8_t *tmp = matrix_prev;
        matrix_prev = matrix;
        matrix = tmp;
    }

    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        unselect_rows();
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
		if ( i == ( MATRIX_ROWS - 1 ) ) {							// CHECK CAPS LOCK
       		if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {		// CAPS LOCK is ON on HOST
				if ( ~read_col(i) & (1<< 4) ) { 							// CAPS LOCK is still DOWN ( 0bXXX1_XXXX)	
					matrix[i]        = ~read_col(i) & 0b11101111;				// change CAPS LOCK as released
				} else {													// CAPS LOCK in UP
					matrix[i] = ~read_col(i) | 0b00010000;						// send fake caps lock down
				}
			} else {													// CAPS LOCK is OFF on HOST
        		if (matrix[i] != (uint8_t)~read_col(i)) {
           			matrix[i] = (uint8_t)~read_col(i);
        			if (debouncing) {
        				debug("bounce!: "); debug_hex(debouncing); print("\n");
					}
       				debouncing = DEBOUNCE;
				}
			}
		} else {
        	if (matrix[i] != (uint8_t)~read_col(i)) {
           		matrix[i] = (uint8_t)~read_col(i);
        		if (debouncing) {
        			debug("bounce!: "); debug_hex(debouncing); print("\n");
				}
       			debouncing = DEBOUNCE;
			}
		}
	}
    unselect_rows();

    if (debouncing) {
        debouncing--;
    }

    return 1;
}
Пример #24
0
void rgb_matrix_indicators_user(void) {
	  uint8_t this_led = host_keyboard_leds();
	  if (!g_suspend_state) {
	    switch (biton32(layer_state)) {
	      case _LAYER1:
		    rgb_matrix_layer_helper(0xFF, 0x00, 0x00, false); break;
	      case _LAYER2:
	        rgb_matrix_layer_helper(0x00, 0xFF, 0x00, false); break;
	      case _LAYER3:
	        rgb_matrix_layer_helper(0x00, 0x00, 0xFF, false); break;
	      case _LAYER4:
	        rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, false); break;
	    							  }
	                        }
	  if ( this_led & (1<<USB_LED_CAPS_LOCK)) {
	        rgb_matrix_set_color(41, 0xFF, 0xFF, 0xFF);
	  }

}
Пример #25
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
  case CLEAR:
    if (record->event.pressed) { SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); }
    return false;

  case NUMPAD:
    if (record->event.pressed) {
      layer_invert(L_NUMPAD);
      bool num_lock = host_keyboard_leds() & 1<<USB_LED_NUM_LOCK;
      if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) {
        tap_code(KC_NLCK); // Toggle Num Lock to match layer state.
      }
    }
    return false;

  default:
    return true;
  }
}
Пример #26
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();
    }

};
Пример #27
0
// New keycode KC_LAYO rotates between available default layers (for e.g.,
// selecting a base layout). Shift+KC_LAYO makes the current one persistent.
bool process_record_layout(uint16_t keycode, keyrecord_t *record) {
  uint32_t default_layer;
  uint8_t i;
  #if defined(AUDIO_ENABLE)
  float saved_song[][2] = SONG(COIN_SOUND);
  #endif

  if (keycode != KC_LAYO || !record->event.pressed) {
    return true;
  }

  if (get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))) { // shift pressed
    // save default layer. whatever the current default layer is, store that
    eeconfig_update_default_layer(default_layer_state);
    #if defined(AUDIO_ENABLE)
        PLAY_SONG(saved_song);
    #endif
  } else {
    // rotate default layer.
    // find the current default layer
    default_layer = biton32(default_layer_state);
    // find next valid default layer
    for (i = 1; i < defaultlayers_n; i++) {
      if (defaultlayers[(default_layer + i) % defaultlayers_n]) {
        break;
      }
    }
    if (i == defaultlayers_n) {
      // we fell out of the loop without finding another default layer to switch
      // to.
      return false;
    }
    default_layer = (default_layer + i) % defaultlayers_n;
    default_layer_set(1U<<default_layer);
    led_set(host_keyboard_leds());
    #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
      PLAY_SONG(default_layer_songs[default_layer]);
    #endif
  }
  return false;
}
Пример #28
0
uint32_t layer_state_set_keymap (uint32_t state) {
  uint8_t modifiders = get_mods();
  uint8_t led_usb_state = host_keyboard_leds();
  uint8_t one_shot = get_oneshot_mods();


  if (modifiders & MODS_SHIFT_MASK || led_usb_state & (1<<USB_LED_CAPS_LOCK) || one_shot & MODS_SHIFT_MASK) {
    rgblight_sethsv_at(0, 255, 255, 5);
    rgblight_sethsv_at(0, 255, 255, 10);
  }
  if (modifiders & MODS_CTRL_MASK || one_shot & MODS_CTRL_MASK) {
    rgblight_sethsv_at(51, 255, 255, 6);
    rgblight_sethsv_at(51, 255, 255, 9);
  }
  if (modifiders & MODS_ALT_MASK || one_shot & MODS_ALT_MASK) {
    rgblight_sethsv_at(120, 255, 255, 7);
    rgblight_sethsv_at(120, 255, 255, 8);
  }

  return state;
}
Пример #29
0
static void render_status(void) {
  // Render to mode icon
  static const char PROGMEM mode_logo[4][4] = {
    {0x95,0x96,0x0a,0},
    {0xb5,0xb6,0x0a,0},
    {0x97,0x98,0x0a,0},
    {0xb7,0xb8,0x0a,0} };

  if (keymap_config.swap_lalt_lgui != false) {
    oled_write_P(mode_logo[0], false);
    oled_write_P(mode_logo[1], false);
  } else {
    oled_write_P(mode_logo[2], false);
    oled_write_P(mode_logo[3], false);
  }

  // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
  oled_write_P(PSTR("Layer: "), false);
  switch (layer_state) {
    case L_BASE:
      oled_write_P(PSTR("Default\n"), false);
      break;
    case L_FN:
      oled_write_P(PSTR("FN     \n"), false);
      break;
    case L_ADJ:
    case L_ADJ_TRI:
      oled_write_P(PSTR("ADJ    \n"), false);
      break;
    default:
      oled_write_P(PSTR("UNDEF  \n"), false);
  }

  // Host Keyboard LED Status
  uint8_t led_usb_state = host_keyboard_leds();
  oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLOCK ") : PSTR("        "), false);
  oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR("     "), false);
  oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCLK ") : PSTR("     "), false);
}
Пример #30
0
void matrix_init_rgb(void) {
#ifdef INDICATOR_LIGHTS
  current_mod = last_mod = get_mods();
  current_led = last_led = host_keyboard_leds();
  current_osm = last_osm = get_oneshot_mods();
#endif

  if (userspace_config.rgb_layer_change) {
    rgblight_enable_noeeprom();
    switch (biton32(eeconfig_read_default_layer())) {
      case _COLEMAK:
        rgblight_sethsv_noeeprom_magenta(); break;
      case _DVORAK:
        rgblight_sethsv_noeeprom_springgreen(); break;
      case _WORKMAN:
        rgblight_sethsv_noeeprom_goldenrod(); break;
      default:
        rgblight_sethsv_noeeprom_cyan(); break;
    }
    rgblight_mode_noeeprom(1);
  }
}