Просмотр исходного кода

Fix Phantom sleep LED.

tags/v1.9
Mathias Andersson 11 лет назад
Родитель
Сommit
28aeef231b
3 измененных файлов: 33 добавлений и 10 удалений
  1. 4
    0
      keyboard/phantom/config.h
  2. 21
    6
      keyboard/phantom/led.c
  3. 8
    4
      keyboard/phantom/matrix.c

+ 4
- 0
keyboard/phantom/config.h Просмотреть файл

/* Set 0 if need no debouncing */ /* Set 0 if need no debouncing */
#define DEBOUNCE 7 #define DEBOUNCE 7


/* Set LED brightness 0-255.
* This have no effect if sleep LED is enabled. */
#define LED_BRIGHTNESS 250

/* key combination for command */ /* key combination for command */
#define IS_COMMAND() ( \ #define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \

+ 21
- 6
keyboard/phantom/led.c Просмотреть файл

*/ */


#include <avr/io.h> #include <avr/io.h>
#include "stdint.h"
#include "led.h" #include "led.h"




void led_set(uint8_t usb_led) void led_set(uint8_t usb_led)
{ {
if (!(usb_led & (1<<USB_LED_CAPS_LOCK)))
DDRB &= ~(1<<6);
else
if (usb_led & (1<<USB_LED_CAPS_LOCK))
{
// Output high.
DDRB |= (1<<6); DDRB |= (1<<6);
PORTB |= (1<<6);
}
else
{
// Output low.
DDRB &= ~(1<<6);
PORTB &= ~(1<<6);
}


if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)))
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
{
// Output high.
DDRB &= ~(1<<7); DDRB &= ~(1<<7);
PORTB |= (1<<7);
}
else else
DDRB |= (1<<7);
{
// Output low.
DDRB &= ~(1<<7);
PORTB &= ~(1<<7);
}
} }

+ 8
- 4
keyboard/phantom/matrix.c Просмотреть файл

static void unselect_cols(void); static void unselect_cols(void);
static void select_col(uint8_t col); static void select_col(uint8_t col);


#ifndef SLEEP_LED_ENABLE
/* LEDs are on output compare pins OC1B OC1C /* LEDs are on output compare pins OC1B OC1C
This activates fast PWM mode on them. This activates fast PWM mode on them.
Prescaler 256 and 8-bit counter results in Prescaler 256 and 8-bit counter results in
TCCR1B |= // Timer control register 1B TCCR1B |= // Timer control register 1B
(1<<WGM12) | // Fast PWM 8-bit (1<<WGM12) | // Fast PWM 8-bit
(1<<CS12); // Prescaler 256 (1<<CS12); // Prescaler 256
OCR1B = 250; // Output compare register 1B
OCR1C = 250; // Output compare register 1C
OCR1B = LED_BRIGHTNESS; // Output compare register 1B
OCR1C = LED_BRIGHTNESS; // Output compare register 1C
// LEDs: LED_A -> PORTB6, LED_B -> PORTB7 // LEDs: LED_A -> PORTB6, LED_B -> PORTB7
DDRB &= 0x3F;
PORTB &= 0x3F;
DDRB |= (1<<6) | (1<<7);
PORTB &= ~((1<<6) | (1<<7));
} }
#endif


inline inline
uint8_t matrix_rows(void) uint8_t matrix_rows(void)
// initialize row and col // initialize row and col
unselect_cols(); unselect_cols();
init_rows(); init_rows();
#ifndef SLEEP_LED_ENABLE
setup_leds(); setup_leds();
#endif


// initialize matrix state: all keys off // initialize matrix state: all keys off
for (uint8_t i = 0; i < MATRIX_ROWS; i++) { for (uint8_t i = 0; i < MATRIX_ROWS; i++) {

Загрузка…
Отмена
Сохранить