summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-06-11 16:22:12 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-06-11 20:09:38 +0100
commitd01f3192f2a1a34d28ee701e8c397cd7f1827b88 (patch)
treea59688babe7fe4d62857a36af7c38ca2348ab7b5 /firmware/export
parent551c74da55dc15238e76713d7477e7e4bfda60ef (diff)
Spin off common ft6x06 code to a driver
Allows for the i2c boilerplate to be shared between the M3K and Shanling Q1 ports. M3K-specific quirks remain in button-fiiom3k. Change-Id: I8879b603cefc16416bb200f1c484ca916d935c6a
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/config/fiiom3k.h2
-rw-r--r--firmware/export/ft6x06.h50
2 files changed, 52 insertions, 0 deletions
diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h
index a28efd43a5..849aa9c0a6 100644
--- a/firmware/export/config/fiiom3k.h
+++ b/firmware/export/config/fiiom3k.h
@@ -22,6 +22,8 @@
/* Drivers */
#define HAVE_I2C_ASYNC
+#define HAVE_FT6x06
+#define FT6x06_SWAP_AXES
/* Buffer for plugins and codecs. */
#define PLUGIN_BUFFER_SIZE 0x200000 /* 2 MiB */
diff --git a/firmware/export/ft6x06.h b/firmware/export/ft6x06.h
new file mode 100644
index 0000000000..de1fdd0979
--- /dev/null
+++ b/firmware/export/ft6x06.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2021 Aidan MacDonald
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __FT6x06_H__
+#define __FT6x06_H__
+
+#include "config.h"
+#include <stdbool.h>
+
+typedef void(*ft6x06_event_cb)(int, int, int);
+
+struct ft6x06_state {
+ int event;
+ int pos_x;
+ int pos_y;
+};
+
+enum ft6x06_event {
+ FT6x06_EVT_NONE = -1,
+ FT6x06_EVT_PRESS = 0,
+ FT6x06_EVT_RELEASE = 1,
+ FT6x06_EVT_CONTACT = 2,
+};
+
+extern struct ft6x06_state ft6x06_state;
+
+void ft6x06_init(void);
+void ft6x06_set_event_cb(ft6x06_event_cb fn);
+void ft6x06_enable(bool en);
+void ft6x06_irq_handler(void);
+
+#endif /* __FT6x06_H__ */