Advertisement
nerdblog

Big Switch WINKEY + L

Mar 14th, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. #include "bigswitch.h"
  2.  
  3. //const uint8_t LED_PINS[] = RGBLED_PINS;
  4.  
  5. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  6.  
  7. KEYMAP(
  8.     LGUI(KC_L)),
  9.  
  10.  
  11. };
  12.  
  13.  
  14. void update_leds(void);
  15. uint8_t ledState = 0;
  16. bool initialized = 0;
  17.  
  18. void set_led(uint8_t pin, uint8_t enable) {
  19.   if (enable) {
  20.     PORTB |= (1 << pin);
  21.   } else {
  22.     PORTB &= ~(1 << pin);
  23.   }
  24. }
  25.  
  26. void update_leds(void) {
  27.   for (uint8_t idx = 0; idx < 3; idx++){
  28.     set_led(idx+5, (ledState >> idx) & 1);
  29.   }
  30. }
  31.  
  32. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
  33.   return MACRO_NONE ;
  34. }
  35.  
  36. void matrix_init_user(void) {
  37.   /* set LED row pins to output and low */
  38.   DDRB |= (1 << 5) | (1 << 6) | (1 << 7);
  39.   PORTB &= ~(1 << 5) & ~(1 << 6) & ~(1 << 7);
  40.   if (!initialized){
  41.       debug_config.enable = true;
  42.       dprintf("Initializing in matrix_scan_user");
  43.       rgblight_enable();
  44.       rgblight_mode(7);
  45.       rgblight_sethsv(0,255,255);
  46.       rgblight_setrgb(0x00, 0x00, 0xFF);
  47.       ledState = 1;
  48.       update_leds();
  49.       initialized = 1;
  50.     }
  51. }
  52.  
  53. void matrix_scan_user(void) {
  54. }
  55.  
  56. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  57.   if (record->event.pressed) {
  58.         ledState = (ledState + 1) % 8;
  59.         xprintf("LED Layer, toggling value: %d\n", ledState);
  60.         update_leds();
  61.       }
  62.   return true;
  63. }
  64.  
  65. void led_set_user(uint8_t usb_led) {
  66.  
  67.   if (usb_led & (1 << USB_LED_NUM_LOCK)) {
  68.  
  69.   } else {
  70.  
  71.   }
  72.  
  73.   if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
  74.  
  75.   } else {
  76.  
  77.   }
  78.  
  79.   if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
  80.  
  81.   } else {
  82.  
  83.   }
  84.  
  85.   if (usb_led & (1 << USB_LED_COMPOSE)) {
  86.  
  87.   } else {
  88.  
  89.   }
  90.  
  91.   if (usb_led & (1 << USB_LED_KANA)) {
  92.  
  93.   } else {
  94.  
  95.   }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement