From 5ff305e41292dab15fbe96047d59536a0e776d10 Mon Sep 17 00:00:00 2001
From: moon2 <moon2protonmail@protonmail.com>
Date: Sun, 23 Apr 2023 17:46:23 +0200
Subject: [PATCH] crappy captouch in c

---
 badge23/captouch.c | 7 +++++++
 badge23/captouch.h | 2 ++
 badge23/espan.c    | 7 ++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/badge23/captouch.c b/badge23/captouch.c
index c277cf87e5..b84205da74 100644
--- a/badge23/captouch.c
+++ b/badge23/captouch.c
@@ -2,6 +2,7 @@
 //#include <string.h>
 #include "esp_log.h"
 #include "driver/i2c.h"
+#include <stdint.h>
 
 
 static const char *TAG = "captouch";
@@ -153,6 +154,12 @@ static void IRAM_ATTR gpio_isr_handler(void* arg)
     xQueueSendFromISR(gpio_evt_queue, &chip, NULL);
 }
 
+void manual_captouch_readout(uint8_t top)
+{
+    struct ad714x_chip* chip = top ? (&chip_top) : (&chip_bot);
+    xQueueSendFromISR(gpio_evt_queue, &chip, NULL);
+}
+
 void espan_handle_captouch(uint16_t pressed_top, uint16_t pressed_bot);
 
 static uint16_t pressed_top, pressed_bot;
diff --git a/badge23/captouch.h b/badge23/captouch.h
index 8c3ff2aaf6..6a4ef88db4 100644
--- a/badge23/captouch.h
+++ b/badge23/captouch.h
@@ -1,6 +1,8 @@
 #pragma once
+#include <stdint.h>
 
 void captouch_init(void);
 void captouch_print_debug_info(void);
 void gpio_event_handler(void * arg);
+void manual_captouch_readout(uint8_t top);
 void captouch_get_cross(int paddle, int * x, int * y);
diff --git a/badge23/espan.c b/badge23/espan.c
index 08caaa49f9..36f6c60bd2 100644
--- a/badge23/espan.c
+++ b/badge23/espan.c
@@ -100,7 +100,7 @@ void os_app_main(void)
     audio_init();
     leds_init();
     //display_init();
-    //captouch_init();
+    captouch_init();
 
     mp_hal_stdout_tx_str("task inits done\n\r");
     //play_bootsound();
@@ -115,6 +115,11 @@ void os_app_main(void)
     int i = 0;
     void * asdasd = &i;
     while(1) {
+        manual_captouch_readout(1);
+        vTaskDelay(10 / portTICK_PERIOD_MS);
+        manual_captouch_readout(0);
+        vTaskDelay(10 / portTICK_PERIOD_MS);
+
         continue;
         i = (i + 1) % 10;
         if(!(i == 2 || i == 8)) continue;
-- 
GitLab