From 3d1bc270dcac892b499b19513c4ec071d226d340 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 7 Jun 2012 23:48:51 +0200 Subject: doc --- gui.c | 9 ++++----- gui.h | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gui.c b/gui.c index 63bd97b0..10c5a72d 100644 --- a/gui.c +++ b/gui.c @@ -16,22 +16,21 @@ static msg_t buttonThread(struct buttonStruct_t *a) { } } -static msg_t TouchPadThread(void *arg) { - (void)arg; +static msg_t TouchPadThread(uint16_t updateInterval) { chRegSetThreadName("GUI"); while(TRUE) { x = tpReadX(); y = tpReadY(); - chThdSleepMilliseconds(10); + chThdSleepMilliseconds(updateInterval); } } -void guiInit(void) { +void guiInit(uint16_t updateInterval) { Thread *tp = NULL; - tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(64), HIGHPRIO-1, TouchPadThread, NULL); + tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(64), HIGHPRIO-1, TouchPadThread, updateInterval); } Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsigned char *str, uint16_t fontColor, uint16_t buttonColor, uint8_t *state) { diff --git a/gui.h b/gui.h index 045d0f2d..21b9e5b4 100644 --- a/gui.h +++ b/gui.h @@ -9,6 +9,28 @@ struct buttonStruct_t { uint8_t *state; }; +/* + * Description: starts main GUI thread which keeps X and Y coordinates of touchpad updated for guiDraw() threads + * + * param: + * - updateInterval: update interval in milliseconds until next coordinates read-out + * + * return: none + */ +void guiInit(uint16_t updateIntervl); + +/* + * Description: draws button and creates thread which keeps pressed/unpressed state up-to-date + * + * param: + * - x0, y0, x1, y1: coordinates where button gets drawn + * - str: string written centered into button + * - fontColor: color of string + * - buttonColor: color of button + * - state: pointer to variable which keeps state (1 = pressed, 0 = unpressed) + * + * return: pointer to created thread + */ Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsigned char *str, uint16_t fontColor, uint16_t buttonColor, uint8_t *state); #endif -- cgit v1.2.3