diff options
| author | Joe Wasson <joe@talljoe.com> | 2020-08-31 22:19:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-31 22:19:51 -0700 |
| commit | 4a6cfb06c5aafb353ddfa056bfa69ae82b5fc894 (patch) | |
| tree | bef6cc895bbc6280a400d579eb43cc06f1bbbcba /keyboards/tmo50 | |
| parent | a9a2817f3aff389fecf1b4bced52093a175a5a65 (diff) | |
| download | qmk_firmware-4a6cfb06c5aafb353ddfa056bfa69ae82b5fc894.tar.gz qmk_firmware-4a6cfb06c5aafb353ddfa056bfa69ae82b5fc894.zip | |
TMO50: use layer_state_set_kb at keyboard level (#10150)
* Change TMO to use layer_state_set_kb as is customary at the keyboard level.
This also factors out `process_indicator_led` to a separate method.
Diffstat (limited to 'keyboards/tmo50')
| -rw-r--r-- | keyboards/tmo50/tmo50.c | 37 | ||||
| -rw-r--r-- | keyboards/tmo50/tmo50.h | 5 |
2 files changed, 31 insertions, 11 deletions
diff --git a/keyboards/tmo50/tmo50.c b/keyboards/tmo50/tmo50.c index 4f6288133..bad4319f1 100644 --- a/keyboards/tmo50/tmo50.c +++ b/keyboards/tmo50/tmo50.c | |||
| @@ -51,34 +51,51 @@ void led_set_kb(uint8_t usb_led) { | |||
| 51 | led_set_user(usb_led); | 51 | led_set_user(usb_led); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | uint32_t layer_state_set_user(uint32_t state) | 54 | layer_state_t layer_state_set_kb(layer_state_t state) |
| 55 | { | 55 | { |
| 56 | // if on layer 0, turn on B0 LED, otherwise off. | 56 | state = layer_state_set_user(state); |
| 57 | if (biton32(state) == 0) { | 57 | process_indicator_led_kb(state); |
| 58 | |||
| 59 | return state; | ||
| 60 | } | ||
| 61 | |||
| 62 | __attribute__((weak)) | ||
| 63 | bool process_indicator_led_user(layer_state_t state){ | ||
| 64 | return true; | ||
| 65 | } | ||
| 66 | |||
| 67 | bool process_indicator_led_kb(layer_state_t state) | ||
| 68 | { | ||
| 69 | if(process_indicator_led_user(state)) | ||
| 70 | { | ||
| 71 | // if on layer 0, turn on B0 LED, otherwise off. | ||
| 72 | if (get_highest_layer(state) == 0) { | ||
| 58 | PORTB &= ~(1<<PB0); | 73 | PORTB &= ~(1<<PB0); |
| 59 | } else { | 74 | } else { |
| 60 | PORTB |= (1<<PB0); | 75 | PORTB |= (1<<PB0); |
| 61 | } | 76 | } |
| 62 | 77 | ||
| 63 | // if on layer 1, turn on B1 LED, otherwise off. | 78 | // if on layer 1, turn on B1 LED, otherwise off. |
| 64 | if (biton32(state) == 1) { | 79 | if (get_highest_layer(state) == 1) { |
| 65 | PORTB &= ~(1<<PB1); | 80 | PORTB &= ~(1<<PB1); |
| 66 | } else { | 81 | } else { |
| 67 | PORTB |= (1<<PB1); | 82 | PORTB |= (1<<PB1); |
| 68 | } | 83 | } |
| 69 | // if on layer 2, turn on B2 LED, otherwise off. | 84 | |
| 70 | if (biton32(state) == 2) { | 85 | // if on layer 2, turn on B2 LED, otherwise off. |
| 86 | if (get_highest_layer(state) == 2) { | ||
| 71 | PORTB &= ~(1<<PB2); | 87 | PORTB &= ~(1<<PB2); |
| 72 | } else { | 88 | } else { |
| 73 | PORTB |= (1<<PB2); | 89 | PORTB |= (1<<PB2); |
| 74 | } | 90 | } |
| 75 | 91 | ||
| 76 | // if on layer 3, turn on B3 LED, otherwise off. | 92 | // if on layer 3, turn on B3 LED, otherwise off. |
| 77 | if (biton32(state) == 3) { | 93 | if (get_highest_layer(state) == 3) { |
| 78 | PORTB &= ~(1<<PB3); | 94 | PORTB &= ~(1<<PB3); |
| 79 | } else { | 95 | } else { |
| 80 | PORTB |= (1<<PB3); | 96 | PORTB |= (1<<PB3); |
| 81 | } | 97 | } |
| 98 | } | ||
| 82 | 99 | ||
| 83 | return state; | 100 | return true; |
| 84 | } | 101 | } |
diff --git a/keyboards/tmo50/tmo50.h b/keyboards/tmo50/tmo50.h index df88350f0..444e6ede9 100644 --- a/keyboards/tmo50/tmo50.h +++ b/keyboards/tmo50/tmo50.h | |||
| @@ -17,6 +17,10 @@ | |||
| 17 | 17 | ||
| 18 | #include "quantum.h" | 18 | #include "quantum.h" |
| 19 | 19 | ||
| 20 | bool process_indicator_led_kb(layer_state_t state); | ||
| 21 | __attribute__((weak)) | ||
| 22 | bool process_indicator_led_user(layer_state_t state); | ||
| 23 | |||
| 20 | /* This a shortcut to help you visually see your layout. | 24 | /* This a shortcut to help you visually see your layout. |
| 21 | * | 25 | * |
| 22 | * The first section contains all of the arguments representing the physical | 26 | * The first section contains all of the arguments representing the physical |
| @@ -51,4 +55,3 @@ | |||
| 51 | { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D }, \ | 55 | { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D }, \ |
| 52 | { K30, K31, K32, K33, KC_NO, KC_NO, KC_NO, K37, KC_NO, KC_NO, K3A, KC_NO, KC_NO, KC_NO } \ | 56 | { K30, K31, K32, K33, KC_NO, KC_NO, KC_NO, K37, KC_NO, KC_NO, K3A, KC_NO, KC_NO, KC_NO } \ |
| 53 | } | 57 | } |
| 54 | |||
