doc
This commit is contained in:
parent
1d10f9df32
commit
3d1bc270dc
2 changed files with 26 additions and 5 deletions
9
gui.c
9
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) {
|
||||
|
|
22
gui.h
22
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
|
||||
|
|
Loading…
Add table
Reference in a new issue