forked from jinschoi/SphereBot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTouchscreenButton.h
40 lines (34 loc) · 1.43 KB
/
TouchscreenButton.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
/*
TouchscreenButton.h - Library for touchscreen button functions.
Created by Terence F. Golla, September 19, 2021
Released into the public domain.
*/
#ifndef TouchscreenButton_h
#define TouchscreenButton_h
#define DebugTouchscreenButton false
#include <Arduino.h>
// This contains the low-level code specific to the TFT display.
#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ImageReader.h> // Image-reading functions.
class TouchscreenButton
{
public:
TouchscreenButton(unsigned int x, unsigned int y,
unsigned int width, unsigned int height, unsigned int tftWidth, unsigned int tftHeight,
unsigned int rotate, char *imageFilename, char *alternateImageFilename);
void Display(Adafruit_ImageReader &reader, Adafruit_SPITFT &tft);
void DisplayAlternate(Adafruit_ImageReader &reader, Adafruit_SPITFT &tft);
boolean Touched(unsigned int x, unsigned int y);
private:
unsigned int _x; // Button's x coordinate.
unsigned int _y; // Button's y coordinate.
unsigned int _width; // Button's width.
unsigned int _height; // Button's height.
unsigned int _tftWidth; // Screen width;
unsigned int _tftHeight; // Screen height.
unsigned int _rotation; // The button's rotation. Correlates with the touchscreen rotation.
char *_imageFilename; // The buttton's image bmp filename.
char *_alternateImageFilename; // The buttton's alternate image bmp filename.
};
#endif