Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Committer:
WiredHome
Date:
Sun Jul 28 02:14:09 2019 +0000
Revision:
179:c7fb7a4fb42f
Parent:
167:8aa3fb2a5a31
Child:
180:d8abf2e70b88
Added a couple of constructors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 31:c72e12cd5c67 1 #ifndef DISPLAYDEFS_H
WiredHome 31:c72e12cd5c67 2 #define DISPLAYDEFS_H
WiredHome 31:c72e12cd5c67 3
WiredHome 167:8aa3fb2a5a31 4 /// A Macro to define a @ref color_t value from independent values of Red, Green, and Blue.
WiredHome 167:8aa3fb2a5a31 5 ///
WiredHome 167:8aa3fb2a5a31 6 /// This macro accepts 3 parameters, each with a range of 0 to 0xFF.
WiredHome 167:8aa3fb2a5a31 7 /// Not all of the bits are used as it creates a 16-bit color from from 24-bits
WiredHome 167:8aa3fb2a5a31 8 /// of information.
WiredHome 167:8aa3fb2a5a31 9 ///
WiredHome 167:8aa3fb2a5a31 10 /// @param r is the Red component, ranging from 0 no-Red to 0xFF maximum-Red
WiredHome 167:8aa3fb2a5a31 11 /// @param g is the Green component, ranging from 0 no-Red to 0xFF maximum-Green
WiredHome 167:8aa3fb2a5a31 12 /// @param b is the Blue component, ranging from 0 no-Red to 0xFF maximum-Blue
WiredHome 167:8aa3fb2a5a31 13 ///
WiredHome 32:0e4f2ae512e2 14 #define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
WiredHome 32:0e4f2ae512e2 15
WiredHome 167:8aa3fb2a5a31 16 /// Return values from numerous APIs.
WiredHome 167:8aa3fb2a5a31 17 ///
WiredHome 167:8aa3fb2a5a31 18 /// This is the return value from various functions. Compare the return value
WiredHome 167:8aa3fb2a5a31 19 /// to the possibilities in this definition, or use the @ref RA8875::GetErrorMessage()
WiredHome 167:8aa3fb2a5a31 20 /// function to translate a @ref RetCode_t value into a text string.
WiredHome 79:544eb4964795 21 ///
WiredHome 31:c72e12cd5c67 22 typedef enum
WiredHome 31:c72e12cd5c67 23 {
WiredHome 31:c72e12cd5c67 24 noerror, ///< no errors, command completed successfully
WiredHome 31:c72e12cd5c67 25 bad_parameter, ///< one or more parameters are invalid
WiredHome 31:c72e12cd5c67 26 file_not_found, ///< specified file could not be found
WiredHome 42:7cbdfd2bbfc5 27 not_bmp_format, ///< file is not a .bmp file
WiredHome 42:7cbdfd2bbfc5 28 not_ico_format, ///< file is not a .ico file
WiredHome 112:325ca91bc03d 29 not_supported_format, ///< file format is not yet supported (e.g. bits per pixel, compression)
WiredHome 31:c72e12cd5c67 30 image_too_big, ///< image is too large for the screen
WiredHome 31:c72e12cd5c67 31 not_enough_ram, ///< could not allocate ram for scanline
WiredHome 122:79e431f98fa9 32 touch_cal_timeout, ///< timeout while trying to calibrate touchscreen, perhaps it is not installed.
WiredHome 115:c9862fd0c689 33 external_abort, ///< an external process caused an abort
WiredHome 79:544eb4964795 34 LastErrCode, // Private marker.
WiredHome 31:c72e12cd5c67 35 } RetCode_t;
WiredHome 31:c72e12cd5c67 36
WiredHome 167:8aa3fb2a5a31 37 /// Touch API Return values.
WiredHome 167:8aa3fb2a5a31 38 ///
WiredHome 167:8aa3fb2a5a31 39 /// This is the return value from various functions:
WiredHome 167:8aa3fb2a5a31 40 /// * @ref RA8875::TouchCode()
WiredHome 167:8aa3fb2a5a31 41 /// * @ref RA8875::TouchPanelReadable()
WiredHome 167:8aa3fb2a5a31 42 /// * @ref RA8875::TouchPanelA2DRaw()
WiredHome 167:8aa3fb2a5a31 43 /// * @ref RA8875::TouchPanelA2DFiltered()
WiredHome 167:8aa3fb2a5a31 44 /// * @ref RA8875::TouchPanelGet()
WiredHome 167:8aa3fb2a5a31 45 ///
WiredHome 83:7bad0068cca0 46 typedef enum
WiredHome 83:7bad0068cca0 47 {
WiredHome 83:7bad0068cca0 48 no_touch, ///< no touch is detected
WiredHome 83:7bad0068cca0 49 touch, ///< touch is detected
WiredHome 83:7bad0068cca0 50 held, ///< held after touch
WiredHome 83:7bad0068cca0 51 release, ///< release is detected
WiredHome 83:7bad0068cca0 52 no_cal, ///< no calibration matrix is available
WiredHome 83:7bad0068cca0 53 } TouchCode_t;
WiredHome 83:7bad0068cca0 54
WiredHome 125:7a0b70f56550 55 /// Data type that manages locations, which is typically an x or y pixel location,
WiredHome 167:8aa3fb2a5a31 56 /// which can range from -N to +N (even as the screen is always defined in the
WiredHome 167:8aa3fb2a5a31 57 /// range of 0 to +n). See also @ref textloc_t.
WiredHome 167:8aa3fb2a5a31 58 ///
WiredHome 37:f19b7e7449dc 59 typedef int16_t loc_t;
WiredHome 37:f19b7e7449dc 60
WiredHome 125:7a0b70f56550 61 /// Data type that manages text locations, which are row or column values in
WiredHome 167:8aa3fb2a5a31 62 /// units of character, not pixel. See also @ref loc_t.
WiredHome 167:8aa3fb2a5a31 63 ///
WiredHome 37:f19b7e7449dc 64 typedef uint16_t textloc_t;
WiredHome 37:f19b7e7449dc 65
WiredHome 37:f19b7e7449dc 66 /// type that manages dimensions of width or height, which range from 0 to N.
WiredHome 167:8aa3fb2a5a31 67 ///
WiredHome 167:8aa3fb2a5a31 68 /// @note that a dimension cannot be negative.
WiredHome 167:8aa3fb2a5a31 69 ///
WiredHome 37:f19b7e7449dc 70 typedef uint16_t dim_t;
WiredHome 37:f19b7e7449dc 71
WiredHome 32:0e4f2ae512e2 72 /// type that manages x,y pairs
WiredHome 167:8aa3fb2a5a31 73 ///
WiredHome 179:c7fb7a4fb42f 74 struct point_t
WiredHome 32:0e4f2ae512e2 75 {
WiredHome 37:f19b7e7449dc 76 loc_t x; ///< x value in the point
WiredHome 37:f19b7e7449dc 77 loc_t y; ///< y value in the point
WiredHome 179:c7fb7a4fb42f 78
WiredHome 179:c7fb7a4fb42f 79 // constructors:
WiredHome 179:c7fb7a4fb42f 80 point_t(loc_t arg_x, loc_t arg_y) :
WiredHome 179:c7fb7a4fb42f 81 x(arg_x), y(arg_y) {}
WiredHome 179:c7fb7a4fb42f 82 point_t() :
WiredHome 179:c7fb7a4fb42f 83 x(0), y(0){};
WiredHome 179:c7fb7a4fb42f 84 };
WiredHome 32:0e4f2ae512e2 85
WiredHome 167:8aa3fb2a5a31 86 /// Data type that manages rectangles, which are pairs of points.
WiredHome 167:8aa3fb2a5a31 87 ///
WiredHome 167:8aa3fb2a5a31 88 /// @note It is recommended that p1 contains the top-left point and p2 contains
WiredHome 167:8aa3fb2a5a31 89 /// the bottom-right point, even though it should not matter.
WiredHome 167:8aa3fb2a5a31 90 ///
WiredHome 179:c7fb7a4fb42f 91 struct rect_t
WiredHome 81:01da2e34283d 92 {
WiredHome 81:01da2e34283d 93 point_t p1; ///< p1 defines one point on the rectangle
WiredHome 81:01da2e34283d 94 point_t p2; ///< p2 defines the opposite point on the rectangle
WiredHome 179:c7fb7a4fb42f 95
WiredHome 179:c7fb7a4fb42f 96 // constructors:
WiredHome 179:c7fb7a4fb42f 97 rect_t(point_t arg_p1, point_t arg_p2) :
WiredHome 179:c7fb7a4fb42f 98 p1(arg_p1), p2(arg_p2) {};
WiredHome 179:c7fb7a4fb42f 99
WiredHome 179:c7fb7a4fb42f 100 rect_t(loc_t arg_p1_x, loc_t arg_p1_y, loc_t arg_p2_x, loc_t arg_p2_y) :
WiredHome 179:c7fb7a4fb42f 101 p1(point_t(arg_p1_x, arg_p1_y)), p2(point_t(arg_p2_x, arg_p2_y)){};
WiredHome 179:c7fb7a4fb42f 102
WiredHome 179:c7fb7a4fb42f 103 rect_t() :
WiredHome 179:c7fb7a4fb42f 104 p1(point_t()), p2(point_t()) {};
WiredHome 179:c7fb7a4fb42f 105 };
WiredHome 81:01da2e34283d 106
WiredHome 125:7a0b70f56550 107 /// Data type that manages the calibration matrix for the resistive touch panel.
WiredHome 125:7a0b70f56550 108 ///
WiredHome 125:7a0b70f56550 109 /// This object, when instantiated, may be passed back and forth, stored
WiredHome 125:7a0b70f56550 110 /// and loaded, but the internals are generally of little interest.
WiredHome 167:8aa3fb2a5a31 111 ///
WiredHome 77:9206c13aa527 112 typedef struct
WiredHome 77:9206c13aa527 113 {
WiredHome 125:7a0b70f56550 114 int32_t An; ///< calibration factor, see source for details
WiredHome 125:7a0b70f56550 115 int32_t Bn; ///< calibration factor, see source for details
WiredHome 125:7a0b70f56550 116 int32_t Cn; ///< calibration factor, see source for details
WiredHome 125:7a0b70f56550 117 int32_t Dn; ///< calibration factor, see source for details
WiredHome 125:7a0b70f56550 118 int32_t En; ///< calibration factor, see source for details
WiredHome 125:7a0b70f56550 119 int32_t Fn; ///< calibration factor, see source for details
WiredHome 125:7a0b70f56550 120 int32_t Divider; ///< calibration factor, see source for details
WiredHome 77:9206c13aa527 121 } tpMatrix_t;
WiredHome 77:9206c13aa527 122
WiredHome 167:8aa3fb2a5a31 123 /// color type definition to let the compiler type-check parameters that
WiredHome 167:8aa3fb2a5a31 124 /// are passed to or returned from APIs that use color.
WiredHome 32:0e4f2ae512e2 125 ///
WiredHome 167:8aa3fb2a5a31 126 /// colors can be easily defined with the @ref RGB(r,g,b) macro, or from
WiredHome 167:8aa3fb2a5a31 127 /// the @ref PredefinedColors.
WiredHome 32:0e4f2ae512e2 128 ///
WiredHome 32:0e4f2ae512e2 129 typedef uint16_t color_t;
WiredHome 32:0e4f2ae512e2 130
WiredHome 32:0e4f2ae512e2 131 /// background fill info for drawing Text, Rectangles, RoundedRectanges, Circles, Ellipses and Triangles.
WiredHome 32:0e4f2ae512e2 132 typedef enum
WiredHome 32:0e4f2ae512e2 133 {
WiredHome 32:0e4f2ae512e2 134 NOFILL, ///< do not fill the object with the background color
WiredHome 32:0e4f2ae512e2 135 FILL ///< fill the object space with the background color
WiredHome 32:0e4f2ae512e2 136 } fill_t;
WiredHome 32:0e4f2ae512e2 137
WiredHome 31:c72e12cd5c67 138 #endif // DISPLAYDEFS_H