Skip to content

Commit a046e8d

Browse files
committed
GIGA touch - convert callback to simple forward instead of processing in the fixups.c
Also add clear out the callback in the initVariant such that if new program is launched it does not use old address
1 parent 8d40a21 commit a046e8d

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

loader/fixups.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,34 @@ SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT)
4848
#include <zephyr/input/input.h>
4949

5050
// experiment to try to capture touch screen events
51+
#define GIGA_TOUCH_SET_CB
52+
#ifdef GIGA_TOUCH_SET_CB
53+
// This version we just register a callback function with the zephyr
54+
// object, which then allows are Arduino Code to register a call back
55+
// to be called...
56+
57+
58+
void (*_giga_touch_callback)(struct input_event *evt, void *user_data) = 0;
59+
60+
void registerGigaTouchCallback(void (*cb)(struct input_event *evt, void *user_data)) {
61+
_giga_touch_callback = cb;
62+
}
63+
64+
65+
void touch_event_callback(struct input_event *evt, void *user_data)
66+
{
67+
//printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
68+
// evt->dev, evt->sync, evt->type, evt->code, evt->value);
69+
if (_giga_touch_callback) {
70+
(*_giga_touch_callback)(evt, user_data);
71+
72+
}
73+
}
74+
#else
5175
typedef struct {
52-
int32_t x;
53-
int32_t y;
54-
int32_t pressed;
76+
size_t x;
77+
size_t y;
78+
bool pressed;
5579
} touch_point_t;
5680

5781
touch_point_t last_touch_point;
@@ -84,18 +108,22 @@ void touch_event_callback(struct input_event *evt, void *user_data)
84108
k_sem_give(&touch_event_sync);
85109
}
86110
}
111+
#endif
112+
87113
static const struct device *const touch_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_touch));
88114
INPUT_CALLBACK_DEFINE(touch_dev, touch_event_callback, NULL);
89115

90116

117+
91118
int camera_ext_clock_enable(void)
92119
{
93120
int ret;
94121
uint32_t rate;
95122

123+
#ifndef GIGA_TOUCH_SET_CB
96124
// Hack in init semaphore for touch events
97125
k_sem_init(&touch_event_sync, 0, 1);
98-
126+
#endif
99127

100128
const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));
101129

loader/llext_exports.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ FORCE_EXPORT_SYM(video_buffer_release);
132132
FORCE_EXPORT_SYM(video_set_ctrl);
133133
#endif
134134
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_VIDEO)
135-
FORCE_EXPORT_SYM(getVideoTouchEvent)
135+
//FORCE_EXPORT_SYM(getVideoTouchEvent);
136+
FORCE_EXPORT_SYM(registerGigaTouchCallback);
137+
136138
#endif
137139

138140
#if defined(CONFIG_SHARED_MULTI_HEAP)

variants/arduino_giga_r1_stm32h747xx_m7/variant.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ void _on_1200_bps() {
66
*(__IO uint32_t *)tmp = (uint32_t)0xDF59;
77
NVIC_SystemReset();
88
}
9+
10+
extern "C" void registerGigaTouchCallback(void (*cb)(struct input_event *evt, void *user_data));
11+
void initVariant(void) {
12+
// Make sure to set to NULL in case previous sketch or pvevious build of sketch
13+
// set a callback, whoes pointer may not be valid
14+
registerGigaTouchCallback(nullptr);
15+
}

0 commit comments

Comments
 (0)