diff options
author | Tectu <joel@unormal.org> | 2012-06-07 23:48:51 +0200 |
---|---|---|
committer | Tectu <joel@unormal.org> | 2012-06-07 23:48:51 +0200 |
commit | 3d1bc270dcac892b499b19513c4ec071d226d340 (patch) | |
tree | 61dbdfe2c76c5e38db77b9d97e04cac57044dc48 | |
parent | 1d10f9df321c3ded9459a820f6e43b0360da95d8 (diff) | |
download | uGFX-3d1bc270dcac892b499b19513c4ec071d226d340.tar.gz uGFX-3d1bc270dcac892b499b19513c4ec071d226d340.tar.bz2 uGFX-3d1bc270dcac892b499b19513c4ec071d226d340.zip |
doc
-rw-r--r-- | gui.c | 9 | ||||
-rw-r--r-- | gui.h | 22 |
2 files changed, 26 insertions, 5 deletions
@@ -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) { @@ -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 |