Compare commits
8 Commits
hid_api
...
planck-4.2
Author | SHA1 | Date | |
---|---|---|---|
|
c8e232907f | ||
|
994592f985 | ||
|
4d5b7dea14 | ||
|
4d5eeb3d7d | ||
|
4edfa97e03 | ||
|
5f154f0a00 | ||
|
94f8b758b3 | ||
|
f0db2c0512 |
@@ -92,7 +92,7 @@ The following shortcuts automatically add `LSFT()` to keycodes to get commonly u
|
||||
| KC_RCBR | } |
|
||||
| KC_LABK | < |
|
||||
| KC_RABK | > |
|
||||
| KC_PIPE | | |
|
||||
| KC_PIPE | | |
|
||||
| KC_COLN | : |
|
||||
|
||||
## Mod Tap
|
||||
|
@@ -1 +1,16 @@
|
||||
#include "lets_split.h"
|
||||
#include "lets_split.h"
|
||||
|
||||
#ifdef ONEHAND_ENABLE
|
||||
__attribute__ ((weak))
|
||||
const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
{{5, 4}, {4, 4}, {3, 4}, {2, 4}, {1, 4}, {0, 4}},
|
||||
{{5, 5}, {4, 5}, {3, 5}, {2, 5}, {1, 5}, {0, 5}},
|
||||
{{5, 6}, {4, 6}, {3, 6}, {2, 6}, {1, 6}, {0, 6}},
|
||||
{{5, 7}, {4, 7}, {3, 7}, {2, 7}, {1, 7}, {0, 7}},
|
||||
{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}},
|
||||
{{0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}},
|
||||
{{0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}},
|
||||
{{0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}},
|
||||
};
|
||||
#endif
|
||||
|
@@ -57,7 +57,7 @@ CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
MIDI_ENABLE = yes # MIDI controls
|
||||
AUDIO_ENABLE = yes # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
|
@@ -51,7 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define BACKLIGHT_PIN F5
|
||||
#define BACKLIGHT_BREATHING
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
#define BACKLIGHT_LEVELS 6
|
||||
|
||||
|
||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "print.h"
|
||||
#include "audio.h"
|
||||
#include "keymap.h"
|
||||
#include "wait.h"
|
||||
|
||||
#include "eeconfig.h"
|
||||
|
||||
@@ -122,14 +123,19 @@ bool glissando = true;
|
||||
#ifndef STARTUP_SONG
|
||||
#define STARTUP_SONG SONG(STARTUP_SOUND)
|
||||
#endif
|
||||
#ifndef AUDIO_ON_SONG
|
||||
#define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND)
|
||||
#endif
|
||||
#ifndef AUDIO_OFF_SONG
|
||||
#define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
|
||||
#endif
|
||||
float startup_song[][2] = STARTUP_SONG;
|
||||
float audio_on_song[][2] = AUDIO_ON_SONG;
|
||||
float audio_off_song[][2] = AUDIO_OFF_SONG;
|
||||
|
||||
void audio_init()
|
||||
{
|
||||
|
||||
if (audio_initialized)
|
||||
return;
|
||||
|
||||
// Check EEPROM
|
||||
if (!eeconfig_is_enabled())
|
||||
{
|
||||
@@ -137,46 +143,49 @@ void audio_init()
|
||||
}
|
||||
audio_config.raw = eeconfig_read_audio();
|
||||
|
||||
// Set port PC6 (OC3A and /OC4A) as output
|
||||
if (!audio_initialized) {
|
||||
|
||||
#ifdef C6_AUDIO
|
||||
DDRC |= _BV(PORTC6);
|
||||
#else
|
||||
DDRC |= _BV(PORTC6);
|
||||
PORTC &= ~_BV(PORTC6);
|
||||
#endif
|
||||
// Set port PC6 (OC3A and /OC4A) as output
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
DDRB |= _BV(PORTB5);
|
||||
#else
|
||||
DDRB |= _BV(PORTB5);
|
||||
PORTB &= ~_BV(PORTB5);
|
||||
#endif
|
||||
#ifdef C6_AUDIO
|
||||
DDRC |= _BV(PORTC6);
|
||||
#else
|
||||
DDRC |= _BV(PORTC6);
|
||||
PORTC &= ~_BV(PORTC6);
|
||||
#endif
|
||||
|
||||
#ifdef C6_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#endif
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
#endif
|
||||
#ifdef B5_AUDIO
|
||||
DDRB |= _BV(PORTB5);
|
||||
#else
|
||||
DDRB |= _BV(PORTB5);
|
||||
PORTB &= ~_BV(PORTB5);
|
||||
#endif
|
||||
|
||||
// TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
|
||||
// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
|
||||
// Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A)
|
||||
// Clock Select (CS3n) = 0b010 = Clock / 8
|
||||
#ifdef C6_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#endif
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
#endif
|
||||
|
||||
#ifdef C6_AUDIO
|
||||
TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
|
||||
TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
|
||||
#endif
|
||||
// TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
|
||||
// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
|
||||
// Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A)
|
||||
// Clock Select (CS3n) = 0b010 = Clock / 8
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10);
|
||||
TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
|
||||
#endif
|
||||
#ifdef C6_AUDIO
|
||||
TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
|
||||
TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
|
||||
#endif
|
||||
|
||||
audio_initialized = true;
|
||||
#ifdef B5_AUDIO
|
||||
TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10);
|
||||
TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
|
||||
#endif
|
||||
|
||||
audio_initialized = true;
|
||||
}
|
||||
|
||||
if (audio_config.enable) {
|
||||
PLAY_SONG(startup_song);
|
||||
@@ -186,7 +195,7 @@ void audio_init()
|
||||
|
||||
void stop_all_notes()
|
||||
{
|
||||
dprintf("audio stop all notes\n");
|
||||
dprintf("audio stop all notes");
|
||||
|
||||
if (!audio_initialized) {
|
||||
audio_init();
|
||||
@@ -219,7 +228,7 @@ void stop_all_notes()
|
||||
|
||||
void stop_note(float freq)
|
||||
{
|
||||
dprintf("audio stop note freq=%d\n", (int)freq);
|
||||
dprintf("audio stop note freq=%d", (int)freq);
|
||||
|
||||
if (playing_note) {
|
||||
if (!audio_initialized) {
|
||||
@@ -717,13 +726,16 @@ void audio_toggle(void) {
|
||||
}
|
||||
|
||||
void audio_on(void) {
|
||||
PLAY_SONG(startup_song);
|
||||
audio_config.enable = 1;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
audio_on_user();
|
||||
PLAY_SONG(audio_on_song);
|
||||
}
|
||||
|
||||
void audio_off(void) {
|
||||
PLAY_SONG(audio_off_song);
|
||||
wait_ms(100);
|
||||
stop_all_notes();
|
||||
audio_config.enable = 0;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
@@ -127,6 +127,14 @@
|
||||
E__NOTE(_GS6), \
|
||||
E__NOTE(_A6 ),
|
||||
|
||||
#define AUDIO_ON_SOUND \
|
||||
E__NOTE(_A5 ), \
|
||||
E__NOTE(_A6 ),
|
||||
|
||||
#define AUDIO_OFF_SOUND \
|
||||
E__NOTE(_A6 ), \
|
||||
E__NOTE(_A5 ),
|
||||
|
||||
#define MUSIC_SCALE_SOUND MUSIC_ON_SOUND
|
||||
|
||||
#define MUSIC_OFF_SOUND \
|
||||
|
@@ -134,11 +134,11 @@ void reset_keyboard(void) {
|
||||
clear_keyboard();
|
||||
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
|
||||
music_all_notes_off();
|
||||
// uint16_t timer_start = timer_read();
|
||||
uint16_t timer_start = timer_read();
|
||||
PLAY_SONG(goodbye_song);
|
||||
shutdown_user();
|
||||
// while(timer_elapsed(timer_start) < 500)
|
||||
wait_ms(250);
|
||||
while(timer_elapsed(timer_start) < 250)
|
||||
wait_ms(1);
|
||||
stop_all_notes();
|
||||
#else
|
||||
wait_ms(250);
|
||||
@@ -253,8 +253,8 @@ bool process_record_quantum(keyrecord_t *record) {
|
||||
break;
|
||||
case DEBUG:
|
||||
if (record->event.pressed) {
|
||||
print("\nDEBUG: enabled.\n");
|
||||
debug_enable = true;
|
||||
print("DEBUG: enabled.\n");
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
@@ -539,56 +539,35 @@ void rgblight_effect_snake(uint8_t interval) {
|
||||
}
|
||||
}
|
||||
void rgblight_effect_knight(uint8_t interval) {
|
||||
static int8_t pos = 0;
|
||||
static uint16_t last_timer = 0;
|
||||
uint8_t i, j, cur;
|
||||
int8_t k;
|
||||
LED_TYPE preled[RGBLED_NUM];
|
||||
static int8_t increment = -1;
|
||||
if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) {
|
||||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
|
||||
static int8_t low_bound = 0;
|
||||
static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
|
||||
static int8_t increment = 1;
|
||||
uint8_t i, cur;
|
||||
|
||||
for (i = 0; i < RGBLED_NUM; i++) {
|
||||
preled[i].r = 0;
|
||||
preled[i].g = 0;
|
||||
preled[i].b = 0;
|
||||
for (j = 0; j < RGBLIGHT_EFFECT_KNIGHT_LENGTH; j++) {
|
||||
k = pos + j * increment;
|
||||
if (k < 0) {
|
||||
k = 0;
|
||||
}
|
||||
if (k >= RGBLED_NUM) {
|
||||
k = RGBLED_NUM - 1;
|
||||
}
|
||||
if (i == k) {
|
||||
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&preled[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (RGBLIGHT_EFFECT_KNIGHT_OFFSET) {
|
||||
for (i = 0; i < RGBLED_NUM; i++) {
|
||||
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM;
|
||||
led[i].r = preled[cur].r;
|
||||
led[i].g = preled[cur].g;
|
||||
led[i].b = preled[cur].b;
|
||||
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM;
|
||||
|
||||
if (i >= low_bound && i <= high_bound) {
|
||||
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
|
||||
} else {
|
||||
led[cur].r = 0;
|
||||
led[cur].g = 0;
|
||||
led[cur].b = 0;
|
||||
}
|
||||
}
|
||||
rgblight_set();
|
||||
if (increment == 1) {
|
||||
if (pos - 1 < 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH) {
|
||||
pos = 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH;
|
||||
increment = -1;
|
||||
} else {
|
||||
pos -= 1;
|
||||
}
|
||||
} else {
|
||||
if (pos + 1 > RGBLED_NUM + RGBLIGHT_EFFECT_KNIGHT_LENGTH) {
|
||||
pos = RGBLED_NUM + RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
|
||||
increment = 1;
|
||||
} else {
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
low_bound += increment;
|
||||
high_bound += increment;
|
||||
|
||||
if (high_bound <= 0 || low_bound >= RGBLED_NUM - 1) {
|
||||
increment = -increment;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -30,11 +30,7 @@
|
||||
#define RGBLIGHT_EFFECT_KNIGHT_LENGTH 7
|
||||
#endif
|
||||
#ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
|
||||
#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 9
|
||||
#endif
|
||||
|
||||
#ifndef RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH
|
||||
#define RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH 4
|
||||
#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0
|
||||
#endif
|
||||
|
||||
#ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL
|
||||
|
@@ -205,8 +205,8 @@ typedef struct
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
# define CONSOLE_IN_EPNUM (RAW_OUT_EPNUM + 1)
|
||||
# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 2)
|
||||
//# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 1)
|
||||
//# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 2)
|
||||
# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 1)
|
||||
#else
|
||||
# define CONSOLE_OUT_EPNUM RAW_OUT_EPNUM
|
||||
#endif
|
||||
|
@@ -260,52 +260,19 @@ static void raw_hid_task(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__ ((weak))
|
||||
void ProcessConsoleHIDReport(uint8_t * data, uint8_t length) {
|
||||
|
||||
// print("Received message:\n ");
|
||||
// while (*data) {
|
||||
// sendchar(*data);
|
||||
// data++;
|
||||
// }
|
||||
switch (data[0]) {
|
||||
case 0xFE:
|
||||
print("Entering bootloader\n");
|
||||
reset_keyboard();
|
||||
break;
|
||||
case 0x01:
|
||||
print("Saying hello\n");
|
||||
audio_on();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Console
|
||||
******************************************************************************/
|
||||
#ifdef CONSOLE_ENABLE
|
||||
|
||||
static bool console_flush = false;
|
||||
#define CONSOLE_FLUSH_SET(b) do { \
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {\
|
||||
console_flush = b; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
static void Console_Task(void)
|
||||
{
|
||||
|
||||
/* Device must be connected and configured for the task to run */
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
return;
|
||||
|
||||
|
||||
/* Create a temporary buffer to hold the read in report from the host */
|
||||
uint8_t ConsoleData[CONSOLE_EPSIZE];
|
||||
bool data_read = false;
|
||||
uint8_t ep = Endpoint_GetCurrentEndpoint();
|
||||
|
||||
#if 0
|
||||
// TODO: impl receivechar()/recvchar()
|
||||
Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM);
|
||||
|
||||
@@ -315,43 +282,38 @@ static void Console_Task(void)
|
||||
/* Check to see if the packet contains data */
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Create a temporary buffer to hold the read in report from the host */
|
||||
uint8_t ConsoleData[CONSOLE_EPSIZE];
|
||||
|
||||
/* Read Console Report Data */
|
||||
Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL);
|
||||
data_read = true;
|
||||
|
||||
/* Process Console Report Data */
|
||||
//ProcessConsoleHIDReport(ConsoleData);
|
||||
}
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data_read) {
|
||||
/* Process Console Report Data */
|
||||
ProcessConsoleHIDReport(ConsoleData, sizeof(ConsoleData));
|
||||
}
|
||||
|
||||
/* IN packet */
|
||||
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
|
||||
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
|
||||
Endpoint_SelectEndpoint(ep);
|
||||
return;
|
||||
}
|
||||
|
||||
if (console_flush) {
|
||||
/* IN packet */
|
||||
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
|
||||
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
|
||||
Endpoint_SelectEndpoint(ep);
|
||||
return;
|
||||
}
|
||||
// fill empty bank
|
||||
while (Endpoint_IsReadWriteAllowed())
|
||||
Endpoint_Write_8(0);
|
||||
|
||||
// fill empty bank
|
||||
while (Endpoint_IsReadWriteAllowed())
|
||||
Endpoint_Write_8(0);
|
||||
|
||||
// flash senchar packet
|
||||
if (Endpoint_IsINReady()) {
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
// CONSOLE_FLUSH_SET(false);
|
||||
// flash senchar packet
|
||||
if (Endpoint_IsINReady()) {
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
Endpoint_SelectEndpoint(ep);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -419,6 +381,13 @@ void EVENT_USB_Device_WakeUp()
|
||||
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
static bool console_flush = false;
|
||||
#define CONSOLE_FLUSH_SET(b) do { \
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {\
|
||||
console_flush = b; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// called every 1ms
|
||||
void EVENT_USB_Device_StartOfFrame(void)
|
||||
{
|
||||
@@ -426,9 +395,9 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
if (++count % 50) return;
|
||||
count = 0;
|
||||
|
||||
//if (!console_flush) return;
|
||||
if (!console_flush) return;
|
||||
Console_Task();
|
||||
//console_flush = false;
|
||||
console_flush = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -471,9 +440,11 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
/* Setup Console HID Report Endpoints */
|
||||
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
|
||||
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||
#if 0
|
||||
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
|
||||
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
/* Setup NKRO HID Report Endpoints */
|
||||
|
Reference in New Issue
Block a user