logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (1509B)


  1. #include QMK_KEYBOARD_H
  2. enum custom_keycodes {
  3. BL1 = SAFE_RANGE,
  4. BL2,
  5. BL3,
  6. BL4
  7. };
  8. const uint8_t LED_PINS[] = LED_ROW_PINS;
  9. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  10. [0] = LAYOUT_ortho_4x4(
  11. KC_P7, KC_P8, KC_P9, KC_PPLS,
  12. KC_P4, KC_P5, KC_P6, KC_PMNS,
  13. KC_P1, KC_P2, KC_P3, KC_PAST,
  14. MO(1), KC_P0, KC_PDOT, KC_ENT
  15. ),
  16. [1] = LAYOUT_ortho_4x4(
  17. KC_NUM, BL1, KC_TRNS, KC_PSLS,
  18. QK_BOOT, BL2, KC_TRNS, KC_TRNS,
  19. KC_TRNS, BL3, KC_TRNS, KC_TRNS,
  20. KC_TRNS, BL4, KC_TRNS, KC_TRNS
  21. ),
  22. };
  23. void set_led(int idx, bool enable) {
  24. uint8_t pin = LED_PINS[idx];
  25. if (enable) {
  26. _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);
  27. } else {
  28. /* PORTx &= ~n */
  29. _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF);
  30. }
  31. }
  32. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  33. switch (keycode) {
  34. case BL1:
  35. gpio_write_pin(B4, record->event.pressed);
  36. return false;
  37. case BL2:
  38. gpio_write_pin(B5, record->event.pressed);
  39. return false;
  40. case BL3:
  41. gpio_write_pin(B6, record->event.pressed);
  42. return false;
  43. case BL4:
  44. gpio_write_pin(B7, record->event.pressed);
  45. return false;
  46. }
  47. return true;
  48. }
  49. void matrix_init_user(void) {
  50. /* set LED row pins to output and low */
  51. gpio_set_pin_output(B4);
  52. gpio_set_pin_output(B5);
  53. gpio_set_pin_output(B6);
  54. gpio_set_pin_output(B7);
  55. gpio_write_pin_low(B4);
  56. gpio_write_pin_low(B5);
  57. gpio_write_pin_low(B6);
  58. gpio_write_pin_low(B7);
  59. }