Compare commits

..

1 Commits

Author SHA1 Message Date
Jack Humbert
07e68b2240 using pjrc hid UP to communicate with toolbox 2017-09-03 17:15:12 -04:00
11 changed files with 120 additions and 65 deletions

View File

@@ -92,7 +92,7 @@ The following shortcuts automatically add `LSFT()` to keycodes to get commonly u
| KC_RCBR | } | | KC_RCBR | } |
| KC_LABK | < | | KC_LABK | < |
| KC_RABK | > | | KC_RABK | > |
| KC_PIPE | &#x7C; | | KC_PIPE | | |
| KC_COLN | : | | KC_COLN | : |
## Mod Tap ## Mod Tap

View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB Device descriptor parameter */ /* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED #define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6060 #define PRODUCT_ID 0x6060
#define MANUFACTURER Ortholinear Keyboards #define MANUFACTURER OLKB
#define PRODUCT The Planck Keyboard #define PRODUCT The Planck Keyboard
#define DESCRIPTION A compact ortholinear keyboard #define DESCRIPTION A compact ortholinear keyboard

View File

@@ -163,7 +163,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------' * `-----------------------------------------------------------------------------------'
*/ */
[_ADJUST] = { [_ADJUST] = {
{_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL }, {_______, RESET, DEBUG, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL },
{_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, {_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
{_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______},
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}

View File

@@ -53,11 +53,11 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = no # Mouse keys(+4700) MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400) CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration 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 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 = yes # Enable keyboard backlight functionality BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = yes # MIDI controls MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = yes # Audio output on port C6 AUDIO_ENABLE = yes # Audio output on port C6
UNICODE_ENABLE = no # Unicode UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID

View File

@@ -51,7 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_PIN F5 #define BACKLIGHT_PIN F5
#define BACKLIGHT_BREATHING #define BACKLIGHT_BREATHING
#define BACKLIGHT_LEVELS 6 #define BACKLIGHT_LEVELS 3
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */

View File

@@ -186,7 +186,7 @@ void audio_init()
void stop_all_notes() void stop_all_notes()
{ {
dprintf("audio stop all notes"); dprintf("audio stop all notes\n");
if (!audio_initialized) { if (!audio_initialized) {
audio_init(); audio_init();
@@ -219,7 +219,7 @@ void stop_all_notes()
void stop_note(float freq) void stop_note(float freq)
{ {
dprintf("audio stop note freq=%d", (int)freq); dprintf("audio stop note freq=%d\n", (int)freq);
if (playing_note) { if (playing_note) {
if (!audio_initialized) { if (!audio_initialized) {
@@ -717,6 +717,7 @@ void audio_toggle(void) {
} }
void audio_on(void) { void audio_on(void) {
PLAY_SONG(startup_song);
audio_config.enable = 1; audio_config.enable = 1;
eeconfig_update_audio(audio_config.raw); eeconfig_update_audio(audio_config.raw);
audio_on_user(); audio_on_user();

View File

@@ -134,11 +134,11 @@ void reset_keyboard(void) {
clear_keyboard(); clear_keyboard();
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
music_all_notes_off(); music_all_notes_off();
uint16_t timer_start = timer_read(); // uint16_t timer_start = timer_read();
PLAY_SONG(goodbye_song); PLAY_SONG(goodbye_song);
shutdown_user(); shutdown_user();
while(timer_elapsed(timer_start) < 250) // while(timer_elapsed(timer_start) < 500)
wait_ms(1); wait_ms(250);
stop_all_notes(); stop_all_notes();
#else #else
wait_ms(250); wait_ms(250);

View File

@@ -539,35 +539,56 @@ void rgblight_effect_snake(uint8_t interval) {
} }
} }
void rgblight_effect_knight(uint8_t interval) { void rgblight_effect_knight(uint8_t interval) {
static int8_t pos = 0;
static uint16_t last_timer = 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])) { if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) {
return; return;
} }
last_timer = timer_read(); 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++) { for (i = 0; i < RGBLED_NUM; i++) {
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; preled[i].r = 0;
preled[i].g = 0;
if (i >= low_bound && i <= high_bound) { preled[i].b = 0;
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]); for (j = 0; j < RGBLIGHT_EFFECT_KNIGHT_LENGTH; j++) {
} else { k = pos + j * increment;
led[cur].r = 0; if (k < 0) {
led[cur].g = 0; k = 0;
led[cur].b = 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;
} }
} }
rgblight_set(); rgblight_set();
if (increment == 1) {
low_bound += increment; if (pos - 1 < 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH) {
high_bound += increment; pos = 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH;
increment = -1;
if (high_bound <= 0 || low_bound >= RGBLED_NUM - 1) { } else {
increment = -increment; 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;
}
} }
} }

View File

@@ -30,7 +30,11 @@
#define RGBLIGHT_EFFECT_KNIGHT_LENGTH 7 #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 7
#endif #endif
#ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET #ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 9
#endif
#ifndef RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH
#define RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH 4
#endif #endif
#ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL

View File

@@ -205,8 +205,8 @@ typedef struct
#ifdef CONSOLE_ENABLE #ifdef CONSOLE_ENABLE
# define CONSOLE_IN_EPNUM (RAW_OUT_EPNUM + 1) # define CONSOLE_IN_EPNUM (RAW_OUT_EPNUM + 1)
//# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 2) # define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 2)
# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 1) //# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 1)
#else #else
# define CONSOLE_OUT_EPNUM RAW_OUT_EPNUM # define CONSOLE_OUT_EPNUM RAW_OUT_EPNUM
#endif #endif

View File

@@ -260,19 +260,52 @@ static void raw_hid_task(void)
} }
#endif #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 * Console
******************************************************************************/ ******************************************************************************/
#ifdef CONSOLE_ENABLE #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) static void Console_Task(void)
{ {
/* Device must be connected and configured for the task to run */ /* Device must be connected and configured for the task to run */
if (USB_DeviceState != DEVICE_STATE_Configured) if (USB_DeviceState != DEVICE_STATE_Configured)
return; 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(); uint8_t ep = Endpoint_GetCurrentEndpoint();
#if 0
// TODO: impl receivechar()/recvchar() // TODO: impl receivechar()/recvchar()
Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM); Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM);
@@ -282,38 +315,43 @@ static void Console_Task(void)
/* Check to see if the packet contains data */ /* Check to see if the packet contains data */
if (Endpoint_IsReadWriteAllowed()) 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 */ /* Read Console Report Data */
Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL); 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 */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearOUT(); Endpoint_ClearOUT();
}
#endif
/* IN packet */ if (data_read) {
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); /* Process Console Report Data */
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) { ProcessConsoleHIDReport(ConsoleData, sizeof(ConsoleData));
Endpoint_SelectEndpoint(ep); }
return;
} }
// fill empty bank if (console_flush) {
while (Endpoint_IsReadWriteAllowed()) /* IN packet */
Endpoint_Write_8(0); Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
Endpoint_SelectEndpoint(ep);
return;
}
// flash senchar packet // fill empty bank
if (Endpoint_IsINReady()) { while (Endpoint_IsReadWriteAllowed())
Endpoint_ClearIN(); Endpoint_Write_8(0);
// flash senchar packet
if (Endpoint_IsINReady()) {
Endpoint_ClearIN();
}
// CONSOLE_FLUSH_SET(false);
} }
Endpoint_SelectEndpoint(ep); Endpoint_SelectEndpoint(ep);
} }
#endif #endif
@@ -381,13 +419,6 @@ void EVENT_USB_Device_WakeUp()
#ifdef CONSOLE_ENABLE #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 // called every 1ms
void EVENT_USB_Device_StartOfFrame(void) void EVENT_USB_Device_StartOfFrame(void)
{ {
@@ -395,9 +426,9 @@ void EVENT_USB_Device_StartOfFrame(void)
if (++count % 50) return; if (++count % 50) return;
count = 0; count = 0;
if (!console_flush) return; //if (!console_flush) return;
Console_Task(); Console_Task();
console_flush = false; //console_flush = false;
} }
#endif #endif
@@ -440,11 +471,9 @@ void EVENT_USB_Device_ConfigurationChanged(void)
/* Setup Console HID Report Endpoints */ /* Setup Console HID Report Endpoints */
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#if 0
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#endif #endif
#endif
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
/* Setup NKRO HID Report Endpoints */ /* Setup NKRO HID Report Endpoints */