gui.c cleanup

ugfx_release_2.6
Tectu 2012-07-09 03:17:03 +02:00
parent b3d7994cfd
commit 0dc6154ee1
1 changed files with 34 additions and 23 deletions

57
gui.c
View File

@ -1,6 +1,7 @@
#include "gui.h" #include "gui.h"
static struct guiNode_t *firstGUI = NULL; static struct guiNode_t *firstGUI = NULL;
uint16_t x, y; // global touchpad coordinates
static uint8_t addElement(struct guiNode_t *newNode) { static uint8_t addElement(struct guiNode_t *newNode) {
struct guiNode_t *new; struct guiNode_t *new;
@ -79,8 +80,27 @@ void guiPrintElements(BaseSequentialStream *chp) {
} }
} }
static inline void buttonUpdate(struct guiNode_t *node) {
if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) {
*(node->state) = 1;
} else {
*(node->state) = 0;
}
}
static inline void sliderUpdate(struct guiNode_t *node) {
(void)node;
}
static inline void wheelUpdate(struct guiNode_t *node) {
(void)node;
}
static inline void keymatrixUpdate(struct guiNode_t *node) {
(void)node;
}
static void guiThread(const uint16_t interval) { static void guiThread(const uint16_t interval) {
uint16_t x, y, color;
struct guiNode_t *node; struct guiNode_t *node;
chRegSetThreadName("GUI"); chRegSetThreadName("GUI");
@ -92,28 +112,19 @@ static void guiThread(const uint16_t interval) {
x = tpReadX(); x = tpReadX();
y = tpReadY(); y = tpReadY();
// we got a button switch(node->type) {
if(node->type == button) { case button:
if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) { buttonUpdate(node);
*(node->state) = 1; break;
} else { case slider:
*(node->state) = 0; sliderUpdate(node);
} break;
} case wheel:
wheelUpdate(node);
// we got a slider break;
else if(node->type == slider) { case keymatrix:
keymatrixUpdate(node);
} break;
// we got a wheel
else if(node->type == wheel) {
}
// we got a keymatrix
else if(node->type == keymatrix) {
} }
} }
} }