Skip to content

Commit 20a4caf

Browse files
committed
Starting touch support.
Note this branch is based off of commit 130 and hand modified the changes from arduino#117 it has a callback added from the touch controller which saves the last touch point and a call function, that allows you to retrieve the last notification
1 parent 03c28b7 commit 20a4caf

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

loader/fixups.c

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,58 @@ SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT)
4545
#include <zephyr/drivers/clock_control.h>
4646
#include <zephyr/logging/log.h>
4747

48+
#include <zephyr/input/input.h>
49+
50+
// experiment to try to capture touch screen events
51+
typedef struct {
52+
int32_t x;
53+
int32_t y;
54+
int32_t pressed;
55+
} touch_point_t;
56+
57+
touch_point_t last_touch_point;
58+
59+
static struct k_sem touch_event_sync;
60+
61+
bool getVideoTouchEvent(touch_point_t *tp, k_timeout_t timeout) {
62+
if (k_sem_take(&touch_event_sync, timeout) != 0) return false;
63+
// BUGBUG: should probably put stuff in to return only
64+
// data from whole event, but first see if anything works
65+
memcpy(tp, &last_touch_point, sizeof(touch_point_t));
66+
return true;
67+
}
68+
69+
70+
void touch_event_callback(struct input_event *evt, void *user_data)
71+
{
72+
//printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
73+
// evt->dev, evt->sync, evt->type, evt->code, evt->value);
74+
if (evt->code == INPUT_ABS_X) {
75+
last_touch_point.x = evt->value;
76+
}
77+
if (evt->code == INPUT_ABS_Y) {
78+
last_touch_point.y = evt->value;
79+
}
80+
if (evt->code == INPUT_BTN_TOUCH) {
81+
last_touch_point.pressed = evt->value;
82+
}
83+
if (evt->sync) {
84+
k_sem_give(&touch_event_sync);
85+
}
86+
}
87+
static const struct device *const touch_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_touch));
88+
INPUT_CALLBACK_DEFINE(touch_dev, touch_event_callback, NULL);
89+
90+
4891
int camera_ext_clock_enable(void)
4992
{
5093
int ret;
5194
uint32_t rate;
95+
96+
// Hack in init semaphore for touch events
97+
k_sem_init(&touch_event_sync, 0, 1);
98+
99+
52100
const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));
53101

54102
if (!device_is_ready(cam_ext_clk_dev)) {
@@ -99,7 +147,7 @@ int smh_init(void) {
99147
return 0;
100148
}
101149

102-
SYS_INIT(smh_init, POST_KERNEL, CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY);
150+
SYS_INIT(smh_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
103151
#endif
104152

105153
#if defined(CONFIG_BOARD_ARDUINO_PORTENTA_C33) && defined(CONFIG_LLEXT)

loader/llext_exports.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ FORCE_EXPORT_SYM(video_buffer_aligned_alloc);
133133
FORCE_EXPORT_SYM(video_buffer_alloc);
134134
FORCE_EXPORT_SYM(video_buffer_release);
135135
#endif
136+
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_VIDEO)
137+
FORCE_EXPORT_SYM(getVideoTouchEvent)
138+
#endif
136139

137140
#if defined(CONFIG_SHARED_MULTI_HEAP)
138141
FORCE_EXPORT_SYM(shared_multi_heap_aligned_alloc);

variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ CONFIG_VIDEO_GC2145=y
4646

4747
CONFIG_DISPLAY=y
4848
CONFIG_INPUT=y
49+
CONFIG_STM32_LTDC_FB_USE_SHARED_MULTI_HEAP=y
50+
CONFIG_STM32_LTDC_FB_SMH_ATTRIBUTE=2
4951

5052
CONFIG_BT=y
5153
CONFIG_BT_HCI_RAW=y

variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.overlay

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@
395395
<&gpiob 2 0>,
396396
<&gpiok 0 0>,
397397
<&gpioe 4 0>,
398-
<&gpioi 11 0>,
398+
<&gpioi 11 0>, /* 50 */
399399
<&gpioe 5 0>,
400400
<&gpiok 2 0>,
401401
<&gpiog 7 0>,
@@ -424,7 +424,7 @@
424424
<&gpiob 12 0>,
425425
<&gpiod 3 0>,
426426

427-
<&gpioc 4 0>, /* A0 */
427+
<&gpioc 4 0>, /* A0 - 76*/
428428
<&gpioc 5 0>,
429429
<&gpiob 0 0>,
430430
<&gpiob 1 0>,
@@ -435,7 +435,7 @@
435435
<&gpioa 4 0>, /* A12 */
436436
<&gpioa 5 0>, /* A13 */
437437

438-
<&gpioi 12 GPIO_ACTIVE_LOW>,
438+
<&gpioi 12 GPIO_ACTIVE_LOW>, /* 86 */
439439
<&gpioj 13 GPIO_ACTIVE_LOW>,
440440
<&gpioe 3 GPIO_ACTIVE_LOW>,
441441

@@ -451,10 +451,11 @@
451451
<&gpiob 6 0>, /* SDA1 */
452452
<&gpioh 12 0>,
453453

454-
<&gpioz 0 0>, /* analog only A8 */
454+
<&gpioz 0 0>, /* analog only A8 97 */
455455
<&gpioz 1 0>, /* analog only A9 */
456456
<&gpioz 2 0>, /* analog only A10 */
457-
<&gpioz 3 0>; /* analog only A11 */
457+
<&gpioz 3 0>, /* analog only A11 */
458+
<&gpioa 10 0>; /* Test add pin for BLE enable 101 */
458459

459460
builtin-led-gpios = <&gpioi 12 GPIO_ACTIVE_LOW>,
460461
<&gpioj 13 GPIO_ACTIVE_LOW>,

0 commit comments

Comments
 (0)