#include "orbit.h"
#include "split_util.h"
#include "transport.h"
void led_toggle(int id, bool on) {
if (isLeftHand) {
switch(id) {
case 0:
if (on)
writePinHigh(C6);
else
writePinLow(C6);
break;
case 1:
if (on)
writePinHigh(B6);
else
writePinLow(B6);
break;
case 2:
if (on)
writePinHigh(B5);
else
writePinLow(B5);
break;
default:
break;
}
} else {
switch(id) {
case 3:
if (on)
writePinHigh(F6);
else
writePinLow(F6);
break;
case 4:
if (on)
writePinHigh(F7);
else
writePinLow(F7);
break;
case 5:
if (on)
writePinHigh(C7);
else
writePinLow(C7);
break;
default:
break;
}
}
}
void set_all_leds(bool leds[6]) {
for (int i = 0; i < 6; i++) {
led_toggle(i, leds[i]);
}
}
void set_layer_indicators(uint8_t layer) {
switch (layer)
{
case 0:
led_toggle(0, true);
led_toggle(1, false);
led_toggle(2, false);
break;
case 1:
led_toggle(0, true);
led_toggle(1, true);
led_toggle(2, false);
break;
case 2:
led_toggle(0, true);
led_toggle(1, true);
led_toggle(2, true);
break;
case 3:
led_toggle(0, false);
led_toggle(1, true);
led_toggle(2, true);
break;
case 4:
led_toggle(0, false);
led_toggle(1, false);
led_toggle(2, true);
break;
default:
led_toggle(0, true);
led_toggle(1, false);
led_toggle(2, true);
break;
}
}
void matrix_init_kb(void) {
if (isLeftHand)
{
setPinOutput(C6);
setPinOutput(B6);
setPinOutput(B5);
}
else
{
setPinOutput(F6);
setPinOutput(F7);
setPinOutput(C7);
}
set_layer_indicators(0);
matrix_init_user();
}
void matrix_scan_kb(void) {
matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
if (is_keyboard_master()) {
serial_m2s_buffer.nlock_led = IS_LED_ON(usb_led, USB_LED_NUM_LOCK);
serial_m2s_buffer.clock_led = IS_LED_ON(usb_led, USB_LED_CAPS_LOCK);
serial_m2s_buffer.slock_led = IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK);
led_toggle(3, IS_LED_ON(usb_led, USB_LED_NUM_LOCK));
led_toggle(4, IS_LED_ON(usb_led, USB_LED_CAPS_LOCK));
led_toggle(5, IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK));
}
led_set_user(usb_led);
}
uint32_t layer_state_set_kb(uint32_t state) {
if (is_keyboard_master())
{
serial_m2s_buffer.current_layer = biton32(state);
if (isLeftHand)
{
set_layer_indicators(biton32(state));
}
}
return layer_state_set_user(state);
}