Skip to content

Commit 412c1c1

Browse files
authored
Merge pull request vial-kb#1 from jjggzhou:futabargb
STRENGTH_THRESHOLD
2 parents 4077d69 + e3f75b0 commit 412c1c1

File tree

9 files changed

+209
-18
lines changed

9 files changed

+209
-18
lines changed

keyboards/futaba/config.h

+13
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@
1717
#define MOUSE_EXTENDED_REPORT
1818

1919
// #define POINTING_DEVICE_DEBUG
20+
#define AZOTEQ_IQS5XX_PRESS_AND_HOLD_ENABLE true
21+
// #define POINTING_DEVICE_DEBUG
22+
23+
24+
#define DRV2605L_FB_ERM_LRA 1
25+
#define DRV2605L_FB_BRAKEFACTOR 6 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
26+
#define DRV2605L_FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
27+
28+
/* Please refer to your datasheet for the optimal setting for your specific motor. */
29+
#define DRV2605L_RATED_VOLTAGE 3
30+
#define DRV2605L_V_RMS 3
31+
#define DRV2605L_V_PEAK 3
32+
#define DRV2605L_F_LRA 220 /* resonance freq */

keyboards/futaba/gr_trackpad65_driver.c

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "timer.h"
2828
#include "gr_trackpad65_driver.h"
2929
#include <math.h>
30+
#include "drivers/haptic/drv2605l.h"
3031

3132
#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
3233
#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt)))
@@ -295,6 +296,7 @@ touch_state_t get_touch_state(trackpad_base_data_t *trackpad_data) {
295296
if (trackpad_data->touch_strength == 0) {
296297
return touch_state_none;
297298
} else if (trackpad_data->touch_strength >= FUTABA_TAP_STRENGTH_THRESHOLD) {
299+
drv2605l_pulse(1);
298300
return touch_state_press;
299301
}
300302
return touch_state_touch;

keyboards/futaba/gr_trackpad65_driver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const static int8_t FUTABA_SWIPE_THRESHOLD_PIXEL = 20;
9595
const static uint16_t FUTABA_MAX_GESTURE_ACTIVE_TIME = 1000;
9696
const static uint16_t FUTABA_RETAP_WAITING_TIME = 300;
9797
// 必ずpressにする閾値
98-
const static uint16_t FUTABA_TAP_STRENGTH_THRESHOLD = 850;
98+
const static uint16_t FUTABA_TAP_STRENGTH_THRESHOLD = 800;
9999
// 弱いタッチでもクリックにする時間の最大値
100100
const static uint16_t FUTABA_MAX_TAP_TIME = 200;
101101

keyboards/futaba/keyboard.json

+124-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"extrakey": true,
1212
"mousekey": true,
1313
"nkro": true,
14-
"encoder": true
14+
"rgb_matrix": true,
15+
"haptic": true
1516
},
1617
"matrix_pins": {
1718
"cols": ["GP4", "GP1", "GP0", "GP7", "GP6", "GP5"],
@@ -24,15 +25,129 @@
2425
"pid": "0x0000",
2526
"vid": "0xFEED"
2627
},
27-
"encoder": {
28-
"rotary": [
29-
{
30-
"pin_a": "GP13",
31-
"pin_b" : "GP14",
32-
"resolution" : 2
33-
}
34-
]
28+
29+
"ws2812": {
30+
"driver": "vendor",
31+
"pin": "GP12"
3532
},
33+
34+
"rgb_matrix": {
35+
"driver": "ws2812",
36+
"timeout": 120000,
37+
"max_brightness": 160,
38+
"sleep": true,
39+
"hue_steps": 4,
40+
"sat_steps": 4,
41+
"val_steps": 4,
42+
"speed_steps": 4,
43+
"default": {
44+
"animation": "cycle_out_in"
45+
},
46+
"animations": {
47+
"alphas_mods": true,
48+
"gradient_up_down": true,
49+
"gradient_left_right": true,
50+
"breathing": true,
51+
"band_sat": true,
52+
"band_val": true,
53+
"band_pinwheel_sat": true,
54+
"band_pinwheel_val": true,
55+
"band_spiral_sat": true,
56+
"band_spiral_val": true,
57+
"cycle_all": true,
58+
"cycle_left_right": true,
59+
"cycle_up_down": true,
60+
"cycle_out_in": true,
61+
"cycle_out_in_dual": true,
62+
"rainbow_moving_chevron": true,
63+
"cycle_pinwheel": true,
64+
"cycle_spiral": true,
65+
"dual_beacon": true,
66+
"rainbow_beacon": true,
67+
"rainbow_pinwheels": true,
68+
"raindrops": true,
69+
"jellybean_raindrops": true,
70+
"hue_breathing": true,
71+
"hue_pendulum": true,
72+
"hue_wave": true,
73+
"pixel_fractal": true,
74+
"pixel_flow": true,
75+
"pixel_rain": true,
76+
"typing_heatmap": true,
77+
"digital_rain": true,
78+
"solid_reactive_simple": true,
79+
"solid_reactive": true,
80+
"solid_reactive_wide": true,
81+
"solid_reactive_multiwide": true,
82+
"solid_reactive_cross": true,
83+
"solid_reactive_multicross": true,
84+
"solid_reactive_nexus": true,
85+
"solid_reactive_multinexus": true,
86+
"splash": true,
87+
"multisplash": true,
88+
"solid_splash": true,
89+
"solid_multisplash": true,
90+
"starlight": true,
91+
"starlight_dual_sat": true,
92+
"starlight_dual_hue": true,
93+
"riverflow": true
94+
},
95+
96+
"layout": [
97+
{"matrix": [7, 5], "x": 140, "y": 30, "flags": 4},
98+
{"matrix": [7, 4], "x": 160, "y": 30, "flags": 4},
99+
{"matrix": [7, 3], "x": 180, "y": 30, "flags": 4},
100+
{"matrix": [7, 2], "x": 200, "y": 30, "flags": 4},
101+
{"matrix": [7, 1], "x": 224, "y": 30, "flags": 4},
102+
{"matrix": [6, 0], "x": 224, "y": 20, "flags": 4},
103+
{"matrix": [5, 0], "x": 224, "y": 10, "flags": 4},
104+
{"matrix": [4, 0], "x": 224, "y": 0, "flags": 4},
105+
{"matrix": [4, 1], "x": 200, "y": 0, "flags": 4},
106+
{"matrix": [5, 1], "x": 200, "y": 10, "flags": 4},
107+
{"matrix": [6, 1], "x": 200, "y": 20, "flags": 4},
108+
{"matrix": [6, 2], "x": 180, "y": 20, "flags": 4},
109+
{"matrix": [5, 2], "x": 180, "y": 10, "flags": 4},
110+
{"matrix": [4, 2], "x": 180, "y": 0, "flags": 4},
111+
{"matrix": [4, 3], "x": 160, "y": 0, "flags": 4},
112+
{"matrix": [5, 3], "x": 160, "y": 10, "flags": 4},
113+
{"matrix": [6, 3], "x": 160, "y": 20, "flags": 4},
114+
{"matrix": [6, 4], "x": 140, "y": 20, "flags": 4},
115+
{"matrix": [5, 4], "x": 140, "y": 10, "flags": 4},
116+
{"matrix": [4, 4], "x": 140, "y": 0, "flags": 4},
117+
{"matrix": [4, 5], "x": 120, "y": 0, "flags": 4},
118+
{"matrix": [5, 5], "x": 120, "y": 10, "flags": 4},
119+
{"matrix": [6, 5], "x": 120, "y": 20, "flags": 4},
120+
121+
{"matrix": [8, 2], "x": 120, "y": 0, "flags": 4},
122+
{"matrix": [8, 1], "x": 120, "y": 0, "flags": 4},
123+
{"matrix": [8, 0], "x": 120, "y": 0, "flags": 4},
124+
125+
{"matrix": [0, 5], "x": 100, "y": 0, "flags": 4},
126+
{"matrix": [1, 5], "x": 100, "y": 10, "flags": 4},
127+
{"matrix": [2, 5], "x": 100, "y": 20, "flags": 4},
128+
{"matrix": [2, 4], "x": 80, "y": 20, "flags": 4},
129+
{"matrix": [1, 4], "x": 80, "y": 10, "flags": 4},
130+
{"matrix": [0, 4], "x": 80, "y": 0, "flags": 4},
131+
{"matrix": [0, 3], "x": 60, "y": 0, "flags": 4},
132+
{"matrix": [1, 3], "x": 60, "y": 10, "flags": 4},
133+
{"matrix": [2, 3], "x": 60, "y": 20, "flags": 4},
134+
{"matrix": [2, 2], "x": 40, "y": 20, "flags": 4},
135+
{"matrix": [1, 2], "x": 40, "y": 10, "flags": 4},
136+
{"matrix": [0, 2], "x": 40, "y": 0, "flags": 4},
137+
{"matrix": [0, 1], "x": 20, "y": 0, "flags": 4},
138+
{"matrix": [1, 1], "x": 20, "y": 10, "flags": 4},
139+
{"matrix": [2, 1], "x": 20, "y": 20, "flags": 4},
140+
{"matrix": [2, 0], "x": 0, "y": 20, "flags": 4},
141+
{"matrix": [1, 0], "x": 0, "y": 10, "flags": 4},
142+
{"matrix": [0, 0], "x": 0, "y": 0, "flags": 4},
143+
{"matrix": [3, 1], "x": 0, "y": 30, "flags": 4},
144+
{"matrix": [3, 2], "x": 20, "y": 30, "flags": 4},
145+
{"matrix": [3, 3], "x": 40, "y": 30, "flags": 4},
146+
{"matrix": [3, 4], "x": 60, "y": 30, "flags": 4},
147+
{"matrix": [3, 5], "x": 80, "y": 30, "flags": 4}
148+
]
149+
},
150+
36151
"layouts": {
37152
"LAYOUT": {
38153
"layout": [

keyboards/futaba/keymaps/default/keymap.c

+32
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include QMK_KEYBOARD_H
55
#include <print.h>
6+
#include "drivers/haptic/drv2605l.h"
67
#include "gr_trackpad65_driver.h"
78

89
enum my_keycodes {
@@ -70,6 +71,7 @@ void keyboard_post_init_user(void) {
7071
//debug_matrix = true;
7172
//debug_keyboard = true;
7273
//debug_mouse = true;
74+
drv2605l_pulse(43);
7375
}
7476

7577
typedef enum {
@@ -149,3 +151,33 @@ report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
149151

150152
return mouse_report;
151153
}
154+
155+
layer_state_t layer_state_set_user(layer_state_t state) {
156+
157+
switch (get_highest_layer(state)) {
158+
159+
case 0:
160+
rgb_matrix_sethsv_noeeprom((rgb_matrix_get_hue() + 21) % 255, rgb_matrix_get_sat(), rgb_matrix_get_val());
161+
break;
162+
case 1:
163+
rgb_matrix_sethsv_noeeprom((rgb_matrix_get_hue() + 234) % 255, rgb_matrix_get_sat(), rgb_matrix_get_val());
164+
break;
165+
case 2:
166+
rgb_matrix_sethsv_noeeprom((rgb_matrix_get_hue() + 116) % 255, rgb_matrix_get_sat(), rgb_matrix_get_val());
167+
break;
168+
default: // 他の全てのレイヤーあるいはデフォルトのレイヤー
169+
rgb_matrix_reload_from_eeprom();
170+
break;
171+
}
172+
return state;
173+
}
174+
175+
bool rgb_matrix_indicators_kb(void) {
176+
if (!rgb_matrix_indicators_user()) {
177+
return false;
178+
}
179+
if (host_keyboard_led_state().caps_lock) {
180+
rgb_matrix_set_color(0, 255, 0, 0);
181+
}
182+
return true;
183+
}

keyboards/futaba/keymaps/vial/keymap.c

+32-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include QMK_KEYBOARD_H
55
#include <print.h>
6+
#include "drivers/haptic/drv2605l.h"
67
#include "gr_trackpad65_driver.h"
78

89
enum my_keycodes {
@@ -57,19 +58,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
5758
)
5859
};
5960

60-
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
61-
[0] = { ENCODER_CCW_CW(KC_UP, KC_DOWN) },
62-
[1] = { ENCODER_CCW_CW(KC_LEFT, KC_RGHT) },
63-
[2] = { ENCODER_CCW_CW(KC_KB_VOLUME_UP, KC_KB_VOLUME_DOWN) },
64-
[3] = { ENCODER_CCW_CW(KC_UP, KC_DOWN) }
65-
};
6661

6762
void keyboard_post_init_user(void) {
6863
// Customise these values to desired behaviour
6964
debug_enable = true;
7065
//debug_matrix = true;
7166
//debug_keyboard = true;
7267
//debug_mouse = true;
68+
drv2605l_pulse(43);
7369
}
7470

7571
typedef enum {
@@ -149,3 +145,33 @@ report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
149145

150146
return mouse_report;
151147
}
148+
149+
layer_state_t layer_state_set_user(layer_state_t state) {
150+
151+
switch (get_highest_layer(state)) {
152+
153+
case 0:
154+
rgb_matrix_sethsv_noeeprom((rgb_matrix_get_hue() + 21) % 255, rgb_matrix_get_sat(), rgb_matrix_get_val());
155+
break;
156+
case 1:
157+
rgb_matrix_sethsv_noeeprom((rgb_matrix_get_hue() + 234) % 255, rgb_matrix_get_sat(), rgb_matrix_get_val());
158+
break;
159+
case 2:
160+
rgb_matrix_sethsv_noeeprom((rgb_matrix_get_hue() + 116) % 255, rgb_matrix_get_sat(), rgb_matrix_get_val());
161+
break;
162+
default: // 他の全てのレイヤーあるいはデフォルトのレイヤー
163+
rgb_matrix_reload_from_eeprom();
164+
break;
165+
}
166+
return state;
167+
}
168+
169+
bool rgb_matrix_indicators_kb(void) {
170+
if (!rgb_matrix_indicators_user()) {
171+
return false;
172+
}
173+
if (host_keyboard_led_state().caps_lock) {
174+
rgb_matrix_set_color(0, 255, 0, 0);
175+
}
176+
return true;
177+
}
+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VIA_ENABLE = yes
22
VIAL_ENABLE = yes
3+
VIALRGB_ENABLE = yes

keyboards/futaba/keymaps/vial/vial.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Futaba",
3-
"lighting": "none",
3+
"lighting": "vialrgb",
44
"customKeycodes": [
55
{
66
"shortName": "CHi",

keyboards/futaba/rules.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ POINTING_DEVICE_ENABLE = yes
44
# MOUSEKEY_ENABLE = yes
55
POINTING_DEVICE_DRIVER = custom
66

7-
ENCODER_MAP_ENABLE = yes
7+
88
I2C_DRIVER_REQUIRED = yes
99
SRC += azoteq_iqs5xx.c
1010
SRC += gr_trackpad65_driver.c
11+
12+
HAPTIC_DRIVER = drv2605l

0 commit comments

Comments
 (0)