-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.h
104 lines (79 loc) · 2.01 KB
/
ui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef _UIH_
#define _UIH_
#include "avr/io.h"
#include "util/delay.h"
#include <stdlib.h>
#include <stdbool.h>
#include "lcd.h"
#define SCTOP 0
#define SCLEFT 0
#define SCBOTTOM 240
#define SCRIGHT 320
#define SPAD 20
#define SWIDTH 280
#define CHAR_W 6
// Extra colors
#define DARKGREY 0x39E7
#define LIGHTGREY 0x7BEF
#define ORANGE 0xFE00
#define NXGRID 11
#define NYGRID 15
/* ----------- Utility ---------- */
uint8_t getTextw(const char *text);
void debugPrint(volatile int n);
void uiMoveRect(rectangle *r, int x, int y, int color, int shadow);
/* ----------- uiSlider ---------- */
typedef struct{
uint16_t x, y;
uint16_t pos, oldpos;
uint16_t color, oldcolor;
} uiSlider;
void uiSliderMove(uiSlider * const me, uint16_t pos);
void uiSliderStatus(uiSlider * const me, uint16_t color);
void uiSliderDraw(uiSlider * const me);
/* ----------- uiText -------*/
typedef struct{
uint16_t x, y;
char text[140];
} uiText;
void uiTextDraw(uiText * const me);
void uiTextRefresh(uiText * const me, double newval);
/* ----------- uiTextBox -------*/
typedef struct{
uint16_t x, y;
char text[15];
uint16_t color;
bool hover, oldhover;
} uiTextBox;
void uiTextBoxSelect(uiTextBox * const me, bool hover);
void uiTextBoxDraw(uiTextBox * const me);
void uiTextBoxHide(uiTextBox * const me);
/* ----------- uiCursor -------*/
typedef struct{
char arrow;
uint16_t color;
bool trace;
bool old, hover;
uint16_t pos, oldpos;
} uiCursor;
void uiCursorMove(uiCursor * const me, uint16_t newpos);
void uiCursorDraw(uiCursor * const me);
void uiCursorHide(uiCursor * const me);
/* ----------- uiGrid -------*/
typedef struct{
uint8_t major, minor;
} uiGrid;
void uiGridDraw(uiGrid * const me);
void uiGridHide(uiGrid * const me);
/* ----------- uiPlot -------*/
typedef struct{
double scale;
uint16_t startp;
uint8_t offset;
bool clipping;
rectangle *dp;
volatile uint8_t *data;
} uiPlot;
void uiPlotUpdate(uiPlot * const me, double scale, uint16_t startp, uint8_t offset);
void uiPlotDraw(uiPlot * const me);
#endif