]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
support LEDs
authorGabriel Young <gabeplaysdrums@live.com>
Mon, 20 Mar 2017 03:45:10 +0000 (20:45 -0700)
committerGabriel Young <gabeplaysdrums@live.com>
Mon, 20 Mar 2017 03:45:10 +0000 (20:45 -0700)
keyboards/frosty_flake/frosty_flake.c
keyboards/frosty_flake/matrix.c

index 22979a45156bfafc646b086c78357748aa3f0526..ed17361840ccd232d9a42b27cbe41cc17640c84f 100644 (file)
@@ -1,28 +1,46 @@
 #include "frosty_flake.h"
 
 void matrix_init_kb(void) {
-       // put your keyboard start-up code here
-       // runs once when the firmware starts up
+    // put your keyboard start-up code here
+    // runs once when the firmware starts up
 
-       matrix_init_user();
+    matrix_init_user();
 }
 
 void matrix_scan_kb(void) {
-       // put your looping keyboard code here
-       // runs every cycle (a lot)
+    // put your looping keyboard code here
+    // runs every cycle (a lot)
 
-       matrix_scan_user();
+    matrix_scan_user();
 }
 
 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
-       // put your per-action keyboard code here
-       // runs for every action, just before processing by the firmware
+    // put your per-action keyboard code here
+    // runs for every action, just before processing by the firmware
 
-       return process_record_user(keycode, record);
+    return process_record_user(keycode, record);
 }
 
 void led_set_kb(uint8_t usb_led) {
-       // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
+    DDRB |= (1<<7);
+    DDRC |= (1<<5) | (1<<6);
 
-       led_set_user(usb_led);
+    print_dec(usb_led);
+
+    if (usb_led & (1<<USB_LED_CAPS_LOCK))
+        PORTC &= ~(1<<5);
+    else
+        PORTC |=  (1<<5);
+
+    if (usb_led & (1<<USB_LED_NUM_LOCK))
+        PORTB &= ~(1<<7);
+    else
+        PORTB |=  (1<<7);
+
+    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
+        PORTC &= ~(1<<6);
+    else
+        PORTC |=  (1<<6);
+
+    led_set_user(usb_led);
 }
index f289f506ad0c41fb49566b3d2222f92ca29c65fa..5d711a660fb613a7a9caea345b67278c2827ce07 100644 (file)
 #include "util.h"
 #include "matrix.h"
 
-#define CONFIG_LED_IO \
-  DDRB |= (1<<7); \
-  DDRC |= (1<<5) | (1<<6);
-
-#define USB_LED_CAPS_LOCK_ON    PORTC &= ~(1<<5)
-#define USB_LED_CAPS_LOCK_OFF   PORTC |=  (1<<5)
-#define USB_LED_NUM_LOCK_ON     PORTB &= ~(1<<7)
-#define USB_LED_NUM_LOCK_OFF    PORTB |=  (1<<7)
-#define USB_LED_SCROLL_LOCK_ON  PORTC &= ~(1<<6)
-#define USB_LED_SCROLL_LOCK_OFF PORTC |=  (1<<6)
-
 #ifndef DEBOUNCING_DELAY
 #   define DEBOUNCING_DELAY 5
 #endif
@@ -62,34 +51,34 @@ void matrix_init(void) {
 }
 
 uint8_t matrix_scan(void) {
-  for (uint8_t col = 0; col < MATRIX_COLS; col++) {
-    select_col(col);
-    _delay_us(3);
-    matrix_row_t col_scan = scan_col();
-    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
-      bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
-      bool curr_bit = col_scan & (1<<row);
-      if (prev_bit != curr_bit) {
-        matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
-        debouncing = DEBOUNCING_DELAY;
-      }
+    for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+        select_col(col);
+        _delay_us(3);
+        matrix_row_t col_scan = scan_col();
+        for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+            bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
+            bool curr_bit = col_scan & (1<<row);
+            if (prev_bit != curr_bit) {
+                matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
+                debouncing = DEBOUNCING_DELAY;
+            }
+        }
     }
-  }
 
-  if (debouncing) {
-    if (--debouncing)
-      _delay_ms(1);
-    else
-      for (uint8_t i = 0; i < MATRIX_ROWS; i++)
-        matrix[i] = matrix_debouncing[i];
-  }
+    if (debouncing) {
+        if (--debouncing)
+            _delay_ms(1);
+        else
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++)
+                matrix[i] = matrix_debouncing[i];
+    }
 
-  matrix_scan_quantum();
-  return 1;
+    matrix_scan_quantum();
+    return 1;
 }
 
 inline matrix_row_t matrix_get_row(uint8_t row) {
-  return matrix[row];
+    return matrix[row];
 }
 
 void matrix_print(void) {