File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,19 @@ config ENABLE_ENCODER
5050 help
5151 Select this to enable encoder input.
5252
53+ choice EC_TYPE
54+ prompt "Encoder Type"
55+ default EC_TYPE_1P2D
56+ depends on ENABLE_ENCODER
57+ help
58+ Select the encoder type.
59+
60+ config EC_TYPE_1P1D
61+ bool "1-Pulse 1-Detent"
62+ config EC_TYPE_1P2D
63+ bool "1-Pulse 2-Detents"
64+ endchoice
65+
5366config EC_PHASE_A_PIN
5467 int "Encoder Phase A Pin"
5568 default 21
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ static void key_task(void *pvParameter)
3939 portTickType xLastWakeTime ;
4040 bool phase_a_p = false;
4141 bool phase_a_n = false;
42+ #ifdef CONFIG_EC_TYPE_1P2D
4243 bool phase_b_p = false;
44+ #endif
4345 bool phase_b_n = false;
4446 bool button_n = false;
4547 uint32_t fan_evt = 0 ;
@@ -66,6 +68,15 @@ static void key_task(void *pvParameter)
6668 fan_evt = EC_EVT_N ;
6769
6870 if (phase_a_n != phase_a_p ) {
71+ #ifdef CONFIG_EC_TYPE_1P1D
72+ if (!phase_a_n ) {
73+ if (phase_b_n ) {
74+ fan_evt = EC_EVT_I ;
75+ } else {
76+ fan_evt = EC_EVT_D ;
77+ }
78+ }
79+ #else
6980 if (phase_a_n ) {
7081 if (phase_b_p & !phase_b_n ) {
7182 fan_evt = EC_EVT_I ;
@@ -93,9 +104,9 @@ static void key_task(void *pvParameter)
93104 fan_evt = EC_EVT_I ;
94105 }
95106 }
96-
97- phase_a_p = phase_a_n ;
98107 phase_b_p = phase_b_n ;
108+ #endif
109+ phase_a_p = phase_a_n ;
99110 }
100111
101112 if (!button_n ) {
You can’t perform that action at this time.
0 commit comments