tillitis / tillitis-key1

Board designs, FPGA verilog, firmware for TKey, the flexible and open USB security key 🔑
https://www.tillitis.se
394 stars 24 forks source link

Device app to test hold touch #223

Closed mchack-work closed 1 week ago

mchack-work commented 4 months ago

We need a device app to test hold touch, indicating a finger present for a long time.

See connected PR.

dehanj commented 4 months ago

With the linked PR in tkey-libs and this snipped below, it is possible to test this feature.

// Copyright (C) Tillitis AB
// SPDX-License-Identifier: GPL-2.0-only

#include <stdbool.h>
#include <tkey/led.h>
#include <tkey/tk1_mem.h>
#include <tkey/qemu_debug.h>
#include <tkey/touch.h>

int main(void)
{
    qemu_puts("Hello, world!\n");
    qemu_lf();

    touch_wait(LED_BLUE, 10);

    for (;;) {

        if (touch()) {  
        led_set(LED_GREEN);
        } else {
        led_set(LED_RED);
        }
    }
}

It will first to a touch_wait with a timeout of 10 seconds, then it will simply show green when touched and red when not touched.