Skip to content

Instantly share code, notes, and snippets.

@jackhumbert
Last active January 7, 2018 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackhumbert/807cf6efa2aa60423721194caccf6f3e to your computer and use it in GitHub Desktop.
Save jackhumbert/807cf6efa2aa60423721194caccf6f3e to your computer and use it in GitHub Desktop.
#include "kb.h"
#include "led.h"
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
matrix_init_user();
led_init_ports();
};
void matrix_scan_kb(void) {
// put your looping keyboard code here
// runs every cycle (a lot)
matrix_scan_user();
};
void led_init_ports(void) {
// * Set our LED pins as output
DDRE |= (1<<6);
DDRD |= (1<<3);
DDRC |= (1<<6);
DDRC |= (1<<7);
}
void led_set_kb(uint8_t usb_led) {
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
PORTE |= (1<<6);
} else {
PORTE &= ~(1<<6);
}
}
uint32_t layer_state_set_kb(uint32_t state) {
if (state & (1<<5)) {
PORTD |= (1<<3);
} else {
PORTD &= ~(1<<3);
}
if (state & (1<<4)) {
PORTC |= (1<<6);
} else {
PORTC &= ~(1<<6);
}
if (state & (1<<1)) {
PORTC |= (1<<7);
} else {
PORTC &= ~(1<<7);
}
if (state & (1<<4)) {
PORTE |= (1<<6);
PORTD |= (1<<3);
PORTC |= (1<<6);
PORTC |= (1<<7);
}
return layer_state_set_user(state);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment