aboutsummaryrefslogtreecommitdiff
path: root/docs/ja/feature_encoders.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ja/feature_encoders.md')
-rw-r--r--docs/ja/feature_encoders.md85
1 files changed, 85 insertions, 0 deletions
diff --git a/docs/ja/feature_encoders.md b/docs/ja/feature_encoders.md
new file mode 100644
index 000000000..b93d9a9a2
--- /dev/null
+++ b/docs/ja/feature_encoders.md
@@ -0,0 +1,85 @@
1# エンコーダ
2
3<!---
4 original document: 0.9.43:docs/feature_encoders.md
5 git diff 0.9.43 HEAD -- docs/feature_encoders.md | cat
6-->
7
8以下を `rules.mk` に追加することで基本的なエンコーダがサポートされます:
9
10```make
11ENCODER_ENABLE = yes
12```
13
14さらに、以下を `config.h` に追加します:
15
16```c
17#define ENCODERS_PAD_A { B12 }
18#define ENCODERS_PAD_B { B13 }
19```
20
21各 PAD_A/B 変数は配列を定義するため、複数のエンコーダを定義することができます。例えば:
22
23```c
24#define ENCODERS_PAD_A { encoder1a, encoder2a }
25#define ENCODERS_PAD_B { encoder1b, encoder2b }
26```
27
28エンコーダの時計回りの方向が間違っている場合は、A と B のパッド定義を交換することができます。define を使って逆にすることもできます:
29
30```c
31#define ENCODER_DIRECTION_FLIP
32```
33
34さらに、エンコーダが各戻り止め(デテント)間に登録するパルス数を定義する解像度は、次のように定義できます:
35
36```c
37#define ENCODER_RESOLUTION 4
38```
39
40## 分割キーボード
41
42分割キーボードのそれぞれの側のエンコーダに異なるピン配列を使っている場合、右側のピン配列を以下のように定義することができます:
43
44```c
45#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
46#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
47```
48
49## コールバック
50
51コールバック関数を `<keyboard>.c` に記述することができます:
52
53```c
54bool encoder_update_kb(uint8_t index, bool clockwise) {
55 if (!encoder_update_user(index, clockwise)) {
56 return false;
57 }
58
59}
60```
61
62あるいは `keymap.c` に記述することもできます:
63
64```c
65bool encoder_update_user(uint8_t index, bool clockwise) {
66 if (index == 0) { /* First encoder */
67 if (clockwise) {
68 tap_code(KC_PGDN);
69 } else {
70 tap_code(KC_PGUP);
71 }
72 } else if (index == 1) { /* Second encoder */
73 if (clockwise) {
74 tap_code(KC_DOWN);
75 } else {
76 tap_code(KC_UP);
77 }
78 }
79 return false;
80}
81```
82
83## ハードウェア
84
85エンコーダの A と B の線は MCU に直接配線し、C/common 線はグランドに配線する必要があります。