ugfx/gui.h

96 lines
2.8 KiB
C
Raw Normal View History

2012-06-07 12:37:29 +00:00
#ifndef GUI_H
#define GUI_H
2012-06-26 10:47:25 +00:00
#include "ch.h"
#include "hal.h"
#include "glcd.h"
2012-07-09 00:39:28 +00:00
#include "chprintf.h"
2012-06-26 10:47:25 +00:00
#include "touchpad.h"
2012-07-09 00:39:28 +00:00
#include <string.h>
2012-07-09 00:34:40 +00:00
struct guiNode_t {
2012-06-26 18:47:35 +00:00
uint8_t type;
2012-06-09 17:29:35 +00:00
uint16_t x0;
uint16_t y0;
uint16_t x1;
uint16_t y1;
2012-06-26 19:48:12 +00:00
uint16_t r1;
uint16_t r2;
uint16_t shadow;
2012-07-09 17:29:49 +00:00
uint16_t bkColor;
uint16_t valueColor;
2012-07-09 20:40:35 +00:00
uint16_t value;
uint16_t oldValue;
uint16_t percentage;
2012-06-26 19:43:21 +00:00
uint8_t orientation;
2012-07-09 18:45:02 +00:00
uint8_t mode;
uint8_t *active;
2012-06-26 10:47:25 +00:00
uint8_t *state;
2012-06-27 08:23:42 +00:00
char *label;
2012-06-26 10:47:25 +00:00
struct guiNode_t *next;
2012-06-09 17:29:35 +00:00
};
#ifdef __cplusplus
extern "C" {
#endif
2012-06-26 19:43:21 +00:00
enum {button, slider, wheel, keymatrix};
2012-06-26 10:47:25 +00:00
enum {horizontal, vertical};
enum {inactive, active};
2012-07-09 18:45:02 +00:00
enum {modePassive, modeActive};
2012-06-07 21:48:51 +00:00
/*
2012-06-26 11:57:00 +00:00
* Description: creates the GUI thread
2012-06-07 21:48:51 +00:00
*
2012-06-26 11:57:00 +00:00
* param: - interval: thread sleep in milliseconds after each GUI element update
* - priority: priority of the thread
2012-06-07 21:48:51 +00:00
*
2012-06-26 11:57:00 +00:00
* return: pointer to created thread
2012-06-07 21:48:51 +00:00
*/
2012-06-26 11:50:12 +00:00
Thread *guiInit(uint16_t interval, tprio_t priority);
2012-06-07 21:48:51 +00:00
/*
2012-06-26 11:57:00 +00:00
* Description: prints all GUI elements structs (linked list)
*
* param: - chp: pointer to output stream
2012-06-07 21:48:51 +00:00
*
2012-06-26 11:57:00 +00:00
* return: none
2012-06-07 21:48:51 +00:00
*/
2012-06-27 08:11:42 +00:00
void guiPrintElements(BaseSequentialStream *chp);
2012-06-09 13:41:28 +00:00
2012-06-09 17:29:35 +00:00
/*
2012-06-27 08:10:45 +00:00
* Description: deletes a GUI element from the linked list
2012-06-09 17:29:35 +00:00
*
2012-06-27 08:23:42 +00:00
* param: - label: label of the element (parameter of each guiDrawXXX function)
2012-06-09 17:29:35 +00:00
*
2012-06-27 08:10:45 +00:00
* return: 1 if successful, 0 otherwise
2012-06-09 17:29:35 +00:00
*/
2012-06-27 08:23:42 +00:00
uint8_t guiDeleteElement(char *label);
2012-07-09 00:29:58 +00:00
2012-06-26 11:57:00 +00:00
/*
* Description: draws a button on the screen and keeps it's state up to date
*
* param: - x0, y0, x1, y1: start and end coordinates of the button's rectangle
* - str: string that gets drawn into the rectangle - button's lable
* - fontColor: color of the lable
* - buttonColor: color of the rectangle
2012-06-27 09:12:45 +00:00
* - shadow: draws a black shadow with N pixels size if != 0
2012-06-26 11:57:00 +00:00
* - active: pass pointer to variable which holds the state 'active' or 'inactive'
* - state: pass pointer to variable whcih will keep the state of the button (pressed / unpressed)'
*
* return: 1 if button successfully created
*/
2012-06-27 16:51:08 +00:00
uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state);
2012-06-09 17:29:35 +00:00
2012-07-09 18:45:02 +00:00
uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value);
2012-06-26 20:20:55 +00:00
2012-06-27 08:23:42 +00:00
uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value);
2012-06-09 17:29:35 +00:00
2012-07-09 01:46:13 +00:00
uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t buttonSize, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value);
#ifdef __cplusplus
}
#endif
2012-06-07 12:37:29 +00:00
#endif