David Smart / RA8875_L
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DisplayDefs.h Source File

DisplayDefs.h

00001 #ifndef DISPLAYDEFS_H
00002 #define DISPLAYDEFS_H
00003 
00004 /// A Macro to define a @ref color_t value from independent values of Red, Green, and Blue.
00005 ///
00006 /// This macro accepts 3 parameters, each with a range of 0 to 0xFF.
00007 /// Not all of the bits are used as it creates a 16-bit color from from 24-bits
00008 /// of information.
00009 ///
00010 /// @param r is the Red component, ranging from 0 no-Red to 0xFF maximum-Red
00011 /// @param g is the Green component, ranging from 0 no-Red to 0xFF maximum-Green
00012 /// @param b is the Blue component, ranging from 0 no-Red to 0xFF maximum-Blue
00013 ///
00014 #define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
00015 
00016 /// Return values from numerous APIs.
00017 ///
00018 /// This is the return value from various functions. Compare the return value
00019 /// to the possibilities in this definition, or use the @ref RA8875::GetErrorMessage() 
00020 /// function to translate a @ref RetCode_t value into a text string.
00021 ///
00022 typedef enum
00023 {
00024     noerror,                ///< no errors, command completed successfully
00025     bad_parameter,          ///< one or more parameters are invalid
00026     file_not_found,         ///< specified file could not be found
00027     not_bmp_format,         ///< file is not a .bmp file
00028     not_ico_format,         ///< file is not a .ico file
00029     not_supported_format,   ///< file format is not yet supported (e.g. bits per pixel, compression)
00030     image_too_big,          ///< image is too large for the screen
00031     not_enough_ram,         ///< could not allocate ram for scanline
00032     touch_cal_timeout,      ///< timeout while trying to calibrate touchscreen, perhaps it is not installed.
00033     external_abort,         ///< an external process caused an abort
00034     LastErrCode,            // Private marker.
00035 } RetCode_t;
00036 
00037 /// Touch API Return values.
00038 ///
00039 /// This is the return value from various functions:
00040 /// * @ref RA8875::TouchCode()
00041 /// * @ref RA8875::TouchPanelReadable()
00042 /// * @ref RA8875::TouchPanelA2DRaw()
00043 /// * @ref RA8875::TouchPanelA2DFiltered()
00044 /// * @ref RA8875::TouchPanelGet() 
00045 ///
00046 typedef enum
00047 {
00048     no_touch,               ///< no touch is detected
00049     touch,                  ///< touch is detected
00050     held,                   ///< held after touch
00051     release,                ///< release is detected
00052     no_cal,                 ///< no calibration matrix is available
00053 } TouchCode_t;
00054 
00055 /// Data type that manages locations, which is typically an x or y pixel location,
00056 /// which can range from -N to +N (even as the screen is always defined in the
00057 /// range of 0 to +n). See also @ref textloc_t.
00058 ///
00059 typedef int16_t loc_t;
00060 
00061 /// Data type that manages text locations, which are row or column values in
00062 /// units of character, not pixel. See also @ref loc_t.
00063 ///
00064 typedef uint16_t textloc_t;
00065 
00066 /// type that manages dimensions of width or height, which range from 0 to N.
00067 ///
00068 /// @note that a dimension cannot be negative.
00069 ///
00070 typedef uint16_t dim_t;
00071 
00072 /// type that manages x,y pairs
00073 ///
00074 struct point_t
00075 {
00076     loc_t x;             ///< x value in the point
00077     loc_t y;             ///< y value in the point
00078     
00079     // constructors:
00080     point_t(loc_t arg_x, loc_t arg_y) : 
00081     x(arg_x), y(arg_y) {}   
00082     point_t() :
00083     x(0), y(0){};          
00084 };
00085 
00086 /// Data type that manages rectangles, which are pairs of points. 
00087 ///
00088 /// @note It is recommended that p1 contains the top-left point and p2 contains 
00089 /// the bottom-right point, even though it should not matter.
00090 ///
00091 struct rect_t
00092 {
00093     point_t p1;         ///< p1 defines one point on the rectangle
00094     point_t p2;         ///< p2 defines the opposite point on the rectangle
00095     
00096     // constructors:
00097     rect_t(point_t arg_p1, point_t arg_p2) :
00098     p1(arg_p1), p2(arg_p2) {};
00099     
00100     rect_t(loc_t arg_p1_x, loc_t arg_p1_y, loc_t arg_p2_x, loc_t arg_p2_y) :
00101     p1(point_t(arg_p1_x, arg_p1_y)), p2(point_t(arg_p2_x, arg_p2_y)){};
00102     
00103     rect_t() :
00104     p1(point_t()), p2(point_t()) {};
00105 };
00106 
00107 /// Data type that manages the calibration matrix for the resistive touch panel.
00108 ///
00109 /// This object, when instantiated, may be passed back and forth, stored
00110 /// and loaded, but the internals are generally of little interest.
00111 ///
00112 typedef struct
00113 {
00114     int32_t An;         ///< calibration factor, see source for details
00115     int32_t Bn;         ///< calibration factor, see source for details
00116     int32_t Cn;         ///< calibration factor, see source for details
00117     int32_t Dn;         ///< calibration factor, see source for details
00118     int32_t En;         ///< calibration factor, see source for details
00119     int32_t Fn;         ///< calibration factor, see source for details
00120     int32_t Divider;    ///< calibration factor, see source for details
00121 } tpMatrix_t;
00122 
00123 /// color type definition to let the compiler type-check parameters that
00124 /// are passed to or returned from APIs that use color.
00125 /// 
00126 /// colors can be easily defined with the @ref RGB(r,g,b) macro, or from 
00127 /// the @ref PredefinedColors.
00128 ///
00129 typedef uint16_t color_t;   
00130 
00131 /// background fill info for drawing Text, Rectangles, RoundedRectanges, Circles, Ellipses and Triangles.
00132 typedef enum
00133 {
00134     NOFILL,     ///< do not fill the object with the background color
00135     FILL        ///< fill the object space with the background color
00136 } fill_t;
00137 
00138 #endif // DISPLAYDEFS_H