From ba91ff10e8c974e50e429d072641ac5e0acdd72e Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Wed, 19 Oct 2016 17:03:52 +0200 Subject: nwztools: add a new plattools directory with code to run on the device This is code is intended to development into a library of code for the NWZ that will be useful to write the "bootloader" on those device. At the same time, it comes with test programs that are easy to run in firmware upgrade mode and also provide a great test bench for the library. At the moment, two test programs are available: - test_display: simply prints two messages using /usr/bin/lcdmsg - test_keys: displays input key event Change-Id: I9d214894ffc9127b528fcdd3eb5d6b61f4e657a7 --- utils/nwztools/plattools/nwz_lib.h | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 utils/nwztools/plattools/nwz_lib.h (limited to 'utils/nwztools/plattools/nwz_lib.h') diff --git a/utils/nwztools/plattools/nwz_lib.h b/utils/nwztools/plattools/nwz_lib.h new file mode 100644 index 0000000000..e9d885d87a --- /dev/null +++ b/utils/nwztools/plattools/nwz_lib.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 Amaury Pouly + * + * 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 _NWZLIB_H_ +#define _NWZLIB_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nwz_keys.h" + +/* run a program and exit with nonzero status in case of error + * argument list must be NULL terminated */ +void nwz_run(const char *file, const char *args[], bool wait); + +/* invoke /usr/bin/lcdmsg to display a message using the small font, optionally + * clearing the screen before */ +void nwz_lcdmsg(bool clear, int x, int y, const char *msg); +void nwz_lcdmsgf(bool clear, int x, int y, const char *format, ...); + +/* open icx_key input device and return file descriptor */ +int nwz_key_open(void); +void nwz_key_close(int fd); +/* return HOLD status: 0 or 1, or -1 on error */ +int nwz_key_get_hold_status(int fd); +/* wait for an input event (and return 1), or a timeout (return 0), or error (-1) + * set the timeout to -1 to block */ +int nwz_key_wait_event(int fd, long tmo_us); +/* read an event from the device (may block unless you waited for an event before), + * return 1 on success, <0 on error */ +int nwz_key_read_event(int fd, struct input_event *evt); +/* return keycode from event */ +int nwz_key_event_get_keycode(struct input_event *evt); +/* return press/released status from event */ +bool nwz_key_event_is_press(struct input_event *evt); +/* return HOLD status from event */ +bool nwz_key_event_get_hold_status(struct input_event *evt); +/* get keycode name */ +const char *nwz_key_get_name(int keycode); + +#endif /* _NWZLIB_H_ */ -- cgit v1.2.3