added type of GUI element
This commit is contained in:
parent
9693778666
commit
cc7943305e
2 changed files with 10 additions and 6 deletions
14
gui.c
14
gui.c
|
@ -86,13 +86,14 @@ static void guiThread(const uint16_t interval) {
|
||||||
if(*(node->active) == active) {
|
if(*(node->active) == active) {
|
||||||
x = tpReadX();
|
x = tpReadX();
|
||||||
y = tpReadY();
|
y = tpReadY();
|
||||||
|
if(node->type == button) {
|
||||||
if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1)
|
if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1)
|
||||||
*(node->state) = 1;
|
*(node->state) = 1;
|
||||||
else
|
else
|
||||||
|
*(node->state) = 0;
|
||||||
|
} else {
|
||||||
*(node->state) = 0;
|
*(node->state) = 0;
|
||||||
} else {
|
}
|
||||||
*(node->state) = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *
|
||||||
newNode->y0 = y0;
|
newNode->y0 = y0;
|
||||||
newNode->x1 = x1;
|
newNode->x1 = x1;
|
||||||
newNode->y1 = y1;
|
newNode->y1 = y1;
|
||||||
|
newNode->type = button;
|
||||||
newNode->name = str;
|
newNode->name = str;
|
||||||
newNode->active = active;
|
newNode->active = active;
|
||||||
newNode->state = state;
|
newNode->state = state;
|
||||||
|
|
2
gui.h
2
gui.h
|
@ -7,6 +7,7 @@
|
||||||
#include "touchpad.h"
|
#include "touchpad.h"
|
||||||
|
|
||||||
static struct guiNode_t {
|
static struct guiNode_t {
|
||||||
|
uint8_t type;
|
||||||
uint16_t x0;
|
uint16_t x0;
|
||||||
uint16_t y0;
|
uint16_t y0;
|
||||||
uint16_t x1;
|
uint16_t x1;
|
||||||
|
@ -21,6 +22,7 @@ static struct guiNode_t {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum {button};
|
||||||
enum {horizontal, vertical};
|
enum {horizontal, vertical};
|
||||||
enum {inactive, active};
|
enum {inactive, active};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue