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

Use top-right as origin #256 #16022

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
63efc20
Add chonkerkey POC
roxk Oct 11, 2021
6e7a08d
Temporarily set pid to 0x0001
roxk Oct 28, 2021
5d53767
Use different product IDs
roxk Nov 5, 2021
6de084b
Add chonkerkeys protocol
roxk Nov 25, 2021
4c4a783
Implement chonkerkeys protocol
roxk Nov 25, 2021
492c1ae
Fix protocol issue and remove some debug log
roxk Nov 26, 2021
14cc0e3
Fix chonkerkeys max not processing protocol
roxk Nov 26, 2021
9478730
Implement basic zoom layers
roxk Dec 6, 2021
0577be7
Add get version respose event #chonkerkeys/164
roxk Dec 7, 2021
56849d8
Add doc for get config #74
roxk Dec 8, 2021
672d4b8
Fix original pin and layout #chonkerkeys/6
roxk Dec 8, 2021
3759bcc
Fix macros not working #chonkerkeys/6
roxk Dec 8, 2021
404c3b7
Add config for protocol #chonkerkeys/74
roxk Dec 9, 2021
c6c7d52
Add get config response event #chonkerkeys/46
roxk Dec 9, 2021
aeb5ee1
Fix incorrect config and action type #chonkerkeys/74
roxk Dec 9, 2021
e86b486
Fix lint #chonkerkeys/74
roxk Dec 9, 2021
aad606a
Add doc for connect and keydown #chonkerkeys165
roxk Dec 9, 2021
decf026
Merge to add default layers, version/config protocol #chonkerkey/74
roxk Dec 9, 2021
684ea4c
Add connect command #chonkerkeys/165
roxk Dec 9, 2021
28e0ff3
Add keydown event #165
roxk Dec 9, 2021
141dbc0
Fix keys not working
roxk Dec 9, 2021
b2fb0c0
Fix reading keymap not working #chonkerkeys/165
roxk Dec 9, 2021
13a5eee
Merge to add connect and key down #chonkerkeys/165
roxk Dec 9, 2021
8c1026a
Update structure for generated config.c #chonkerkeys/10
roxk Dec 10, 2021
cb83dd3
Ignore config.c #chonkerkeys/10
roxk Dec 10, 2021
772b439
Merge to restructure for code generator #chonkerkeys/10
roxk Dec 10, 2021
f553ab9
Add reset command #chonkerkeys/201
roxk Dec 14, 2021
0700b6e
Merge to add reset command #chonokerkeys/201
roxk Dec 14, 2021
fdf88ff
Update keyboard action #chonkerkeys/180
roxk Dec 14, 2021
639a236
Merge to update keyboard action #chonkerkeys/180
roxk Dec 14, 2021
64fcfe7
Add macos keyconfig #chonkerkeys/206
roxk Dec 15, 2021
9a70c45
Fix camelCase name
roxk Dec 15, 2021
670c2da
Fix template not updating keyboard action
roxk Dec 15, 2021
db2d918
Fix zoom macros #chonkerkeys/211
roxk Dec 15, 2021
9b0cd4d
Merge to add macos keyboard actions #chonkerkeys/206
roxk Dec 15, 2021
6b79d65
Fix max firmware #chonkerkeys/211
roxk Dec 15, 2021
d3001d5
Merge to fix zoom macros and max #chonkerkeys/211 #191
roxk Dec 15, 2021
6fde485
Fix max pin #chonkerkeys/191
roxk Dec 17, 2021
3605fbd
Add RGB Strands skeleton code
9gel Jan 4, 2022
193bc50
Wired up ChonkerKeys to use RGB Strands
9gel Jan 4, 2022
0a3646d
All RGB strands working.
9gel Jan 4, 2022
aff6567
Limit Max LED brightness to save current.
9gel Jan 4, 2022
f79dd7c
Only do CH_ keycode if in range
9gel Jan 4, 2022
9747af5
RGB Strands don't use CIE1931 by default
9gel Jan 4, 2022
e9fd536
Add framework code for RGB Strand animations
9gel Jan 4, 2022
b511e38
Set RGB val smaller. Remove unused Max configs
9gel Jan 4, 2022
bd9d59f
Don't use CIE1931 for Max
9gel Jan 4, 2022
e1d87a6
Max use animations
9gel Jan 4, 2022
2d7e17d
Update light protocol doc #chonkerkeys/235
roxk Jan 5, 2022
c8a6422
Update ResetCommand and add msic fixes
roxk Jan 5, 2022
9bc7da4
Update set led protocol #chonkerkeys/234
roxk Jan 5, 2022
403c940
Merge to update set led protocol #chonkerkeys/234
roxk Jan 5, 2022
e4cb811
Implemented some RGB Strands animations
9gel Jan 5, 2022
bc15584
Use the latest RGB Strand animations.
9gel Jan 5, 2022
0d9f61f
Example to hook up CK protocol with lights
9gel Jan 5, 2022
438b24f
Change default blink times to 10
9gel Jan 5, 2022
d2381a9
Merge branch 'master' into rgb_strands
9gel Jan 6, 2022
1aba0b2
Merge pull request #11 from Chonkerkeys/rgb_strands
9gel Jan 6, 2022
88de96b
RGB strand implemented breathing and rainbow
9gel Jan 6, 2022
724950c
Change two max keys to rainbow and breathing
9gel Jan 6, 2022
6d2e998
Make original work with rgb_strands.
9gel Jan 6, 2022
920077f
Merge to add rgb strands new animation and original
roxk Jan 7, 2022
945b215
Move key_strand to keymap.c #chonkerkeys/262
roxk Jan 12, 2022
d03431a
Merge to move key_strand #chonkerkeys/262
roxk Jan 12, 2022
694146a
Fix not using per-layer key_anim #chonkerkeys/262
roxk Jan 13, 2022
01a5955
Merge to fix key_anim #chonkerkeys/262
roxk Jan 13, 2022
5d7388d
Integrate protocol with rgb strand #chonkekerkeys/262
roxk Jan 13, 2022
aee24cf
Merge to integrate protocol with rgb strand #chonkerkeys/262
roxk Jan 13, 2022
df4fc6f
Add off LED command #chonkerkeys/264
roxk Jan 13, 2022
c2464af
Implement off command #chonkerkeys/264
roxk Jan 13, 2022
e3dcbb9
Fix naming convention #chonkerkeys/262
roxk Jan 13, 2022
8010054
Merge to add off LED command #chonkerkey/264
roxk Jan 13, 2022
dcfb56f
Use momentary instead of static for steady #chonkerkeys/264
roxk Jan 13, 2022
a1b7aba
Merge to use momentary instead of static #chonkerkeys/264
roxk Jan 13, 2022
560dcf6
Add gen-config #chonkerkeys/266
roxk Jan 17, 2022
6f18a91
Add doc for gen #chonkerkeys/266
roxk Jan 17, 2022
f4aec5c
Add rest of the layer and key action macros
roxk Jan 19, 2022
5caab5b
Use bottom-row-left-most hotkeys for switch layer #chonkerkeys/277
roxk Jan 21, 2022
c1099cb
Use top-right as origin for original #chonkerkeys/256
roxk Jan 24, 2022
18994d1
Use top-right as original for max #256
roxk Jan 24, 2022
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
35 changes: 35 additions & 0 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,36 @@ endif
endif
endif

RGB_STRANDS_ENABLE ?= no
VALID_RGB_STRANDS_TYPES := WS2812

ifeq ($(strip $(RGB_STRANDS_CUSTOM_DRIVER)), yes)
RGB_STRANDS_DRIVER ?= custom
endif

ifeq ($(strip $(RGB_STRANDS_ENABLE)), yes)
RGB_STRANDS_DRIVER ?= WS2812

ifeq ($(filter $(RGB_STRANDS_DRIVER),$(VALID_RGB_STRANDS_TYPES)),)
$(error RGB_STRANDS_DRIVER="$(RGB_STRANDS_DRIVER)" is not a valid RGB strand type)
else
COMMON_VPATH += $(QUANTUM_DIR)/rgb_strands
POST_CONFIG_H += $(QUANTUM_DIR)/rgb_strands/rgb_strands_post_config.h
OPT_DEFS += -DRGB_STRANDS_ENABLE
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_strands/rgb_strands.c
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb_strands.c
endif

ifeq ($(strip $(RGB_STRANDS_DRIVER)), WS2812)
WS2812_STRANDS_DRIVER_REQUIRED := yes
endif

ifeq ($(strip $(RGB_STRANDS_DRIVER)), custom)
OPT_DEFS += -DRGB_STRANDS_CUSTOM_DRIVER
endif
endif

ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
endif
Expand Down Expand Up @@ -438,6 +468,11 @@ ifeq ($(strip $(APA102_DRIVER_REQUIRED)), yes)
SRC += apa102.c
endif

ifeq ($(strip $(WS2812_STRANDS_DRIVER_REQUIRED)), yes)
OPT_DEFS += -DWS2812_STRANDS_DRIVER
SRC += ws2812_strands.c
endif

ifeq ($(strip $(CIE1931_CURVE)), yes)
OPT_DEFS += -DUSE_CIE1931_CURVE
LED_TABLES := yes
Expand Down
31 changes: 31 additions & 0 deletions drivers/ws2812_strands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "ws2812.h"

/* User Interface
*
* Input:
* ledarray: An array of GRB data describing the LED colors
* number_of_leds: The number of LEDs to write
*
* The functions will perform the following actions:
* - Set the data-out pin as output
* - Send out the LED data
* - Wait 50us to reset the LEDs
*/
void ws2812_strand_setleds(uint8_t strand, LED_TYPE *ledarray, uint16_t number_of_leds);
1 change: 1 addition & 0 deletions keyboards/chonkerkeys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.c
26 changes: 26 additions & 0 deletions keyboards/chonkerkeys/command.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

struct command_get_version {
// no data
};
struct command_get_config {
// no data
};
struct command_connect {
// no data
};
struct command_reset {
// no data
};
struct command_set_led {
uint8_t type;
uint8_t key_x;
uint8_t key_y;
uint8_t r;
uint8_t g;
uint8_t b;
union animation_data_t {
uint8_t blink_frequency;
uint8_t momentary_duration_10ms;
} animation_data;
};
9 changes: 9 additions & 0 deletions keyboards/chonkerkeys/command_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

enum command_type {
command_type_get_version,
command_type_get_config,
command_type_connect,
command_type_reset,
command_type_set_led
};
170 changes: 170 additions & 0 deletions keyboards/chonkerkeys/core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#include "quantum.h"
#include "keyconfig.h"
#include "rgb_strands/rgb_strands.h"

// This file is not meant to be compiled directly, but included in keymap.c
// LAYER_COUNT, keymaps etc are defined in config.c

bool is_connected = false;

uint8_t get_layer_count() {
return LAYER_COUNT;
}

uint8_t get_layer_type(uint8_t index) {
return layers[index];
}

uint8_t get_key_size_and_ordinal(uint8_t layer, uint8_t x, uint8_t y) {
return key_size_and_ordinals[layer][y][x];
}

uint8_t get_key_action_type(uint8_t layer, uint8_t x, uint8_t y) {
return pgm_read_byte(&keymaps[layer][y][x]) - CH_CUSTOM;
}

uint32_t get_key_icon(uint8_t layer, uint8_t x, uint8_t y) {
// TODO: Confirm with client.
return 0;
}

bool is_windows(uint8_t layer) {
return layer % 2 == 0;
}

uint8_t get_current_layer(void) {
uint16_t current_layer = 0;
for (uint16_t i = 0; i < LAYER_COUNT; ++i) {
if (IS_LAYER_ON(i)) {
current_layer = i;
break;
}
}
return current_layer;
}

void switch_layer(void) {
uint8_t current_layer = get_current_layer();
layer_clear();
uint16_t next_layer = current_layer + 1;
if (next_layer >= LAYER_COUNT) {
next_layer = 0;
}
layer_on(next_layer);
}

void virtser_recv(uint8_t c) {
process_protocol(c);
}

void send_protocol(uint8_t c) {
virtser_send(c);
}

void on_connected() {
is_connected = true;
}

uint8_t from_x_y_to_index(uint8_t x, uint8_t y) {
return (y * MATRIX_COLS) + x;
}

void from_app_to_firmware_origin(uint8_t *x, uint8_t *y) {
// TODO: Flip x as well once w use top-right as origin
*x = MATRIX_COLS - 1 - *x;
*y = MATRIX_ROWS - 1 - *y;
}

void from_firmware_to_app_origin(uint8_t *x, uint8_t *y) {
// app to firmware is the reverse op of itself, so just call it once more
from_app_to_firmware_origin(x, y);
}

void start_key_anim(uint8_t x, uint8_t y, rgb_strands_anim_t anim) {
from_app_to_firmware_origin(&x, &y);
uint8_t rgb_strand = from_x_y_to_index(x, y);
rgb_strand_animation_start(rgb_strand, anim,
get_default_rgb_strand_anim_config(anim),
RGB_STRAND_ANIM_STATE_STEADY);
rgb_strand_animation_set_state(rgb_strand, RGB_STRAND_ANIM_STATE_START);
}

void set_led_off(uint8_t key_x, uint8_t key_y) {
start_key_anim(key_x, key_y, RGB_STRAND_EFFECT_NONE);
}

void set_led_steady(uint8_t key_x, uint8_t key_y, uint8_t r, uint8_t g, uint8_t b) {
// Seems STATIC isn't working, use momentary for now
// TODO: Fix STATIC
start_key_anim(key_x, key_y, RGB_STRAND_EFFECT_MOMENTARY);
}

void set_led_blink(uint8_t key_x, uint8_t key_y, uint8_t r, uint8_t g, uint8_t b, uint8_t frequency_tbc) {
start_key_anim(key_x, key_y, RGB_STRAND_EFFECT_BLINKY);
}

void set_led_like(uint8_t key_x, uint8_t key_y, uint8_t r, uint8_t g, uint8_t b) {
start_key_anim(key_x, key_y, RGB_STRAND_EFFECT_LIKE);
}

void set_led_leave_meeting(uint8_t key_x, uint8_t key_y, uint8_t r, uint8_t g, uint8_t b) {
start_key_anim(key_x, key_y, RGB_STRAND_EFFECT_DRAINSWIRL);
}

void set_led_momentary(uint8_t key_x, uint8_t key_y, uint8_t r, uint8_t g, uint8_t b, uint32_t duration_ms) {
start_key_anim(key_x, key_y, RGB_STRAND_EFFECT_MOMENTARY);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
static bool is_either_pressed = false;
uint8_t app_x = record->event.key.col;
uint8_t app_y = record->event.key.row;
// QMK uses top left as origin, but the app uses KU origin (i.e. bottom left) for switching layer
from_firmware_to_app_origin(&app_x, &app_y);
// Requirement is, use the bottom row and left-most keys as key-switching hotkey
if (app_y == 0 && app_x <= 1) {
if (record->event.pressed) {
if (is_either_pressed) {
switch_layer();
return false;
}
}
is_either_pressed = record->event.pressed;
}

uint8_t row = record->event.key.row;
uint8_t col = record->event.key.col;
uint8_t key_strand = from_x_y_to_index(col, row);
if (record->event.pressed) {
if (is_connected) {
key_down(get_current_layer(), app_x, app_y);
} else {
if (keycode > CH_CUSTOM && keycode < CH_LAST_KEYCODE) {
uint16_t key_config_index = keycode - CH_CUSTOM;
uint16_t current_layer = get_current_layer();
uint16_t const* keyMacros = is_windows(current_layer) ? windows_configs[key_config_index] : macos_configs[key_config_index];
for (uint32_t i = 0; i < KEY_MACROS_MAX_COUNT; ++i) {
uint16_t code = keyMacros[i];
if (code == KC_NO) continue;
register_code(code);
}
for (int32_t i = KEY_MACROS_MAX_COUNT - 1; i >= 0; --i) {
uint16_t code = keyMacros[i];
if (code == KC_NO) continue;
unregister_code(code);
}
} else {
register_code(keycode);
unregister_code(keycode);
}
uint8_t current_layer = get_current_layer();
rgb_strands_anim_t anim = key_anim[current_layer][row][col];
rgb_strand_animation_start(key_strand, anim,
get_default_rgb_strand_anim_config(anim),
RGB_STRAND_ANIM_STATE_STEADY);
}
} else { // released
rgb_strand_animation_set_state(key_strand, RGB_STRAND_ANIM_STATE_START);
}
return false;
}
11 changes: 11 additions & 0 deletions keyboards/chonkerkeys/event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

struct event_get_version_response {
uint32_t version;
};

struct event_key_down {
uint8_t layer;
uint8_t x;
uint8_t y;
};
7 changes: 7 additions & 0 deletions keyboards/chonkerkeys/event_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

enum event_type {
event_type_get_version_response,
event_type_get_config_response,
event_type_key_down
};
1 change: 1 addition & 0 deletions keyboards/chonkerkeys/gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.c
Loading