Forked para SNOCC
Fork of RA8875 by
RA8875.cpp@89:04575562c961, 2015-01-25 (annotated)
- Committer:
- WiredHome
- Date:
- Sun Jan 25 00:15:02 2015 +0000
- Revision:
- 89:04575562c961
- Parent:
- 87:ee2240581aa7
- Child:
- 90:d113d71ae4f0
Minor change to the text for return code lookup.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WiredHome | 19:3f82c1161fd2 | 1 | /// RA8875 Display Controller Library. |
WiredHome | 73:f22a18707b5e | 2 | /// |
WiredHome | 68:ab08efabfc88 | 3 | /// This is being created for a Raio RA8875-based display from buydisplay.com, |
WiredHome | 80:cc4fab58179c | 4 | /// which is 480 x 272 using a 4-wire SPI interface. Support is provided for |
WiredHome | 80:cc4fab58179c | 5 | /// both a keypad and a resistive touch-screen. |
WiredHome | 80:cc4fab58179c | 6 | /// |
WiredHome | 68:ab08efabfc88 | 7 | /// This display controller is used in other display resolutions, up to 800x600. |
WiredHome | 68:ab08efabfc88 | 8 | /// While this driver has not been tested with these variants, nothing was done |
WiredHome | 68:ab08efabfc88 | 9 | /// to prevent easily supporting them. |
WiredHome | 19:3f82c1161fd2 | 10 | /// |
WiredHome | 19:3f82c1161fd2 | 11 | #include "RA8875.h" |
WiredHome | 19:3f82c1161fd2 | 12 | |
WiredHome | 41:2956a0a221e5 | 13 | //#define DEBUG "RAIO" |
WiredHome | 19:3f82c1161fd2 | 14 | // ... |
WiredHome | 19:3f82c1161fd2 | 15 | // INFO("Stuff to show %d", var); // new-line is automatically appended |
WiredHome | 19:3f82c1161fd2 | 16 | // |
WiredHome | 19:3f82c1161fd2 | 17 | #if (defined(DEBUG) && !defined(TARGET_LPC11U24)) |
WiredHome | 19:3f82c1161fd2 | 18 | #define INFO(x, ...) std::printf("[INF %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 19 | #define WARN(x, ...) std::printf("[WRN %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 20 | #define ERR(x, ...) std::printf("[ERR %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 73:f22a18707b5e | 21 | static void HexDump(char * title, uint8_t * p, int count) |
WiredHome | 73:f22a18707b5e | 22 | { |
WiredHome | 73:f22a18707b5e | 23 | int i; |
WiredHome | 73:f22a18707b5e | 24 | char buf[100] = "0000: "; |
WiredHome | 73:f22a18707b5e | 25 | |
WiredHome | 73:f22a18707b5e | 26 | if (*title) |
WiredHome | 73:f22a18707b5e | 27 | INFO("%s", title); |
WiredHome | 73:f22a18707b5e | 28 | for (i=0; i<count; ) { |
WiredHome | 73:f22a18707b5e | 29 | sprintf(buf + strlen(buf), "%02X ", *(p+i)); |
WiredHome | 73:f22a18707b5e | 30 | if ((++i & 0x0F) == 0x00) { |
WiredHome | 73:f22a18707b5e | 31 | INFO("%s", buf); |
WiredHome | 73:f22a18707b5e | 32 | if (i < count) |
WiredHome | 73:f22a18707b5e | 33 | sprintf(buf, "%04X: ", i); |
WiredHome | 73:f22a18707b5e | 34 | else |
WiredHome | 73:f22a18707b5e | 35 | buf[0] = '\0'; |
WiredHome | 73:f22a18707b5e | 36 | } |
WiredHome | 73:f22a18707b5e | 37 | } |
WiredHome | 73:f22a18707b5e | 38 | if (strlen(buf)) |
WiredHome | 73:f22a18707b5e | 39 | INFO("%s", buf); |
WiredHome | 73:f22a18707b5e | 40 | } |
WiredHome | 19:3f82c1161fd2 | 41 | #else |
WiredHome | 19:3f82c1161fd2 | 42 | #define INFO(x, ...) |
WiredHome | 19:3f82c1161fd2 | 43 | #define WARN(x, ...) |
WiredHome | 19:3f82c1161fd2 | 44 | #define ERR(x, ...) |
WiredHome | 73:f22a18707b5e | 45 | #define HexDump(a, b, c) |
WiredHome | 19:3f82c1161fd2 | 46 | #endif |
WiredHome | 19:3f82c1161fd2 | 47 | |
WiredHome | 19:3f82c1161fd2 | 48 | |
WiredHome | 19:3f82c1161fd2 | 49 | #define RA8875_DISPLAY_WIDTH 480 |
WiredHome | 19:3f82c1161fd2 | 50 | #define RA8875_DISPLAY_HEIGHT 272 |
WiredHome | 43:3becae133285 | 51 | #define RA8875_COLORDEPTH_BPP 16 /* Not an API */ |
WiredHome | 19:3f82c1161fd2 | 52 | |
WiredHome | 19:3f82c1161fd2 | 53 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 54 | #define PERFORMANCE_RESET performance.reset() |
WiredHome | 19:3f82c1161fd2 | 55 | #define REGISTERPERFORMANCE(a) RegisterPerformance(a) |
WiredHome | 68:ab08efabfc88 | 56 | #define COUNTIDLETIME(a) CountIdleTime(a) |
WiredHome | 73:f22a18707b5e | 57 | static const char *metricsName[] = { |
WiredHome | 73:f22a18707b5e | 58 | "Cls", "Pixel", "Pixel Stream", |
WiredHome | 41:2956a0a221e5 | 59 | "Read Pixel", "Read Pixel Stream", |
WiredHome | 73:f22a18707b5e | 60 | "Line", |
WiredHome | 73:f22a18707b5e | 61 | "Rectangle", "Rounded Rectangle", |
WiredHome | 68:ab08efabfc88 | 62 | "Triangle", "Circle", "Ellipse" |
WiredHome | 19:3f82c1161fd2 | 63 | }; |
WiredHome | 19:3f82c1161fd2 | 64 | #else |
WiredHome | 19:3f82c1161fd2 | 65 | #define PERFORMANCE_RESET |
WiredHome | 19:3f82c1161fd2 | 66 | #define REGISTERPERFORMANCE(a) |
WiredHome | 68:ab08efabfc88 | 67 | #define COUNTIDLETIME(a) |
WiredHome | 19:3f82c1161fd2 | 68 | #endif |
WiredHome | 19:3f82c1161fd2 | 69 | |
WiredHome | 73:f22a18707b5e | 70 | // When it is going to poll a register for completion, how many |
WiredHome | 19:3f82c1161fd2 | 71 | // uSec should it wait between each polling activity. |
WiredHome | 19:3f82c1161fd2 | 72 | #define POLLWAITuSec 10 |
WiredHome | 19:3f82c1161fd2 | 73 | |
WiredHome | 75:ca78388cfd77 | 74 | // Private RawKeyMap for the Keyboard interface |
WiredHome | 79:544eb4964795 | 75 | static const uint8_t DefaultKeyMap[22] = { |
WiredHome | 77:9206c13aa527 | 76 | 0, |
WiredHome | 77:9206c13aa527 | 77 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
WiredHome | 75:ca78388cfd77 | 78 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
WiredHome | 75:ca78388cfd77 | 79 | 255 |
WiredHome | 77:9206c13aa527 | 80 | }; |
WiredHome | 75:ca78388cfd77 | 81 | |
WiredHome | 79:544eb4964795 | 82 | static const char * ErrMessages[] = { |
WiredHome | 79:544eb4964795 | 83 | "noerror", ///< no errors, command completed successfully |
WiredHome | 89:04575562c961 | 84 | "bad parameter", ///< one or more parameters are invalid |
WiredHome | 89:04575562c961 | 85 | "file not found", ///< specified file could not be found |
WiredHome | 89:04575562c961 | 86 | "not bmp format", ///< file is not a .bmp file |
WiredHome | 89:04575562c961 | 87 | "not ico format", ///< file is not a .ico file |
WiredHome | 89:04575562c961 | 88 | "not supported format", ///< file format is not yet supported |
WiredHome | 89:04575562c961 | 89 | "image too big", ///< image is too large for the screen |
WiredHome | 89:04575562c961 | 90 | "not enough ram", ///< could not allocate ram for scanline |
WiredHome | 79:544eb4964795 | 91 | }; |
WiredHome | 19:3f82c1161fd2 | 92 | |
WiredHome | 19:3f82c1161fd2 | 93 | RA8875::RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset, const char *name) |
WiredHome | 58:26658a56112a | 94 | : GraphicsDisplay(name) |
WiredHome | 58:26658a56112a | 95 | , spi(mosi, miso, sclk) |
WiredHome | 19:3f82c1161fd2 | 96 | , cs(csel) |
WiredHome | 19:3f82c1161fd2 | 97 | , res(reset) |
WiredHome | 19:3f82c1161fd2 | 98 | { |
WiredHome | 19:3f82c1161fd2 | 99 | } |
WiredHome | 19:3f82c1161fd2 | 100 | |
WiredHome | 19:3f82c1161fd2 | 101 | //RA8875::~RA8875() |
WiredHome | 19:3f82c1161fd2 | 102 | //{ |
WiredHome | 19:3f82c1161fd2 | 103 | //} |
WiredHome | 19:3f82c1161fd2 | 104 | |
WiredHome | 81:01da2e34283d | 105 | RetCode_t RA8875::init(int width, int height, int color_bpp, bool poweron, bool keypadon, bool touchscreenon) |
WiredHome | 79:544eb4964795 | 106 | { |
WiredHome | 79:544eb4964795 | 107 | font = NULL; // no external font, use internal. |
WiredHome | 79:544eb4964795 | 108 | pKeyMap = DefaultKeyMap; // set default key map |
WiredHome | 79:544eb4964795 | 109 | _select(false); // deselect the display |
WiredHome | 79:544eb4964795 | 110 | frequency(RA8875_DEFAULT_SPI_FREQ); // data rate |
WiredHome | 79:544eb4964795 | 111 | Reset(); |
WiredHome | 79:544eb4964795 | 112 | WriteCommand(0x88, 0x0B); // PLLC1 - Phase Lock Loop registers |
WiredHome | 79:544eb4964795 | 113 | wait_ms(1); |
WiredHome | 79:544eb4964795 | 114 | WriteCommand(0x89, 0x02); |
WiredHome | 79:544eb4964795 | 115 | wait_ms(1); |
WiredHome | 79:544eb4964795 | 116 | |
WiredHome | 79:544eb4964795 | 117 | // System Config Register (SYSR) |
WiredHome | 79:544eb4964795 | 118 | if (color_bpp == 16) { |
WiredHome | 79:544eb4964795 | 119 | WriteCommand(0x10, 0x0C); // 16-bpp (65K colors) color depth, 8-bit interface |
WiredHome | 79:544eb4964795 | 120 | } else { // color_bpp == 8 |
WiredHome | 79:544eb4964795 | 121 | WriteCommand(0x10, 0x00); // 8-bpp (256 colors) |
WiredHome | 79:544eb4964795 | 122 | } |
WiredHome | 79:544eb4964795 | 123 | // Pixel Clock Setting Register (PCSR) |
WiredHome | 79:544eb4964795 | 124 | WriteCommand(0x04, 0x82); // PDAT on PCLK falling edge, PCLK = 4 x System Clock |
WiredHome | 79:544eb4964795 | 125 | wait_ms(1); |
WiredHome | 79:544eb4964795 | 126 | |
WiredHome | 79:544eb4964795 | 127 | // Horizontal Settings |
WiredHome | 79:544eb4964795 | 128 | WriteCommand(0x14, width/8 - 1); //HDWR//Horizontal Display Width Setting Bit[6:0] |
WiredHome | 79:544eb4964795 | 129 | WriteCommand(0x15, 0x02); //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0] |
WiredHome | 79:544eb4964795 | 130 | WriteCommand(0x16, 0x03); //HNDR//Horizontal Non-Display Period Bit[4:0] |
WiredHome | 79:544eb4964795 | 131 | WriteCommand(0x17, 0x01); //HSTR//HSYNC Start Position[4:0] |
WiredHome | 79:544eb4964795 | 132 | WriteCommand(0x18, 0x03); //HPWR//HSYNC Polarity ,The period width of HSYNC. |
WiredHome | 79:544eb4964795 | 133 | |
WiredHome | 79:544eb4964795 | 134 | // Vertical Settings |
WiredHome | 79:544eb4964795 | 135 | WriteCommand(0x19, (height-1)&0xFF); //VDHR0 //Vertical Display Height Bit [7:0] |
WiredHome | 79:544eb4964795 | 136 | WriteCommand(0x1a, (height-1)>>8); //VDHR1 //Vertical Display Height Bit [8] |
WiredHome | 79:544eb4964795 | 137 | WriteCommand(0x1b, 0x0F); //VNDR0 //Vertical Non-Display Period Bit [7:0] |
WiredHome | 79:544eb4964795 | 138 | WriteCommand(0x1c, 0x00); //VNDR1 //Vertical Non-Display Period Bit [8] |
WiredHome | 79:544eb4964795 | 139 | WriteCommand(0x1d, 0x0e); //VSTR0 //VSYNC Start Position[7:0] |
WiredHome | 79:544eb4964795 | 140 | WriteCommand(0x1e, 0x06); //VSTR1 //VSYNC Start Position[8] |
WiredHome | 79:544eb4964795 | 141 | WriteCommand(0x1f, 0x01); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0] |
WiredHome | 79:544eb4964795 | 142 | |
WiredHome | 79:544eb4964795 | 143 | if (width >= 800 && height >= 480 && color_bpp > 8) { |
WiredHome | 79:544eb4964795 | 144 | WriteCommand(0x20, 0x00); // DPCR - 1-layer mode when the resolution is too high |
WiredHome | 79:544eb4964795 | 145 | } else { |
WiredHome | 79:544eb4964795 | 146 | WriteCommand(0x20, 0x80); // DPCR - 2-layer mode |
WiredHome | 79:544eb4964795 | 147 | } |
WiredHome | 79:544eb4964795 | 148 | |
WiredHome | 79:544eb4964795 | 149 | // Set display image to Blue on Black as default |
WiredHome | 79:544eb4964795 | 150 | window(0,0, width, height); // Initialize to full screen |
WiredHome | 79:544eb4964795 | 151 | SetTextCursorControl(); |
WiredHome | 79:544eb4964795 | 152 | foreground(Blue); |
WiredHome | 79:544eb4964795 | 153 | background(Black); |
WiredHome | 79:544eb4964795 | 154 | cls(3); |
WiredHome | 79:544eb4964795 | 155 | |
WiredHome | 79:544eb4964795 | 156 | Power(poweron); |
WiredHome | 79:544eb4964795 | 157 | if (poweron) |
WiredHome | 79:544eb4964795 | 158 | Backlight_u8(255); |
WiredHome | 81:01da2e34283d | 159 | if (keypadon) |
WiredHome | 81:01da2e34283d | 160 | KeypadInit(); |
WiredHome | 81:01da2e34283d | 161 | if (touchscreenon) |
WiredHome | 81:01da2e34283d | 162 | TouchPanelInit(); |
WiredHome | 79:544eb4964795 | 163 | #ifdef PERF_METRICS |
WiredHome | 79:544eb4964795 | 164 | performance.start(); |
WiredHome | 79:544eb4964795 | 165 | ClearPerformance(); |
WiredHome | 79:544eb4964795 | 166 | #endif |
WiredHome | 79:544eb4964795 | 167 | return noerror; |
WiredHome | 79:544eb4964795 | 168 | } |
WiredHome | 79:544eb4964795 | 169 | |
WiredHome | 79:544eb4964795 | 170 | |
WiredHome | 79:544eb4964795 | 171 | RetCode_t RA8875::Reset(void) |
WiredHome | 79:544eb4964795 | 172 | { |
WiredHome | 79:544eb4964795 | 173 | RetCode_t ret; |
WiredHome | 79:544eb4964795 | 174 | |
WiredHome | 79:544eb4964795 | 175 | ret = WriteCommand(0x01, 0x01); // Apply Display Off, Reset |
WiredHome | 79:544eb4964795 | 176 | wait_ms(2); // no idea if I need to wait, or how long |
WiredHome | 79:544eb4964795 | 177 | if (ret == noerror) { |
WiredHome | 79:544eb4964795 | 178 | ret = WriteCommand(0x01, 0x00); // Display off, Remove reset |
WiredHome | 79:544eb4964795 | 179 | wait_ms(2); // no idea if I need to wait, or how long |
WiredHome | 79:544eb4964795 | 180 | } |
WiredHome | 79:544eb4964795 | 181 | return ret; |
WiredHome | 79:544eb4964795 | 182 | } |
WiredHome | 79:544eb4964795 | 183 | |
WiredHome | 79:544eb4964795 | 184 | |
WiredHome | 79:544eb4964795 | 185 | const char * RA8875::GetErrorMessage(RetCode_t code) |
WiredHome | 79:544eb4964795 | 186 | { |
WiredHome | 79:544eb4964795 | 187 | if (code >= LastErrCode) |
WiredHome | 79:544eb4964795 | 188 | code = bad_parameter; |
WiredHome | 79:544eb4964795 | 189 | return ErrMessages[code]; |
WiredHome | 79:544eb4964795 | 190 | } |
WiredHome | 79:544eb4964795 | 191 | |
WiredHome | 79:544eb4964795 | 192 | |
WiredHome | 61:8f3153bf0baa | 193 | uint16_t RA8875::GetDrawingLayer(void) |
WiredHome | 61:8f3153bf0baa | 194 | { |
WiredHome | 61:8f3153bf0baa | 195 | return (ReadCommand(0x41) & 0x01); |
WiredHome | 61:8f3153bf0baa | 196 | } |
WiredHome | 43:3becae133285 | 197 | |
WiredHome | 79:544eb4964795 | 198 | |
WiredHome | 50:2c4f474a2453 | 199 | RetCode_t RA8875::SelectDrawingLayer(uint16_t layer) |
WiredHome | 43:3becae133285 | 200 | { |
WiredHome | 43:3becae133285 | 201 | unsigned char mwcr1 = ReadCommand(0x41) & ~0x01; // retain all but the currently selected layer |
WiredHome | 43:3becae133285 | 202 | |
WiredHome | 43:3becae133285 | 203 | if (width() >= 800 && height() >= 480 && color_bpp() == 8) { |
WiredHome | 43:3becae133285 | 204 | return bad_parameter; |
WiredHome | 43:3becae133285 | 205 | } else if (layer > 1) { |
WiredHome | 43:3becae133285 | 206 | return bad_parameter; |
WiredHome | 43:3becae133285 | 207 | } else { // layer == 0 ro 1 |
WiredHome | 72:ecffe56af969 | 208 | return WriteCommand(0x41, mwcr1 | layer); |
WiredHome | 43:3becae133285 | 209 | } |
WiredHome | 43:3becae133285 | 210 | } |
WiredHome | 43:3becae133285 | 211 | |
WiredHome | 44:207594dece70 | 212 | |
WiredHome | 82:f7d300f26540 | 213 | RA8875::LayerMode_T RA8875::GetLayerMode(void) |
WiredHome | 82:f7d300f26540 | 214 | { |
WiredHome | 82:f7d300f26540 | 215 | return (LayerMode_T)(ReadCommand(0x52) & 0x7); |
WiredHome | 82:f7d300f26540 | 216 | } |
WiredHome | 82:f7d300f26540 | 217 | |
WiredHome | 82:f7d300f26540 | 218 | |
WiredHome | 53:86d24b9480b9 | 219 | RetCode_t RA8875::SetLayerMode(LayerMode_T mode) |
WiredHome | 44:207594dece70 | 220 | { |
WiredHome | 53:86d24b9480b9 | 221 | unsigned char ltpr0 = ReadCommand(0x52) & ~0x7; // retain all but the display layer mode |
WiredHome | 53:86d24b9480b9 | 222 | if (mode <= (LayerMode_T)6) { |
WiredHome | 53:86d24b9480b9 | 223 | WriteCommand(0x52, ltpr0 | (mode & 0x7)); |
WiredHome | 53:86d24b9480b9 | 224 | return noerror; |
WiredHome | 53:86d24b9480b9 | 225 | } else { |
WiredHome | 53:86d24b9480b9 | 226 | return bad_parameter; |
WiredHome | 53:86d24b9480b9 | 227 | } |
WiredHome | 44:207594dece70 | 228 | } |
WiredHome | 44:207594dece70 | 229 | |
WiredHome | 44:207594dece70 | 230 | |
WiredHome | 44:207594dece70 | 231 | RetCode_t RA8875::SetLayerTransparency(uint8_t layer1, uint8_t layer2) |
WiredHome | 44:207594dece70 | 232 | { |
WiredHome | 44:207594dece70 | 233 | if (layer1 > 8) |
WiredHome | 44:207594dece70 | 234 | layer1 = 8; |
WiredHome | 44:207594dece70 | 235 | if (layer2 > 8) |
WiredHome | 44:207594dece70 | 236 | layer2 = 8; |
WiredHome | 44:207594dece70 | 237 | WriteCommand(0x53, ((layer2 & 0xF) << 4) | (layer1 & 0xF)); |
WiredHome | 44:207594dece70 | 238 | return noerror; |
WiredHome | 44:207594dece70 | 239 | } |
WiredHome | 44:207594dece70 | 240 | |
WiredHome | 44:207594dece70 | 241 | |
WiredHome | 53:86d24b9480b9 | 242 | RetCode_t RA8875::SetBackgroundTransparencyColor(color_t color) |
WiredHome | 53:86d24b9480b9 | 243 | { |
WiredHome | 53:86d24b9480b9 | 244 | WriteCommand(0x67, (color >> 11) & 0x1F); |
WiredHome | 53:86d24b9480b9 | 245 | WriteCommand(0x68, (color >> 5) & 0x3F); |
WiredHome | 53:86d24b9480b9 | 246 | WriteCommand(0x69, (color & 0x1F)); |
WiredHome | 53:86d24b9480b9 | 247 | return noerror; |
WiredHome | 53:86d24b9480b9 | 248 | } |
WiredHome | 53:86d24b9480b9 | 249 | |
WiredHome | 79:544eb4964795 | 250 | |
WiredHome | 73:f22a18707b5e | 251 | color_t RA8875::GetBackgroundTransparencyColor(void) |
WiredHome | 73:f22a18707b5e | 252 | { |
WiredHome | 73:f22a18707b5e | 253 | RGBQUAD q; |
WiredHome | 73:f22a18707b5e | 254 | q.rgbRed = ReadCommand(0x67); |
WiredHome | 73:f22a18707b5e | 255 | q.rgbGreen = ReadCommand(0x68); |
WiredHome | 73:f22a18707b5e | 256 | q.rgbBlue = ReadCommand(0x69); |
WiredHome | 73:f22a18707b5e | 257 | return RGBQuadToRGB16(&q, 0); |
WiredHome | 73:f22a18707b5e | 258 | } |
WiredHome | 73:f22a18707b5e | 259 | |
WiredHome | 71:dcac8efd842d | 260 | |
WiredHome | 77:9206c13aa527 | 261 | RetCode_t RA8875::KeypadInit(bool scanEnable, bool longDetect, uint8_t sampleTime, uint8_t scanFrequency, |
WiredHome | 77:9206c13aa527 | 262 | uint8_t longTimeAdjustment, bool interruptEnable, bool wakeupEnable) |
WiredHome | 71:dcac8efd842d | 263 | { |
WiredHome | 71:dcac8efd842d | 264 | uint8_t value = 0; |
WiredHome | 77:9206c13aa527 | 265 | |
WiredHome | 71:dcac8efd842d | 266 | if (sampleTime > 3 || scanFrequency > 7 || longTimeAdjustment > 3) |
WiredHome | 71:dcac8efd842d | 267 | return bad_parameter; |
WiredHome | 71:dcac8efd842d | 268 | value |= (scanEnable) ? 0x80 : 0x00; |
WiredHome | 71:dcac8efd842d | 269 | value |= (longDetect) ? 0x40 : 0x00; |
WiredHome | 71:dcac8efd842d | 270 | value |= (sampleTime & 0x03) << 4; |
WiredHome | 71:dcac8efd842d | 271 | value |= (scanFrequency & 0x07); |
WiredHome | 75:ca78388cfd77 | 272 | WriteCommand(0xC0, value); // KSCR1 - Enable Key Scan (and ignore possibility of an error) |
WiredHome | 77:9206c13aa527 | 273 | |
WiredHome | 71:dcac8efd842d | 274 | value = 0; |
WiredHome | 71:dcac8efd842d | 275 | value |= (wakeupEnable) ? 0x80 : 0x00; |
WiredHome | 71:dcac8efd842d | 276 | value |= (longTimeAdjustment & 0x03) << 2; |
WiredHome | 75:ca78388cfd77 | 277 | WriteCommand(0xC1, value); // KSCR2 - (and ignore possibility of an error) |
WiredHome | 77:9206c13aa527 | 278 | |
WiredHome | 75:ca78388cfd77 | 279 | value = ReadCommand(0xF0); // (and ignore possibility of an error) |
WiredHome | 71:dcac8efd842d | 280 | value &= ~0x10; |
WiredHome | 71:dcac8efd842d | 281 | value |= (interruptEnable) ? 0x10 : 0x00; |
WiredHome | 75:ca78388cfd77 | 282 | return WriteCommand(0xF0, value); // INT |
WiredHome | 71:dcac8efd842d | 283 | } |
WiredHome | 71:dcac8efd842d | 284 | |
WiredHome | 79:544eb4964795 | 285 | |
WiredHome | 75:ca78388cfd77 | 286 | RetCode_t RA8875::SetKeyMap(const uint8_t * CodeList) |
WiredHome | 75:ca78388cfd77 | 287 | { |
WiredHome | 75:ca78388cfd77 | 288 | pKeyMap = CodeList; |
WiredHome | 75:ca78388cfd77 | 289 | return noerror; |
WiredHome | 75:ca78388cfd77 | 290 | } |
WiredHome | 75:ca78388cfd77 | 291 | |
WiredHome | 79:544eb4964795 | 292 | |
WiredHome | 75:ca78388cfd77 | 293 | bool RA8875::readable(void) |
WiredHome | 71:dcac8efd842d | 294 | { |
WiredHome | 71:dcac8efd842d | 295 | return (ReadCommand(0xF1) & 0x10); // check KS status - true if kbhit |
WiredHome | 71:dcac8efd842d | 296 | } |
WiredHome | 71:dcac8efd842d | 297 | |
WiredHome | 79:544eb4964795 | 298 | |
WiredHome | 75:ca78388cfd77 | 299 | uint8_t RA8875::getc(void) |
WiredHome | 71:dcac8efd842d | 300 | { |
WiredHome | 79:544eb4964795 | 301 | //#define GETC_DEV // for development |
WiredHome | 77:9206c13aa527 | 302 | #ifdef GETC_DEV |
WiredHome | 75:ca78388cfd77 | 303 | uint8_t keyCode1, keyCode2; |
WiredHome | 77:9206c13aa527 | 304 | #endif |
WiredHome | 75:ca78388cfd77 | 305 | uint8_t keyCode3; |
WiredHome | 75:ca78388cfd77 | 306 | static uint8_t count = 0; |
WiredHome | 75:ca78388cfd77 | 307 | uint8_t col, row; |
WiredHome | 75:ca78388cfd77 | 308 | uint8_t key; |
WiredHome | 77:9206c13aa527 | 309 | |
WiredHome | 75:ca78388cfd77 | 310 | while (!readable()) { |
WiredHome | 71:dcac8efd842d | 311 | wait_us(POLLWAITuSec); |
WiredHome | 75:ca78388cfd77 | 312 | // COUNTIDLETIME(POLLWAITuSec); // As it is voluntary to call the getc and pend. Don't tally it. |
WiredHome | 71:dcac8efd842d | 313 | } |
WiredHome | 71:dcac8efd842d | 314 | // read the key press number |
WiredHome | 71:dcac8efd842d | 315 | uint8_t keyNumReg = ReadCommand(0xC1) & 0x03; |
WiredHome | 75:ca78388cfd77 | 316 | count++; |
WiredHome | 75:ca78388cfd77 | 317 | switch (keyNumReg) { |
WiredHome | 75:ca78388cfd77 | 318 | case 0x01: // one key |
WiredHome | 75:ca78388cfd77 | 319 | keyCode3 = ReadCommand(0xC2); |
WiredHome | 77:9206c13aa527 | 320 | #ifdef GETC_DEV |
WiredHome | 75:ca78388cfd77 | 321 | keyCode2 = 0; |
WiredHome | 75:ca78388cfd77 | 322 | keyCode1 = 0; |
WiredHome | 77:9206c13aa527 | 323 | #endif |
WiredHome | 75:ca78388cfd77 | 324 | break; |
WiredHome | 75:ca78388cfd77 | 325 | case 0x02: // two keys |
WiredHome | 75:ca78388cfd77 | 326 | keyCode3 = ReadCommand(0xC3); |
WiredHome | 77:9206c13aa527 | 327 | #ifdef GETC_DEV |
WiredHome | 75:ca78388cfd77 | 328 | keyCode2 = ReadCommand(0xC2); |
WiredHome | 75:ca78388cfd77 | 329 | keyCode1 = 0; |
WiredHome | 77:9206c13aa527 | 330 | #endif |
WiredHome | 75:ca78388cfd77 | 331 | break; |
WiredHome | 75:ca78388cfd77 | 332 | case 0x03: // three keys |
WiredHome | 75:ca78388cfd77 | 333 | keyCode3 = ReadCommand(0xC4); |
WiredHome | 77:9206c13aa527 | 334 | #ifdef GETC_DEV |
WiredHome | 75:ca78388cfd77 | 335 | keyCode2 = ReadCommand(0xC3); |
WiredHome | 75:ca78388cfd77 | 336 | keyCode1 = ReadCommand(0xC2); |
WiredHome | 77:9206c13aa527 | 337 | #endif |
WiredHome | 75:ca78388cfd77 | 338 | break; |
WiredHome | 75:ca78388cfd77 | 339 | default: // no keys (key released) |
WiredHome | 75:ca78388cfd77 | 340 | keyCode3 = 0xFF; |
WiredHome | 77:9206c13aa527 | 341 | #ifdef GETC_DEV |
WiredHome | 75:ca78388cfd77 | 342 | keyCode2 = 0; |
WiredHome | 75:ca78388cfd77 | 343 | keyCode1 = 0; |
WiredHome | 77:9206c13aa527 | 344 | #endif |
WiredHome | 75:ca78388cfd77 | 345 | break; |
WiredHome | 75:ca78388cfd77 | 346 | } |
WiredHome | 75:ca78388cfd77 | 347 | if (keyCode3 == 0xFF) |
WiredHome | 75:ca78388cfd77 | 348 | key = pKeyMap[0]; // Key value 0 |
WiredHome | 75:ca78388cfd77 | 349 | else { |
WiredHome | 75:ca78388cfd77 | 350 | row = (keyCode3 >> 4) & 0x03; |
WiredHome | 75:ca78388cfd77 | 351 | col = (keyCode3 & 7); |
WiredHome | 75:ca78388cfd77 | 352 | key = row * 5 + col + 1; // Keys value 1 - 20 |
WiredHome | 75:ca78388cfd77 | 353 | if (key > 21) { |
WiredHome | 75:ca78388cfd77 | 354 | key = 21; |
WiredHome | 75:ca78388cfd77 | 355 | } |
WiredHome | 75:ca78388cfd77 | 356 | key = pKeyMap[key]; |
WiredHome | 75:ca78388cfd77 | 357 | key |= (keyCode3 & 0x80); // combine the key held flag |
WiredHome | 75:ca78388cfd77 | 358 | } |
WiredHome | 77:9206c13aa527 | 359 | #if GETC_DEV // for Development only |
WiredHome | 75:ca78388cfd77 | 360 | SetTextCursor(0, 20); |
WiredHome | 75:ca78388cfd77 | 361 | printf(" Reg: %02x\r\n", keyNumReg); |
WiredHome | 75:ca78388cfd77 | 362 | printf(" key1: %02x\r\n", keyCode1); |
WiredHome | 75:ca78388cfd77 | 363 | printf(" key2: %02x\r\n", keyCode2); |
WiredHome | 75:ca78388cfd77 | 364 | printf(" key3: %02x\r\n", keyCode3); |
WiredHome | 75:ca78388cfd77 | 365 | printf(" count: %02X\r\n", count); |
WiredHome | 75:ca78388cfd77 | 366 | printf(" key: %02X\r\n", key); |
WiredHome | 77:9206c13aa527 | 367 | #endif |
WiredHome | 75:ca78388cfd77 | 368 | WriteCommand(0xF1, 0x10); // Clear KS status |
WiredHome | 75:ca78388cfd77 | 369 | return key; |
WiredHome | 71:dcac8efd842d | 370 | } |
WiredHome | 71:dcac8efd842d | 371 | |
WiredHome | 79:544eb4964795 | 372 | |
WiredHome | 19:3f82c1161fd2 | 373 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 374 | void RA8875::ClearPerformance() |
WiredHome | 19:3f82c1161fd2 | 375 | { |
WiredHome | 19:3f82c1161fd2 | 376 | for (int i=0; i<METRICCOUNT; i++) |
WiredHome | 19:3f82c1161fd2 | 377 | metrics[i] = 0; |
WiredHome | 75:ca78388cfd77 | 378 | idletime_usec = 0; |
WiredHome | 19:3f82c1161fd2 | 379 | } |
WiredHome | 19:3f82c1161fd2 | 380 | |
WiredHome | 79:544eb4964795 | 381 | |
WiredHome | 19:3f82c1161fd2 | 382 | void RA8875::RegisterPerformance(method_e method) |
WiredHome | 19:3f82c1161fd2 | 383 | { |
WiredHome | 19:3f82c1161fd2 | 384 | unsigned long elapsed = performance.read_us(); |
WiredHome | 73:f22a18707b5e | 385 | |
WiredHome | 19:3f82c1161fd2 | 386 | if (method < METRICCOUNT && elapsed > metrics[method]) |
WiredHome | 19:3f82c1161fd2 | 387 | metrics[method] = elapsed; |
WiredHome | 19:3f82c1161fd2 | 388 | } |
WiredHome | 19:3f82c1161fd2 | 389 | |
WiredHome | 79:544eb4964795 | 390 | |
WiredHome | 66:468a11f05580 | 391 | void RA8875::CountIdleTime(uint32_t t) |
WiredHome | 66:468a11f05580 | 392 | { |
WiredHome | 75:ca78388cfd77 | 393 | idletime_usec += t; |
WiredHome | 66:468a11f05580 | 394 | } |
WiredHome | 44:207594dece70 | 395 | |
WiredHome | 79:544eb4964795 | 396 | |
WiredHome | 41:2956a0a221e5 | 397 | void RA8875::ReportPerformance(Serial & pc) |
WiredHome | 19:3f82c1161fd2 | 398 | { |
WiredHome | 41:2956a0a221e5 | 399 | pc.printf("\r\nPerformance Metrics\r\n"); |
WiredHome | 19:3f82c1161fd2 | 400 | for (int i=0; i<METRICCOUNT; i++) { |
WiredHome | 41:2956a0a221e5 | 401 | pc.printf("%10d uS %s\r\n", metrics[i], metricsName[i]); |
WiredHome | 66:468a11f05580 | 402 | } |
WiredHome | 75:ca78388cfd77 | 403 | pc.printf("%10d uS Idle time polling display for ready.\r\n", idletime_usec); |
WiredHome | 19:3f82c1161fd2 | 404 | } |
WiredHome | 19:3f82c1161fd2 | 405 | #endif |
WiredHome | 19:3f82c1161fd2 | 406 | |
WiredHome | 44:207594dece70 | 407 | |
WiredHome | 82:f7d300f26540 | 408 | bool RA8875::Intersect(rect_t rect, point_t p) |
WiredHome | 82:f7d300f26540 | 409 | { |
WiredHome | 82:f7d300f26540 | 410 | if (p.x >= min(rect.p1.x, rect.p2.x) && p.x <= max(rect.p1.x, rect.p2.x) |
WiredHome | 82:f7d300f26540 | 411 | && p.y >= min(rect.p1.y, rect.p2.y) && p.y <= max(rect.p1.y, rect.p2.y)) |
WiredHome | 82:f7d300f26540 | 412 | return true; |
WiredHome | 82:f7d300f26540 | 413 | else |
WiredHome | 82:f7d300f26540 | 414 | return false; |
WiredHome | 82:f7d300f26540 | 415 | } |
WiredHome | 82:f7d300f26540 | 416 | |
WiredHome | 82:f7d300f26540 | 417 | |
WiredHome | 82:f7d300f26540 | 418 | |
WiredHome | 38:38d503b4fad6 | 419 | RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t data) |
WiredHome | 38:38d503b4fad6 | 420 | { |
WiredHome | 38:38d503b4fad6 | 421 | WriteCommand(command, data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 422 | WriteCommand(command+1, data >> 8); |
WiredHome | 38:38d503b4fad6 | 423 | return noerror; |
WiredHome | 38:38d503b4fad6 | 424 | } |
WiredHome | 38:38d503b4fad6 | 425 | |
WiredHome | 44:207594dece70 | 426 | |
WiredHome | 19:3f82c1161fd2 | 427 | RetCode_t RA8875::WriteCommand(unsigned char command, unsigned int data) |
WiredHome | 19:3f82c1161fd2 | 428 | { |
WiredHome | 79:544eb4964795 | 429 | _select(true); |
WiredHome | 83:7bad0068cca0 | 430 | _spiwrite(0x80); // RS:1 (Cmd/Status), RW:0 (Write) |
WiredHome | 79:544eb4964795 | 431 | _spiwrite(command); |
WiredHome | 19:3f82c1161fd2 | 432 | if (data <= 0xFF) { // only if in the valid range |
WiredHome | 79:544eb4964795 | 433 | _spiwrite(0x00); |
WiredHome | 79:544eb4964795 | 434 | _spiwrite(data); |
WiredHome | 19:3f82c1161fd2 | 435 | } |
WiredHome | 79:544eb4964795 | 436 | _select(false); |
WiredHome | 19:3f82c1161fd2 | 437 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 438 | } |
WiredHome | 19:3f82c1161fd2 | 439 | |
WiredHome | 44:207594dece70 | 440 | |
WiredHome | 38:38d503b4fad6 | 441 | RetCode_t RA8875::WriteDataW(uint16_t data) |
WiredHome | 38:38d503b4fad6 | 442 | { |
WiredHome | 79:544eb4964795 | 443 | _select(true); |
WiredHome | 83:7bad0068cca0 | 444 | _spiwrite(0x00); // RS:0 (Data), RW:0 (Write) |
WiredHome | 79:544eb4964795 | 445 | _spiwrite(data & 0xFF); |
WiredHome | 79:544eb4964795 | 446 | _spiwrite(data >> 8); |
WiredHome | 79:544eb4964795 | 447 | _select(false); |
WiredHome | 38:38d503b4fad6 | 448 | return noerror; |
WiredHome | 38:38d503b4fad6 | 449 | } |
WiredHome | 38:38d503b4fad6 | 450 | |
WiredHome | 44:207594dece70 | 451 | |
WiredHome | 19:3f82c1161fd2 | 452 | RetCode_t RA8875::WriteData(unsigned char data) |
WiredHome | 19:3f82c1161fd2 | 453 | { |
WiredHome | 79:544eb4964795 | 454 | _select(true); |
WiredHome | 83:7bad0068cca0 | 455 | _spiwrite(0x00); // RS:0 (Data), RW:0 (Write) |
WiredHome | 79:544eb4964795 | 456 | _spiwrite(data); |
WiredHome | 79:544eb4964795 | 457 | _select(false); |
WiredHome | 19:3f82c1161fd2 | 458 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 459 | } |
WiredHome | 19:3f82c1161fd2 | 460 | |
WiredHome | 44:207594dece70 | 461 | |
WiredHome | 19:3f82c1161fd2 | 462 | unsigned char RA8875::ReadCommand(unsigned char command) |
WiredHome | 19:3f82c1161fd2 | 463 | { |
WiredHome | 19:3f82c1161fd2 | 464 | WriteCommand(command); |
WiredHome | 19:3f82c1161fd2 | 465 | return ReadData(); |
WiredHome | 19:3f82c1161fd2 | 466 | } |
WiredHome | 19:3f82c1161fd2 | 467 | |
WiredHome | 44:207594dece70 | 468 | |
WiredHome | 19:3f82c1161fd2 | 469 | unsigned char RA8875::ReadData(void) |
WiredHome | 19:3f82c1161fd2 | 470 | { |
WiredHome | 19:3f82c1161fd2 | 471 | unsigned char data; |
WiredHome | 73:f22a18707b5e | 472 | |
WiredHome | 79:544eb4964795 | 473 | _select(true); |
WiredHome | 83:7bad0068cca0 | 474 | _spiwrite(0x40); // RS:0 (Data), RW:1 (Read) |
WiredHome | 79:544eb4964795 | 475 | data = _spiread(); |
WiredHome | 79:544eb4964795 | 476 | _select(false); |
WiredHome | 19:3f82c1161fd2 | 477 | return data; |
WiredHome | 19:3f82c1161fd2 | 478 | } |
WiredHome | 19:3f82c1161fd2 | 479 | |
WiredHome | 44:207594dece70 | 480 | |
WiredHome | 41:2956a0a221e5 | 481 | uint16_t RA8875::ReadDataW(void) |
WiredHome | 41:2956a0a221e5 | 482 | { |
WiredHome | 41:2956a0a221e5 | 483 | uint16_t data; |
WiredHome | 73:f22a18707b5e | 484 | |
WiredHome | 79:544eb4964795 | 485 | _select(true); |
WiredHome | 83:7bad0068cca0 | 486 | _spiwrite(0x40); // RS:0 (Data), RW:1 (Read) |
WiredHome | 79:544eb4964795 | 487 | data = _spiread(); |
WiredHome | 79:544eb4964795 | 488 | data |= (_spiread() << 8); |
WiredHome | 79:544eb4964795 | 489 | _select(false); |
WiredHome | 41:2956a0a221e5 | 490 | return data; |
WiredHome | 41:2956a0a221e5 | 491 | } |
WiredHome | 41:2956a0a221e5 | 492 | |
WiredHome | 44:207594dece70 | 493 | |
WiredHome | 19:3f82c1161fd2 | 494 | unsigned char RA8875::ReadStatus(void) |
WiredHome | 19:3f82c1161fd2 | 495 | { |
WiredHome | 19:3f82c1161fd2 | 496 | unsigned char data; |
WiredHome | 73:f22a18707b5e | 497 | |
WiredHome | 79:544eb4964795 | 498 | _select(true); |
WiredHome | 83:7bad0068cca0 | 499 | _spiwrite(0xC0); // RS:1 (Cmd/Status), RW:1 (Read) (Read STSR) |
WiredHome | 79:544eb4964795 | 500 | data = _spiread(); |
WiredHome | 79:544eb4964795 | 501 | _select(false); |
WiredHome | 19:3f82c1161fd2 | 502 | return data; |
WiredHome | 19:3f82c1161fd2 | 503 | } |
WiredHome | 19:3f82c1161fd2 | 504 | |
WiredHome | 79:544eb4964795 | 505 | |
WiredHome | 66:468a11f05580 | 506 | /// @todo add a timeout and return false, but how long |
WiredHome | 66:468a11f05580 | 507 | /// to wait since some operations can be very long. |
WiredHome | 66:468a11f05580 | 508 | bool RA8875::_WaitWhileBusy(uint8_t mask) |
WiredHome | 66:468a11f05580 | 509 | { |
WiredHome | 66:468a11f05580 | 510 | int i = 20000/POLLWAITuSec; // 20 msec max |
WiredHome | 66:468a11f05580 | 511 | |
WiredHome | 67:9f834f0ff97d | 512 | while (i-- && ReadStatus() & mask) { |
WiredHome | 66:468a11f05580 | 513 | wait_us(POLLWAITuSec); |
WiredHome | 68:ab08efabfc88 | 514 | COUNTIDLETIME(POLLWAITuSec); |
WiredHome | 67:9f834f0ff97d | 515 | } |
WiredHome | 66:468a11f05580 | 516 | if (i) |
WiredHome | 66:468a11f05580 | 517 | return true; |
WiredHome | 66:468a11f05580 | 518 | else |
WiredHome | 66:468a11f05580 | 519 | return false; |
WiredHome | 66:468a11f05580 | 520 | } |
WiredHome | 66:468a11f05580 | 521 | |
WiredHome | 79:544eb4964795 | 522 | |
WiredHome | 66:468a11f05580 | 523 | /// @todo add a timeout and return false, but how long |
WiredHome | 66:468a11f05580 | 524 | /// to wait since some operations can be very long. |
WiredHome | 66:468a11f05580 | 525 | bool RA8875::_WaitWhileReg(uint8_t reg, uint8_t mask) |
WiredHome | 66:468a11f05580 | 526 | { |
WiredHome | 66:468a11f05580 | 527 | int i = 20000/POLLWAITuSec; // 20 msec max |
WiredHome | 66:468a11f05580 | 528 | |
WiredHome | 67:9f834f0ff97d | 529 | while (i-- && ReadCommand(reg) & mask) { |
WiredHome | 66:468a11f05580 | 530 | wait_us(POLLWAITuSec); |
WiredHome | 68:ab08efabfc88 | 531 | COUNTIDLETIME(POLLWAITuSec); |
WiredHome | 67:9f834f0ff97d | 532 | } |
WiredHome | 66:468a11f05580 | 533 | if (i) |
WiredHome | 66:468a11f05580 | 534 | return true; |
WiredHome | 66:468a11f05580 | 535 | else |
WiredHome | 66:468a11f05580 | 536 | return false; |
WiredHome | 66:468a11f05580 | 537 | } |
WiredHome | 66:468a11f05580 | 538 | |
WiredHome | 66:468a11f05580 | 539 | |
WiredHome | 37:f19b7e7449dc | 540 | dim_t RA8875::fontwidth(void) |
WiredHome | 19:3f82c1161fd2 | 541 | { |
WiredHome | 19:3f82c1161fd2 | 542 | if (font == NULL) |
WiredHome | 55:dfbabef7003e | 543 | return (((ReadCommand(0x22) >> 2) & 0x3) + 1) * 8; |
WiredHome | 19:3f82c1161fd2 | 544 | else |
WiredHome | 29:422616aa04bd | 545 | return font[1]; |
WiredHome | 19:3f82c1161fd2 | 546 | } |
WiredHome | 19:3f82c1161fd2 | 547 | |
WiredHome | 44:207594dece70 | 548 | |
WiredHome | 37:f19b7e7449dc | 549 | dim_t RA8875::fontheight(void) |
WiredHome | 19:3f82c1161fd2 | 550 | { |
WiredHome | 19:3f82c1161fd2 | 551 | if (font == NULL) |
WiredHome | 23:a50ded45dbaf | 552 | return (((ReadCommand(0x22) >> 0) & 0x3) + 1) * 16; |
WiredHome | 19:3f82c1161fd2 | 553 | else |
WiredHome | 29:422616aa04bd | 554 | return font[2]; |
WiredHome | 19:3f82c1161fd2 | 555 | } |
WiredHome | 19:3f82c1161fd2 | 556 | |
WiredHome | 44:207594dece70 | 557 | |
WiredHome | 37:f19b7e7449dc | 558 | RetCode_t RA8875::locate(textloc_t column, textloc_t row) |
WiredHome | 19:3f82c1161fd2 | 559 | { |
WiredHome | 32:0e4f2ae512e2 | 560 | return SetTextCursor(column * fontwidth(), row * fontheight()); |
WiredHome | 19:3f82c1161fd2 | 561 | } |
WiredHome | 19:3f82c1161fd2 | 562 | |
WiredHome | 44:207594dece70 | 563 | |
WiredHome | 19:3f82c1161fd2 | 564 | int RA8875::columns(void) |
WiredHome | 19:3f82c1161fd2 | 565 | { |
WiredHome | 19:3f82c1161fd2 | 566 | return width() / fontwidth(); |
WiredHome | 19:3f82c1161fd2 | 567 | } |
WiredHome | 19:3f82c1161fd2 | 568 | |
WiredHome | 44:207594dece70 | 569 | |
WiredHome | 19:3f82c1161fd2 | 570 | int RA8875::rows(void) |
WiredHome | 19:3f82c1161fd2 | 571 | { |
WiredHome | 19:3f82c1161fd2 | 572 | return height() / fontheight(); |
WiredHome | 19:3f82c1161fd2 | 573 | } |
WiredHome | 19:3f82c1161fd2 | 574 | |
WiredHome | 44:207594dece70 | 575 | |
WiredHome | 38:38d503b4fad6 | 576 | dim_t RA8875::width(void) |
WiredHome | 19:3f82c1161fd2 | 577 | { |
WiredHome | 29:422616aa04bd | 578 | return (ReadCommand(0x14) + 1) * 8; |
WiredHome | 19:3f82c1161fd2 | 579 | } |
WiredHome | 19:3f82c1161fd2 | 580 | |
WiredHome | 44:207594dece70 | 581 | |
WiredHome | 38:38d503b4fad6 | 582 | dim_t RA8875::height(void) |
WiredHome | 19:3f82c1161fd2 | 583 | { |
WiredHome | 29:422616aa04bd | 584 | return (ReadCommand(0x19) | (ReadCommand(0x1A) << 8)) + 1; |
WiredHome | 19:3f82c1161fd2 | 585 | } |
WiredHome | 19:3f82c1161fd2 | 586 | |
WiredHome | 44:207594dece70 | 587 | |
WiredHome | 43:3becae133285 | 588 | dim_t RA8875::color_bpp(void) |
WiredHome | 43:3becae133285 | 589 | { |
WiredHome | 43:3becae133285 | 590 | if ((ReadCommand(0x10) & 0x0C) == 0x04) |
WiredHome | 43:3becae133285 | 591 | return 16; |
WiredHome | 43:3becae133285 | 592 | else |
WiredHome | 43:3becae133285 | 593 | return 8; |
WiredHome | 43:3becae133285 | 594 | } |
WiredHome | 43:3becae133285 | 595 | |
WiredHome | 44:207594dece70 | 596 | |
WiredHome | 37:f19b7e7449dc | 597 | RetCode_t RA8875::SetTextCursor(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 598 | { |
WiredHome | 75:ca78388cfd77 | 599 | cursor_x = x; // set these values for non-internal fonts |
WiredHome | 75:ca78388cfd77 | 600 | cursor_y = y; |
WiredHome | 38:38d503b4fad6 | 601 | WriteCommandW(0x2A, x); |
WiredHome | 38:38d503b4fad6 | 602 | WriteCommandW(0x2C, y); |
WiredHome | 19:3f82c1161fd2 | 603 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 604 | } |
WiredHome | 19:3f82c1161fd2 | 605 | |
WiredHome | 44:207594dece70 | 606 | |
WiredHome | 37:f19b7e7449dc | 607 | loc_t RA8875::GetTextCursor_Y(void) |
WiredHome | 29:422616aa04bd | 608 | { |
WiredHome | 29:422616aa04bd | 609 | if (font == NULL) |
WiredHome | 29:422616aa04bd | 610 | return ReadCommand(0x2C) | (ReadCommand(0x2D) << 8); |
WiredHome | 29:422616aa04bd | 611 | else |
WiredHome | 29:422616aa04bd | 612 | return cursor_y; |
WiredHome | 29:422616aa04bd | 613 | } |
WiredHome | 29:422616aa04bd | 614 | |
WiredHome | 44:207594dece70 | 615 | |
WiredHome | 37:f19b7e7449dc | 616 | loc_t RA8875::GetTextCursor_X(void) |
WiredHome | 29:422616aa04bd | 617 | { |
WiredHome | 29:422616aa04bd | 618 | if (font == NULL) |
WiredHome | 29:422616aa04bd | 619 | return ReadCommand(0x2A) | (ReadCommand(0x2B) << 8); |
WiredHome | 29:422616aa04bd | 620 | else |
WiredHome | 29:422616aa04bd | 621 | return cursor_x; |
WiredHome | 29:422616aa04bd | 622 | } |
WiredHome | 29:422616aa04bd | 623 | |
WiredHome | 44:207594dece70 | 624 | |
WiredHome | 24:8ca861acf12d | 625 | RetCode_t RA8875::SetTextCursorControl(cursor_t cursor, bool blink) |
WiredHome | 23:a50ded45dbaf | 626 | { |
WiredHome | 23:a50ded45dbaf | 627 | unsigned char mwcr0 = ReadCommand(0x40) & 0x0F; // retain direction, auto-increase |
WiredHome | 43:3becae133285 | 628 | unsigned char mwcr1 = ReadCommand(0x41) & 0x01; // retain currently selected layer |
WiredHome | 24:8ca861acf12d | 629 | unsigned char horz = 0; |
WiredHome | 24:8ca861acf12d | 630 | unsigned char vert = 0; |
WiredHome | 73:f22a18707b5e | 631 | |
WiredHome | 24:8ca861acf12d | 632 | mwcr0 |= 0x80; // text mode |
WiredHome | 24:8ca861acf12d | 633 | if (cursor != NOCURSOR) |
WiredHome | 24:8ca861acf12d | 634 | mwcr0 |= 0x40; // visible |
WiredHome | 23:a50ded45dbaf | 635 | if (blink) |
WiredHome | 24:8ca861acf12d | 636 | mwcr0 |= 0x20; // blink |
WiredHome | 23:a50ded45dbaf | 637 | WriteCommand(0x40, mwcr0); // configure the cursor |
WiredHome | 43:3becae133285 | 638 | WriteCommand(0x41, mwcr1); // close the graphics cursor |
WiredHome | 24:8ca861acf12d | 639 | WriteCommand(0x44, 0x1f); // The cursor flashing cycle |
WiredHome | 24:8ca861acf12d | 640 | switch (cursor) { |
WiredHome | 24:8ca861acf12d | 641 | case IBEAM: |
WiredHome | 24:8ca861acf12d | 642 | horz = 0x01; |
WiredHome | 24:8ca861acf12d | 643 | vert = 0x1F; |
WiredHome | 24:8ca861acf12d | 644 | break; |
WiredHome | 24:8ca861acf12d | 645 | case UNDER: |
WiredHome | 24:8ca861acf12d | 646 | horz = 0x07; |
WiredHome | 24:8ca861acf12d | 647 | vert = 0x01; |
WiredHome | 24:8ca861acf12d | 648 | break; |
WiredHome | 24:8ca861acf12d | 649 | case BLOCK: |
WiredHome | 24:8ca861acf12d | 650 | horz = 0x07; |
WiredHome | 24:8ca861acf12d | 651 | vert = 0x1F; |
WiredHome | 24:8ca861acf12d | 652 | break; |
WiredHome | 24:8ca861acf12d | 653 | case NOCURSOR: |
WiredHome | 24:8ca861acf12d | 654 | default: |
WiredHome | 24:8ca861acf12d | 655 | break; |
WiredHome | 24:8ca861acf12d | 656 | } |
WiredHome | 24:8ca861acf12d | 657 | WriteCommand(0x4e, horz); // The cursor size horz |
WiredHome | 24:8ca861acf12d | 658 | WriteCommand(0x4f, vert); // The cursor size vert |
WiredHome | 23:a50ded45dbaf | 659 | return noerror; |
WiredHome | 23:a50ded45dbaf | 660 | } |
WiredHome | 23:a50ded45dbaf | 661 | |
WiredHome | 44:207594dece70 | 662 | |
WiredHome | 19:3f82c1161fd2 | 663 | RetCode_t RA8875::SetTextFont(RA8875::font_t font) |
WiredHome | 19:3f82c1161fd2 | 664 | { |
WiredHome | 19:3f82c1161fd2 | 665 | if (/*font >= RA8875::ISO8859_1 && */ font <= RA8875::ISO8859_4) { |
WiredHome | 19:3f82c1161fd2 | 666 | WriteCommand(0x21, (unsigned int)(font)); |
WiredHome | 19:3f82c1161fd2 | 667 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 668 | } else { |
WiredHome | 19:3f82c1161fd2 | 669 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 670 | } |
WiredHome | 19:3f82c1161fd2 | 671 | } |
WiredHome | 19:3f82c1161fd2 | 672 | |
WiredHome | 44:207594dece70 | 673 | |
WiredHome | 84:e102021864b5 | 674 | RetCode_t RA8875::SetOrientation(RA8875::orientation_t angle) |
WiredHome | 84:e102021864b5 | 675 | { |
WiredHome | 84:e102021864b5 | 676 | uint8_t fncr1Val = ReadCommand(0x22); |
WiredHome | 84:e102021864b5 | 677 | uint8_t dpcrVal = ReadCommand(0x20); |
WiredHome | 84:e102021864b5 | 678 | |
WiredHome | 84:e102021864b5 | 679 | fncr1Val &= ~0x10; // remove the old direction bit |
WiredHome | 84:e102021864b5 | 680 | dpcrVal &= ~0x0C; // remove the old scan direction bits |
WiredHome | 84:e102021864b5 | 681 | switch (angle) { |
WiredHome | 84:e102021864b5 | 682 | case RA8875::normal: |
WiredHome | 84:e102021864b5 | 683 | //fncr1Val |= 0x10; |
WiredHome | 84:e102021864b5 | 684 | //dpcrVal |= 0x00; |
WiredHome | 84:e102021864b5 | 685 | break; |
WiredHome | 84:e102021864b5 | 686 | case RA8875::rotate_90: |
WiredHome | 84:e102021864b5 | 687 | fncr1Val |= 0x10; |
WiredHome | 84:e102021864b5 | 688 | dpcrVal |= 0x08; |
WiredHome | 84:e102021864b5 | 689 | break; |
WiredHome | 84:e102021864b5 | 690 | case RA8875::rotate_180: |
WiredHome | 84:e102021864b5 | 691 | //fncr1Val |= 0x00; |
WiredHome | 84:e102021864b5 | 692 | dpcrVal |= 0x0C; |
WiredHome | 84:e102021864b5 | 693 | break; |
WiredHome | 84:e102021864b5 | 694 | case RA8875::rotate_270: |
WiredHome | 84:e102021864b5 | 695 | fncr1Val |= 0x10; |
WiredHome | 84:e102021864b5 | 696 | dpcrVal |= 0x04; |
WiredHome | 84:e102021864b5 | 697 | break; |
WiredHome | 84:e102021864b5 | 698 | default: |
WiredHome | 84:e102021864b5 | 699 | return bad_parameter; |
WiredHome | 84:e102021864b5 | 700 | } |
WiredHome | 84:e102021864b5 | 701 | WriteCommand(0x22, fncr1Val); |
WiredHome | 84:e102021864b5 | 702 | return WriteCommand(0x20, dpcrVal); |
WiredHome | 84:e102021864b5 | 703 | } |
WiredHome | 84:e102021864b5 | 704 | |
WiredHome | 84:e102021864b5 | 705 | |
WiredHome | 19:3f82c1161fd2 | 706 | RetCode_t RA8875::SetTextFontControl(fill_t fillit, |
WiredHome | 73:f22a18707b5e | 707 | RA8875::HorizontalScale hScale, |
WiredHome | 73:f22a18707b5e | 708 | RA8875::VerticalScale vScale, |
WiredHome | 73:f22a18707b5e | 709 | RA8875::alignment_t alignment) |
WiredHome | 19:3f82c1161fd2 | 710 | { |
WiredHome | 73:f22a18707b5e | 711 | if (hScale >= 1 && hScale <= 4 && |
WiredHome | 73:f22a18707b5e | 712 | vScale >= 1 && vScale <= 4) { |
WiredHome | 84:e102021864b5 | 713 | uint8_t fncr1Val = ReadCommand(0x22); |
WiredHome | 84:e102021864b5 | 714 | |
WiredHome | 84:e102021864b5 | 715 | fncr1Val &= ~0x10; // do not disturbe the rotate flag |
WiredHome | 19:3f82c1161fd2 | 716 | if (alignment == align_full) |
WiredHome | 84:e102021864b5 | 717 | fncr1Val |= 0x80; |
WiredHome | 19:3f82c1161fd2 | 718 | if (fillit == NOFILL) |
WiredHome | 84:e102021864b5 | 719 | fncr1Val |= 0x40; |
WiredHome | 84:e102021864b5 | 720 | fncr1Val |= ((hScale - 1) << 2); |
WiredHome | 84:e102021864b5 | 721 | fncr1Val |= ((vScale - 1) << 0); |
WiredHome | 84:e102021864b5 | 722 | return WriteCommand(0x22, fncr1Val); |
WiredHome | 19:3f82c1161fd2 | 723 | } else { |
WiredHome | 19:3f82c1161fd2 | 724 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 725 | } |
WiredHome | 19:3f82c1161fd2 | 726 | } |
WiredHome | 19:3f82c1161fd2 | 727 | |
WiredHome | 44:207594dece70 | 728 | |
WiredHome | 19:3f82c1161fd2 | 729 | RetCode_t RA8875::SetTextFontSize(RA8875::HorizontalScale hScale, RA8875::VerticalScale vScale) |
WiredHome | 19:3f82c1161fd2 | 730 | { |
WiredHome | 19:3f82c1161fd2 | 731 | unsigned char reg = ReadCommand(0x22); |
WiredHome | 73:f22a18707b5e | 732 | |
WiredHome | 40:04aa280dfa39 | 733 | if (vScale == -1) |
WiredHome | 40:04aa280dfa39 | 734 | vScale = hScale; |
WiredHome | 19:3f82c1161fd2 | 735 | if (hScale >= 1 && hScale <= 4 && vScale >= 1 && vScale <= 4) { |
WiredHome | 19:3f82c1161fd2 | 736 | reg &= 0xF0; // keep the high nibble as is. |
WiredHome | 19:3f82c1161fd2 | 737 | reg |= ((hScale - 1) << 2); |
WiredHome | 19:3f82c1161fd2 | 738 | reg |= ((vScale - 1) << 0); |
WiredHome | 19:3f82c1161fd2 | 739 | WriteCommand(0x22, reg); |
WiredHome | 19:3f82c1161fd2 | 740 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 741 | } else { |
WiredHome | 19:3f82c1161fd2 | 742 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 743 | } |
WiredHome | 19:3f82c1161fd2 | 744 | } |
WiredHome | 19:3f82c1161fd2 | 745 | |
WiredHome | 44:207594dece70 | 746 | |
WiredHome | 19:3f82c1161fd2 | 747 | int RA8875::_putc(int c) |
WiredHome | 19:3f82c1161fd2 | 748 | { |
WiredHome | 29:422616aa04bd | 749 | if (font == NULL) { |
WiredHome | 29:422616aa04bd | 750 | return _internal_putc(c); |
WiredHome | 29:422616aa04bd | 751 | } else { |
WiredHome | 29:422616aa04bd | 752 | return _external_putc(c); |
WiredHome | 29:422616aa04bd | 753 | } |
WiredHome | 29:422616aa04bd | 754 | } |
WiredHome | 29:422616aa04bd | 755 | |
WiredHome | 44:207594dece70 | 756 | |
WiredHome | 29:422616aa04bd | 757 | int RA8875::_external_putc(int c) |
WiredHome | 29:422616aa04bd | 758 | { |
WiredHome | 19:3f82c1161fd2 | 759 | if (c) { |
WiredHome | 19:3f82c1161fd2 | 760 | if (c == '\r') { |
WiredHome | 29:422616aa04bd | 761 | cursor_x = 0; |
WiredHome | 29:422616aa04bd | 762 | } else if (c == '\n') { |
WiredHome | 29:422616aa04bd | 763 | cursor_y += font[2]; |
WiredHome | 29:422616aa04bd | 764 | } else { |
WiredHome | 29:422616aa04bd | 765 | int advance = character(cursor_x, cursor_y, c); // advance tells us how many pixels we advanced |
WiredHome | 37:f19b7e7449dc | 766 | //INFO("x,y,advance %d,%d,%d", cursor_x, cursor_y, advance); |
WiredHome | 29:422616aa04bd | 767 | if (advance) { |
WiredHome | 29:422616aa04bd | 768 | cursor_x += advance; |
WiredHome | 29:422616aa04bd | 769 | if (cursor_x >= width()) { |
WiredHome | 29:422616aa04bd | 770 | cursor_x = 0; |
WiredHome | 29:422616aa04bd | 771 | cursor_y += font[2]; |
WiredHome | 29:422616aa04bd | 772 | if (cursor_y >= height()) { |
WiredHome | 29:422616aa04bd | 773 | cursor_y = 0; // @todo Should it scroll? |
WiredHome | 29:422616aa04bd | 774 | } |
WiredHome | 29:422616aa04bd | 775 | } |
WiredHome | 29:422616aa04bd | 776 | } |
WiredHome | 29:422616aa04bd | 777 | } |
WiredHome | 29:422616aa04bd | 778 | } |
WiredHome | 29:422616aa04bd | 779 | return c; |
WiredHome | 29:422616aa04bd | 780 | } |
WiredHome | 29:422616aa04bd | 781 | |
WiredHome | 44:207594dece70 | 782 | |
WiredHome | 29:422616aa04bd | 783 | int RA8875::_internal_putc(int c) |
WiredHome | 29:422616aa04bd | 784 | { |
WiredHome | 29:422616aa04bd | 785 | if (c) { |
WiredHome | 29:422616aa04bd | 786 | unsigned char mwcr0; |
WiredHome | 73:f22a18707b5e | 787 | |
WiredHome | 29:422616aa04bd | 788 | mwcr0 = ReadCommand(0x40); |
WiredHome | 29:422616aa04bd | 789 | if ((mwcr0 & 0x80) == 0x00) { |
WiredHome | 29:422616aa04bd | 790 | WriteCommand(0x40, 0x80 | mwcr0); // Put in Text mode if not already |
WiredHome | 29:422616aa04bd | 791 | } |
WiredHome | 29:422616aa04bd | 792 | if (c == '\r') { |
WiredHome | 37:f19b7e7449dc | 793 | loc_t x; |
WiredHome | 19:3f82c1161fd2 | 794 | x = ReadCommand(0x30) | (ReadCommand(0x31) << 8); // Left edge of active window |
WiredHome | 38:38d503b4fad6 | 795 | WriteCommandW(0x2A, x); |
WiredHome | 19:3f82c1161fd2 | 796 | } else if (c == '\n') { |
WiredHome | 37:f19b7e7449dc | 797 | loc_t y; |
WiredHome | 19:3f82c1161fd2 | 798 | y = ReadCommand(0x2C) | (ReadCommand(0x2D) << 8); // current y location |
WiredHome | 19:3f82c1161fd2 | 799 | y += fontheight(); |
WiredHome | 47:d96a09269f91 | 800 | if (y >= height()) // @TODO after bottom of active window, then scroll window? |
WiredHome | 19:3f82c1161fd2 | 801 | y = 0; |
WiredHome | 38:38d503b4fad6 | 802 | WriteCommandW(0x2C, y); |
WiredHome | 19:3f82c1161fd2 | 803 | } else { |
WiredHome | 29:422616aa04bd | 804 | WriteCommand(0x02); // RA8875 Internal Fonts |
WiredHome | 79:544eb4964795 | 805 | _select(true); |
WiredHome | 29:422616aa04bd | 806 | WriteData(c); |
WiredHome | 66:468a11f05580 | 807 | _WaitWhileBusy(0x80); |
WiredHome | 79:544eb4964795 | 808 | _select(false); |
WiredHome | 19:3f82c1161fd2 | 809 | } |
WiredHome | 19:3f82c1161fd2 | 810 | } |
WiredHome | 19:3f82c1161fd2 | 811 | return c; |
WiredHome | 19:3f82c1161fd2 | 812 | } |
WiredHome | 19:3f82c1161fd2 | 813 | |
WiredHome | 44:207594dece70 | 814 | |
WiredHome | 32:0e4f2ae512e2 | 815 | RetCode_t RA8875::_StartGraphicsStream(void) |
WiredHome | 32:0e4f2ae512e2 | 816 | { |
WiredHome | 32:0e4f2ae512e2 | 817 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 32:0e4f2ae512e2 | 818 | WriteCommand(0x02); // Prepare for streaming data |
WiredHome | 32:0e4f2ae512e2 | 819 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 820 | } |
WiredHome | 32:0e4f2ae512e2 | 821 | |
WiredHome | 44:207594dece70 | 822 | |
WiredHome | 32:0e4f2ae512e2 | 823 | RetCode_t RA8875::_EndGraphicsStream(void) |
WiredHome | 32:0e4f2ae512e2 | 824 | { |
WiredHome | 32:0e4f2ae512e2 | 825 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 826 | } |
WiredHome | 32:0e4f2ae512e2 | 827 | |
WiredHome | 44:207594dece70 | 828 | |
WiredHome | 55:dfbabef7003e | 829 | RetCode_t RA8875::_putp(color_t pixel) |
WiredHome | 32:0e4f2ae512e2 | 830 | { |
WiredHome | 38:38d503b4fad6 | 831 | WriteDataW((pixel>>8) | (pixel<<8)); |
WiredHome | 73:f22a18707b5e | 832 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 833 | } |
WiredHome | 29:422616aa04bd | 834 | |
WiredHome | 44:207594dece70 | 835 | |
WiredHome | 37:f19b7e7449dc | 836 | void RA8875::puts(loc_t x, loc_t y, const char * string) |
WiredHome | 19:3f82c1161fd2 | 837 | { |
WiredHome | 19:3f82c1161fd2 | 838 | SetTextCursor(x,y); |
WiredHome | 19:3f82c1161fd2 | 839 | puts(string); |
WiredHome | 19:3f82c1161fd2 | 840 | } |
WiredHome | 19:3f82c1161fd2 | 841 | |
WiredHome | 44:207594dece70 | 842 | |
WiredHome | 19:3f82c1161fd2 | 843 | void RA8875::puts(const char * string) |
WiredHome | 19:3f82c1161fd2 | 844 | { |
WiredHome | 29:422616aa04bd | 845 | unsigned char mwcr0 = ReadCommand(0x40); |
WiredHome | 73:f22a18707b5e | 846 | |
WiredHome | 37:f19b7e7449dc | 847 | if (font == NULL) { |
WiredHome | 37:f19b7e7449dc | 848 | if ((mwcr0 & 0x80) == 0x00) |
WiredHome | 37:f19b7e7449dc | 849 | WriteCommand(0x40,0x80); // Put in Text mode if not already |
WiredHome | 37:f19b7e7449dc | 850 | } else { |
WiredHome | 37:f19b7e7449dc | 851 | _StartGraphicsStream(); |
WiredHome | 37:f19b7e7449dc | 852 | } |
WiredHome | 19:3f82c1161fd2 | 853 | if (*string != '\0') { |
WiredHome | 73:f22a18707b5e | 854 | #if 1 |
WiredHome | 29:422616aa04bd | 855 | while (*string) { // @TODO calling individual _putc is slower... optimizations? |
WiredHome | 19:3f82c1161fd2 | 856 | _putc(*string++); |
WiredHome | 19:3f82c1161fd2 | 857 | } |
WiredHome | 73:f22a18707b5e | 858 | #else |
WiredHome | 19:3f82c1161fd2 | 859 | WriteCommand(0x02); |
WiredHome | 79:544eb4964795 | 860 | _select(true); |
WiredHome | 19:3f82c1161fd2 | 861 | while (*string != '\0') { |
WiredHome | 19:3f82c1161fd2 | 862 | WriteData(*string); |
WiredHome | 19:3f82c1161fd2 | 863 | ++string; |
WiredHome | 66:468a11f05580 | 864 | _WaitWhileBusy(0x80); |
WiredHome | 19:3f82c1161fd2 | 865 | } |
WiredHome | 79:544eb4964795 | 866 | _select(false); |
WiredHome | 73:f22a18707b5e | 867 | #endif |
WiredHome | 19:3f82c1161fd2 | 868 | } |
WiredHome | 37:f19b7e7449dc | 869 | if (font) |
WiredHome | 37:f19b7e7449dc | 870 | _EndGraphicsStream(); |
WiredHome | 19:3f82c1161fd2 | 871 | } |
WiredHome | 19:3f82c1161fd2 | 872 | |
WiredHome | 44:207594dece70 | 873 | |
WiredHome | 37:f19b7e7449dc | 874 | RetCode_t RA8875::SetGraphicsCursor(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 875 | { |
WiredHome | 38:38d503b4fad6 | 876 | WriteCommandW(0x46, x); |
WiredHome | 38:38d503b4fad6 | 877 | WriteCommandW(0x48, y); |
WiredHome | 19:3f82c1161fd2 | 878 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 879 | } |
WiredHome | 19:3f82c1161fd2 | 880 | |
WiredHome | 44:207594dece70 | 881 | |
WiredHome | 41:2956a0a221e5 | 882 | RetCode_t RA8875::SetGraphicsCursorRead(loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 883 | { |
WiredHome | 41:2956a0a221e5 | 884 | //WriteCommand(0x40, 0); // Graphics mode |
WiredHome | 41:2956a0a221e5 | 885 | //WriteCommand(0x45, 0); // left->right, top->bottom |
WiredHome | 41:2956a0a221e5 | 886 | WriteCommandW(0x4A, x); |
WiredHome | 41:2956a0a221e5 | 887 | WriteCommandW(0x4C, y); |
WiredHome | 41:2956a0a221e5 | 888 | return noerror; |
WiredHome | 41:2956a0a221e5 | 889 | } |
WiredHome | 41:2956a0a221e5 | 890 | |
WiredHome | 44:207594dece70 | 891 | |
WiredHome | 37:f19b7e7449dc | 892 | RetCode_t RA8875::window(loc_t x, loc_t y, dim_t width, dim_t height) |
WiredHome | 19:3f82c1161fd2 | 893 | { |
WiredHome | 37:f19b7e7449dc | 894 | GraphicsDisplay::window(x,y, width,height); |
WiredHome | 38:38d503b4fad6 | 895 | WriteCommandW(0x30, x); |
WiredHome | 38:38d503b4fad6 | 896 | WriteCommandW(0x32, y); |
WiredHome | 38:38d503b4fad6 | 897 | WriteCommandW(0x34, (x+width-1)); |
WiredHome | 38:38d503b4fad6 | 898 | WriteCommandW(0x36, (y+height-1)); |
WiredHome | 37:f19b7e7449dc | 899 | SetGraphicsCursor(x,y); |
WiredHome | 19:3f82c1161fd2 | 900 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 901 | } |
WiredHome | 19:3f82c1161fd2 | 902 | |
WiredHome | 44:207594dece70 | 903 | |
WiredHome | 61:8f3153bf0baa | 904 | RetCode_t RA8875::cls(uint16_t layers) |
WiredHome | 19:3f82c1161fd2 | 905 | { |
WiredHome | 61:8f3153bf0baa | 906 | RetCode_t ret; |
WiredHome | 73:f22a18707b5e | 907 | |
WiredHome | 19:3f82c1161fd2 | 908 | PERFORMANCE_RESET; |
WiredHome | 61:8f3153bf0baa | 909 | if (layers == 0) { |
WiredHome | 61:8f3153bf0baa | 910 | ret = clsw(FULLWINDOW); |
WiredHome | 61:8f3153bf0baa | 911 | ret = SetTextCursor(0,0); |
WiredHome | 61:8f3153bf0baa | 912 | } else if (layers > 3) { |
WiredHome | 61:8f3153bf0baa | 913 | ret = bad_parameter; |
WiredHome | 61:8f3153bf0baa | 914 | } else { |
WiredHome | 61:8f3153bf0baa | 915 | uint16_t prevLayer = GetDrawingLayer(); |
WiredHome | 61:8f3153bf0baa | 916 | if (layers & 1) { |
WiredHome | 61:8f3153bf0baa | 917 | SelectDrawingLayer(0); |
WiredHome | 61:8f3153bf0baa | 918 | clsw(FULLWINDOW); |
WiredHome | 61:8f3153bf0baa | 919 | } |
WiredHome | 61:8f3153bf0baa | 920 | if (layers & 2) { |
WiredHome | 61:8f3153bf0baa | 921 | SelectDrawingLayer(1); |
WiredHome | 61:8f3153bf0baa | 922 | clsw(FULLWINDOW); |
WiredHome | 61:8f3153bf0baa | 923 | } |
WiredHome | 61:8f3153bf0baa | 924 | ret = SelectDrawingLayer(prevLayer); |
WiredHome | 61:8f3153bf0baa | 925 | } |
WiredHome | 19:3f82c1161fd2 | 926 | REGISTERPERFORMANCE(PRF_CLS); |
WiredHome | 61:8f3153bf0baa | 927 | return ret; |
WiredHome | 19:3f82c1161fd2 | 928 | } |
WiredHome | 19:3f82c1161fd2 | 929 | |
WiredHome | 44:207594dece70 | 930 | |
WiredHome | 19:3f82c1161fd2 | 931 | RetCode_t RA8875::clsw(RA8875::Region_t region) |
WiredHome | 19:3f82c1161fd2 | 932 | { |
WiredHome | 19:3f82c1161fd2 | 933 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 934 | WriteCommand(0x8E, (region == ACTIVEWINDOW) ? 0xC0 : 0x80); |
WiredHome | 66:468a11f05580 | 935 | _WaitWhileReg(0x8E, 0x80); |
WiredHome | 19:3f82c1161fd2 | 936 | REGISTERPERFORMANCE(PRF_CLS); |
WiredHome | 19:3f82c1161fd2 | 937 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 938 | } |
WiredHome | 19:3f82c1161fd2 | 939 | |
WiredHome | 44:207594dece70 | 940 | |
WiredHome | 87:ee2240581aa7 | 941 | RetCode_t RA8875::pixel(point_t p, color_t color) |
WiredHome | 87:ee2240581aa7 | 942 | { |
WiredHome | 87:ee2240581aa7 | 943 | return pixel(p.x, p.y, color); |
WiredHome | 87:ee2240581aa7 | 944 | } |
WiredHome | 87:ee2240581aa7 | 945 | |
WiredHome | 87:ee2240581aa7 | 946 | RetCode_t RA8875::pixel(point_t p) |
WiredHome | 87:ee2240581aa7 | 947 | { |
WiredHome | 87:ee2240581aa7 | 948 | return pixel(p.x, p.y); |
WiredHome | 87:ee2240581aa7 | 949 | } |
WiredHome | 87:ee2240581aa7 | 950 | |
WiredHome | 37:f19b7e7449dc | 951 | RetCode_t RA8875::pixel(loc_t x, loc_t y, color_t color) |
WiredHome | 19:3f82c1161fd2 | 952 | { |
WiredHome | 62:ba5d33438fda | 953 | RetCode_t ret; |
WiredHome | 73:f22a18707b5e | 954 | |
WiredHome | 62:ba5d33438fda | 955 | PERFORMANCE_RESET; |
WiredHome | 73:f22a18707b5e | 956 | #if 1 |
WiredHome | 62:ba5d33438fda | 957 | ret = pixelStream(&color, 1, x,y); |
WiredHome | 73:f22a18707b5e | 958 | #else |
WiredHome | 19:3f82c1161fd2 | 959 | foreground(color); |
WiredHome | 62:ba5d33438fda | 960 | ret = pixel(x,y); |
WiredHome | 73:f22a18707b5e | 961 | #endif |
WiredHome | 62:ba5d33438fda | 962 | REGISTERPERFORMANCE(PRF_DRAWPIXEL); |
WiredHome | 62:ba5d33438fda | 963 | return ret; |
WiredHome | 19:3f82c1161fd2 | 964 | } |
WiredHome | 19:3f82c1161fd2 | 965 | |
WiredHome | 44:207594dece70 | 966 | |
WiredHome | 37:f19b7e7449dc | 967 | RetCode_t RA8875::pixel(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 968 | { |
WiredHome | 19:3f82c1161fd2 | 969 | RetCode_t ret; |
WiredHome | 73:f22a18707b5e | 970 | |
WiredHome | 19:3f82c1161fd2 | 971 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 972 | color_t color = GetForeColor(); |
WiredHome | 73:f22a18707b5e | 973 | #if 1 |
WiredHome | 62:ba5d33438fda | 974 | ret = pixelStream(&color, 1, x, y); |
WiredHome | 73:f22a18707b5e | 975 | #else |
WiredHome | 19:3f82c1161fd2 | 976 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 32:0e4f2ae512e2 | 977 | SetGraphicsCursor(x, y); |
WiredHome | 38:38d503b4fad6 | 978 | WriteCommand(0x02); |
WiredHome | 38:38d503b4fad6 | 979 | WriteDataW(color); |
WiredHome | 19:3f82c1161fd2 | 980 | ret = noerror; |
WiredHome | 73:f22a18707b5e | 981 | #endif |
WiredHome | 41:2956a0a221e5 | 982 | REGISTERPERFORMANCE(PRF_DRAWPIXEL); |
WiredHome | 19:3f82c1161fd2 | 983 | return ret; |
WiredHome | 19:3f82c1161fd2 | 984 | } |
WiredHome | 19:3f82c1161fd2 | 985 | |
WiredHome | 44:207594dece70 | 986 | |
WiredHome | 41:2956a0a221e5 | 987 | RetCode_t RA8875::pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 988 | { |
WiredHome | 41:2956a0a221e5 | 989 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 990 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 41:2956a0a221e5 | 991 | SetGraphicsCursor(x, y); |
WiredHome | 41:2956a0a221e5 | 992 | WriteCommand(0x02); |
WiredHome | 79:544eb4964795 | 993 | _select(true); |
WiredHome | 79:544eb4964795 | 994 | _spiwrite(0x00); // Cmd: write data |
WiredHome | 41:2956a0a221e5 | 995 | while (count--) { |
WiredHome | 79:544eb4964795 | 996 | _spiwrite(*p >> 8); |
WiredHome | 79:544eb4964795 | 997 | _spiwrite(*p & 0xFF); |
WiredHome | 41:2956a0a221e5 | 998 | p++; |
WiredHome | 41:2956a0a221e5 | 999 | } |
WiredHome | 79:544eb4964795 | 1000 | _select(false); |
WiredHome | 41:2956a0a221e5 | 1001 | REGISTERPERFORMANCE(PRF_PIXELSTREAM); |
WiredHome | 41:2956a0a221e5 | 1002 | return(noerror); |
WiredHome | 41:2956a0a221e5 | 1003 | } |
WiredHome | 41:2956a0a221e5 | 1004 | |
WiredHome | 44:207594dece70 | 1005 | |
WiredHome | 41:2956a0a221e5 | 1006 | color_t RA8875::getPixel(loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 1007 | { |
WiredHome | 41:2956a0a221e5 | 1008 | color_t pixel; |
WiredHome | 73:f22a18707b5e | 1009 | |
WiredHome | 41:2956a0a221e5 | 1010 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 1011 | //WriteCommand(0x45,0x00); // read left->right, top->bottom |
WiredHome | 41:2956a0a221e5 | 1012 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 41:2956a0a221e5 | 1013 | SetGraphicsCursorRead(x, y); |
WiredHome | 41:2956a0a221e5 | 1014 | WriteCommand(0x02); |
WiredHome | 79:544eb4964795 | 1015 | _select(true); |
WiredHome | 79:544eb4964795 | 1016 | _spiwrite(0x40); // Cmd: read data |
WiredHome | 79:544eb4964795 | 1017 | _spiwrite(0x00); // dummy read |
WiredHome | 79:544eb4964795 | 1018 | pixel = _spiread(); |
WiredHome | 79:544eb4964795 | 1019 | pixel |= (_spiread() << 8); |
WiredHome | 79:544eb4964795 | 1020 | _select(false); |
WiredHome | 41:2956a0a221e5 | 1021 | REGISTERPERFORMANCE(PRF_READPIXEL); |
WiredHome | 41:2956a0a221e5 | 1022 | return pixel; |
WiredHome | 41:2956a0a221e5 | 1023 | } |
WiredHome | 41:2956a0a221e5 | 1024 | |
WiredHome | 44:207594dece70 | 1025 | |
WiredHome | 41:2956a0a221e5 | 1026 | RetCode_t RA8875::getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 1027 | { |
WiredHome | 41:2956a0a221e5 | 1028 | color_t pixel; |
WiredHome | 86:e86b355940f4 | 1029 | RetCode_t ret = noerror; |
WiredHome | 73:f22a18707b5e | 1030 | |
WiredHome | 86:e86b355940f4 | 1031 | INFO("getPixelStream(%p, %u, %d, %d)", p, count, x, y); |
WiredHome | 41:2956a0a221e5 | 1032 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 1033 | //WriteCommand(0x45,0x00); // read left->right, top->bottom |
WiredHome | 86:e86b355940f4 | 1034 | ret = WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 86:e86b355940f4 | 1035 | INFO(" r = %d", ret); |
WiredHome | 86:e86b355940f4 | 1036 | ret = SetGraphicsCursorRead(x, y); |
WiredHome | 86:e86b355940f4 | 1037 | INFO(" r = %d", ret); |
WiredHome | 86:e86b355940f4 | 1038 | ret = WriteCommand(0x02); |
WiredHome | 86:e86b355940f4 | 1039 | INFO(" r = %d", ret); |
WiredHome | 79:544eb4964795 | 1040 | _select(true); |
WiredHome | 79:544eb4964795 | 1041 | _spiwrite(0x40); // Cmd: read data |
WiredHome | 79:544eb4964795 | 1042 | _spiwrite(0x00); // dummy read |
WiredHome | 41:2956a0a221e5 | 1043 | while (count--) { |
WiredHome | 79:544eb4964795 | 1044 | pixel = _spiread(); |
WiredHome | 79:544eb4964795 | 1045 | pixel |= (_spiread() << 8); |
WiredHome | 41:2956a0a221e5 | 1046 | *p++ = pixel; |
WiredHome | 41:2956a0a221e5 | 1047 | } |
WiredHome | 79:544eb4964795 | 1048 | _select(false); |
WiredHome | 41:2956a0a221e5 | 1049 | REGISTERPERFORMANCE(PRF_READPIXELSTREAM); |
WiredHome | 86:e86b355940f4 | 1050 | return ret; |
WiredHome | 41:2956a0a221e5 | 1051 | } |
WiredHome | 41:2956a0a221e5 | 1052 | |
WiredHome | 44:207594dece70 | 1053 | |
WiredHome | 83:7bad0068cca0 | 1054 | RetCode_t RA8875::line(point_t p1, point_t p2) |
WiredHome | 83:7bad0068cca0 | 1055 | { |
WiredHome | 83:7bad0068cca0 | 1056 | return line(p1.x, p1.y, p2.x, p2.y); |
WiredHome | 83:7bad0068cca0 | 1057 | } |
WiredHome | 83:7bad0068cca0 | 1058 | |
WiredHome | 83:7bad0068cca0 | 1059 | |
WiredHome | 83:7bad0068cca0 | 1060 | RetCode_t RA8875::line(point_t p1, point_t p2, color_t color) |
WiredHome | 83:7bad0068cca0 | 1061 | { |
WiredHome | 83:7bad0068cca0 | 1062 | return line(p1.x, p1.y, p2.x, p2.y, color); |
WiredHome | 83:7bad0068cca0 | 1063 | } |
WiredHome | 83:7bad0068cca0 | 1064 | |
WiredHome | 83:7bad0068cca0 | 1065 | |
WiredHome | 37:f19b7e7449dc | 1066 | RetCode_t RA8875::line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color) |
WiredHome | 19:3f82c1161fd2 | 1067 | { |
WiredHome | 19:3f82c1161fd2 | 1068 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1069 | return line(x1,y1,x2,y2); |
WiredHome | 19:3f82c1161fd2 | 1070 | } |
WiredHome | 19:3f82c1161fd2 | 1071 | |
WiredHome | 44:207594dece70 | 1072 | |
WiredHome | 37:f19b7e7449dc | 1073 | RetCode_t RA8875::line(loc_t x1, loc_t y1, loc_t x2, loc_t y2) |
WiredHome | 19:3f82c1161fd2 | 1074 | { |
WiredHome | 19:3f82c1161fd2 | 1075 | PERFORMANCE_RESET; |
WiredHome | 62:ba5d33438fda | 1076 | if (x1 == x2 && y1 == y2) { |
WiredHome | 60:2dfd574f63bd | 1077 | pixel(x1, y1); |
WiredHome | 62:ba5d33438fda | 1078 | } else { |
WiredHome | 60:2dfd574f63bd | 1079 | WriteCommandW(0x91, x1); |
WiredHome | 60:2dfd574f63bd | 1080 | WriteCommandW(0x93, y1); |
WiredHome | 60:2dfd574f63bd | 1081 | WriteCommandW(0x95, x2); |
WiredHome | 60:2dfd574f63bd | 1082 | WriteCommandW(0x97, y2); |
WiredHome | 60:2dfd574f63bd | 1083 | unsigned char drawCmd = 0x00; // Line |
WiredHome | 60:2dfd574f63bd | 1084 | WriteCommand(0x90, drawCmd); |
WiredHome | 60:2dfd574f63bd | 1085 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 66:468a11f05580 | 1086 | _WaitWhileReg(0x90, 0x80); |
WiredHome | 60:2dfd574f63bd | 1087 | } |
WiredHome | 19:3f82c1161fd2 | 1088 | REGISTERPERFORMANCE(PRF_DRAWLINE); |
WiredHome | 19:3f82c1161fd2 | 1089 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1090 | } |
WiredHome | 19:3f82c1161fd2 | 1091 | |
WiredHome | 81:01da2e34283d | 1092 | RetCode_t RA8875::fillrect(rect_t r, color_t color, fill_t fillit) |
WiredHome | 81:01da2e34283d | 1093 | { |
WiredHome | 81:01da2e34283d | 1094 | return rect(r.p1.x, r.p1.y, r.p2.x, r.p2.y, color, fillit); |
WiredHome | 81:01da2e34283d | 1095 | } |
WiredHome | 44:207594dece70 | 1096 | |
WiredHome | 73:f22a18707b5e | 1097 | RetCode_t RA8875::fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1098 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1099 | { |
WiredHome | 19:3f82c1161fd2 | 1100 | return rect(x1,y1,x2,y2,color,fillit); |
WiredHome | 19:3f82c1161fd2 | 1101 | } |
WiredHome | 19:3f82c1161fd2 | 1102 | |
WiredHome | 81:01da2e34283d | 1103 | RetCode_t RA8875::rect(rect_t r, color_t color, fill_t fillit) |
WiredHome | 81:01da2e34283d | 1104 | { |
WiredHome | 81:01da2e34283d | 1105 | return rect(r.p1.x, r.p1.y, r.p2.x, r.p2.y, color, fillit); |
WiredHome | 81:01da2e34283d | 1106 | } |
WiredHome | 44:207594dece70 | 1107 | |
WiredHome | 73:f22a18707b5e | 1108 | RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1109 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1110 | { |
WiredHome | 19:3f82c1161fd2 | 1111 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1112 | return rect(x1,y1,x2,y2,fillit); |
WiredHome | 19:3f82c1161fd2 | 1113 | } |
WiredHome | 19:3f82c1161fd2 | 1114 | |
WiredHome | 44:207594dece70 | 1115 | |
WiredHome | 73:f22a18707b5e | 1116 | RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1117 | fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1118 | { |
WiredHome | 85:022bba13c5c4 | 1119 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 1120 | PERFORMANCE_RESET; |
WiredHome | 85:022bba13c5c4 | 1121 | // check for bad_parameter |
WiredHome | 85:022bba13c5c4 | 1122 | if (x1 < 0 || x1 >= width() || x2 < 0 || x2 >= width() |
WiredHome | 85:022bba13c5c4 | 1123 | || y1 < 0 || y1 >= height() || y2 < 0 || y2 >= height()) |
WiredHome | 85:022bba13c5c4 | 1124 | ret = bad_parameter; |
WiredHome | 85:022bba13c5c4 | 1125 | else { |
WiredHome | 85:022bba13c5c4 | 1126 | if (x1 == x2 && y1 == y2) { |
WiredHome | 85:022bba13c5c4 | 1127 | pixel(x1, y1); |
WiredHome | 85:022bba13c5c4 | 1128 | } else if (x1 == x2) { |
WiredHome | 85:022bba13c5c4 | 1129 | line(x1, y1, x2, y2); |
WiredHome | 85:022bba13c5c4 | 1130 | } else if (y1 == y2) { |
WiredHome | 85:022bba13c5c4 | 1131 | line(x1, y1, x2, y2); |
WiredHome | 85:022bba13c5c4 | 1132 | } else { |
WiredHome | 85:022bba13c5c4 | 1133 | WriteCommandW(0x91, x1); |
WiredHome | 85:022bba13c5c4 | 1134 | WriteCommandW(0x93, y1); |
WiredHome | 85:022bba13c5c4 | 1135 | WriteCommandW(0x95, x2); |
WiredHome | 85:022bba13c5c4 | 1136 | WriteCommandW(0x97, y2); |
WiredHome | 85:022bba13c5c4 | 1137 | unsigned char drawCmd = 0x10; // Rectangle |
WiredHome | 85:022bba13c5c4 | 1138 | if (fillit == FILL) |
WiredHome | 85:022bba13c5c4 | 1139 | drawCmd |= 0x20; |
WiredHome | 85:022bba13c5c4 | 1140 | WriteCommand(0x90, drawCmd); |
WiredHome | 85:022bba13c5c4 | 1141 | ret = WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 85:022bba13c5c4 | 1142 | _WaitWhileReg(0x90, 0x80); |
WiredHome | 85:022bba13c5c4 | 1143 | } |
WiredHome | 19:3f82c1161fd2 | 1144 | } |
WiredHome | 19:3f82c1161fd2 | 1145 | REGISTERPERFORMANCE(PRF_DRAWRECTANGLE); |
WiredHome | 85:022bba13c5c4 | 1146 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1147 | } |
WiredHome | 19:3f82c1161fd2 | 1148 | |
WiredHome | 44:207594dece70 | 1149 | |
WiredHome | 73:f22a18707b5e | 1150 | RetCode_t RA8875::fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1151 | dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1152 | { |
WiredHome | 19:3f82c1161fd2 | 1153 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1154 | return roundrect(x1,y1,x2,y2,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 1155 | } |
WiredHome | 19:3f82c1161fd2 | 1156 | |
WiredHome | 44:207594dece70 | 1157 | |
WiredHome | 73:f22a18707b5e | 1158 | RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1159 | dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1160 | { |
WiredHome | 19:3f82c1161fd2 | 1161 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1162 | return roundrect(x1,y1,x2,y2,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 1163 | } |
WiredHome | 19:3f82c1161fd2 | 1164 | |
WiredHome | 44:207594dece70 | 1165 | |
WiredHome | 73:f22a18707b5e | 1166 | RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1167 | dim_t radius1, dim_t radius2, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1168 | { |
WiredHome | 19:3f82c1161fd2 | 1169 | RetCode_t ret = noerror; |
WiredHome | 73:f22a18707b5e | 1170 | |
WiredHome | 19:3f82c1161fd2 | 1171 | PERFORMANCE_RESET; |
WiredHome | 85:022bba13c5c4 | 1172 | if (x1 < 0 || x1 >= width() || x2 < 0 || x2 >= width() |
WiredHome | 85:022bba13c5c4 | 1173 | || y1 < 0 || y1 >= height() || y2 < 0 || y2 >= height()) { |
WiredHome | 85:022bba13c5c4 | 1174 | ret = bad_parameter; |
WiredHome | 85:022bba13c5c4 | 1175 | } else if (x1 > x2 || y1 > y2 || (radius1 > (x2-x1)/2) || (radius2 > (y2-y1)/2) ) { |
WiredHome | 21:3c1efb192927 | 1176 | ret = bad_parameter; |
WiredHome | 21:3c1efb192927 | 1177 | } else if (x1 == x2 && y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 1178 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 1179 | } else if (x1 == x2) { |
WiredHome | 19:3f82c1161fd2 | 1180 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 1181 | } else if (y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 1182 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 1183 | } else { |
WiredHome | 38:38d503b4fad6 | 1184 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 1185 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 1186 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 1187 | WriteCommandW(0x97, y2); |
WiredHome | 38:38d503b4fad6 | 1188 | WriteCommandW(0xA1, radius1); |
WiredHome | 38:38d503b4fad6 | 1189 | WriteCommandW(0xA3, radius2); |
WiredHome | 21:3c1efb192927 | 1190 | // Should not need this... |
WiredHome | 38:38d503b4fad6 | 1191 | WriteCommandW(0xA5, 0); |
WiredHome | 38:38d503b4fad6 | 1192 | WriteCommandW(0xA7, 0); |
WiredHome | 19:3f82c1161fd2 | 1193 | unsigned char drawCmd = 0x20; // Rounded Rectangle |
WiredHome | 19:3f82c1161fd2 | 1194 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1195 | drawCmd |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 1196 | WriteCommand(0xA0, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1197 | WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing. |
WiredHome | 66:468a11f05580 | 1198 | _WaitWhileReg(0xA0, 0x80); |
WiredHome | 19:3f82c1161fd2 | 1199 | } |
WiredHome | 19:3f82c1161fd2 | 1200 | REGISTERPERFORMANCE(PRF_DRAWROUNDEDRECTANGLE); |
WiredHome | 19:3f82c1161fd2 | 1201 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1202 | } |
WiredHome | 19:3f82c1161fd2 | 1203 | |
WiredHome | 44:207594dece70 | 1204 | |
WiredHome | 73:f22a18707b5e | 1205 | RetCode_t RA8875::triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1206 | loc_t x3, loc_t y3, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1207 | { |
WiredHome | 20:6e2e4a8372eb | 1208 | RetCode_t ret; |
WiredHome | 20:6e2e4a8372eb | 1209 | |
WiredHome | 85:022bba13c5c4 | 1210 | if (x1 < 0 || x1 >= width() || x2 < 0 || x2 >= width() || x3 < 0 || x3 >= width() |
WiredHome | 85:022bba13c5c4 | 1211 | || y1 < 0 || y1 >= height() || y2 < 0 || y2 >= height() || y3 < 0 || y3 >= height()) |
WiredHome | 85:022bba13c5c4 | 1212 | ret = bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 1213 | foreground(color); |
WiredHome | 20:6e2e4a8372eb | 1214 | ret = triangle(x1,y1,x2,y2,x3,y3,fillit); |
WiredHome | 20:6e2e4a8372eb | 1215 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1216 | } |
WiredHome | 19:3f82c1161fd2 | 1217 | |
WiredHome | 44:207594dece70 | 1218 | |
WiredHome | 73:f22a18707b5e | 1219 | RetCode_t RA8875::filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1220 | loc_t x3, loc_t y3, color_t color, fill_t fillit) |
WiredHome | 73:f22a18707b5e | 1221 | { |
WiredHome | 73:f22a18707b5e | 1222 | RetCode_t ret; |
WiredHome | 73:f22a18707b5e | 1223 | |
WiredHome | 73:f22a18707b5e | 1224 | foreground(color); |
WiredHome | 73:f22a18707b5e | 1225 | ret = triangle(x1,y1,x2,y2,x3,y3,fillit); |
WiredHome | 73:f22a18707b5e | 1226 | return ret; |
WiredHome | 73:f22a18707b5e | 1227 | } |
WiredHome | 73:f22a18707b5e | 1228 | |
WiredHome | 73:f22a18707b5e | 1229 | |
WiredHome | 73:f22a18707b5e | 1230 | RetCode_t RA8875::triangle(loc_t x1, loc_t y1 ,loc_t x2, loc_t y2, |
WiredHome | 73:f22a18707b5e | 1231 | loc_t x3, loc_t y3, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1232 | { |
WiredHome | 19:3f82c1161fd2 | 1233 | RetCode_t ret = noerror; |
WiredHome | 73:f22a18707b5e | 1234 | |
WiredHome | 19:3f82c1161fd2 | 1235 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 1236 | if (x1 == x2 && y1 == y2 && x1 == x3 && y1 == y3) { |
WiredHome | 19:3f82c1161fd2 | 1237 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 1238 | } else { |
WiredHome | 38:38d503b4fad6 | 1239 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 1240 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 1241 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 1242 | WriteCommandW(0x97, y2); |
WiredHome | 38:38d503b4fad6 | 1243 | WriteCommandW(0xA9, x3); |
WiredHome | 38:38d503b4fad6 | 1244 | WriteCommandW(0xAB, y3); |
WiredHome | 19:3f82c1161fd2 | 1245 | unsigned char drawCmd = 0x01; // Triangle |
WiredHome | 19:3f82c1161fd2 | 1246 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1247 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 1248 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1249 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 66:468a11f05580 | 1250 | _WaitWhileReg(0x90, 0x80); |
WiredHome | 19:3f82c1161fd2 | 1251 | } |
WiredHome | 19:3f82c1161fd2 | 1252 | REGISTERPERFORMANCE(PRF_DRAWTRIANGLE); |
WiredHome | 19:3f82c1161fd2 | 1253 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1254 | } |
WiredHome | 19:3f82c1161fd2 | 1255 | |
WiredHome | 83:7bad0068cca0 | 1256 | |
WiredHome | 83:7bad0068cca0 | 1257 | RetCode_t RA8875::circle(point_t p, dim_t radius, |
WiredHome | 83:7bad0068cca0 | 1258 | color_t color, fill_t fillit) |
WiredHome | 83:7bad0068cca0 | 1259 | { |
WiredHome | 83:7bad0068cca0 | 1260 | foreground(color); |
WiredHome | 83:7bad0068cca0 | 1261 | return circle(p.x,p.y,radius,fillit); |
WiredHome | 83:7bad0068cca0 | 1262 | } |
WiredHome | 83:7bad0068cca0 | 1263 | |
WiredHome | 83:7bad0068cca0 | 1264 | |
WiredHome | 83:7bad0068cca0 | 1265 | RetCode_t RA8875::fillcircle(point_t p, dim_t radius, |
WiredHome | 83:7bad0068cca0 | 1266 | color_t color, fill_t fillit) |
WiredHome | 83:7bad0068cca0 | 1267 | { |
WiredHome | 83:7bad0068cca0 | 1268 | foreground(color); |
WiredHome | 83:7bad0068cca0 | 1269 | return circle(p.x,p.y,radius,fillit); |
WiredHome | 83:7bad0068cca0 | 1270 | } |
WiredHome | 83:7bad0068cca0 | 1271 | |
WiredHome | 83:7bad0068cca0 | 1272 | |
WiredHome | 83:7bad0068cca0 | 1273 | RetCode_t RA8875::circle(point_t p, dim_t radius, fill_t fillit) |
WiredHome | 83:7bad0068cca0 | 1274 | { |
WiredHome | 83:7bad0068cca0 | 1275 | return circle(p.x,p.y,radius,fillit); |
WiredHome | 83:7bad0068cca0 | 1276 | } |
WiredHome | 83:7bad0068cca0 | 1277 | |
WiredHome | 83:7bad0068cca0 | 1278 | |
WiredHome | 73:f22a18707b5e | 1279 | RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, |
WiredHome | 73:f22a18707b5e | 1280 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1281 | { |
WiredHome | 19:3f82c1161fd2 | 1282 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1283 | return circle(x,y,radius,fillit); |
WiredHome | 19:3f82c1161fd2 | 1284 | } |
WiredHome | 19:3f82c1161fd2 | 1285 | |
WiredHome | 44:207594dece70 | 1286 | |
WiredHome | 73:f22a18707b5e | 1287 | RetCode_t RA8875::fillcircle(loc_t x, loc_t y, dim_t radius, |
WiredHome | 73:f22a18707b5e | 1288 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1289 | { |
WiredHome | 19:3f82c1161fd2 | 1290 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1291 | return circle(x,y,radius,fillit); |
WiredHome | 19:3f82c1161fd2 | 1292 | } |
WiredHome | 19:3f82c1161fd2 | 1293 | |
WiredHome | 44:207594dece70 | 1294 | |
WiredHome | 37:f19b7e7449dc | 1295 | RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1296 | { |
WiredHome | 19:3f82c1161fd2 | 1297 | RetCode_t ret = noerror; |
WiredHome | 73:f22a18707b5e | 1298 | |
WiredHome | 19:3f82c1161fd2 | 1299 | PERFORMANCE_RESET; |
WiredHome | 85:022bba13c5c4 | 1300 | if (radius <= 0 || (x - radius) < 0 || (x + radius) > width() |
WiredHome | 85:022bba13c5c4 | 1301 | || (y - radius) < 0 || (y + radius) > height()) { |
WiredHome | 19:3f82c1161fd2 | 1302 | ret = bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 1303 | } else if (radius == 1) { |
WiredHome | 19:3f82c1161fd2 | 1304 | pixel(x,y); |
WiredHome | 19:3f82c1161fd2 | 1305 | } else { |
WiredHome | 38:38d503b4fad6 | 1306 | WriteCommandW(0x99, x); |
WiredHome | 38:38d503b4fad6 | 1307 | WriteCommandW(0x9B, y); |
WiredHome | 19:3f82c1161fd2 | 1308 | WriteCommand(0x9d, radius & 0xFF); |
WiredHome | 19:3f82c1161fd2 | 1309 | unsigned char drawCmd = 0x00; // Circle |
WiredHome | 19:3f82c1161fd2 | 1310 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1311 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 1312 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1313 | WriteCommand(0x90, 0x40 + drawCmd); // Start drawing. |
WiredHome | 66:468a11f05580 | 1314 | _WaitWhileReg(0x90, 0x40); |
WiredHome | 19:3f82c1161fd2 | 1315 | } |
WiredHome | 19:3f82c1161fd2 | 1316 | REGISTERPERFORMANCE(PRF_DRAWCIRCLE); |
WiredHome | 19:3f82c1161fd2 | 1317 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1318 | } |
WiredHome | 19:3f82c1161fd2 | 1319 | |
WiredHome | 44:207594dece70 | 1320 | |
WiredHome | 37:f19b7e7449dc | 1321 | RetCode_t RA8875::ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1322 | { |
WiredHome | 19:3f82c1161fd2 | 1323 | foreground(color); |
WiredHome | 25:9556a3a9b7cc | 1324 | return ellipse(x,y,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 1325 | } |
WiredHome | 19:3f82c1161fd2 | 1326 | |
WiredHome | 44:207594dece70 | 1327 | |
WiredHome | 37:f19b7e7449dc | 1328 | RetCode_t RA8875::fillellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 25:9556a3a9b7cc | 1329 | { |
WiredHome | 25:9556a3a9b7cc | 1330 | foreground(color); |
WiredHome | 25:9556a3a9b7cc | 1331 | return ellipse(x,y,radius1,radius2,fillit); |
WiredHome | 25:9556a3a9b7cc | 1332 | } |
WiredHome | 44:207594dece70 | 1333 | |
WiredHome | 73:f22a18707b5e | 1334 | |
WiredHome | 37:f19b7e7449dc | 1335 | RetCode_t RA8875::ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1336 | { |
WiredHome | 19:3f82c1161fd2 | 1337 | RetCode_t ret = noerror; |
WiredHome | 73:f22a18707b5e | 1338 | |
WiredHome | 19:3f82c1161fd2 | 1339 | PERFORMANCE_RESET; |
WiredHome | 85:022bba13c5c4 | 1340 | if (radius1 <= 0 || radius2 <= 0 || (x - radius1) < 0 || (x + radius1) > width() |
WiredHome | 85:022bba13c5c4 | 1341 | || (y - radius2) < 0 || (y + radius2) > height()) { |
WiredHome | 85:022bba13c5c4 | 1342 | ret = bad_parameter; |
WiredHome | 25:9556a3a9b7cc | 1343 | } else if (radius1 == 1 && radius2 == 1) { |
WiredHome | 19:3f82c1161fd2 | 1344 | pixel(x, y); |
WiredHome | 19:3f82c1161fd2 | 1345 | } else { |
WiredHome | 38:38d503b4fad6 | 1346 | WriteCommandW(0xA5, x); |
WiredHome | 38:38d503b4fad6 | 1347 | WriteCommandW(0xA7, y); |
WiredHome | 38:38d503b4fad6 | 1348 | WriteCommandW(0xA1, radius1); |
WiredHome | 38:38d503b4fad6 | 1349 | WriteCommandW(0xA3, radius2); |
WiredHome | 19:3f82c1161fd2 | 1350 | unsigned char drawCmd = 0x00; // Ellipse |
WiredHome | 19:3f82c1161fd2 | 1351 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1352 | drawCmd |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 1353 | WriteCommand(0xA0, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1354 | WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing. |
WiredHome | 66:468a11f05580 | 1355 | _WaitWhileReg(0xA0, 0x80); |
WiredHome | 19:3f82c1161fd2 | 1356 | } |
WiredHome | 19:3f82c1161fd2 | 1357 | REGISTERPERFORMANCE(PRF_DRAWELLIPSE); |
WiredHome | 19:3f82c1161fd2 | 1358 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1359 | } |
WiredHome | 19:3f82c1161fd2 | 1360 | |
WiredHome | 44:207594dece70 | 1361 | |
WiredHome | 68:ab08efabfc88 | 1362 | RetCode_t RA8875::frequency(unsigned long Hz, unsigned long Hz2) |
WiredHome | 19:3f82c1161fd2 | 1363 | { |
WiredHome | 66:468a11f05580 | 1364 | spiwritefreq = Hz; |
WiredHome | 68:ab08efabfc88 | 1365 | if (Hz2 != 0) |
WiredHome | 68:ab08efabfc88 | 1366 | spireadfreq = Hz2; |
WiredHome | 68:ab08efabfc88 | 1367 | else |
WiredHome | 68:ab08efabfc88 | 1368 | spireadfreq = Hz/2; |
WiredHome | 68:ab08efabfc88 | 1369 | _setWriteSpeed(true); |
WiredHome | 19:3f82c1161fd2 | 1370 | // __ ___ |
WiredHome | 19:3f82c1161fd2 | 1371 | // Clock ___A Rising edge latched |
WiredHome | 19:3f82c1161fd2 | 1372 | // ___ ____ |
WiredHome | 19:3f82c1161fd2 | 1373 | // Data ___X____ |
WiredHome | 19:3f82c1161fd2 | 1374 | spi.format(8, 3); // 8 bits and clock to data phase 0 |
WiredHome | 19:3f82c1161fd2 | 1375 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1376 | } |
WiredHome | 19:3f82c1161fd2 | 1377 | |
WiredHome | 68:ab08efabfc88 | 1378 | void RA8875::_setWriteSpeed(bool writeSpeed) |
WiredHome | 68:ab08efabfc88 | 1379 | { |
WiredHome | 68:ab08efabfc88 | 1380 | if (writeSpeed) { |
WiredHome | 68:ab08efabfc88 | 1381 | spi.frequency(spiwritefreq); |
WiredHome | 68:ab08efabfc88 | 1382 | spiWriteSpeed = true; |
WiredHome | 68:ab08efabfc88 | 1383 | } else { |
WiredHome | 68:ab08efabfc88 | 1384 | spi.frequency(spireadfreq); |
WiredHome | 68:ab08efabfc88 | 1385 | spiWriteSpeed = false; |
WiredHome | 68:ab08efabfc88 | 1386 | } |
WiredHome | 68:ab08efabfc88 | 1387 | } |
WiredHome | 44:207594dece70 | 1388 | |
WiredHome | 19:3f82c1161fd2 | 1389 | RetCode_t RA8875::Power(bool on) |
WiredHome | 19:3f82c1161fd2 | 1390 | { |
WiredHome | 19:3f82c1161fd2 | 1391 | WriteCommand(0x01, (on) ? 0x80 : 0x00); |
WiredHome | 19:3f82c1161fd2 | 1392 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1393 | } |
WiredHome | 19:3f82c1161fd2 | 1394 | |
WiredHome | 44:207594dece70 | 1395 | |
WiredHome | 19:3f82c1161fd2 | 1396 | RetCode_t RA8875::Backlight_u8(unsigned char brightness) |
WiredHome | 19:3f82c1161fd2 | 1397 | { |
WiredHome | 19:3f82c1161fd2 | 1398 | static bool is_enabled = false; |
WiredHome | 19:3f82c1161fd2 | 1399 | if (brightness == 0) { |
WiredHome | 19:3f82c1161fd2 | 1400 | WriteCommand(0x8a); // Disable the PWM |
WiredHome | 19:3f82c1161fd2 | 1401 | WriteData(0x00); |
WiredHome | 19:3f82c1161fd2 | 1402 | is_enabled = false; |
WiredHome | 19:3f82c1161fd2 | 1403 | } else if (!is_enabled) { |
WiredHome | 19:3f82c1161fd2 | 1404 | WriteCommand(0x8a); // Enable the PWM |
WiredHome | 19:3f82c1161fd2 | 1405 | WriteData(0x80); |
WiredHome | 19:3f82c1161fd2 | 1406 | WriteCommand(0x8a); // Not sure why this is needed, but following the pattern |
WiredHome | 19:3f82c1161fd2 | 1407 | WriteData(0x81); // open PWM (SYS_CLK / 2 as best I can tell) |
WiredHome | 19:3f82c1161fd2 | 1408 | is_enabled = true; |
WiredHome | 19:3f82c1161fd2 | 1409 | } |
WiredHome | 19:3f82c1161fd2 | 1410 | WriteCommand(0x8b, brightness); // Brightness parameter 0xff-0x00 |
WiredHome | 19:3f82c1161fd2 | 1411 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1412 | } |
WiredHome | 19:3f82c1161fd2 | 1413 | |
WiredHome | 86:e86b355940f4 | 1414 | uint8_t RA8875::GetBacklight_u8(void) |
WiredHome | 86:e86b355940f4 | 1415 | { |
WiredHome | 86:e86b355940f4 | 1416 | return ReadCommand(0x8b); |
WiredHome | 86:e86b355940f4 | 1417 | } |
WiredHome | 44:207594dece70 | 1418 | |
WiredHome | 19:3f82c1161fd2 | 1419 | RetCode_t RA8875::Backlight(float brightness) |
WiredHome | 19:3f82c1161fd2 | 1420 | { |
WiredHome | 19:3f82c1161fd2 | 1421 | unsigned char b; |
WiredHome | 73:f22a18707b5e | 1422 | |
WiredHome | 29:422616aa04bd | 1423 | if (brightness >= 1.0) |
WiredHome | 19:3f82c1161fd2 | 1424 | b = 255; |
WiredHome | 29:422616aa04bd | 1425 | else if (brightness <= 0.0) |
WiredHome | 19:3f82c1161fd2 | 1426 | b = 0; |
WiredHome | 19:3f82c1161fd2 | 1427 | else |
WiredHome | 19:3f82c1161fd2 | 1428 | b = (unsigned char)(brightness * 255); |
WiredHome | 19:3f82c1161fd2 | 1429 | return Backlight_u8(b); |
WiredHome | 19:3f82c1161fd2 | 1430 | } |
WiredHome | 19:3f82c1161fd2 | 1431 | |
WiredHome | 86:e86b355940f4 | 1432 | float RA8875::GetBacklight(void) |
WiredHome | 86:e86b355940f4 | 1433 | { |
WiredHome | 86:e86b355940f4 | 1434 | return (float)(GetBacklight_u8())/255; |
WiredHome | 86:e86b355940f4 | 1435 | } |
WiredHome | 44:207594dece70 | 1436 | |
WiredHome | 19:3f82c1161fd2 | 1437 | RetCode_t RA8875::set_font(const unsigned char * _font) |
WiredHome | 19:3f82c1161fd2 | 1438 | { |
WiredHome | 37:f19b7e7449dc | 1439 | if (font && ! _font) { |
WiredHome | 37:f19b7e7449dc | 1440 | SetTextCursor(cursor_x, cursor_y); // soft-font cursor -> hw cursor |
WiredHome | 37:f19b7e7449dc | 1441 | } |
WiredHome | 19:3f82c1161fd2 | 1442 | font = _font; |
WiredHome | 29:422616aa04bd | 1443 | GraphicsDisplay::set_font(_font); |
WiredHome | 29:422616aa04bd | 1444 | return noerror; // trusting them, but it might be good to put some checks in here... |
WiredHome | 19:3f82c1161fd2 | 1445 | } |
WiredHome | 19:3f82c1161fd2 | 1446 | |
WiredHome | 44:207594dece70 | 1447 | |
WiredHome | 19:3f82c1161fd2 | 1448 | RetCode_t RA8875::background(color_t color) |
WiredHome | 19:3f82c1161fd2 | 1449 | { |
WiredHome | 37:f19b7e7449dc | 1450 | GraphicsDisplay::background(color); |
WiredHome | 19:3f82c1161fd2 | 1451 | WriteCommand(0x60, (color>>11)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 1452 | WriteCommand(0x61, (unsigned char)(color>>5)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 1453 | WriteCommand(0x62, (unsigned char)(color)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 1454 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1455 | } |
WiredHome | 19:3f82c1161fd2 | 1456 | |
WiredHome | 44:207594dece70 | 1457 | |
WiredHome | 19:3f82c1161fd2 | 1458 | RetCode_t RA8875::background(unsigned char r, unsigned char g, unsigned char b) |
WiredHome | 19:3f82c1161fd2 | 1459 | { |
WiredHome | 37:f19b7e7449dc | 1460 | background(RGB(r,g,b)); |
WiredHome | 19:3f82c1161fd2 | 1461 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1462 | } |
WiredHome | 19:3f82c1161fd2 | 1463 | |
WiredHome | 44:207594dece70 | 1464 | |
WiredHome | 19:3f82c1161fd2 | 1465 | RetCode_t RA8875::foreground(color_t color) |
WiredHome | 19:3f82c1161fd2 | 1466 | { |
WiredHome | 37:f19b7e7449dc | 1467 | GraphicsDisplay::foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1468 | WriteCommand(0x63, (unsigned char)(color>>11)); |
WiredHome | 19:3f82c1161fd2 | 1469 | WriteCommand(0x64, (unsigned char)(color>>5)); |
WiredHome | 19:3f82c1161fd2 | 1470 | WriteCommand(0x65, (unsigned char)(color)); |
WiredHome | 19:3f82c1161fd2 | 1471 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1472 | } |
WiredHome | 19:3f82c1161fd2 | 1473 | |
WiredHome | 44:207594dece70 | 1474 | |
WiredHome | 37:f19b7e7449dc | 1475 | RetCode_t RA8875::foreground(unsigned char r, unsigned char g, unsigned char b) |
WiredHome | 19:3f82c1161fd2 | 1476 | { |
WiredHome | 37:f19b7e7449dc | 1477 | foreground(RGB(r,g,b)); |
WiredHome | 19:3f82c1161fd2 | 1478 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1479 | } |
WiredHome | 19:3f82c1161fd2 | 1480 | |
WiredHome | 44:207594dece70 | 1481 | |
WiredHome | 37:f19b7e7449dc | 1482 | color_t RA8875::GetForeColor(void) |
WiredHome | 19:3f82c1161fd2 | 1483 | { |
WiredHome | 19:3f82c1161fd2 | 1484 | color_t color; |
WiredHome | 73:f22a18707b5e | 1485 | |
WiredHome | 19:3f82c1161fd2 | 1486 | color = (ReadCommand(0x63) & 0x1F) << 11; |
WiredHome | 19:3f82c1161fd2 | 1487 | color |= (ReadCommand(0x64) & 0x3F) << 5; |
WiredHome | 19:3f82c1161fd2 | 1488 | color |= (ReadCommand(0x65) & 0x1F); |
WiredHome | 19:3f82c1161fd2 | 1489 | return color; |
WiredHome | 19:3f82c1161fd2 | 1490 | } |
WiredHome | 19:3f82c1161fd2 | 1491 | |
WiredHome | 44:207594dece70 | 1492 | |
WiredHome | 19:3f82c1161fd2 | 1493 | color_t RA8875::DOSColor(int i) |
WiredHome | 73:f22a18707b5e | 1494 | { |
WiredHome | 73:f22a18707b5e | 1495 | const color_t colors[16] = { |
WiredHome | 19:3f82c1161fd2 | 1496 | Black, Blue, Green, Cyan, |
WiredHome | 19:3f82c1161fd2 | 1497 | Red, Magenta, Brown, Gray, |
WiredHome | 19:3f82c1161fd2 | 1498 | Charcoal, BrightBlue, BrightGreen, BrightCyan, |
WiredHome | 19:3f82c1161fd2 | 1499 | Orange, Pink, Yellow, White |
WiredHome | 73:f22a18707b5e | 1500 | }; |
WiredHome | 85:022bba13c5c4 | 1501 | if (i >= 0 && i < 16) |
WiredHome | 19:3f82c1161fd2 | 1502 | return colors[i]; |
WiredHome | 19:3f82c1161fd2 | 1503 | else |
WiredHome | 19:3f82c1161fd2 | 1504 | return 0; |
WiredHome | 73:f22a18707b5e | 1505 | } |
WiredHome | 19:3f82c1161fd2 | 1506 | |
WiredHome | 44:207594dece70 | 1507 | |
WiredHome | 73:f22a18707b5e | 1508 | const char * RA8875::DOSColorNames(int i) |
WiredHome | 73:f22a18707b5e | 1509 | { |
WiredHome | 73:f22a18707b5e | 1510 | const char * names[16] = { |
WiredHome | 19:3f82c1161fd2 | 1511 | "Black", "Blue", "Green", "Cyan", |
WiredHome | 19:3f82c1161fd2 | 1512 | "Red", "Magenta", "Brown", "Gray", |
WiredHome | 19:3f82c1161fd2 | 1513 | "Charcoal", "BrightBlue", "BrightGreen", "BrightCyan", |
WiredHome | 19:3f82c1161fd2 | 1514 | "Orange", "Pink", "Yellow", "White" |
WiredHome | 73:f22a18707b5e | 1515 | }; |
WiredHome | 85:022bba13c5c4 | 1516 | if (i >= 0 && i < 16) |
WiredHome | 19:3f82c1161fd2 | 1517 | return names[i]; |
WiredHome | 19:3f82c1161fd2 | 1518 | else |
WiredHome | 19:3f82c1161fd2 | 1519 | return NULL; |
WiredHome | 73:f22a18707b5e | 1520 | } |
WiredHome | 19:3f82c1161fd2 | 1521 | |
WiredHome | 19:3f82c1161fd2 | 1522 | |
WiredHome | 19:3f82c1161fd2 | 1523 | /////////////////////////////////////////////////////////////// |
WiredHome | 19:3f82c1161fd2 | 1524 | // Private functions |
WiredHome | 19:3f82c1161fd2 | 1525 | |
WiredHome | 79:544eb4964795 | 1526 | unsigned char RA8875::_spiwrite(unsigned char data) |
WiredHome | 19:3f82c1161fd2 | 1527 | { |
WiredHome | 19:3f82c1161fd2 | 1528 | unsigned char retval; |
WiredHome | 73:f22a18707b5e | 1529 | |
WiredHome | 68:ab08efabfc88 | 1530 | if (!spiWriteSpeed) |
WiredHome | 68:ab08efabfc88 | 1531 | _setWriteSpeed(true); |
WiredHome | 19:3f82c1161fd2 | 1532 | retval = spi.write(data); |
WiredHome | 19:3f82c1161fd2 | 1533 | return retval; |
WiredHome | 19:3f82c1161fd2 | 1534 | } |
WiredHome | 19:3f82c1161fd2 | 1535 | |
WiredHome | 44:207594dece70 | 1536 | |
WiredHome | 79:544eb4964795 | 1537 | unsigned char RA8875::_spiread(void) |
WiredHome | 19:3f82c1161fd2 | 1538 | { |
WiredHome | 19:3f82c1161fd2 | 1539 | unsigned char retval; |
WiredHome | 19:3f82c1161fd2 | 1540 | unsigned char data = 0; |
WiredHome | 73:f22a18707b5e | 1541 | |
WiredHome | 68:ab08efabfc88 | 1542 | if (spiWriteSpeed) |
WiredHome | 68:ab08efabfc88 | 1543 | _setWriteSpeed(false); |
WiredHome | 19:3f82c1161fd2 | 1544 | retval = spi.write(data); |
WiredHome | 19:3f82c1161fd2 | 1545 | return retval; |
WiredHome | 19:3f82c1161fd2 | 1546 | } |
WiredHome | 19:3f82c1161fd2 | 1547 | |
WiredHome | 44:207594dece70 | 1548 | |
WiredHome | 79:544eb4964795 | 1549 | RetCode_t RA8875::_select(bool chipsel) |
WiredHome | 19:3f82c1161fd2 | 1550 | { |
WiredHome | 19:3f82c1161fd2 | 1551 | cs = (chipsel == true) ? 0 : 1; |
WiredHome | 19:3f82c1161fd2 | 1552 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1553 | } |
WiredHome | 19:3f82c1161fd2 | 1554 | |
WiredHome | 44:207594dece70 | 1555 | |
WiredHome | 72:ecffe56af969 | 1556 | RetCode_t RA8875::PrintScreen(uint16_t layer, loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP) |
WiredHome | 72:ecffe56af969 | 1557 | { |
WiredHome | 74:686faa218914 | 1558 | (void)layer; |
WiredHome | 74:686faa218914 | 1559 | return PrintScreen(x, y, w, h, Name_BMP); |
WiredHome | 72:ecffe56af969 | 1560 | } |
WiredHome | 72:ecffe56af969 | 1561 | |
WiredHome | 79:544eb4964795 | 1562 | |
WiredHome | 72:ecffe56af969 | 1563 | RetCode_t RA8875::PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP) |
WiredHome | 72:ecffe56af969 | 1564 | { |
WiredHome | 72:ecffe56af969 | 1565 | BITMAPFILEHEADER BMP_Header; |
WiredHome | 72:ecffe56af969 | 1566 | BITMAPINFOHEADER BMP_Info; |
WiredHome | 86:e86b355940f4 | 1567 | uint8_t * lineBuffer = NULL; |
WiredHome | 86:e86b355940f4 | 1568 | color_t * pixelBuffer = NULL; |
WiredHome | 86:e86b355940f4 | 1569 | color_t * pixelBuffer2 = NULL; |
WiredHome | 86:e86b355940f4 | 1570 | |
WiredHome | 72:ecffe56af969 | 1571 | INFO("(%d,%d) - (%d,%d) %s", x,y,w,h,Name_BMP); |
WiredHome | 72:ecffe56af969 | 1572 | if (x >= 0 && x < width() |
WiredHome | 73:f22a18707b5e | 1573 | && y >= 0 && y < height() |
WiredHome | 73:f22a18707b5e | 1574 | && w > 0 && x + w <= width() |
WiredHome | 73:f22a18707b5e | 1575 | && h > 0 && y + h <= height()) { |
WiredHome | 72:ecffe56af969 | 1576 | |
WiredHome | 72:ecffe56af969 | 1577 | BMP_Header.bfType = BF_TYPE; |
WiredHome | 72:ecffe56af969 | 1578 | BMP_Header.bfSize = (w * h * sizeof(RGBQUAD)) + sizeof(BMP_Header) + sizeof(BMP_Header); |
WiredHome | 72:ecffe56af969 | 1579 | BMP_Header.bfReserved1 = 0; |
WiredHome | 72:ecffe56af969 | 1580 | BMP_Header.bfReserved2 = 0; |
WiredHome | 72:ecffe56af969 | 1581 | BMP_Header.bfOffBits = sizeof(BMP_Header) + sizeof(BMP_Header); |
WiredHome | 73:f22a18707b5e | 1582 | |
WiredHome | 72:ecffe56af969 | 1583 | BMP_Info.biSize = sizeof(BMP_Info); |
WiredHome | 72:ecffe56af969 | 1584 | BMP_Info.biWidth = w; |
WiredHome | 72:ecffe56af969 | 1585 | BMP_Info.biHeight = h; |
WiredHome | 72:ecffe56af969 | 1586 | BMP_Info.biPlanes = 1; |
WiredHome | 72:ecffe56af969 | 1587 | BMP_Info.biBitCount = 24; |
WiredHome | 72:ecffe56af969 | 1588 | BMP_Info.biCompression = BI_RGB; |
WiredHome | 72:ecffe56af969 | 1589 | BMP_Info.biSizeImage = 0; |
WiredHome | 72:ecffe56af969 | 1590 | BMP_Info.biXPelsPerMeter = 0; |
WiredHome | 72:ecffe56af969 | 1591 | BMP_Info.biYPelsPerMeter = 0; |
WiredHome | 72:ecffe56af969 | 1592 | BMP_Info.biClrUsed = 0; |
WiredHome | 72:ecffe56af969 | 1593 | BMP_Info.biClrImportant = 0; |
WiredHome | 72:ecffe56af969 | 1594 | |
WiredHome | 86:e86b355940f4 | 1595 | // Allocate the memory we need to proceed |
WiredHome | 86:e86b355940f4 | 1596 | int lineBufSize = ((24 * w + 7)/8); |
WiredHome | 86:e86b355940f4 | 1597 | lineBuffer = (uint8_t *)malloc(lineBufSize); |
WiredHome | 86:e86b355940f4 | 1598 | if (lineBuffer == NULL) { |
WiredHome | 86:e86b355940f4 | 1599 | ERR("Not enough RAM for PrintScreen lineBuffer"); |
WiredHome | 86:e86b355940f4 | 1600 | return(not_enough_ram); |
WiredHome | 86:e86b355940f4 | 1601 | } |
WiredHome | 86:e86b355940f4 | 1602 | |
WiredHome | 86:e86b355940f4 | 1603 | #define DOUBLEBUF /* one larger buffer instead of two */ |
WiredHome | 86:e86b355940f4 | 1604 | |
WiredHome | 86:e86b355940f4 | 1605 | #ifdef DOUBLEBUF |
WiredHome | 86:e86b355940f4 | 1606 | // In the "#else", pixelBuffer2 malloc returns a value, |
WiredHome | 86:e86b355940f4 | 1607 | // but is actually causing a failure later. |
WiredHome | 86:e86b355940f4 | 1608 | // This test helps determine if it is truly out of memory, |
WiredHome | 86:e86b355940f4 | 1609 | // or if malloc is broken. |
WiredHome | 86:e86b355940f4 | 1610 | pixelBuffer = (color_t *)malloc(2 * w * sizeof(color_t)); |
WiredHome | 86:e86b355940f4 | 1611 | pixelBuffer2 = pixelBuffer + (w * sizeof(color_t)); |
WiredHome | 86:e86b355940f4 | 1612 | #else |
WiredHome | 86:e86b355940f4 | 1613 | pixelBuffer = (color_t *)malloc(w * sizeof(color_t)); |
WiredHome | 86:e86b355940f4 | 1614 | pixelBuffer2 = (color_t *)malloc(w * sizeof(color_t)); |
WiredHome | 86:e86b355940f4 | 1615 | #endif |
WiredHome | 86:e86b355940f4 | 1616 | if (pixelBuffer == NULL || pixelBuffer2 == NULL) { |
WiredHome | 86:e86b355940f4 | 1617 | ERR("Not enough RAM for pixelBuffer"); |
WiredHome | 86:e86b355940f4 | 1618 | #ifndef DOUBLEBUF |
WiredHome | 86:e86b355940f4 | 1619 | if (pixelBuffer2) |
WiredHome | 86:e86b355940f4 | 1620 | free(pixelBuffer2); |
WiredHome | 86:e86b355940f4 | 1621 | #endif |
WiredHome | 86:e86b355940f4 | 1622 | if (pixelBuffer) |
WiredHome | 86:e86b355940f4 | 1623 | free(pixelBuffer); |
WiredHome | 86:e86b355940f4 | 1624 | free(lineBuffer); |
WiredHome | 86:e86b355940f4 | 1625 | if (pixelBuffer) |
WiredHome | 86:e86b355940f4 | 1626 | free(pixelBuffer); |
WiredHome | 86:e86b355940f4 | 1627 | return(not_enough_ram); |
WiredHome | 86:e86b355940f4 | 1628 | } |
WiredHome | 86:e86b355940f4 | 1629 | |
WiredHome | 72:ecffe56af969 | 1630 | FILE *Image = fopen(Name_BMP, "wb"); |
WiredHome | 72:ecffe56af969 | 1631 | if (!Image) { |
WiredHome | 86:e86b355940f4 | 1632 | ERR("Can't open file for write"); |
WiredHome | 86:e86b355940f4 | 1633 | #ifndef DOUBLEBUF |
WiredHome | 86:e86b355940f4 | 1634 | if (pixelBuffer2) |
WiredHome | 86:e86b355940f4 | 1635 | free(pixelBuffer2); |
WiredHome | 86:e86b355940f4 | 1636 | #endif |
WiredHome | 86:e86b355940f4 | 1637 | if (pixelBuffer) |
WiredHome | 86:e86b355940f4 | 1638 | free(pixelBuffer); |
WiredHome | 86:e86b355940f4 | 1639 | free(lineBuffer); |
WiredHome | 86:e86b355940f4 | 1640 | if (pixelBuffer) |
WiredHome | 86:e86b355940f4 | 1641 | free(pixelBuffer); |
WiredHome | 72:ecffe56af969 | 1642 | return(file_not_found); |
WiredHome | 72:ecffe56af969 | 1643 | } |
WiredHome | 72:ecffe56af969 | 1644 | |
WiredHome | 72:ecffe56af969 | 1645 | // Be optimistic - don't check for errors. |
WiredHome | 72:ecffe56af969 | 1646 | //HexDump("BMP_Header", (uint8_t *)&BMP_Header, sizeof(BMP_Header)); |
WiredHome | 86:e86b355940f4 | 1647 | size_t r = fwrite(&BMP_Header, sizeof(char), sizeof(BMP_Header), Image); |
WiredHome | 73:f22a18707b5e | 1648 | |
WiredHome | 72:ecffe56af969 | 1649 | //HexDump("BMP_Info", (uint8_t *)&BMP_Info, sizeof(BMP_Info)); |
WiredHome | 86:e86b355940f4 | 1650 | r = fwrite(&BMP_Info, sizeof(char), sizeof(BMP_Info), Image); |
WiredHome | 73:f22a18707b5e | 1651 | |
WiredHome | 73:f22a18707b5e | 1652 | color_t transparency = GetBackgroundTransparencyColor(); |
WiredHome | 73:f22a18707b5e | 1653 | unsigned char ltpr0 = ReadCommand(0x52) & 0x7; |
WiredHome | 73:f22a18707b5e | 1654 | |
WiredHome | 73:f22a18707b5e | 1655 | uint16_t prevLayer = GetDrawingLayer(); |
WiredHome | 73:f22a18707b5e | 1656 | // If only one of the layers is visible, select that layer |
WiredHome | 73:f22a18707b5e | 1657 | switch(ltpr0) { |
WiredHome | 73:f22a18707b5e | 1658 | case 0: |
WiredHome | 73:f22a18707b5e | 1659 | SelectDrawingLayer(0); |
WiredHome | 73:f22a18707b5e | 1660 | break; |
WiredHome | 73:f22a18707b5e | 1661 | case 1: |
WiredHome | 73:f22a18707b5e | 1662 | SelectDrawingLayer(1); |
WiredHome | 73:f22a18707b5e | 1663 | break; |
WiredHome | 73:f22a18707b5e | 1664 | default: |
WiredHome | 73:f22a18707b5e | 1665 | break; |
WiredHome | 73:f22a18707b5e | 1666 | } |
WiredHome | 73:f22a18707b5e | 1667 | |
WiredHome | 72:ecffe56af969 | 1668 | // Read the display from the last line toward the top |
WiredHome | 72:ecffe56af969 | 1669 | // so we can write the file in one pass. |
WiredHome | 72:ecffe56af969 | 1670 | for (int j = h - 1; j >= 0; j--) { |
WiredHome | 73:f22a18707b5e | 1671 | if (ltpr0 >= 2) // Need to combine the layers... |
WiredHome | 73:f22a18707b5e | 1672 | SelectDrawingLayer(0); // so read layer 0 first |
WiredHome | 72:ecffe56af969 | 1673 | // Read one line of pixels to a local buffer |
WiredHome | 72:ecffe56af969 | 1674 | if (getPixelStream(pixelBuffer, w, x,y+j) != noerror) { |
WiredHome | 72:ecffe56af969 | 1675 | ERR("getPixelStream error, and no recovery handler..."); |
WiredHome | 72:ecffe56af969 | 1676 | } |
WiredHome | 73:f22a18707b5e | 1677 | if (ltpr0 >= 2) { // Need to combine the layers... |
WiredHome | 86:e86b355940f4 | 1678 | SelectDrawingLayer(1); // so read layer 1 next |
WiredHome | 73:f22a18707b5e | 1679 | if (getPixelStream(pixelBuffer2, w, x,y+j) != noerror) { |
WiredHome | 73:f22a18707b5e | 1680 | ERR("getPixelStream error, and no recovery handler..."); |
WiredHome | 73:f22a18707b5e | 1681 | } |
WiredHome | 73:f22a18707b5e | 1682 | } |
WiredHome | 72:ecffe56af969 | 1683 | // Convert the local buffer to RGBQUAD format |
WiredHome | 72:ecffe56af969 | 1684 | int lb = 0; |
WiredHome | 72:ecffe56af969 | 1685 | for (int i=0; i<w; i++) { |
WiredHome | 73:f22a18707b5e | 1686 | RGBQUAD q0 = RGB16ToRGBQuad(pixelBuffer[x+i]); // Scale to 24-bits |
WiredHome | 73:f22a18707b5e | 1687 | RGBQUAD q1 = RGB16ToRGBQuad(pixelBuffer2[x+i]); // Scale to 24-bits |
WiredHome | 73:f22a18707b5e | 1688 | switch (ltpr0) { |
WiredHome | 73:f22a18707b5e | 1689 | case 0: |
WiredHome | 73:f22a18707b5e | 1690 | case 1: |
WiredHome | 73:f22a18707b5e | 1691 | case 2: // lighten-overlay (@TODO Not supported yet) |
WiredHome | 73:f22a18707b5e | 1692 | case 6: // Floating Windows (@TODO not sure how to support) |
WiredHome | 73:f22a18707b5e | 1693 | default: // Reserved... |
WiredHome | 73:f22a18707b5e | 1694 | lineBuffer[lb++] = q0.rgbBlue; |
WiredHome | 73:f22a18707b5e | 1695 | lineBuffer[lb++] = q0.rgbGreen; |
WiredHome | 73:f22a18707b5e | 1696 | lineBuffer[lb++] = q0.rgbRed; |
WiredHome | 73:f22a18707b5e | 1697 | break; |
WiredHome | 73:f22a18707b5e | 1698 | case 3: // transparent mode (@TODO Read the background color register for transparent) |
WiredHome | 73:f22a18707b5e | 1699 | case 4: // boolean or |
WiredHome | 73:f22a18707b5e | 1700 | lineBuffer[lb++] = q0.rgbBlue | q1.rgbBlue; |
WiredHome | 73:f22a18707b5e | 1701 | lineBuffer[lb++] = q0.rgbGreen | q1.rgbGreen; |
WiredHome | 73:f22a18707b5e | 1702 | lineBuffer[lb++] = q0.rgbRed | q1.rgbRed; |
WiredHome | 73:f22a18707b5e | 1703 | break; |
WiredHome | 73:f22a18707b5e | 1704 | case 5: // boolean AND |
WiredHome | 73:f22a18707b5e | 1705 | lineBuffer[lb++] = q0.rgbBlue & q1.rgbBlue; |
WiredHome | 73:f22a18707b5e | 1706 | lineBuffer[lb++] = q0.rgbGreen & q1.rgbGreen; |
WiredHome | 73:f22a18707b5e | 1707 | lineBuffer[lb++] = q0.rgbRed & q1.rgbRed; |
WiredHome | 73:f22a18707b5e | 1708 | break; |
WiredHome | 73:f22a18707b5e | 1709 | } |
WiredHome | 72:ecffe56af969 | 1710 | } |
WiredHome | 73:f22a18707b5e | 1711 | if (j == h - 1) |
WiredHome | 73:f22a18707b5e | 1712 | HexDump("Line", lineBuffer, lineBufSize); |
WiredHome | 72:ecffe56af969 | 1713 | // Write to disk |
WiredHome | 72:ecffe56af969 | 1714 | fwrite(lineBuffer, sizeof(char), lb, Image); |
WiredHome | 72:ecffe56af969 | 1715 | } |
WiredHome | 73:f22a18707b5e | 1716 | SelectDrawingLayer(prevLayer); |
WiredHome | 72:ecffe56af969 | 1717 | fclose(Image); |
WiredHome | 86:e86b355940f4 | 1718 | #ifndef DOUBLEBUF |
WiredHome | 86:e86b355940f4 | 1719 | if (pixelBuffer2) |
WiredHome | 86:e86b355940f4 | 1720 | free(pixelBuffer2); |
WiredHome | 86:e86b355940f4 | 1721 | #endif |
WiredHome | 86:e86b355940f4 | 1722 | if (pixelBuffer) |
WiredHome | 86:e86b355940f4 | 1723 | free(pixelBuffer); |
WiredHome | 72:ecffe56af969 | 1724 | free(lineBuffer); |
WiredHome | 86:e86b355940f4 | 1725 | if (pixelBuffer) |
WiredHome | 86:e86b355940f4 | 1726 | free(pixelBuffer); |
WiredHome | 73:f22a18707b5e | 1727 | INFO("Image closed"); |
WiredHome | 72:ecffe56af969 | 1728 | return noerror; |
WiredHome | 72:ecffe56af969 | 1729 | } else { |
WiredHome | 72:ecffe56af969 | 1730 | return bad_parameter; |
WiredHome | 72:ecffe56af969 | 1731 | } |
WiredHome | 72:ecffe56af969 | 1732 | } |
WiredHome | 72:ecffe56af969 | 1733 | |
WiredHome | 72:ecffe56af969 | 1734 | |
WiredHome | 72:ecffe56af969 | 1735 | // ########################################################################## |
WiredHome | 72:ecffe56af969 | 1736 | // ########################################################################## |
WiredHome | 72:ecffe56af969 | 1737 | // ########################################################################## |
WiredHome | 72:ecffe56af969 | 1738 | |
WiredHome | 23:a50ded45dbaf | 1739 | #ifdef TESTENABLE |
WiredHome | 23:a50ded45dbaf | 1740 | |
WiredHome | 37:f19b7e7449dc | 1741 | #include "Arial12x12.h" |
WiredHome | 37:f19b7e7449dc | 1742 | #include "Small_6.h" |
WiredHome | 37:f19b7e7449dc | 1743 | |
WiredHome | 23:a50ded45dbaf | 1744 | // ______________ ______________ ______________ _______________ |
WiredHome | 23:a50ded45dbaf | 1745 | // /_____ _____/ / ___________/ / ___________/ /_____ ______/ |
WiredHome | 23:a50ded45dbaf | 1746 | // / / / / / / / / |
WiredHome | 23:a50ded45dbaf | 1747 | // / / / /___ / /__________ / / |
WiredHome | 23:a50ded45dbaf | 1748 | // / / / ____/ /__________ / / / |
WiredHome | 23:a50ded45dbaf | 1749 | // / / / / / / / / |
WiredHome | 23:a50ded45dbaf | 1750 | // / / / /__________ ___________/ / / / |
WiredHome | 23:a50ded45dbaf | 1751 | // /__/ /_____________/ /_____________/ /__/ |
WiredHome | 23:a50ded45dbaf | 1752 | // |
WiredHome | 23:a50ded45dbaf | 1753 | // Everything from here down is test code. |
WiredHome | 75:ca78388cfd77 | 1754 | // |
WiredHome | 41:2956a0a221e5 | 1755 | bool SuppressSlowStuff = false; |
WiredHome | 23:a50ded45dbaf | 1756 | |
WiredHome | 49:c5182231d1b9 | 1757 | void TextWrapTest(RA8875 & display, Serial & pc) |
WiredHome | 49:c5182231d1b9 | 1758 | { |
WiredHome | 49:c5182231d1b9 | 1759 | if (!SuppressSlowStuff) |
WiredHome | 49:c5182231d1b9 | 1760 | pc.printf("Text Wrap Test\r\n"); |
WiredHome | 49:c5182231d1b9 | 1761 | display.background(Black); |
WiredHome | 49:c5182231d1b9 | 1762 | display.foreground(Blue); |
WiredHome | 49:c5182231d1b9 | 1763 | display.cls(); |
WiredHome | 49:c5182231d1b9 | 1764 | display.Backlight_u8(255); |
WiredHome | 49:c5182231d1b9 | 1765 | display.puts(0,0, "Text Wrap Test.\r\n"); |
WiredHome | 52:e6039a823420 | 1766 | for (int i=1; i<60; i++) { |
WiredHome | 52:e6039a823420 | 1767 | display.printf("L%2d\n", i % 17); |
WiredHome | 49:c5182231d1b9 | 1768 | if (!SuppressSlowStuff) |
WiredHome | 52:e6039a823420 | 1769 | wait_ms(100); |
WiredHome | 49:c5182231d1b9 | 1770 | } |
WiredHome | 49:c5182231d1b9 | 1771 | if (!SuppressSlowStuff) |
WiredHome | 49:c5182231d1b9 | 1772 | wait_ms(3000); |
WiredHome | 49:c5182231d1b9 | 1773 | } |
WiredHome | 49:c5182231d1b9 | 1774 | |
WiredHome | 75:ca78388cfd77 | 1775 | |
WiredHome | 75:ca78388cfd77 | 1776 | void ShowKey(RA8875 & display, int key) |
WiredHome | 75:ca78388cfd77 | 1777 | { |
WiredHome | 75:ca78388cfd77 | 1778 | loc_t col, row; |
WiredHome | 75:ca78388cfd77 | 1779 | dim_t r1 = 25; |
WiredHome | 75:ca78388cfd77 | 1780 | color_t color = (key & 0x80) ? Red : Green; |
WiredHome | 75:ca78388cfd77 | 1781 | |
WiredHome | 75:ca78388cfd77 | 1782 | key &= 0x7F; // remove the long-press flag |
WiredHome | 75:ca78388cfd77 | 1783 | row = (key - 1) / 5; |
WiredHome | 75:ca78388cfd77 | 1784 | col = (key - 1) % 5; |
WiredHome | 75:ca78388cfd77 | 1785 | if (col > 5) col = 5; |
WiredHome | 75:ca78388cfd77 | 1786 | if (row > 4) row = 4; |
WiredHome | 75:ca78388cfd77 | 1787 | display.circle(450 - + (2 * r1) * col, 200 - (2 * r1) * row, r1-2, color, FILL); |
WiredHome | 75:ca78388cfd77 | 1788 | } |
WiredHome | 75:ca78388cfd77 | 1789 | |
WiredHome | 75:ca78388cfd77 | 1790 | void HideKey(RA8875 & display, int key) |
WiredHome | 75:ca78388cfd77 | 1791 | { |
WiredHome | 75:ca78388cfd77 | 1792 | loc_t col, row; |
WiredHome | 75:ca78388cfd77 | 1793 | dim_t r1 = 25; |
WiredHome | 75:ca78388cfd77 | 1794 | |
WiredHome | 75:ca78388cfd77 | 1795 | row = (key - 1) / 5; |
WiredHome | 75:ca78388cfd77 | 1796 | col = (key - 1) % 5; |
WiredHome | 75:ca78388cfd77 | 1797 | if (col > 5) col = 5; |
WiredHome | 75:ca78388cfd77 | 1798 | if (row > 4) row = 4; |
WiredHome | 75:ca78388cfd77 | 1799 | display.background(Black); |
WiredHome | 75:ca78388cfd77 | 1800 | display.circle(450 - (2 * r1) * col, 200 - (2 * r1) * row, r1-2, Black, FILL); |
WiredHome | 75:ca78388cfd77 | 1801 | display.circle(450 - (2 * r1) * col, 200 - (2 * r1) * row, r1-2, Blue); |
WiredHome | 75:ca78388cfd77 | 1802 | } |
WiredHome | 75:ca78388cfd77 | 1803 | |
WiredHome | 75:ca78388cfd77 | 1804 | void KeyPadTest(RA8875 & display, Serial & pc) |
WiredHome | 75:ca78388cfd77 | 1805 | { |
WiredHome | 75:ca78388cfd77 | 1806 | const uint8_t myMap[22] = { |
WiredHome | 77:9206c13aa527 | 1807 | 0, |
WiredHome | 75:ca78388cfd77 | 1808 | 'a', 'b', 'c', 'd', 'e', |
WiredHome | 75:ca78388cfd77 | 1809 | 'f', 'g', 'h', 'i', 'j', |
WiredHome | 75:ca78388cfd77 | 1810 | 'k', 'l', 'm', 'n', 'o', |
WiredHome | 75:ca78388cfd77 | 1811 | 'p', 'q', 'r', 's', 't', |
WiredHome | 75:ca78388cfd77 | 1812 | 'x' |
WiredHome | 75:ca78388cfd77 | 1813 | }; |
WiredHome | 77:9206c13aa527 | 1814 | |
WiredHome | 75:ca78388cfd77 | 1815 | display.background(Black); |
WiredHome | 75:ca78388cfd77 | 1816 | display.foreground(Blue); |
WiredHome | 75:ca78388cfd77 | 1817 | display.cls(); |
WiredHome | 75:ca78388cfd77 | 1818 | display.Backlight_u8(255); |
WiredHome | 75:ca78388cfd77 | 1819 | display.puts(0,0, "KeyPad Test. Touch the keypad..."); |
WiredHome | 75:ca78388cfd77 | 1820 | pc.printf("\r\n" |
WiredHome | 75:ca78388cfd77 | 1821 | "Raw KeyPad Test. Keypad returns the key-number.\r\n" |
WiredHome | 75:ca78388cfd77 | 1822 | "Press [most] any PC keyboard key to advance to next test.\r\n"); |
WiredHome | 75:ca78388cfd77 | 1823 | RetCode_t ret = display.KeypadInit(true, true, 3, 7, 3); |
WiredHome | 75:ca78388cfd77 | 1824 | if (ret != noerror) |
WiredHome | 75:ca78388cfd77 | 1825 | pc.printf("returncode from KeypadInit is %d\r\n", ret); |
WiredHome | 75:ca78388cfd77 | 1826 | int lastKey = 0; |
WiredHome | 75:ca78388cfd77 | 1827 | while (!pc.readable()) { |
WiredHome | 75:ca78388cfd77 | 1828 | if (display.readable()) { |
WiredHome | 75:ca78388cfd77 | 1829 | int key = display.getc(); |
WiredHome | 75:ca78388cfd77 | 1830 | if (key) { |
WiredHome | 75:ca78388cfd77 | 1831 | if (((key & 0x7F) != lastKey) && (lastKey != 0)) |
WiredHome | 75:ca78388cfd77 | 1832 | HideKey(display, lastKey); |
WiredHome | 75:ca78388cfd77 | 1833 | ShowKey(display, key); |
WiredHome | 75:ca78388cfd77 | 1834 | lastKey = key & 0x7F; |
WiredHome | 75:ca78388cfd77 | 1835 | } else { |
WiredHome | 75:ca78388cfd77 | 1836 | // erase the last one |
WiredHome | 75:ca78388cfd77 | 1837 | if (lastKey) |
WiredHome | 75:ca78388cfd77 | 1838 | HideKey(display, lastKey); |
WiredHome | 75:ca78388cfd77 | 1839 | } |
WiredHome | 75:ca78388cfd77 | 1840 | } |
WiredHome | 75:ca78388cfd77 | 1841 | } |
WiredHome | 75:ca78388cfd77 | 1842 | (void)pc.getc(); |
WiredHome | 75:ca78388cfd77 | 1843 | pc.printf("\r\n" |
WiredHome | 75:ca78388cfd77 | 1844 | "Map KeyPad Test. Keypad returns the remapped key 'a' - 't'.\r\n" |
WiredHome | 75:ca78388cfd77 | 1845 | "Press [most] any PC keyboard key to advance to exit test.\r\n"); |
WiredHome | 75:ca78388cfd77 | 1846 | display.SetKeyMap(myMap); |
WiredHome | 75:ca78388cfd77 | 1847 | while (!pc.readable()) { |
WiredHome | 75:ca78388cfd77 | 1848 | if (display.readable()) { |
WiredHome | 75:ca78388cfd77 | 1849 | int key = display.getc(); |
WiredHome | 75:ca78388cfd77 | 1850 | bool longPress = key & 0x80; |
WiredHome | 75:ca78388cfd77 | 1851 | display.SetTextCursor(0, 120); |
WiredHome | 75:ca78388cfd77 | 1852 | display.printf("Long Press: %d\r\n", longPress); |
WiredHome | 75:ca78388cfd77 | 1853 | display.printf(" Remapped: %c %02X\r\n", (key) ? key & 0x7F : ' ', key); |
WiredHome | 75:ca78388cfd77 | 1854 | } |
WiredHome | 75:ca78388cfd77 | 1855 | } |
WiredHome | 75:ca78388cfd77 | 1856 | (void)pc.getc(); |
WiredHome | 75:ca78388cfd77 | 1857 | display.SetKeyMap(); |
WiredHome | 75:ca78388cfd77 | 1858 | pc.printf("\r\n"); |
WiredHome | 75:ca78388cfd77 | 1859 | } |
WiredHome | 75:ca78388cfd77 | 1860 | |
WiredHome | 23:a50ded45dbaf | 1861 | void TextCursorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1862 | { |
WiredHome | 75:ca78388cfd77 | 1863 | const char * iCursor = "The I-Beam cursor should be visible for this text.\r\n"; |
WiredHome | 75:ca78388cfd77 | 1864 | const char * uCursor = "The Underscore cursor should be visible for this text.\r\n"; |
WiredHome | 75:ca78388cfd77 | 1865 | const char * bCursor = "The Block cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 1866 | const char * bbCursor = "The Blinking Block cursor should be visible for this text.\r\n"; |
WiredHome | 23:a50ded45dbaf | 1867 | const char * p; |
WiredHome | 41:2956a0a221e5 | 1868 | int delay = 100; |
WiredHome | 73:f22a18707b5e | 1869 | |
WiredHome | 41:2956a0a221e5 | 1870 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1871 | pc.printf("Text Cursor Test\r\n"); |
WiredHome | 73:f22a18707b5e | 1872 | else |
WiredHome | 41:2956a0a221e5 | 1873 | delay = 0; |
WiredHome | 23:a50ded45dbaf | 1874 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1875 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1876 | display.cls(); |
WiredHome | 25:9556a3a9b7cc | 1877 | display.Backlight_u8(255); |
WiredHome | 23:a50ded45dbaf | 1878 | display.puts(0,0, "Text Cursor Test."); |
WiredHome | 73:f22a18707b5e | 1879 | |
WiredHome | 23:a50ded45dbaf | 1880 | // visible, non-blinking |
WiredHome | 24:8ca861acf12d | 1881 | display.SetTextCursor(0,20); |
WiredHome | 53:86d24b9480b9 | 1882 | display.SetTextCursorControl(RA8875::IBEAM, false); |
WiredHome | 24:8ca861acf12d | 1883 | p = iCursor; |
WiredHome | 23:a50ded45dbaf | 1884 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1885 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1886 | wait_ms(delay); |
WiredHome | 24:8ca861acf12d | 1887 | } |
WiredHome | 24:8ca861acf12d | 1888 | |
WiredHome | 53:86d24b9480b9 | 1889 | display.SetTextCursorControl(RA8875::UNDER, false); |
WiredHome | 24:8ca861acf12d | 1890 | p = uCursor; |
WiredHome | 24:8ca861acf12d | 1891 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1892 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1893 | wait_ms(delay); |
WiredHome | 23:a50ded45dbaf | 1894 | } |
WiredHome | 73:f22a18707b5e | 1895 | |
WiredHome | 53:86d24b9480b9 | 1896 | display.SetTextCursorControl(RA8875::BLOCK, false); |
WiredHome | 24:8ca861acf12d | 1897 | p = bCursor; |
WiredHome | 24:8ca861acf12d | 1898 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1899 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1900 | wait_ms(delay); |
WiredHome | 24:8ca861acf12d | 1901 | } |
WiredHome | 24:8ca861acf12d | 1902 | |
WiredHome | 53:86d24b9480b9 | 1903 | display.SetTextCursorControl(RA8875::BLOCK, true); |
WiredHome | 24:8ca861acf12d | 1904 | p = bbCursor; |
WiredHome | 24:8ca861acf12d | 1905 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1906 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1907 | wait_ms(delay); |
WiredHome | 24:8ca861acf12d | 1908 | } |
WiredHome | 41:2956a0a221e5 | 1909 | wait_ms(delay * 20); |
WiredHome | 53:86d24b9480b9 | 1910 | display.SetTextCursorControl(RA8875::NOCURSOR, false); |
WiredHome | 23:a50ded45dbaf | 1911 | } |
WiredHome | 23:a50ded45dbaf | 1912 | |
WiredHome | 44:207594dece70 | 1913 | |
WiredHome | 23:a50ded45dbaf | 1914 | void BacklightTest(RA8875 & display, Serial & pc, float ramptime) |
WiredHome | 23:a50ded45dbaf | 1915 | { |
WiredHome | 29:422616aa04bd | 1916 | char buf[60]; |
WiredHome | 41:2956a0a221e5 | 1917 | unsigned int w = (ramptime * 1000)/ 256; |
WiredHome | 41:2956a0a221e5 | 1918 | int delay = 200; |
WiredHome | 41:2956a0a221e5 | 1919 | |
WiredHome | 41:2956a0a221e5 | 1920 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1921 | pc.printf("Backlight Test - ramp over %f sec.\r\n", ramptime); |
WiredHome | 41:2956a0a221e5 | 1922 | else { |
WiredHome | 41:2956a0a221e5 | 1923 | delay = 0; |
WiredHome | 41:2956a0a221e5 | 1924 | w = 0; |
WiredHome | 41:2956a0a221e5 | 1925 | } |
WiredHome | 23:a50ded45dbaf | 1926 | display.Backlight_u8(0); |
WiredHome | 29:422616aa04bd | 1927 | display.background(White); |
WiredHome | 23:a50ded45dbaf | 1928 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1929 | display.cls(); |
WiredHome | 41:2956a0a221e5 | 1930 | wait_ms(delay); |
WiredHome | 23:a50ded45dbaf | 1931 | display.puts(0,0, "RA8875 Backlight Test - Ramp up."); |
WiredHome | 38:38d503b4fad6 | 1932 | for (int i=0; i <= 255; i++) { |
WiredHome | 29:422616aa04bd | 1933 | sprintf(buf, "%3d, %4d", i, w); |
WiredHome | 37:f19b7e7449dc | 1934 | display.puts(100,100,buf); |
WiredHome | 23:a50ded45dbaf | 1935 | display.Backlight_u8(i); |
WiredHome | 29:422616aa04bd | 1936 | wait_ms(w); |
WiredHome | 23:a50ded45dbaf | 1937 | } |
WiredHome | 23:a50ded45dbaf | 1938 | } |
WiredHome | 23:a50ded45dbaf | 1939 | |
WiredHome | 44:207594dece70 | 1940 | |
WiredHome | 23:a50ded45dbaf | 1941 | void BacklightTest2(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1942 | { |
WiredHome | 41:2956a0a221e5 | 1943 | int delay = 20; |
WiredHome | 41:2956a0a221e5 | 1944 | |
WiredHome | 41:2956a0a221e5 | 1945 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1946 | pc.printf("Backlight Test 2\r\n"); |
WiredHome | 41:2956a0a221e5 | 1947 | else |
WiredHome | 41:2956a0a221e5 | 1948 | delay = 0; |
WiredHome | 41:2956a0a221e5 | 1949 | |
WiredHome | 23:a50ded45dbaf | 1950 | // Dim it out at the end of the tests. |
WiredHome | 37:f19b7e7449dc | 1951 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1952 | display.puts(0,0, "Ramp Backlight down."); |
WiredHome | 23:a50ded45dbaf | 1953 | // Ramp it off |
WiredHome | 23:a50ded45dbaf | 1954 | for (int i=255; i != 0; i--) { |
WiredHome | 23:a50ded45dbaf | 1955 | display.Backlight_u8(i); |
WiredHome | 41:2956a0a221e5 | 1956 | wait_ms(delay); |
WiredHome | 23:a50ded45dbaf | 1957 | } |
WiredHome | 23:a50ded45dbaf | 1958 | display.Backlight_u8(0); |
WiredHome | 23:a50ded45dbaf | 1959 | } |
WiredHome | 23:a50ded45dbaf | 1960 | |
WiredHome | 44:207594dece70 | 1961 | |
WiredHome | 23:a50ded45dbaf | 1962 | void ExternalFontTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1963 | { |
WiredHome | 41:2956a0a221e5 | 1964 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1965 | pc.printf("External Font Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1966 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1967 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1968 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1969 | display.Backlight(1); |
WiredHome | 37:f19b7e7449dc | 1970 | display.puts(0,0, "External Font Test."); |
WiredHome | 37:f19b7e7449dc | 1971 | |
WiredHome | 37:f19b7e7449dc | 1972 | display.set_font(Small_6); |
WiredHome | 73:f22a18707b5e | 1973 | display.puts(0,30, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n"); |
WiredHome | 37:f19b7e7449dc | 1974 | |
WiredHome | 23:a50ded45dbaf | 1975 | display.set_font(Arial12x12); |
WiredHome | 37:f19b7e7449dc | 1976 | display.puts("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n"); |
WiredHome | 37:f19b7e7449dc | 1977 | display.set_font(); // restore to internal |
WiredHome | 73:f22a18707b5e | 1978 | |
WiredHome | 37:f19b7e7449dc | 1979 | display.puts("Normal font again."); |
WiredHome | 37:f19b7e7449dc | 1980 | //display.window(0,0, display.width(), display.height()); |
WiredHome | 23:a50ded45dbaf | 1981 | } |
WiredHome | 23:a50ded45dbaf | 1982 | |
WiredHome | 44:207594dece70 | 1983 | |
WiredHome | 23:a50ded45dbaf | 1984 | void DOSColorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1985 | { |
WiredHome | 41:2956a0a221e5 | 1986 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1987 | pc.printf("DOS Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1988 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1989 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1990 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1991 | display.puts(0,0, "DOS Colors - Fore"); |
WiredHome | 23:a50ded45dbaf | 1992 | display.puts(280,0, "Back"); |
WiredHome | 23:a50ded45dbaf | 1993 | display.background(Gray); |
WiredHome | 23:a50ded45dbaf | 1994 | for (int i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1995 | display.foreground(display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1996 | display.puts(160, i*16, display.DOSColorNames(i)); |
WiredHome | 23:a50ded45dbaf | 1997 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1998 | } |
WiredHome | 23:a50ded45dbaf | 1999 | display.foreground(White); |
WiredHome | 23:a50ded45dbaf | 2000 | for (int i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2001 | display.background(display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2002 | display.puts(360, i*16, display.DOSColorNames(i)); |
WiredHome | 23:a50ded45dbaf | 2003 | display.foreground(White); |
WiredHome | 23:a50ded45dbaf | 2004 | } |
WiredHome | 23:a50ded45dbaf | 2005 | } |
WiredHome | 23:a50ded45dbaf | 2006 | |
WiredHome | 44:207594dece70 | 2007 | |
WiredHome | 23:a50ded45dbaf | 2008 | void WebColorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2009 | { |
WiredHome | 41:2956a0a221e5 | 2010 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2011 | pc.printf("Web Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2012 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2013 | display.foreground(Blue); |
WiredHome | 32:0e4f2ae512e2 | 2014 | display.window(0,0, display.width(), display.height()); |
WiredHome | 23:a50ded45dbaf | 2015 | display.cls(); |
WiredHome | 59:fb40aad4efd4 | 2016 | display.SetTextFontSize(1,1); |
WiredHome | 59:fb40aad4efd4 | 2017 | display.puts(200,0, "Web Color Test"); |
WiredHome | 59:fb40aad4efd4 | 2018 | display.SetTextCursor(0,0); |
WiredHome | 59:fb40aad4efd4 | 2019 | display.puts(" "); |
WiredHome | 59:fb40aad4efd4 | 2020 | for (int i=0; i<16; i++) |
WiredHome | 59:fb40aad4efd4 | 2021 | display.printf("%X", i&0xF); |
WiredHome | 59:fb40aad4efd4 | 2022 | display.puts("\r\n0 "); |
WiredHome | 23:a50ded45dbaf | 2023 | for (int i=0; i<sizeof(WebColors)/sizeof(WebColors[0]); i++) { |
WiredHome | 23:a50ded45dbaf | 2024 | display.background(WebColors[i]); |
WiredHome | 23:a50ded45dbaf | 2025 | display.puts(" "); |
WiredHome | 59:fb40aad4efd4 | 2026 | if (i % 16 == 15 && i < 255) { |
WiredHome | 59:fb40aad4efd4 | 2027 | display.printf("\r\n%X ", ((i+1)/16)); |
WiredHome | 59:fb40aad4efd4 | 2028 | } |
WiredHome | 23:a50ded45dbaf | 2029 | } |
WiredHome | 23:a50ded45dbaf | 2030 | display.SetTextFontSize(1,1); |
WiredHome | 23:a50ded45dbaf | 2031 | } |
WiredHome | 23:a50ded45dbaf | 2032 | |
WiredHome | 44:207594dece70 | 2033 | |
WiredHome | 37:f19b7e7449dc | 2034 | void PixelTest(RA8875 & display, Serial & pc) |
WiredHome | 37:f19b7e7449dc | 2035 | { |
WiredHome | 37:f19b7e7449dc | 2036 | int i, c, x, y; |
WiredHome | 37:f19b7e7449dc | 2037 | |
WiredHome | 41:2956a0a221e5 | 2038 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2039 | pc.printf("Pixel Test\r\n"); |
WiredHome | 37:f19b7e7449dc | 2040 | display.background(Black); |
WiredHome | 37:f19b7e7449dc | 2041 | display.foreground(Blue); |
WiredHome | 37:f19b7e7449dc | 2042 | display.cls(); |
WiredHome | 37:f19b7e7449dc | 2043 | display.puts(0,0, "Pixel Test"); |
WiredHome | 37:f19b7e7449dc | 2044 | for (i=0; i<1000; i++) { |
WiredHome | 37:f19b7e7449dc | 2045 | x = rand() % 480; |
WiredHome | 37:f19b7e7449dc | 2046 | y = 16 + rand() % (272-16); |
WiredHome | 37:f19b7e7449dc | 2047 | c = rand() % 16; |
WiredHome | 37:f19b7e7449dc | 2048 | //pc.printf(" (%d,%d) - %d\r\n", x,y,r1); |
WiredHome | 37:f19b7e7449dc | 2049 | display.pixel(x,y, display.DOSColor(c)); |
WiredHome | 37:f19b7e7449dc | 2050 | } |
WiredHome | 37:f19b7e7449dc | 2051 | } |
WiredHome | 37:f19b7e7449dc | 2052 | |
WiredHome | 44:207594dece70 | 2053 | |
WiredHome | 23:a50ded45dbaf | 2054 | void LineTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2055 | { |
WiredHome | 23:a50ded45dbaf | 2056 | int i, x, y, x2, y2; |
WiredHome | 23:a50ded45dbaf | 2057 | |
WiredHome | 41:2956a0a221e5 | 2058 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2059 | pc.printf("Line Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2060 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2061 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 2062 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 2063 | display.puts(0,0, "Line Test"); |
WiredHome | 23:a50ded45dbaf | 2064 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2065 | // Lines |
WiredHome | 23:a50ded45dbaf | 2066 | x = rand() % 480; |
WiredHome | 23:a50ded45dbaf | 2067 | y = rand() % 272; |
WiredHome | 23:a50ded45dbaf | 2068 | x2 = rand() % 480; |
WiredHome | 23:a50ded45dbaf | 2069 | y2 = rand() % 272; |
WiredHome | 23:a50ded45dbaf | 2070 | display.line(x,y, x2,y2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2071 | } |
WiredHome | 62:ba5d33438fda | 2072 | display.foreground(BrightRed); |
WiredHome | 62:ba5d33438fda | 2073 | display.foreground(BrightGreen); |
WiredHome | 62:ba5d33438fda | 2074 | display.foreground(BrightBlue); |
WiredHome | 62:ba5d33438fda | 2075 | display.line(55,50, 79,74, BrightRed); |
WiredHome | 62:ba5d33438fda | 2076 | display.line(57,50, 81,74, BrightGreen); |
WiredHome | 62:ba5d33438fda | 2077 | display.line(59,50, 83,74, BrightBlue); |
WiredHome | 62:ba5d33438fda | 2078 | // horz |
WiredHome | 62:ba5d33438fda | 2079 | display.line(30,40, 32,40, BrightRed); |
WiredHome | 62:ba5d33438fda | 2080 | display.line(30,42, 32,42, BrightGreen); |
WiredHome | 62:ba5d33438fda | 2081 | display.line(30,44, 32,44, BrightBlue); |
WiredHome | 62:ba5d33438fda | 2082 | // vert |
WiredHome | 62:ba5d33438fda | 2083 | display.line(20,40, 20,42, BrightRed); |
WiredHome | 62:ba5d33438fda | 2084 | display.line(22,40, 22,42, BrightGreen); |
WiredHome | 62:ba5d33438fda | 2085 | display.line(24,40, 24,42, BrightBlue); |
WiredHome | 62:ba5d33438fda | 2086 | // compare point to line-point |
WiredHome | 62:ba5d33438fda | 2087 | display.pixel(20,50, BrightRed); |
WiredHome | 62:ba5d33438fda | 2088 | display.pixel(22,50, BrightGreen); |
WiredHome | 62:ba5d33438fda | 2089 | display.pixel(24,50, BrightBlue); |
WiredHome | 62:ba5d33438fda | 2090 | display.line(20,52, 20,52, BrightRed); |
WiredHome | 62:ba5d33438fda | 2091 | display.line(22,52, 22,52, BrightGreen); |
WiredHome | 62:ba5d33438fda | 2092 | display.line(24,52, 24,52, BrightBlue); |
WiredHome | 73:f22a18707b5e | 2093 | |
WiredHome | 62:ba5d33438fda | 2094 | // point |
WiredHome | 62:ba5d33438fda | 2095 | display.line(50,50, 50,50, Red); |
WiredHome | 62:ba5d33438fda | 2096 | display.line(52,52, 52,52, Green); |
WiredHome | 62:ba5d33438fda | 2097 | display.line(54,54, 54,54, Blue); |
WiredHome | 62:ba5d33438fda | 2098 | display.line(60,60, 60,60, BrightRed); |
WiredHome | 62:ba5d33438fda | 2099 | display.line(62,62, 62,62, BrightGreen); |
WiredHome | 62:ba5d33438fda | 2100 | display.line(64,64, 64,64, BrightBlue); |
WiredHome | 62:ba5d33438fda | 2101 | display.line(70,70, 70,70, DarkRed); |
WiredHome | 62:ba5d33438fda | 2102 | display.line(72,72, 72,72, DarkGreen); |
WiredHome | 62:ba5d33438fda | 2103 | display.line(74,74, 74,74, DarkBlue); |
WiredHome | 23:a50ded45dbaf | 2104 | } |
WiredHome | 23:a50ded45dbaf | 2105 | |
WiredHome | 44:207594dece70 | 2106 | |
WiredHome | 23:a50ded45dbaf | 2107 | void RectangleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2108 | { |
WiredHome | 23:a50ded45dbaf | 2109 | int i, x1,y1, x2,y2; |
WiredHome | 23:a50ded45dbaf | 2110 | |
WiredHome | 41:2956a0a221e5 | 2111 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2112 | pc.printf("Rectangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2113 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2114 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 2115 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 2116 | display.puts(0,0, "Rectangle Test"); |
WiredHome | 23:a50ded45dbaf | 2117 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2118 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2119 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2120 | x2 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2121 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2122 | display.rect(x1,y1, x2,y2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2123 | |
WiredHome | 23:a50ded45dbaf | 2124 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2125 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2126 | x2 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2127 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2128 | display.rect(x1,y1, x2,y2, FILL); |
WiredHome | 23:a50ded45dbaf | 2129 | } |
WiredHome | 23:a50ded45dbaf | 2130 | } |
WiredHome | 23:a50ded45dbaf | 2131 | |
WiredHome | 44:207594dece70 | 2132 | |
WiredHome | 44:207594dece70 | 2133 | void LayerTest(RA8875 & display, Serial & pc) |
WiredHome | 44:207594dece70 | 2134 | { |
WiredHome | 44:207594dece70 | 2135 | loc_t i, x1,y1, x2,y2, r1,r2; |
WiredHome | 44:207594dece70 | 2136 | |
WiredHome | 44:207594dece70 | 2137 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2138 | pc.printf("Layer Test\r\n"); |
WiredHome | 44:207594dece70 | 2139 | |
WiredHome | 50:2c4f474a2453 | 2140 | display.SelectDrawingLayer(0); |
WiredHome | 44:207594dece70 | 2141 | display.background(Black); |
WiredHome | 44:207594dece70 | 2142 | display.foreground(Blue); |
WiredHome | 44:207594dece70 | 2143 | display.cls(); |
WiredHome | 44:207594dece70 | 2144 | display.puts(0,0, "Layer 0"); |
WiredHome | 44:207594dece70 | 2145 | for (i=0; i<16; i++) { |
WiredHome | 44:207594dece70 | 2146 | x1 = rand() % 240; |
WiredHome | 44:207594dece70 | 2147 | y1 = 50 + rand() % 200; |
WiredHome | 44:207594dece70 | 2148 | x2 = x1 + rand() % 100; |
WiredHome | 44:207594dece70 | 2149 | y2 = y1 + rand() % 100; |
WiredHome | 44:207594dece70 | 2150 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 44:207594dece70 | 2151 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 44:207594dece70 | 2152 | display.roundrect(x1,y1, x2,y2, r1,r2, display.DOSColor(i)); |
WiredHome | 44:207594dece70 | 2153 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2154 | wait_ms(20); |
WiredHome | 44:207594dece70 | 2155 | } |
WiredHome | 44:207594dece70 | 2156 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2157 | wait_ms(1000); |
WiredHome | 44:207594dece70 | 2158 | |
WiredHome | 50:2c4f474a2453 | 2159 | display.SelectDrawingLayer(1); |
WiredHome | 44:207594dece70 | 2160 | display.background(Black); |
WiredHome | 44:207594dece70 | 2161 | display.foreground(Yellow); |
WiredHome | 44:207594dece70 | 2162 | display.cls(); |
WiredHome | 44:207594dece70 | 2163 | display.puts(240,0, "Layer 1"); |
WiredHome | 44:207594dece70 | 2164 | for (i=0; i<16; i++) { |
WiredHome | 44:207594dece70 | 2165 | x1 = 300 + rand() % 100; |
WiredHome | 44:207594dece70 | 2166 | y1 = 70 + rand() % 200; |
WiredHome | 44:207594dece70 | 2167 | r1 = rand() % min(y1 - 20, 100); |
WiredHome | 44:207594dece70 | 2168 | display.circle(x1,y1,r1, display.DOSColor(i)); |
WiredHome | 44:207594dece70 | 2169 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2170 | wait_ms(20); |
WiredHome | 44:207594dece70 | 2171 | } |
WiredHome | 56:7a85d226ad0d | 2172 | display.SetLayerMode(RA8875::ShowLayer1); // Show it after the build-up |
WiredHome | 44:207594dece70 | 2173 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2174 | wait_ms(2000); |
WiredHome | 44:207594dece70 | 2175 | |
WiredHome | 50:2c4f474a2453 | 2176 | display.SelectDrawingLayer(0); |
WiredHome | 56:7a85d226ad0d | 2177 | display.SetLayerMode(RA8875::ShowLayer0); // Show Layer 0 again |
WiredHome | 44:207594dece70 | 2178 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2179 | wait_ms(1000); |
WiredHome | 53:86d24b9480b9 | 2180 | display.SetLayerMode(RA8875::TransparentMode); // Transparent mode |
WiredHome | 44:207594dece70 | 2181 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2182 | wait_ms(1000); |
WiredHome | 44:207594dece70 | 2183 | for (i=0; i<=8; i++) { |
WiredHome | 44:207594dece70 | 2184 | display.SetLayerTransparency(i, 8-i); |
WiredHome | 44:207594dece70 | 2185 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 2186 | wait_ms(200); |
WiredHome | 44:207594dece70 | 2187 | } |
WiredHome | 73:f22a18707b5e | 2188 | |
WiredHome | 44:207594dece70 | 2189 | // Restore before we exit |
WiredHome | 44:207594dece70 | 2190 | display.SetLayerTransparency(0, 0); |
WiredHome | 56:7a85d226ad0d | 2191 | display.SetLayerMode(RA8875::ShowLayer0); // Restore to layer 0 |
WiredHome | 44:207594dece70 | 2192 | } |
WiredHome | 44:207594dece70 | 2193 | |
WiredHome | 44:207594dece70 | 2194 | |
WiredHome | 23:a50ded45dbaf | 2195 | void RoundRectTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2196 | { |
WiredHome | 37:f19b7e7449dc | 2197 | loc_t i, x1,y1, x2,y2, r1,r2; |
WiredHome | 23:a50ded45dbaf | 2198 | |
WiredHome | 41:2956a0a221e5 | 2199 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2200 | pc.printf("Round Rectangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2201 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2202 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 2203 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 2204 | display.puts(0,0, "Rounded Rectangle Test"); |
WiredHome | 73:f22a18707b5e | 2205 | |
WiredHome | 23:a50ded45dbaf | 2206 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2207 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2208 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2209 | x2 = x1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2210 | y2 = y1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2211 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 23:a50ded45dbaf | 2212 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 23:a50ded45dbaf | 2213 | display.roundrect(x1,y1, x2,y2, 5,8, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2214 | |
WiredHome | 23:a50ded45dbaf | 2215 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2216 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2217 | x2 = x1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2218 | y2 = y1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2219 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 23:a50ded45dbaf | 2220 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 23:a50ded45dbaf | 2221 | display.roundrect(x1,y1, x2,y2, r1,r2, FILL); |
WiredHome | 23:a50ded45dbaf | 2222 | } |
WiredHome | 23:a50ded45dbaf | 2223 | } |
WiredHome | 23:a50ded45dbaf | 2224 | |
WiredHome | 44:207594dece70 | 2225 | |
WiredHome | 23:a50ded45dbaf | 2226 | void TriangleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2227 | { |
WiredHome | 23:a50ded45dbaf | 2228 | int i, x1, y1, x2, y2, x3, y3; |
WiredHome | 23:a50ded45dbaf | 2229 | |
WiredHome | 41:2956a0a221e5 | 2230 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2231 | pc.printf("Triangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2232 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2233 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 2234 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 2235 | display.puts(0,0, "Triangle Test"); |
WiredHome | 23:a50ded45dbaf | 2236 | |
WiredHome | 23:a50ded45dbaf | 2237 | x1 = 150; |
WiredHome | 23:a50ded45dbaf | 2238 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 2239 | x2 = 190; |
WiredHome | 23:a50ded45dbaf | 2240 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 2241 | x3 = 170; |
WiredHome | 23:a50ded45dbaf | 2242 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 2243 | display.triangle(x1,y1, x2,y2, x3,y3); |
WiredHome | 23:a50ded45dbaf | 2244 | |
WiredHome | 23:a50ded45dbaf | 2245 | x1 = 200; |
WiredHome | 23:a50ded45dbaf | 2246 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 2247 | x2 = 240; |
WiredHome | 23:a50ded45dbaf | 2248 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 2249 | x3 = 220; |
WiredHome | 23:a50ded45dbaf | 2250 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 2251 | display.filltriangle(x1,y1, x2,y2, x3,y3, BrightRed); |
WiredHome | 23:a50ded45dbaf | 2252 | |
WiredHome | 23:a50ded45dbaf | 2253 | x1 = 300; |
WiredHome | 23:a50ded45dbaf | 2254 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 2255 | x2 = 340; |
WiredHome | 23:a50ded45dbaf | 2256 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 2257 | x3 = 320; |
WiredHome | 23:a50ded45dbaf | 2258 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 2259 | display.triangle(x1,y1, x2,y2, x3,y3, NOFILL); |
WiredHome | 23:a50ded45dbaf | 2260 | |
WiredHome | 23:a50ded45dbaf | 2261 | x1 = 400; |
WiredHome | 23:a50ded45dbaf | 2262 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 2263 | x2 = 440; |
WiredHome | 23:a50ded45dbaf | 2264 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 2265 | x3 = 420; |
WiredHome | 23:a50ded45dbaf | 2266 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 2267 | display.triangle(x1,y1, x2,y2, x3,y3, Blue); |
WiredHome | 23:a50ded45dbaf | 2268 | |
WiredHome | 23:a50ded45dbaf | 2269 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2270 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2271 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2272 | x2 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2273 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2274 | x3 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2275 | y3 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2276 | display.triangle(x1,y1, x2,y2, x3,y3, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2277 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2278 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2279 | x2 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2280 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2281 | x3 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 2282 | y3 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2283 | display.triangle(x1,y1, x2,y2, x3,y3, FILL); |
WiredHome | 23:a50ded45dbaf | 2284 | } |
WiredHome | 23:a50ded45dbaf | 2285 | } |
WiredHome | 23:a50ded45dbaf | 2286 | |
WiredHome | 44:207594dece70 | 2287 | |
WiredHome | 23:a50ded45dbaf | 2288 | void CircleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2289 | { |
WiredHome | 23:a50ded45dbaf | 2290 | int i, x, y, r1; |
WiredHome | 23:a50ded45dbaf | 2291 | |
WiredHome | 41:2956a0a221e5 | 2292 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2293 | pc.printf("Circle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2294 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2295 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 2296 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 2297 | display.puts(0,0, "Circle Test"); |
WiredHome | 23:a50ded45dbaf | 2298 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2299 | x = 100 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2300 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2301 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 2302 | //pc.printf(" (%d,%d) - %d\r\n", x,y,r1); |
WiredHome | 23:a50ded45dbaf | 2303 | display.circle(x,y,r1, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2304 | |
WiredHome | 23:a50ded45dbaf | 2305 | x = 300 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2306 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2307 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 2308 | //pc.printf(" (%d,%d) - %d FILL\r\n", x,y,r1); |
WiredHome | 23:a50ded45dbaf | 2309 | display.circle(x,y,r1, display.DOSColor(i), FILL); |
WiredHome | 23:a50ded45dbaf | 2310 | } |
WiredHome | 23:a50ded45dbaf | 2311 | } |
WiredHome | 23:a50ded45dbaf | 2312 | |
WiredHome | 44:207594dece70 | 2313 | |
WiredHome | 23:a50ded45dbaf | 2314 | void EllipseTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2315 | { |
WiredHome | 23:a50ded45dbaf | 2316 | int i,x,y,r1,r2; |
WiredHome | 23:a50ded45dbaf | 2317 | |
WiredHome | 41:2956a0a221e5 | 2318 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 2319 | pc.printf("Ellipse Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 2320 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 2321 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 2322 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 2323 | display.puts(0,0, "Ellipse Test"); |
WiredHome | 23:a50ded45dbaf | 2324 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 2325 | x = 100 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2326 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2327 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 2328 | r2 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 2329 | display.ellipse(x,y,r1,r2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 2330 | |
WiredHome | 23:a50ded45dbaf | 2331 | x = 300 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 2332 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 2333 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 2334 | r2 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 2335 | display.ellipse(x,y,r1,r2, FILL); |
WiredHome | 23:a50ded45dbaf | 2336 | } |
WiredHome | 23:a50ded45dbaf | 2337 | } |
WiredHome | 23:a50ded45dbaf | 2338 | |
WiredHome | 44:207594dece70 | 2339 | |
WiredHome | 37:f19b7e7449dc | 2340 | void TestGraphicsBitmap(RA8875 & display, Serial & pc) |
WiredHome | 37:f19b7e7449dc | 2341 | { |
WiredHome | 37:f19b7e7449dc | 2342 | LocalFileSystem local("local"); |
WiredHome | 41:2956a0a221e5 | 2343 | if (!SuppressSlowStuff) |
WiredHome | 73:f22a18707b5e | 2344 | pc.printf("Bitmap File Load\r\n"); |
WiredHome | 37:f19b7e7449dc | 2345 | display.background(Black); |
WiredHome | 37:f19b7e7449dc | 2346 | display.foreground(Blue); |
WiredHome | 37:f19b7e7449dc | 2347 | display.cls(); |
WiredHome | 37:f19b7e7449dc | 2348 | display.puts(0,0, "Graphics Test, loading /local/TestPat.bmp"); |
WiredHome | 37:f19b7e7449dc | 2349 | wait(3); |
WiredHome | 37:f19b7e7449dc | 2350 | |
WiredHome | 37:f19b7e7449dc | 2351 | int r = display.RenderBitmapFile(0,0, "/local/TestPat.bmp"); |
WiredHome | 59:fb40aad4efd4 | 2352 | if (!SuppressSlowStuff) |
WiredHome | 59:fb40aad4efd4 | 2353 | pc.printf(" returned %d\r\n", r); |
WiredHome | 37:f19b7e7449dc | 2354 | } |
WiredHome | 37:f19b7e7449dc | 2355 | |
WiredHome | 44:207594dece70 | 2356 | |
WiredHome | 77:9206c13aa527 | 2357 | void TouchPanelTest(RA8875 & display, Serial & pc) |
WiredHome | 77:9206c13aa527 | 2358 | { |
WiredHome | 77:9206c13aa527 | 2359 | Timer t; |
WiredHome | 77:9206c13aa527 | 2360 | loc_t x, y; |
WiredHome | 78:faf49c381591 | 2361 | tpMatrix_t calmatrix; |
WiredHome | 78:faf49c381591 | 2362 | |
WiredHome | 77:9206c13aa527 | 2363 | display.background(Black); |
WiredHome | 77:9206c13aa527 | 2364 | display.foreground(Blue); |
WiredHome | 77:9206c13aa527 | 2365 | display.cls(); |
WiredHome | 77:9206c13aa527 | 2366 | display.puts(0,0, "Touch Panel Test\r\n"); |
WiredHome | 78:faf49c381591 | 2367 | pc.printf("Touch Panel Test\r\n"); |
WiredHome | 77:9206c13aa527 | 2368 | display.TouchPanelInit(); |
WiredHome | 78:faf49c381591 | 2369 | pc.printf(" TP: c - calibrate, r - restore, t - test\r\n"); |
WiredHome | 78:faf49c381591 | 2370 | int c = pc.getc(); |
WiredHome | 78:faf49c381591 | 2371 | if (c == 'c') { |
WiredHome | 78:faf49c381591 | 2372 | point_t pTest[3] = |
WiredHome | 78:faf49c381591 | 2373 | { { 50, 50 }, {450, 150}, {225,250} }; |
WiredHome | 78:faf49c381591 | 2374 | point_t pSample[3]; |
WiredHome | 78:faf49c381591 | 2375 | for (int i=0; i<3; i++) { |
WiredHome | 78:faf49c381591 | 2376 | display.foreground(Blue); |
WiredHome | 78:faf49c381591 | 2377 | display.printf(" (%3d,%3d) => ", pTest[i].x, pTest[i].y); |
WiredHome | 78:faf49c381591 | 2378 | display.line(pTest[i].x-10, pTest[i].y, pTest[i].x+10, pTest[i].y, White); |
WiredHome | 78:faf49c381591 | 2379 | display.line(pTest[i].x, pTest[i].y-10, pTest[i].x, pTest[i].y+10, White); |
WiredHome | 79:544eb4964795 | 2380 | while (!display.TouchPanelA2DFiltered(&x, &y)) |
WiredHome | 78:faf49c381591 | 2381 | wait_ms(20); |
WiredHome | 78:faf49c381591 | 2382 | pSample[i].x = x; |
WiredHome | 78:faf49c381591 | 2383 | pSample[i].y = y; |
WiredHome | 78:faf49c381591 | 2384 | display.line(pTest[i].x-10, pTest[i].y, pTest[i].x+10, pTest[i].y, Black); |
WiredHome | 78:faf49c381591 | 2385 | display.line(pTest[i].x, pTest[i].y-10, pTest[i].x, pTest[i].y+10, Black); |
WiredHome | 78:faf49c381591 | 2386 | display.foreground(Blue); |
WiredHome | 78:faf49c381591 | 2387 | display.printf(" (%4d,%4d)\r\n", x,y); |
WiredHome | 79:544eb4964795 | 2388 | while (display.TouchPanelA2DFiltered(&x, &y)) |
WiredHome | 78:faf49c381591 | 2389 | wait_ms(20); |
WiredHome | 78:faf49c381591 | 2390 | wait(2); |
WiredHome | 78:faf49c381591 | 2391 | } |
WiredHome | 81:01da2e34283d | 2392 | display.TouchPanelComputeCalibration(pTest, pSample, &calmatrix); |
WiredHome | 78:faf49c381591 | 2393 | display.printf(" Writing calibration to tpcal.cfg\r\n"); |
WiredHome | 78:faf49c381591 | 2394 | FILE * fh = fopen("/local/tpcal.cfg", "wb"); |
WiredHome | 78:faf49c381591 | 2395 | if (fh) { |
WiredHome | 78:faf49c381591 | 2396 | fwrite(&calmatrix, sizeof(calmatrix), 1, fh); |
WiredHome | 78:faf49c381591 | 2397 | fclose(fh); |
WiredHome | 78:faf49c381591 | 2398 | } |
WiredHome | 78:faf49c381591 | 2399 | display.printf(" Calibration is complete."); |
WiredHome | 78:faf49c381591 | 2400 | } else if (c == 'r') { |
WiredHome | 78:faf49c381591 | 2401 | display.printf(" Reading calibration from tpcal.cfg\r\n"); |
WiredHome | 78:faf49c381591 | 2402 | FILE * fh = fopen("/local/tpcal.cfg", "rb"); |
WiredHome | 78:faf49c381591 | 2403 | if (fh) { |
WiredHome | 78:faf49c381591 | 2404 | fread(&calmatrix, sizeof(calmatrix), 1, fh); |
WiredHome | 78:faf49c381591 | 2405 | fclose(fh); |
WiredHome | 78:faf49c381591 | 2406 | } |
WiredHome | 78:faf49c381591 | 2407 | display.printf(" Calibration is complete."); |
WiredHome | 78:faf49c381591 | 2408 | display.TouchPanelSetMatrix(&calmatrix); |
WiredHome | 77:9206c13aa527 | 2409 | } |
WiredHome | 77:9206c13aa527 | 2410 | t.start(); |
WiredHome | 77:9206c13aa527 | 2411 | do { |
WiredHome | 77:9206c13aa527 | 2412 | point_t point = {0, 0}; |
WiredHome | 79:544eb4964795 | 2413 | if (display.TouchPanelReadable(&point)) { |
WiredHome | 77:9206c13aa527 | 2414 | display.pixel(point.x, point.y, Red); |
WiredHome | 77:9206c13aa527 | 2415 | } |
WiredHome | 77:9206c13aa527 | 2416 | } while (t.read_ms() < 30000); |
WiredHome | 77:9206c13aa527 | 2417 | pc.printf(">"); |
WiredHome | 77:9206c13aa527 | 2418 | } |
WiredHome | 77:9206c13aa527 | 2419 | |
WiredHome | 77:9206c13aa527 | 2420 | |
WiredHome | 41:2956a0a221e5 | 2421 | void SpeedTest(RA8875 & display, Serial & pc) |
WiredHome | 41:2956a0a221e5 | 2422 | { |
WiredHome | 41:2956a0a221e5 | 2423 | Timer t; |
WiredHome | 41:2956a0a221e5 | 2424 | SuppressSlowStuff = true; |
WiredHome | 41:2956a0a221e5 | 2425 | pc.printf("\r\nSpeedTest disables delays, runs tests, reports overall time.\r\n"); |
WiredHome | 41:2956a0a221e5 | 2426 | t.start(); |
WiredHome | 41:2956a0a221e5 | 2427 | // do stuff fast |
WiredHome | 41:2956a0a221e5 | 2428 | TextCursorTest(display, pc); |
WiredHome | 49:c5182231d1b9 | 2429 | TextWrapTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2430 | BacklightTest(display, pc, 0); |
WiredHome | 41:2956a0a221e5 | 2431 | BacklightTest2(display, pc); |
WiredHome | 41:2956a0a221e5 | 2432 | ExternalFontTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2433 | DOSColorTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2434 | WebColorTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2435 | PixelTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2436 | LineTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2437 | RectangleTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2438 | RoundRectTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2439 | TriangleTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2440 | CircleTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2441 | EllipseTest(display, pc); |
WiredHome | 44:207594dece70 | 2442 | LayerTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 2443 | //TestGraphicsBitmap(display, pc); |
WiredHome | 41:2956a0a221e5 | 2444 | pc.printf("SpeedTest completed in %d msec\r\n", t.read_ms()); |
WiredHome | 73:f22a18707b5e | 2445 | #ifdef PERF_METRICS |
WiredHome | 41:2956a0a221e5 | 2446 | display.ReportPerformance(pc); |
WiredHome | 73:f22a18707b5e | 2447 | #endif |
WiredHome | 41:2956a0a221e5 | 2448 | SuppressSlowStuff = false; |
WiredHome | 41:2956a0a221e5 | 2449 | } |
WiredHome | 41:2956a0a221e5 | 2450 | |
WiredHome | 44:207594dece70 | 2451 | |
WiredHome | 41:2956a0a221e5 | 2452 | void PrintScreen(RA8875 & display, Serial & pc) |
WiredHome | 41:2956a0a221e5 | 2453 | { |
WiredHome | 41:2956a0a221e5 | 2454 | if (!SuppressSlowStuff) |
WiredHome | 73:f22a18707b5e | 2455 | pc.printf("PrintScreen\r\n"); |
WiredHome | 41:2956a0a221e5 | 2456 | display.PrintScreen( 0,0, 480,272, "/local/Capture.bmp"); |
WiredHome | 41:2956a0a221e5 | 2457 | } |
WiredHome | 41:2956a0a221e5 | 2458 | |
WiredHome | 44:207594dece70 | 2459 | |
WiredHome | 23:a50ded45dbaf | 2460 | void RunTestSet(RA8875 & lcd, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 2461 | { |
WiredHome | 23:a50ded45dbaf | 2462 | int q = 0; |
WiredHome | 23:a50ded45dbaf | 2463 | int automode = 0; |
WiredHome | 49:c5182231d1b9 | 2464 | const unsigned char modelist[] = "BDWtGLlFROTPCEbw"; // auto-test in this order. |
WiredHome | 23:a50ded45dbaf | 2465 | |
WiredHome | 23:a50ded45dbaf | 2466 | while(1) { |
WiredHome | 23:a50ded45dbaf | 2467 | pc.printf("\r\n" |
WiredHome | 41:2956a0a221e5 | 2468 | "B - Backlight up b - backlight dim\r\n" |
WiredHome | 41:2956a0a221e5 | 2469 | "D - DOS Colors W - Web Colors\r\n" |
WiredHome | 41:2956a0a221e5 | 2470 | "t - text cursor G - Graphics Bitmap\r\n" |
WiredHome | 41:2956a0a221e5 | 2471 | "L - Lines F - external Font\r\n" |
WiredHome | 41:2956a0a221e5 | 2472 | "R - Rectangles O - rOund rectangles\r\n" |
WiredHome | 41:2956a0a221e5 | 2473 | "T - Triangles P - Pixels \r\n" |
WiredHome | 41:2956a0a221e5 | 2474 | "C - Circles E - Ellipses\r\n" |
WiredHome | 41:2956a0a221e5 | 2475 | "A - Auto Test mode S - Speed Test\r\n" |
WiredHome | 77:9206c13aa527 | 2476 | "K - Keypad Test s - touch screen test\r\n" |
WiredHome | 41:2956a0a221e5 | 2477 | "p - print screen r - reset \r\n" |
WiredHome | 49:c5182231d1b9 | 2478 | "l - layer test w - wrapping text \r\n" |
WiredHome | 73:f22a18707b5e | 2479 | #ifdef PERF_METRICS |
WiredHome | 41:2956a0a221e5 | 2480 | "0 - clear performance 1 - report performance\r\n" |
WiredHome | 73:f22a18707b5e | 2481 | #endif |
WiredHome | 23:a50ded45dbaf | 2482 | "> "); |
WiredHome | 23:a50ded45dbaf | 2483 | if (automode == -1 || pc.readable()) { |
WiredHome | 23:a50ded45dbaf | 2484 | automode = -1; |
WiredHome | 37:f19b7e7449dc | 2485 | q = pc.getc(); |
WiredHome | 37:f19b7e7449dc | 2486 | while (pc.readable()) |
WiredHome | 37:f19b7e7449dc | 2487 | pc.getc(); |
WiredHome | 23:a50ded45dbaf | 2488 | } else if (automode >= 0) { |
WiredHome | 23:a50ded45dbaf | 2489 | q = modelist[automode]; |
WiredHome | 23:a50ded45dbaf | 2490 | } |
WiredHome | 23:a50ded45dbaf | 2491 | switch(q) { |
WiredHome | 73:f22a18707b5e | 2492 | #ifdef PERF_METRICS |
WiredHome | 41:2956a0a221e5 | 2493 | case '0': |
WiredHome | 41:2956a0a221e5 | 2494 | lcd.ClearPerformance(); |
WiredHome | 41:2956a0a221e5 | 2495 | break; |
WiredHome | 41:2956a0a221e5 | 2496 | case '1': |
WiredHome | 41:2956a0a221e5 | 2497 | lcd.ReportPerformance(pc); |
WiredHome | 41:2956a0a221e5 | 2498 | break; |
WiredHome | 73:f22a18707b5e | 2499 | #endif |
WiredHome | 23:a50ded45dbaf | 2500 | case 'A': |
WiredHome | 23:a50ded45dbaf | 2501 | automode = 0; |
WiredHome | 23:a50ded45dbaf | 2502 | break; |
WiredHome | 23:a50ded45dbaf | 2503 | case 'B': |
WiredHome | 41:2956a0a221e5 | 2504 | BacklightTest(lcd, pc, 2); |
WiredHome | 23:a50ded45dbaf | 2505 | break; |
WiredHome | 23:a50ded45dbaf | 2506 | case 'b': |
WiredHome | 23:a50ded45dbaf | 2507 | BacklightTest2(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2508 | break; |
WiredHome | 23:a50ded45dbaf | 2509 | case 'D': |
WiredHome | 23:a50ded45dbaf | 2510 | DOSColorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2511 | break; |
WiredHome | 75:ca78388cfd77 | 2512 | case 'K': |
WiredHome | 75:ca78388cfd77 | 2513 | KeyPadTest(lcd, pc); |
WiredHome | 75:ca78388cfd77 | 2514 | break; |
WiredHome | 23:a50ded45dbaf | 2515 | case 'W': |
WiredHome | 23:a50ded45dbaf | 2516 | WebColorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2517 | break; |
WiredHome | 23:a50ded45dbaf | 2518 | case 't': |
WiredHome | 23:a50ded45dbaf | 2519 | TextCursorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2520 | break; |
WiredHome | 49:c5182231d1b9 | 2521 | case 'w': |
WiredHome | 49:c5182231d1b9 | 2522 | TextWrapTest(lcd, pc); |
WiredHome | 49:c5182231d1b9 | 2523 | break; |
WiredHome | 23:a50ded45dbaf | 2524 | case 'F': |
WiredHome | 23:a50ded45dbaf | 2525 | ExternalFontTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2526 | break; |
WiredHome | 23:a50ded45dbaf | 2527 | case 'L': |
WiredHome | 23:a50ded45dbaf | 2528 | LineTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2529 | break; |
WiredHome | 44:207594dece70 | 2530 | case 'l': |
WiredHome | 44:207594dece70 | 2531 | LayerTest(lcd, pc); |
WiredHome | 44:207594dece70 | 2532 | break; |
WiredHome | 23:a50ded45dbaf | 2533 | case 'R': |
WiredHome | 23:a50ded45dbaf | 2534 | RectangleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2535 | break; |
WiredHome | 23:a50ded45dbaf | 2536 | case 'O': |
WiredHome | 23:a50ded45dbaf | 2537 | RoundRectTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2538 | break; |
WiredHome | 41:2956a0a221e5 | 2539 | case 'p': |
WiredHome | 41:2956a0a221e5 | 2540 | PrintScreen(lcd, pc); |
WiredHome | 41:2956a0a221e5 | 2541 | break; |
WiredHome | 41:2956a0a221e5 | 2542 | case 'S': |
WiredHome | 41:2956a0a221e5 | 2543 | SpeedTest(lcd, pc); |
WiredHome | 41:2956a0a221e5 | 2544 | break; |
WiredHome | 77:9206c13aa527 | 2545 | case 's': |
WiredHome | 77:9206c13aa527 | 2546 | TouchPanelTest(lcd, pc); |
WiredHome | 77:9206c13aa527 | 2547 | break; |
WiredHome | 23:a50ded45dbaf | 2548 | case 'T': |
WiredHome | 23:a50ded45dbaf | 2549 | TriangleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2550 | break; |
WiredHome | 37:f19b7e7449dc | 2551 | case 'P': |
WiredHome | 37:f19b7e7449dc | 2552 | PixelTest(lcd, pc); |
WiredHome | 37:f19b7e7449dc | 2553 | break; |
WiredHome | 37:f19b7e7449dc | 2554 | case 'G': |
WiredHome | 37:f19b7e7449dc | 2555 | TestGraphicsBitmap(lcd, pc); |
WiredHome | 37:f19b7e7449dc | 2556 | break; |
WiredHome | 23:a50ded45dbaf | 2557 | case 'C': |
WiredHome | 23:a50ded45dbaf | 2558 | CircleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2559 | break; |
WiredHome | 23:a50ded45dbaf | 2560 | case 'E': |
WiredHome | 23:a50ded45dbaf | 2561 | EllipseTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2562 | break; |
WiredHome | 23:a50ded45dbaf | 2563 | case 'r': |
WiredHome | 23:a50ded45dbaf | 2564 | pc.printf("Resetting ...\r\n"); |
WiredHome | 23:a50ded45dbaf | 2565 | wait_ms(20); |
WiredHome | 23:a50ded45dbaf | 2566 | mbed_reset(); |
WiredHome | 23:a50ded45dbaf | 2567 | break; |
WiredHome | 75:ca78388cfd77 | 2568 | case ' ': |
WiredHome | 75:ca78388cfd77 | 2569 | break; |
WiredHome | 23:a50ded45dbaf | 2570 | default: |
WiredHome | 23:a50ded45dbaf | 2571 | printf("huh?\n"); |
WiredHome | 23:a50ded45dbaf | 2572 | break; |
WiredHome | 23:a50ded45dbaf | 2573 | } |
WiredHome | 23:a50ded45dbaf | 2574 | if (automode >= 0) { |
WiredHome | 23:a50ded45dbaf | 2575 | automode++; |
WiredHome | 23:a50ded45dbaf | 2576 | if (automode >= sizeof(modelist)) |
WiredHome | 23:a50ded45dbaf | 2577 | automode = 0; |
WiredHome | 23:a50ded45dbaf | 2578 | wait_ms(2000); |
WiredHome | 23:a50ded45dbaf | 2579 | } |
WiredHome | 23:a50ded45dbaf | 2580 | wait_ms(200); |
WiredHome | 23:a50ded45dbaf | 2581 | } |
WiredHome | 23:a50ded45dbaf | 2582 | } |
WiredHome | 23:a50ded45dbaf | 2583 | |
WiredHome | 79:544eb4964795 | 2584 | #endif // TESTENABLE |