GUI threads do now take active/inactive state
This commit is contained in:
parent
e543f15633
commit
7401ade97d
2 changed files with 36 additions and 24 deletions
13
gui.c
13
gui.c
|
@ -27,10 +27,14 @@ static void buttonThread(struct button_t *a) {
|
||||||
y1 = a->y1;
|
y1 = a->y1;
|
||||||
|
|
||||||
while(TRUE) {
|
while(TRUE) {
|
||||||
|
if(*(a->active) == active) {
|
||||||
if(x >= x0 && x <= x1 && y >= y0 && y <= y1)
|
if(x >= x0 && x <= x1 && y >= y0 && y <= y1)
|
||||||
*(a->state) = 1;
|
*(a->state) = 1;
|
||||||
else
|
else
|
||||||
*(a->state) = 0;
|
*(a->state) = 0;
|
||||||
|
} else {
|
||||||
|
*(a->state) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
chThdSleepMilliseconds(a->interval);
|
chThdSleepMilliseconds(a->interval);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +44,7 @@ static void barThread(struct bar_t *a) {
|
||||||
uint16_t percent = 0, value = 0, value_old = 0;
|
uint16_t percent = 0, value = 0, value_old = 0;
|
||||||
|
|
||||||
while(TRUE) {
|
while(TRUE) {
|
||||||
|
if(*(a->active) == active) {
|
||||||
percent = *(a->percent);
|
percent = *(a->percent);
|
||||||
if(percent > 100)
|
if(percent > 100)
|
||||||
percent = 100;
|
percent = 100;
|
||||||
|
@ -59,6 +64,8 @@ static void barThread(struct bar_t *a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
value_old = value;
|
value_old = value;
|
||||||
|
}
|
||||||
|
|
||||||
chThdSleepMilliseconds(a->interval);
|
chThdSleepMilliseconds(a->interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +75,7 @@ void guiInit(uint16_t updateInterval) {
|
||||||
tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(64), HIGHPRIO-1, TouchPadThread, updateInterval);
|
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, uint16_t interval, uint8_t *state) {
|
Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsigned char *str, uint16_t fontColor, uint16_t buttonColor, uint16_t interval, uint8_t *active, uint8_t *state) {
|
||||||
struct button_t *button;
|
struct button_t *button;
|
||||||
Thread *tp = NULL;
|
Thread *tp = NULL;
|
||||||
|
|
||||||
|
@ -78,6 +85,7 @@ Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsign
|
||||||
button->x1 = x1;
|
button->x1 = x1;
|
||||||
button->y1 = y1;
|
button->y1 = y1;
|
||||||
button->state = state;
|
button->state = state;
|
||||||
|
button->active = active;
|
||||||
button->interval = interval;
|
button->interval = interval;
|
||||||
|
|
||||||
lcdDrawRectString(x0, y0, x1, y1, str, fontColor, buttonColor);
|
lcdDrawRectString(x0, y0, x1, y1, str, fontColor, buttonColor);
|
||||||
|
@ -86,7 +94,7 @@ Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsign
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread *guiDrawBarGraph(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t orientation, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, uint16_t interval, uint16_t *percent) {
|
Thread *guiDrawBarGraph(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t orientation, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, uint16_t interval, uint8_t *active, uint16_t *percent) {
|
||||||
struct bar_t *bar;
|
struct bar_t *bar;
|
||||||
Thread *tp = NULL;
|
Thread *tp = NULL;
|
||||||
|
|
||||||
|
@ -101,6 +109,7 @@ Thread *guiDrawBarGraph(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint
|
||||||
bar->valueColor = valueColor;
|
bar->valueColor = valueColor;
|
||||||
bar->percent = percent;
|
bar->percent = percent;
|
||||||
bar->interval = interval;
|
bar->interval = interval;
|
||||||
|
bar->active = active;
|
||||||
|
|
||||||
lcdDrawRect(x0, y0, x1, y1, frame, frameColor);
|
lcdDrawRect(x0, y0, x1, y1, frame, frameColor);
|
||||||
tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(64), NORMALPRIO, barThread, bar);
|
tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(64), NORMALPRIO, barThread, bar);
|
||||||
|
|
9
gui.h
9
gui.h
|
@ -6,7 +6,8 @@ struct button_t {
|
||||||
uint16_t y0;
|
uint16_t y0;
|
||||||
uint16_t x1;
|
uint16_t x1;
|
||||||
uint16_t y1;
|
uint16_t y1;
|
||||||
uint32_t *state;
|
uint8_t *state;
|
||||||
|
uint8_t *active;
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,9 +22,11 @@ struct bar_t {
|
||||||
uint16_t valueColor;
|
uint16_t valueColor;
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
uint8_t *percent;
|
uint8_t *percent;
|
||||||
|
uint8_t *active;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {horizontal, vertical};
|
enum {horizontal, vertical};
|
||||||
|
enum {inactive, active};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -53,7 +56,7 @@ void guiInit(uint16_t updateIntervl);
|
||||||
*
|
*
|
||||||
* return: pointer to created thread
|
* 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, uint16_t inverval, uint8_t *state);
|
Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsigned char *str, uint16_t fontColor, uint16_t buttonColor, uint16_t inverval, uint8_t *active, uint8_t *state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: draws a bar graph and updates it's value
|
* Description: draws a bar graph and updates it's value
|
||||||
|
@ -69,7 +72,7 @@ Thread *guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, unsign
|
||||||
*
|
*
|
||||||
* return : pointer to created thread
|
* return : pointer to created thread
|
||||||
*/
|
*/
|
||||||
Thread *guiDrawBarGraph(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t orientation, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, uint16_t interval, uint16_t *percent);
|
Thread *guiDrawBarGraph(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t orientation, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, uint16_t interval, uint8_t *active, uint16_t *percent);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue