Skip to content

Commit 06236ba

Browse files
committed
drivers: ht16k33: convert from kscan to input
Convert the ht16k33 to use the input subsystem. This can still be used with the kscan API with the zephyr,kscan-input driver, or use the input-keymap one to generate input codes instead. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent eef3e85 commit 06236ba

File tree

11 files changed

+11
-141
lines changed

11 files changed

+11
-141
lines changed

drivers/kscan/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/kscan.h)
44

55
zephyr_library()
66

7-
zephyr_library_sources_ifdef(CONFIG_KSCAN_HT16K33 kscan_ht16k33.c)
87
zephyr_library_sources_ifdef(CONFIG_KSCAN_INPUT kscan_input.c)
98

109
zephyr_library_sources_ifdef(CONFIG_USERSPACE kscan_handlers.c)

drivers/kscan/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ menuconfig KSCAN
1010

1111
if KSCAN
1212

13-
source "drivers/kscan/Kconfig.ht16k33"
1413
source "drivers/kscan/Kconfig.input"
1514

1615
module = KSCAN

drivers/kscan/Kconfig.ht16k33

Lines changed: 0 additions & 13 deletions
This file was deleted.

drivers/kscan/kscan_ht16k33.c

Lines changed: 0 additions & 63 deletions
This file was deleted.

drivers/led/Kconfig.ht16k33

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ menuconfig HT16K33
1515

1616
config HT16K33_KEYSCAN
1717
bool "Keyscan support"
18-
depends on (HT16K33 && KSCAN)
19-
select KSCAN_HT16K33
18+
depends on (HT16K33 && INPUT)
2019
help
2120
Enable keyscan child device support in the HT16K33 LED
2221
driver.

drivers/led/ht16k33.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
#include <zephyr/drivers/gpio.h>
1515
#include <zephyr/drivers/i2c.h>
16+
#include <zephyr/input/input.h>
1617
#include <zephyr/kernel.h>
1718
#include <zephyr/drivers/led.h>
18-
#include <zephyr/drivers/led/ht16k33.h>
1919
#include <zephyr/sys/byteorder.h>
2020
#include <zephyr/logging/log.h>
2121

@@ -77,7 +77,6 @@ struct ht16k33_data {
7777
#ifdef CONFIG_HT16K33_KEYSCAN
7878
struct k_mutex lock;
7979
const struct device *child;
80-
kscan_callback_t kscan_cb;
8180
struct gpio_callback irq_cb;
8281
struct k_thread irq_thread;
8382
struct k_sem irq_sem;
@@ -230,15 +229,13 @@ static bool ht16k33_process_keyscan_data(const struct device *dev)
230229
pressed = true;
231230
}
232231

233-
if (data->kscan_cb == NULL) {
234-
continue;
235-
}
236-
237232
for (col = 0; col < HT16K33_KEYSCAN_COLS; col++) {
238-
if (changed & BIT(col)) {
239-
data->kscan_cb(data->child, row, col,
240-
state & BIT(col));
233+
if ((changed & BIT(col)) == 0) {
234+
continue;
241235
}
236+
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
237+
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
238+
input_report_key(dev, INPUT_BTN_TOUCH, state & BIT(col), true, K_FOREVER);
242239
}
243240
}
244241

@@ -285,20 +282,6 @@ static void ht16k33_timer_callback(struct k_timer *timer)
285282
data = CONTAINER_OF(timer, struct ht16k33_data, timer);
286283
k_sem_give(&data->irq_sem);
287284
}
288-
289-
int ht16k33_register_keyscan_callback(const struct device *parent,
290-
const struct device *child,
291-
kscan_callback_t callback)
292-
{
293-
struct ht16k33_data *data = parent->data;
294-
295-
k_mutex_lock(&data->lock, K_FOREVER);
296-
data->child = child;
297-
data->kscan_cb = callback;
298-
k_mutex_unlock(&data->lock);
299-
300-
return 0;
301-
}
302285
#endif /* CONFIG_HT16K33_KEYSCAN */
303286

304287
static int ht16k33_init(const struct device *dev)

dts/bindings/kscan/holtek,ht16k33-keyscan.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

include/zephyr/drivers/led/ht16k33.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

samples/drivers/ht16k33/boards/nrf52840dk_nrf52840.overlay

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
/* Uncomment to use IRQ instead of polling: */
1414
/* irq-gpios = <&gpio1 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; */
1515

16-
keyscan {
17-
compatible = "holtek,ht16k33-keyscan";
16+
kscan-input {
17+
compatible = "zephyr,kscan-input";
1818
};
1919
};
2020
};

samples/drivers/ht16k33/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ CONFIG_LOG=y
22
CONFIG_I2C=y
33
CONFIG_LED=y
44
CONFIG_KSCAN=y
5-
CONFIG_KSCAN_INIT_PRIORITY=95
5+
CONFIG_INPUT=y
66
CONFIG_HT16K33_KEYSCAN=y

0 commit comments

Comments
 (0)