-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.h
64 lines (55 loc) · 1.83 KB
/
Menu.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
/*
Menu.h - Library for easy to generate menu buttons.
Created by Jan Ole Gödeke, 2018.
*/
#ifndef Menu_h
#define Menu_h
#include "Arduino.h"
#include <Adafruit_TFTLCD.h>
#define rotation 2 //1-4
#define displaywidth 240
#define displayheight 320
#define textSize 3 //see Adafruit_TFTLCD doc
#define textdistotop 12 //distance from text to top button border
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
class Menu {
private:
int _width = displaywidth;
int _height = displayheight;
int _buttonheight = _height / 4 - 10;
int _buttonwidth = _width - 16;
int _textboxheight = _height - 16;
int _border = 8;
int _textColor;
int _buttonColor;
int _backgroundColor;
int _xB2 = 2 * _border + _buttonheight;
int _xB3 = 3 * _border + 2 * _buttonheight;
int _xB4 = 4 * _border + 3 * _buttonheight;
static uint16_t bitcolor(char*);
public:
Menu();
setTextColor(char* color);
setButtonColor(char* color);
setBackgroundColor(char* color);
setColors(char* text, char* button, char* bg);
uint16_t getTextColor();
uint16_t getButtonColor();
uint16_t getBackgroundColor();
int getButtonHeight();
int getButtonWidth();
int getBorder();
oneButton(char* b1, int sel);
twoButtons(char* b1, char*b2, int sel);
threeButtons(char* b1, char*b2, char* b3, int sel);
fourButtons(char* b1, char*b2, char* b3, char* b4, int sel);
textBox(char* text);
};
#endif