Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil committed Aug 7, 2023
1 parent ce4deaa commit 7162723
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/usb.c)
target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.c)
target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c)
target_sources_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/backlight.c)
target_sources_ifdef(CONFIG_ZMK_TRACKPAD app PRIVATE src/trackpad.c)
target_sources(app PRIVATE src/main.c)

add_subdirectory(src/display/)
Expand Down
4 changes: 4 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ config ZMK_BACKLIGHT_AUTO_OFF_USB
#ZMK_BACKLIGHT
endif

config ZMK_TRACKPAD
bool "Enable the trackpad HID reporting and processing"
default n

#Display/LED Options
endmenu

Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/bt60/bt60.dts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
compatible = "cirque,gen4";
status = "okay";
reg = <0x2C>;
dr-gpios = <&gpio0 17 (GPIO_ACTIVE_LOW)>;
dr-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
rotate-90;
sleep;
};
Expand Down
2 changes: 2 additions & 0 deletions app/boards/arm/bt60/bt60_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ CONFIG_PINCTRL=y

CONFIG_ZMK_USB_LOGGING=y

CONFIG_ZMK_TRACKPAD=y
CONFIG_I2C=y
CONFIG_GEN4=y
CONFIG_GEN4_TRIGGER_GLOBAL_THREAD=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y


CONFIG_USE_DT_CODE_PARTITION=y
Expand Down
8 changes: 5 additions & 3 deletions app/drivers/sensor/gen4/gen4.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int gen4_channel_get(const struct device *dev, enum sensor_channel chan,
}

static int gen4_sample_fetch(const struct device *dev, enum sensor_channel) {
uint8_t packet[53];
uint8_t packet[54];
int ret;
ret = gen4_normal_read(dev, packet, 52);
if (ret < 0) {
Expand Down Expand Up @@ -176,11 +176,11 @@ static int gen4_trigger_set(const struct device *dev, const struct sensor_trigge

static void gen4_int_cb(const struct device *dev) {
struct gen4_data *data = dev->data;
set_int(dev, false);

LOG_DBG("Gen4 interrupt trigd: %d", 0);
gen4_sample_fetch(dev, 0);
data->data_ready_handler(dev, data->data_ready_trigger);
set_int(dev, true);
data->in_int = false;
}

#ifdef CONFIG_GEN4_TRIGGER_OWN_THREAD
Expand All @@ -203,6 +203,7 @@ static void gen4_work_cb(struct k_work *work) {
static void gen4_gpio_cb(const struct device *port, struct gpio_callback *cb, uint32_t pins) {
struct gen4_data *data = CONTAINER_OF(cb, struct gen4_data, gpio_cb);
data->in_int = true;
LOG_DBG("Interrupt trigd");
#if defined(CONFIG_GEN4_TRIGGER_OWN_THREAD)
k_sem_give(&data->gpio_sem);
#elif defined(CONFIG_GEN4_TRIGGER_GLOBAL_THREAD)
Expand Down Expand Up @@ -236,6 +237,7 @@ static int gen4_init(const struct device *dev) {
#elif defined(CONFIG_GEN4_TRIGGER_GLOBAL_THREAD)
k_work_init(&data->work, gen4_work_cb);
#endif
set_int(dev, true);
#endif
LOG_WRN("inited");
return 0;
Expand Down
35 changes: 35 additions & 0 deletions app/src/trackpad.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <zephyr/drivers/sensor.h>
#include <zephyr/logging/log.h>

#include "zmk/hid.h"
#include "zmk/endpoints.h"
#include "drivers/sensor/gen4.h"

LOG_MODULE_REGISTER(trackpad, CONFIG_SENSOR_LOG_LEVEL);

const struct device *trackpad = DEVICE_DT_GET(DT_INST(0, cirque_gen4));

static void handle_trackpad(const struct device *dev, const struct sensor_trigger *trig) {
static uint8_t last_pressed = 0;
int ret = sensor_sample_fetch(dev);
if (ret < 0) {
LOG_ERR("fetch: %d", ret);
return;
}
LOG_DBG("Trackpad handler trigd %d", 0);
}

static int trackpad_init() {
struct sensor_trigger trigger = {
.type = SENSOR_TRIG_DATA_READY,
.chan = SENSOR_CHAN_ALL,
};
printk("trackpad");
if (sensor_trigger_set(trackpad, &trigger, handle_trackpad) < 0) {
LOG_ERR("can't set trigger");
return -EIO;
};
return 0;
}

SYS_INIT(trackpad_init, APPLICATION, CONFIG_ZMK_KSCAN_INIT_PRIORITY);

0 comments on commit 7162723

Please sign in to comment.