aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTectu <joel@unormal.org>2012-06-07 23:48:51 +0200
committerTectu <joel@unormal.org>2012-06-07 23:48:51 +0200
commit3d1bc270dcac892b499b19513c4ec071d226d340 (patch)
tree61dbdfe2c76c5e38db77b9d97e04cac57044dc48
parent1d10f9df321c3ded9459a820f6e43b0360da95d8 (diff)
downloaduGFX-3d1bc270dcac892b499b19513c4ec071d226d340.tar.gz
uGFX-3d1bc270dcac892b499b19513c4ec071d226d340.tar.bz2
uGFX-3d1bc270dcac892b499b19513c4ec071d226d340.zip
doc
-rw-r--r--gui.c9
-rw-r--r--gui.h22
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