Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Lisa #24005

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions keyboards/keyten/lisa/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 2
4 changes: 0 additions & 4 deletions keyboards/keyten/lisa/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"cols": ["B7", "B6", "B5", "B4", "B3", "A15", "A3", "A4", "A5", "A6", "A7", "B0", "B1"],
"rows": ["B13", "B15", "B14", "A8"]
},
"indicators": {
"caps_lock": "B10",
"num_lock": "B11"
}
"processor": "STM32F072",
"usb": {
"vid": "0xEB69",
Expand Down
82 changes: 77 additions & 5 deletions keyboards/keyten/lisa/lisa.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,82 @@

#include "quantum.h"

#define LED_INDICATOR_PIN B2
#define LOWER_LED_PIN B11
#define MIDDLE_LED_PIN B10
#define UPPER_LED_PIN B2

void matrix_init_kb(void) {
gpio_set_pin_output(LED_INDICATOR_PIN);
gpio_write_pin_high(LED_INDICATOR_PIN);
matrix_init_user();
typedef union {
uint16_t raw;
struct {
uint16_t lower_led : 3;
uint16_t middle_led: 3;
uint16_t upper_led : 3;
};
} layout_options_t;

static layout_options_t layout_options;

static layer_state_t current_layer_state = 0;

void via_set_layout_options_kb(uint32_t value) {
layout_options.raw = value;
led_update_kb(host_keyboard_led_state());
}

enum led_mode_t {
LED_MODE_OFF,
LED_MODE_ON,
LED_MODE_CAPS_LOCK,
LED_MODE_NUM_LOCK,
LED_MODE_SCROLL_LOCK,
LED_MODE_LAYER_1,
LED_MODE_LAYER_2,
LED_MODE_LAYER_3,
};

void set_led_state(uint32_t pin, uint8_t mode, led_t led_state) {
switch (mode) {
case LED_MODE_OFF:
gpio_write_pin_low(pin);
break;
case LED_MODE_ON:
gpio_write_pin_high(pin);
break;
case LED_MODE_CAPS_LOCK:
gpio_write_pin(pin, led_state.caps_lock);
break;
case LED_MODE_NUM_LOCK:
gpio_write_pin(pin, led_state.num_lock);
break;
case LED_MODE_SCROLL_LOCK:
gpio_write_pin(pin, led_state.scroll_lock);
break;
case LED_MODE_LAYER_1:
gpio_write_pin(pin, (current_layer_state & (1 << 1)) != 0);
break;
case LED_MODE_LAYER_2:
gpio_write_pin(pin, (current_layer_state & (1 << 2)) != 0);
break;
case LED_MODE_LAYER_3:
gpio_write_pin(pin, (current_layer_state & (1 << 3)) != 0);
break;
default:
gpio_write_pin_low(pin);
break;
}
}

void led_update_ports(led_t led_state) {
gpio_set_pin_output(LOWER_LED_PIN);
gpio_set_pin_output(MIDDLE_LED_PIN);
gpio_set_pin_output(UPPER_LED_PIN);

set_led_state(LOWER_LED_PIN, layout_options.lower_led, led_state);
set_led_state(MIDDLE_LED_PIN, layout_options.middle_led, led_state);
set_led_state(UPPER_LED_PIN, layout_options.upper_led, led_state);
}

layer_state_t layer_state_set_user(layer_state_t state) {
current_layer_state = state;
return current_layer_state;
}
Loading