Forked para SNOCC
Fork of RA8875 by
RA8875.cpp@62:ba5d33438fda, 2014-08-17 (annotated)
- Committer:
- WiredHome
- Date:
- Sun Aug 17 15:38:51 2014 +0000
- Revision:
- 62:ba5d33438fda
- Parent:
- 61:8f3153bf0baa
- Child:
- 66:468a11f05580
Fixed a bug in the pixel API which was visible when line( ) with same x,y coordinates for both points was used.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WiredHome | 19:3f82c1161fd2 | 1 | /// RA8875 Display Controller Library. |
WiredHome | 19:3f82c1161fd2 | 2 | /// |
WiredHome | 19:3f82c1161fd2 | 3 | /// This is being created for a specific display from buydisplay.com, |
WiredHome | 44:207594dece70 | 4 | /// which is 480 x 272. It has other attributes (like display controller |
WiredHome | 19:3f82c1161fd2 | 5 | /// managed backlight brightness. So, there are expectations and some |
WiredHome | 44:207594dece70 | 6 | /// defined constants based on that specific display. Some initial work |
WiredHome | 44:207594dece70 | 7 | /// was done to support other display resolutions (e.g. 800 x 480), but |
WiredHome | 44:207594dece70 | 8 | /// this has not been tested. |
WiredHome | 19:3f82c1161fd2 | 9 | /// |
WiredHome | 19:3f82c1161fd2 | 10 | #include "RA8875.h" |
WiredHome | 19:3f82c1161fd2 | 11 | |
WiredHome | 41:2956a0a221e5 | 12 | //#define DEBUG "RAIO" |
WiredHome | 19:3f82c1161fd2 | 13 | // ... |
WiredHome | 19:3f82c1161fd2 | 14 | // INFO("Stuff to show %d", var); // new-line is automatically appended |
WiredHome | 19:3f82c1161fd2 | 15 | // |
WiredHome | 19:3f82c1161fd2 | 16 | #if (defined(DEBUG) && !defined(TARGET_LPC11U24)) |
WiredHome | 19:3f82c1161fd2 | 17 | #define INFO(x, ...) std::printf("[INF %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 18 | #define WARN(x, ...) std::printf("[WRN %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 19 | #define ERR(x, ...) std::printf("[ERR %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 20 | #else |
WiredHome | 19:3f82c1161fd2 | 21 | #define INFO(x, ...) |
WiredHome | 19:3f82c1161fd2 | 22 | #define WARN(x, ...) |
WiredHome | 19:3f82c1161fd2 | 23 | #define ERR(x, ...) |
WiredHome | 19:3f82c1161fd2 | 24 | #endif |
WiredHome | 19:3f82c1161fd2 | 25 | |
WiredHome | 19:3f82c1161fd2 | 26 | |
WiredHome | 19:3f82c1161fd2 | 27 | #define RA8875_DISPLAY_WIDTH 480 |
WiredHome | 19:3f82c1161fd2 | 28 | #define RA8875_DISPLAY_HEIGHT 272 |
WiredHome | 43:3becae133285 | 29 | #define RA8875_COLORDEPTH_BPP 16 /* Not an API */ |
WiredHome | 19:3f82c1161fd2 | 30 | |
WiredHome | 19:3f82c1161fd2 | 31 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 32 | #define PERFORMANCE_RESET performance.reset() |
WiredHome | 19:3f82c1161fd2 | 33 | #define REGISTERPERFORMANCE(a) RegisterPerformance(a) |
WiredHome | 19:3f82c1161fd2 | 34 | static const char *metricsName[] = |
WiredHome | 19:3f82c1161fd2 | 35 | { |
WiredHome | 41:2956a0a221e5 | 36 | "Cls", "Pixel", "Pixel Stream", |
WiredHome | 41:2956a0a221e5 | 37 | "Read Pixel", "Read Pixel Stream", |
WiredHome | 41:2956a0a221e5 | 38 | "Line", |
WiredHome | 41:2956a0a221e5 | 39 | "Rectangle", "Rounded Rectangle", "Triangle", "Circle", "Ellipse" |
WiredHome | 19:3f82c1161fd2 | 40 | }; |
WiredHome | 19:3f82c1161fd2 | 41 | #else |
WiredHome | 19:3f82c1161fd2 | 42 | #define PERFORMANCE_RESET |
WiredHome | 19:3f82c1161fd2 | 43 | #define REGISTERPERFORMANCE(a) |
WiredHome | 19:3f82c1161fd2 | 44 | #endif |
WiredHome | 19:3f82c1161fd2 | 45 | |
WiredHome | 19:3f82c1161fd2 | 46 | // When it is going to poll a register for completion, how many |
WiredHome | 19:3f82c1161fd2 | 47 | // uSec should it wait between each polling activity. |
WiredHome | 19:3f82c1161fd2 | 48 | #define POLLWAITuSec 10 |
WiredHome | 19:3f82c1161fd2 | 49 | |
WiredHome | 19:3f82c1161fd2 | 50 | |
WiredHome | 19:3f82c1161fd2 | 51 | RA8875::RA8875(PinName mosi, PinName miso, PinName sclk, PinName csel, PinName reset, const char *name) |
WiredHome | 58:26658a56112a | 52 | : GraphicsDisplay(name) |
WiredHome | 58:26658a56112a | 53 | , spi(mosi, miso, sclk) |
WiredHome | 19:3f82c1161fd2 | 54 | , cs(csel) |
WiredHome | 19:3f82c1161fd2 | 55 | , res(reset) |
WiredHome | 19:3f82c1161fd2 | 56 | { |
WiredHome | 19:3f82c1161fd2 | 57 | font = NULL; // no external font, use internal. |
WiredHome | 19:3f82c1161fd2 | 58 | select(false); // deselect the display |
WiredHome | 19:3f82c1161fd2 | 59 | frequency(RA8875_DEFAULT_SPI_FREQ); // data rate |
WiredHome | 28:ed102fc442c4 | 60 | Reset(); |
WiredHome | 28:ed102fc442c4 | 61 | Power(true); |
WiredHome | 28:ed102fc442c4 | 62 | Backlight_u8(255); |
WiredHome | 19:3f82c1161fd2 | 63 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 64 | performance.start(); |
WiredHome | 19:3f82c1161fd2 | 65 | ClearPerformance(); |
WiredHome | 19:3f82c1161fd2 | 66 | #endif |
WiredHome | 19:3f82c1161fd2 | 67 | } |
WiredHome | 19:3f82c1161fd2 | 68 | |
WiredHome | 43:3becae133285 | 69 | |
WiredHome | 19:3f82c1161fd2 | 70 | //RA8875::~RA8875() |
WiredHome | 19:3f82c1161fd2 | 71 | //{ |
WiredHome | 19:3f82c1161fd2 | 72 | //} |
WiredHome | 19:3f82c1161fd2 | 73 | |
WiredHome | 61:8f3153bf0baa | 74 | uint16_t RA8875::GetDrawingLayer(void) |
WiredHome | 61:8f3153bf0baa | 75 | { |
WiredHome | 61:8f3153bf0baa | 76 | return (ReadCommand(0x41) & 0x01); |
WiredHome | 61:8f3153bf0baa | 77 | } |
WiredHome | 43:3becae133285 | 78 | |
WiredHome | 50:2c4f474a2453 | 79 | RetCode_t RA8875::SelectDrawingLayer(uint16_t layer) |
WiredHome | 43:3becae133285 | 80 | { |
WiredHome | 43:3becae133285 | 81 | unsigned char mwcr1 = ReadCommand(0x41) & ~0x01; // retain all but the currently selected layer |
WiredHome | 43:3becae133285 | 82 | |
WiredHome | 43:3becae133285 | 83 | if (width() >= 800 && height() >= 480 && color_bpp() == 8) { |
WiredHome | 43:3becae133285 | 84 | return bad_parameter; |
WiredHome | 43:3becae133285 | 85 | } else if (layer > 1) { |
WiredHome | 43:3becae133285 | 86 | return bad_parameter; |
WiredHome | 43:3becae133285 | 87 | } else { // layer == 0 ro 1 |
WiredHome | 43:3becae133285 | 88 | WriteCommand(0x41, mwcr1 | layer); |
WiredHome | 43:3becae133285 | 89 | } |
WiredHome | 43:3becae133285 | 90 | return noerror; |
WiredHome | 43:3becae133285 | 91 | } |
WiredHome | 43:3becae133285 | 92 | |
WiredHome | 44:207594dece70 | 93 | |
WiredHome | 53:86d24b9480b9 | 94 | RetCode_t RA8875::SetLayerMode(LayerMode_T mode) |
WiredHome | 44:207594dece70 | 95 | { |
WiredHome | 53:86d24b9480b9 | 96 | unsigned char ltpr0 = ReadCommand(0x52) & ~0x7; // retain all but the display layer mode |
WiredHome | 53:86d24b9480b9 | 97 | if (mode <= (LayerMode_T)6) { |
WiredHome | 53:86d24b9480b9 | 98 | WriteCommand(0x52, ltpr0 | (mode & 0x7)); |
WiredHome | 53:86d24b9480b9 | 99 | return noerror; |
WiredHome | 53:86d24b9480b9 | 100 | } else { |
WiredHome | 53:86d24b9480b9 | 101 | return bad_parameter; |
WiredHome | 53:86d24b9480b9 | 102 | } |
WiredHome | 44:207594dece70 | 103 | } |
WiredHome | 44:207594dece70 | 104 | |
WiredHome | 44:207594dece70 | 105 | |
WiredHome | 44:207594dece70 | 106 | RetCode_t RA8875::SetLayerTransparency(uint8_t layer1, uint8_t layer2) |
WiredHome | 44:207594dece70 | 107 | { |
WiredHome | 44:207594dece70 | 108 | if (layer1 > 8) |
WiredHome | 44:207594dece70 | 109 | layer1 = 8; |
WiredHome | 44:207594dece70 | 110 | if (layer2 > 8) |
WiredHome | 44:207594dece70 | 111 | layer2 = 8; |
WiredHome | 44:207594dece70 | 112 | WriteCommand(0x53, ((layer2 & 0xF) << 4) | (layer1 & 0xF)); |
WiredHome | 44:207594dece70 | 113 | return noerror; |
WiredHome | 44:207594dece70 | 114 | } |
WiredHome | 44:207594dece70 | 115 | |
WiredHome | 44:207594dece70 | 116 | |
WiredHome | 53:86d24b9480b9 | 117 | RetCode_t RA8875::SetBackgroundTransparencyColor(color_t color) |
WiredHome | 53:86d24b9480b9 | 118 | { |
WiredHome | 53:86d24b9480b9 | 119 | WriteCommand(0x67, (color >> 11) & 0x1F); |
WiredHome | 53:86d24b9480b9 | 120 | WriteCommand(0x68, (color >> 5) & 0x3F); |
WiredHome | 53:86d24b9480b9 | 121 | WriteCommand(0x69, (color & 0x1F)); |
WiredHome | 53:86d24b9480b9 | 122 | return noerror; |
WiredHome | 53:86d24b9480b9 | 123 | } |
WiredHome | 53:86d24b9480b9 | 124 | |
hexley | 54:e117ad10fba6 | 125 | // ### Touch Panel support code additions begin here |
hexley | 54:e117ad10fba6 | 126 | |
hexley | 54:e117ad10fba6 | 127 | RetCode_t RA8875::TouchPanelInit(void) |
hexley | 54:e117ad10fba6 | 128 | { |
hexley | 54:e117ad10fba6 | 129 | //TPCR0: Set enable bit, default sample time, wakeup, and ADC clock |
hexley | 54:e117ad10fba6 | 130 | WriteCommand(TPCR0, TP_ENABLE | TP_ADC_SAMPLE_DEFAULT_CLKS | TP_ADC_CLKDIV_DEFAULT); |
hexley | 54:e117ad10fba6 | 131 | // TPCR1: Set auto/manual, Ref voltage, debounce, manual mode params |
hexley | 54:e117ad10fba6 | 132 | WriteCommand(TPCR1, TP_MODE_DEFAULT | TP_DEBOUNCE_DEFAULT); |
hexley | 54:e117ad10fba6 | 133 | WriteCommand(INTC1, ReadCommand(INTC1) | RA8875_INT_TP); // reg INTC1: Enable Touch Panel Interrupts (D2 = 1) |
hexley | 54:e117ad10fba6 | 134 | WriteCommand(INTC2, RA8875_INT_TP); // reg INTC2: Clear any TP interrupt flag |
hexley | 54:e117ad10fba6 | 135 | return noerror; |
hexley | 54:e117ad10fba6 | 136 | } |
hexley | 54:e117ad10fba6 | 137 | |
hexley | 54:e117ad10fba6 | 138 | RetCode_t RA8875::TouchPanelInit(uint8_t bTpEnable, uint8_t bTpAutoManual, uint8_t bTpDebounce, uint8_t bTpManualMode, uint8_t bTpAdcClkDiv, uint8_t bTpAdcSampleTime) |
hexley | 54:e117ad10fba6 | 139 | { |
hexley | 54:e117ad10fba6 | 140 | // Parameter bounds check |
hexley | 54:e117ad10fba6 | 141 | if( \ |
hexley | 54:e117ad10fba6 | 142 | !(bTpEnable == TP_ENABLE || bTpEnable == TP_ENABLE) || \ |
hexley | 54:e117ad10fba6 | 143 | !(bTpAutoManual == TP_MODE_AUTO || bTpAutoManual == TP_MODE_MANUAL) || \ |
hexley | 54:e117ad10fba6 | 144 | !(bTpDebounce == TP_DEBOUNCE_OFF || bTpDebounce == TP_DEBOUNCE_ON) || \ |
hexley | 54:e117ad10fba6 | 145 | !(bTpManualMode <= TP_MANUAL_LATCH_Y) || \ |
hexley | 54:e117ad10fba6 | 146 | !(bTpAdcClkDiv <= TP_ADC_CLKDIV_128) || \ |
hexley | 54:e117ad10fba6 | 147 | !(bTpAdcSampleTime <= TP_ADC_SAMPLE_65536_CLKS) \ |
hexley | 54:e117ad10fba6 | 148 | ) return bad_parameter; |
hexley | 54:e117ad10fba6 | 149 | // Construct the config byte for TPCR0 and write them |
hexley | 54:e117ad10fba6 | 150 | WriteCommand(TPCR0, bTpEnable | bTpAdcClkDiv | bTpAdcSampleTime); // Note: Wakeup is never enabled |
hexley | 54:e117ad10fba6 | 151 | // Construct the config byte for TPCR1 and write them |
hexley | 54:e117ad10fba6 | 152 | WriteCommand(TPCR1, bTpManualMode | bTpDebounce | bTpManualMode); // Note: Always uses internal Vref. |
hexley | 54:e117ad10fba6 | 153 | // Set up the interrupt flag and enable bits |
hexley | 54:e117ad10fba6 | 154 | WriteCommand(INTC1, ReadCommand(INTC1) | RA8875_INT_TP); // reg INTC1: Enable Touch Panel Interrupts (D2 = 1) |
hexley | 54:e117ad10fba6 | 155 | WriteCommand(INTC2, RA8875_INT_TP); // reg INTC2: Clear any TP interrupt flag |
hexley | 54:e117ad10fba6 | 156 | return noerror; |
hexley | 54:e117ad10fba6 | 157 | } |
hexley | 54:e117ad10fba6 | 158 | |
hexley | 54:e117ad10fba6 | 159 | unsigned char RA8875::TouchPanelRead(loc_t *x, loc_t *y) |
hexley | 54:e117ad10fba6 | 160 | { |
hexley | 54:e117ad10fba6 | 161 | unsigned char touchready; |
hexley | 54:e117ad10fba6 | 162 | static int xbuf[TPBUFSIZE], ybuf[TPBUFSIZE], sample = 0; |
hexley | 54:e117ad10fba6 | 163 | int i, j, temp; |
hexley | 54:e117ad10fba6 | 164 | |
hexley | 54:e117ad10fba6 | 165 | if( (ReadCommand(INTC2) & RA8875_INT_TP) ) { // Test for TP Interrupt pending in register INTC2 |
hexley | 54:e117ad10fba6 | 166 | // Get the next data samples |
hexley | 54:e117ad10fba6 | 167 | ybuf[sample] = ReadCommand(TPYH) << 2 | ( (ReadCommand(TPXYL) & 0xC) >> 2 ); // D[9:2] from reg TPYH, D[1:0] from reg TPXYL[3:2] |
hexley | 54:e117ad10fba6 | 168 | xbuf[sample] = ReadCommand(TPXH) << 2 | ( (ReadCommand(TPXYL) & 0x3) ); // D[9:2] from reg TPXH, D[1:0] from reg TPXYL[1:0] |
hexley | 54:e117ad10fba6 | 169 | // Check for a complete set |
hexley | 54:e117ad10fba6 | 170 | if(++sample == TPBUFSIZE) { |
hexley | 54:e117ad10fba6 | 171 | // Buffers are full, so process them using Finn's method described in Analog Dialogue No. 44, Feb 2010 |
hexley | 54:e117ad10fba6 | 172 | // This requires sorting the samples in order of size, then discarding the top 25% and |
hexley | 54:e117ad10fba6 | 173 | // bottom 25% as noise spikes. Finally, the middle 50% of the values are averaged to |
hexley | 54:e117ad10fba6 | 174 | // reduce Gaussian noise. |
hexley | 54:e117ad10fba6 | 175 | |
hexley | 54:e117ad10fba6 | 176 | // Sort the Y buffer using an Insertion Sort |
hexley | 54:e117ad10fba6 | 177 | for(i = 1; i <= TPBUFSIZE; i++) { |
hexley | 54:e117ad10fba6 | 178 | temp = ybuf[i]; |
hexley | 54:e117ad10fba6 | 179 | j = i; |
hexley | 54:e117ad10fba6 | 180 | while( j && (ybuf[j-1] > temp) ) { |
hexley | 54:e117ad10fba6 | 181 | ybuf[j] = ybuf[j-1]; |
hexley | 54:e117ad10fba6 | 182 | j = j-1; |
hexley | 54:e117ad10fba6 | 183 | } |
hexley | 54:e117ad10fba6 | 184 | ybuf[j] = temp; |
hexley | 54:e117ad10fba6 | 185 | } // End of Y sort |
hexley | 54:e117ad10fba6 | 186 | // Sort the X buffer the same way |
hexley | 54:e117ad10fba6 | 187 | for(i = 1; i <= TPBUFSIZE; i++) { |
hexley | 54:e117ad10fba6 | 188 | temp = xbuf[i]; |
hexley | 54:e117ad10fba6 | 189 | j = i; |
hexley | 54:e117ad10fba6 | 190 | while( j && (xbuf[j-1] > temp) ) { |
hexley | 54:e117ad10fba6 | 191 | xbuf[j] = xbuf[j-1]; |
hexley | 54:e117ad10fba6 | 192 | j = j-1; |
hexley | 54:e117ad10fba6 | 193 | } |
hexley | 54:e117ad10fba6 | 194 | xbuf[j] = temp; |
hexley | 54:e117ad10fba6 | 195 | } // End of X sort |
hexley | 54:e117ad10fba6 | 196 | // Average the middle half of the Y values and report them |
hexley | 54:e117ad10fba6 | 197 | j = 0; |
hexley | 54:e117ad10fba6 | 198 | for(i = (TPBUFSIZE/4) - 1; i < TPBUFSIZE - TPBUFSIZE/4; i++ ) { |
hexley | 54:e117ad10fba6 | 199 | j += ybuf[i]; |
hexley | 54:e117ad10fba6 | 200 | } |
hexley | 54:e117ad10fba6 | 201 | *y = j * (float)2/TPBUFSIZE; // This is the average |
hexley | 54:e117ad10fba6 | 202 | // Average the middle half of the X values and report them |
hexley | 54:e117ad10fba6 | 203 | j = 0; |
hexley | 54:e117ad10fba6 | 204 | for(i = (TPBUFSIZE/4) - 1; i < TPBUFSIZE - TPBUFSIZE/4; i++ ) { |
hexley | 54:e117ad10fba6 | 205 | j += xbuf[i]; |
hexley | 54:e117ad10fba6 | 206 | } |
hexley | 54:e117ad10fba6 | 207 | *x = j * (float)2/TPBUFSIZE; // This is the average |
hexley | 54:e117ad10fba6 | 208 | // Tidy up and return |
hexley | 54:e117ad10fba6 | 209 | touchready = 1; |
hexley | 54:e117ad10fba6 | 210 | sample = 0; // Ready to start on the next set of data samples |
hexley | 54:e117ad10fba6 | 211 | } |
hexley | 54:e117ad10fba6 | 212 | else { |
hexley | 54:e117ad10fba6 | 213 | // Buffer not yet full, so do not return any results yet |
hexley | 54:e117ad10fba6 | 214 | touchready = 0; |
hexley | 54:e117ad10fba6 | 215 | } |
hexley | 54:e117ad10fba6 | 216 | WriteCommand(INTC2, RA8875_INT_TP); // reg INTC2: Clear that TP interrupt flag |
hexley | 54:e117ad10fba6 | 217 | } // End of initial if -- data has been read and processed |
hexley | 54:e117ad10fba6 | 218 | else |
hexley | 54:e117ad10fba6 | 219 | touchready = 0; // Touch Panel "Int" was not set |
hexley | 54:e117ad10fba6 | 220 | return touchready; |
hexley | 54:e117ad10fba6 | 221 | } |
hexley | 54:e117ad10fba6 | 222 | |
hexley | 54:e117ad10fba6 | 223 | unsigned char RA8875::TouchPanelReadRaw(loc_t *x, loc_t *y) |
hexley | 54:e117ad10fba6 | 224 | { |
hexley | 54:e117ad10fba6 | 225 | unsigned char touchready; |
hexley | 54:e117ad10fba6 | 226 | |
hexley | 54:e117ad10fba6 | 227 | if( (ReadCommand(INTC2) & RA8875_INT_TP) ) { // Test for TP Interrupt pending in register INTC2 |
hexley | 54:e117ad10fba6 | 228 | *y = ReadCommand(TPYH) << 2 | ( (ReadCommand(TPXYL) & 0xC) >> 2 ); // D[9:2] from reg TPYH, D[1:0] from reg TPXYL[3:2] |
hexley | 54:e117ad10fba6 | 229 | *x = ReadCommand(TPXH) << 2 | ( (ReadCommand(TPXYL) & 0x3) ); // D[9:2] from reg TPXH, D[1:0] from reg TPXYL[1:0] |
hexley | 54:e117ad10fba6 | 230 | WriteCommand(INTC2, RA8875_INT_TP); // reg INTC2: Clear that TP interrupt flag |
hexley | 54:e117ad10fba6 | 231 | touchready = 1; |
hexley | 54:e117ad10fba6 | 232 | } |
hexley | 54:e117ad10fba6 | 233 | else |
hexley | 54:e117ad10fba6 | 234 | touchready = 0; |
hexley | 54:e117ad10fba6 | 235 | return touchready; |
hexley | 54:e117ad10fba6 | 236 | } |
hexley | 54:e117ad10fba6 | 237 | // #### end of touch panel code additions |
WiredHome | 53:86d24b9480b9 | 238 | |
WiredHome | 19:3f82c1161fd2 | 239 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 240 | void RA8875::ClearPerformance() |
WiredHome | 19:3f82c1161fd2 | 241 | { |
WiredHome | 19:3f82c1161fd2 | 242 | for (int i=0; i<METRICCOUNT; i++) |
WiredHome | 19:3f82c1161fd2 | 243 | metrics[i] = 0; |
WiredHome | 19:3f82c1161fd2 | 244 | } |
WiredHome | 19:3f82c1161fd2 | 245 | |
WiredHome | 44:207594dece70 | 246 | |
WiredHome | 19:3f82c1161fd2 | 247 | void RA8875::RegisterPerformance(method_e method) |
WiredHome | 19:3f82c1161fd2 | 248 | { |
WiredHome | 19:3f82c1161fd2 | 249 | unsigned long elapsed = performance.read_us(); |
WiredHome | 19:3f82c1161fd2 | 250 | |
WiredHome | 19:3f82c1161fd2 | 251 | if (method < METRICCOUNT && elapsed > metrics[method]) |
WiredHome | 19:3f82c1161fd2 | 252 | metrics[method] = elapsed; |
WiredHome | 19:3f82c1161fd2 | 253 | } |
WiredHome | 19:3f82c1161fd2 | 254 | |
WiredHome | 44:207594dece70 | 255 | |
WiredHome | 41:2956a0a221e5 | 256 | void RA8875::ReportPerformance(Serial & pc) |
WiredHome | 19:3f82c1161fd2 | 257 | { |
WiredHome | 41:2956a0a221e5 | 258 | pc.printf("\r\nPerformance Metrics\r\n"); |
WiredHome | 19:3f82c1161fd2 | 259 | for (int i=0; i<METRICCOUNT; i++) { |
WiredHome | 41:2956a0a221e5 | 260 | pc.printf("%10d uS %s\r\n", metrics[i], metricsName[i]); |
WiredHome | 19:3f82c1161fd2 | 261 | } |
WiredHome | 19:3f82c1161fd2 | 262 | } |
WiredHome | 19:3f82c1161fd2 | 263 | #endif |
WiredHome | 19:3f82c1161fd2 | 264 | |
WiredHome | 44:207594dece70 | 265 | |
WiredHome | 38:38d503b4fad6 | 266 | RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t data) |
WiredHome | 38:38d503b4fad6 | 267 | { |
WiredHome | 38:38d503b4fad6 | 268 | #if 1 |
WiredHome | 38:38d503b4fad6 | 269 | WriteCommand(command, data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 270 | WriteCommand(command+1, data >> 8); |
WiredHome | 38:38d503b4fad6 | 271 | #else |
WiredHome | 41:2956a0a221e5 | 272 | // This should be a little faster, but doesn't work... |
WiredHome | 38:38d503b4fad6 | 273 | INFO("WriteCommandW(%02X, %04X)", command, data); |
WiredHome | 38:38d503b4fad6 | 274 | select(true); |
WiredHome | 38:38d503b4fad6 | 275 | spiwrite(0x80); |
WiredHome | 38:38d503b4fad6 | 276 | spiwrite(command); |
WiredHome | 41:2956a0a221e5 | 277 | //spiwrite(0x00); // dummy |
WiredHome | 38:38d503b4fad6 | 278 | spiwrite(data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 279 | spiwrite(data >> 8); |
WiredHome | 38:38d503b4fad6 | 280 | select(false); |
WiredHome | 38:38d503b4fad6 | 281 | #endif |
WiredHome | 38:38d503b4fad6 | 282 | return noerror; |
WiredHome | 38:38d503b4fad6 | 283 | } |
WiredHome | 38:38d503b4fad6 | 284 | |
WiredHome | 44:207594dece70 | 285 | |
WiredHome | 19:3f82c1161fd2 | 286 | RetCode_t RA8875::WriteCommand(unsigned char command, unsigned int data) |
WiredHome | 19:3f82c1161fd2 | 287 | { |
WiredHome | 19:3f82c1161fd2 | 288 | select(true); |
WiredHome | 41:2956a0a221e5 | 289 | spiwrite(0x80); // cmd: write command |
WiredHome | 19:3f82c1161fd2 | 290 | spiwrite(command); |
WiredHome | 19:3f82c1161fd2 | 291 | if (data <= 0xFF) { // only if in the valid range |
WiredHome | 19:3f82c1161fd2 | 292 | spiwrite(0x00); |
WiredHome | 19:3f82c1161fd2 | 293 | spiwrite(data); |
WiredHome | 19:3f82c1161fd2 | 294 | } |
WiredHome | 19:3f82c1161fd2 | 295 | select(false); |
WiredHome | 19:3f82c1161fd2 | 296 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 297 | } |
WiredHome | 19:3f82c1161fd2 | 298 | |
WiredHome | 44:207594dece70 | 299 | |
WiredHome | 38:38d503b4fad6 | 300 | RetCode_t RA8875::WriteDataW(uint16_t data) |
WiredHome | 38:38d503b4fad6 | 301 | { |
WiredHome | 38:38d503b4fad6 | 302 | select(true); |
WiredHome | 41:2956a0a221e5 | 303 | spiwrite(0x00); // cmd: write data |
WiredHome | 38:38d503b4fad6 | 304 | spiwrite(data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 305 | spiwrite(data >> 8); |
WiredHome | 38:38d503b4fad6 | 306 | select(false); |
WiredHome | 38:38d503b4fad6 | 307 | return noerror; |
WiredHome | 38:38d503b4fad6 | 308 | } |
WiredHome | 38:38d503b4fad6 | 309 | |
WiredHome | 44:207594dece70 | 310 | |
WiredHome | 19:3f82c1161fd2 | 311 | RetCode_t RA8875::WriteData(unsigned char data) |
WiredHome | 19:3f82c1161fd2 | 312 | { |
WiredHome | 19:3f82c1161fd2 | 313 | select(true); |
WiredHome | 19:3f82c1161fd2 | 314 | spiwrite(0x00); |
WiredHome | 19:3f82c1161fd2 | 315 | spiwrite(data); |
WiredHome | 19:3f82c1161fd2 | 316 | select(false); |
WiredHome | 19:3f82c1161fd2 | 317 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 318 | } |
WiredHome | 19:3f82c1161fd2 | 319 | |
WiredHome | 44:207594dece70 | 320 | |
WiredHome | 19:3f82c1161fd2 | 321 | unsigned char RA8875::ReadCommand(unsigned char command) |
WiredHome | 19:3f82c1161fd2 | 322 | { |
WiredHome | 19:3f82c1161fd2 | 323 | WriteCommand(command); |
WiredHome | 19:3f82c1161fd2 | 324 | return ReadData(); |
WiredHome | 19:3f82c1161fd2 | 325 | } |
WiredHome | 19:3f82c1161fd2 | 326 | |
WiredHome | 44:207594dece70 | 327 | |
WiredHome | 19:3f82c1161fd2 | 328 | unsigned char RA8875::ReadData(void) |
WiredHome | 19:3f82c1161fd2 | 329 | { |
WiredHome | 19:3f82c1161fd2 | 330 | unsigned char data; |
WiredHome | 19:3f82c1161fd2 | 331 | |
WiredHome | 19:3f82c1161fd2 | 332 | select(true); |
WiredHome | 19:3f82c1161fd2 | 333 | spiwrite(0x40); |
WiredHome | 19:3f82c1161fd2 | 334 | data = spiread(); |
WiredHome | 19:3f82c1161fd2 | 335 | select(false); |
WiredHome | 19:3f82c1161fd2 | 336 | return data; |
WiredHome | 19:3f82c1161fd2 | 337 | } |
WiredHome | 19:3f82c1161fd2 | 338 | |
WiredHome | 44:207594dece70 | 339 | |
WiredHome | 41:2956a0a221e5 | 340 | uint16_t RA8875::ReadDataW(void) |
WiredHome | 41:2956a0a221e5 | 341 | { |
WiredHome | 41:2956a0a221e5 | 342 | uint16_t data; |
WiredHome | 41:2956a0a221e5 | 343 | |
WiredHome | 41:2956a0a221e5 | 344 | select(true); |
WiredHome | 41:2956a0a221e5 | 345 | spiwrite(0x40); |
WiredHome | 41:2956a0a221e5 | 346 | data = spiread(); |
WiredHome | 41:2956a0a221e5 | 347 | data |= (spiread() << 8); |
WiredHome | 41:2956a0a221e5 | 348 | select(false); |
WiredHome | 41:2956a0a221e5 | 349 | return data; |
WiredHome | 41:2956a0a221e5 | 350 | } |
WiredHome | 41:2956a0a221e5 | 351 | |
WiredHome | 44:207594dece70 | 352 | |
WiredHome | 19:3f82c1161fd2 | 353 | unsigned char RA8875::ReadStatus(void) |
WiredHome | 19:3f82c1161fd2 | 354 | { |
WiredHome | 19:3f82c1161fd2 | 355 | unsigned char data; |
WiredHome | 19:3f82c1161fd2 | 356 | |
WiredHome | 19:3f82c1161fd2 | 357 | select(true); |
WiredHome | 19:3f82c1161fd2 | 358 | spiwrite(0xC0); |
WiredHome | 19:3f82c1161fd2 | 359 | data = spiread(); |
WiredHome | 19:3f82c1161fd2 | 360 | select(false); |
WiredHome | 19:3f82c1161fd2 | 361 | return data; |
WiredHome | 19:3f82c1161fd2 | 362 | } |
WiredHome | 19:3f82c1161fd2 | 363 | |
WiredHome | 44:207594dece70 | 364 | |
WiredHome | 37:f19b7e7449dc | 365 | dim_t RA8875::fontwidth(void) |
WiredHome | 19:3f82c1161fd2 | 366 | { |
WiredHome | 19:3f82c1161fd2 | 367 | if (font == NULL) |
WiredHome | 55:dfbabef7003e | 368 | return (((ReadCommand(0x22) >> 2) & 0x3) + 1) * 8; |
WiredHome | 19:3f82c1161fd2 | 369 | else |
WiredHome | 29:422616aa04bd | 370 | return font[1]; |
WiredHome | 19:3f82c1161fd2 | 371 | } |
WiredHome | 19:3f82c1161fd2 | 372 | |
WiredHome | 44:207594dece70 | 373 | |
WiredHome | 37:f19b7e7449dc | 374 | dim_t RA8875::fontheight(void) |
WiredHome | 19:3f82c1161fd2 | 375 | { |
WiredHome | 19:3f82c1161fd2 | 376 | if (font == NULL) |
WiredHome | 23:a50ded45dbaf | 377 | return (((ReadCommand(0x22) >> 0) & 0x3) + 1) * 16; |
WiredHome | 19:3f82c1161fd2 | 378 | else |
WiredHome | 29:422616aa04bd | 379 | return font[2]; |
WiredHome | 19:3f82c1161fd2 | 380 | } |
WiredHome | 19:3f82c1161fd2 | 381 | |
WiredHome | 44:207594dece70 | 382 | |
WiredHome | 37:f19b7e7449dc | 383 | RetCode_t RA8875::locate(textloc_t column, textloc_t row) |
WiredHome | 19:3f82c1161fd2 | 384 | { |
WiredHome | 32:0e4f2ae512e2 | 385 | return SetTextCursor(column * fontwidth(), row * fontheight()); |
WiredHome | 19:3f82c1161fd2 | 386 | } |
WiredHome | 19:3f82c1161fd2 | 387 | |
WiredHome | 44:207594dece70 | 388 | |
WiredHome | 19:3f82c1161fd2 | 389 | int RA8875::columns(void) |
WiredHome | 19:3f82c1161fd2 | 390 | { |
WiredHome | 19:3f82c1161fd2 | 391 | return width() / fontwidth(); |
WiredHome | 19:3f82c1161fd2 | 392 | } |
WiredHome | 19:3f82c1161fd2 | 393 | |
WiredHome | 44:207594dece70 | 394 | |
WiredHome | 19:3f82c1161fd2 | 395 | int RA8875::rows(void) |
WiredHome | 19:3f82c1161fd2 | 396 | { |
WiredHome | 19:3f82c1161fd2 | 397 | return height() / fontheight(); |
WiredHome | 19:3f82c1161fd2 | 398 | } |
WiredHome | 19:3f82c1161fd2 | 399 | |
WiredHome | 44:207594dece70 | 400 | |
WiredHome | 38:38d503b4fad6 | 401 | dim_t RA8875::width(void) |
WiredHome | 19:3f82c1161fd2 | 402 | { |
WiredHome | 29:422616aa04bd | 403 | return (ReadCommand(0x14) + 1) * 8; |
WiredHome | 19:3f82c1161fd2 | 404 | } |
WiredHome | 19:3f82c1161fd2 | 405 | |
WiredHome | 44:207594dece70 | 406 | |
WiredHome | 38:38d503b4fad6 | 407 | dim_t RA8875::height(void) |
WiredHome | 19:3f82c1161fd2 | 408 | { |
WiredHome | 29:422616aa04bd | 409 | return (ReadCommand(0x19) | (ReadCommand(0x1A) << 8)) + 1; |
WiredHome | 19:3f82c1161fd2 | 410 | } |
WiredHome | 19:3f82c1161fd2 | 411 | |
WiredHome | 44:207594dece70 | 412 | |
WiredHome | 43:3becae133285 | 413 | dim_t RA8875::color_bpp(void) |
WiredHome | 43:3becae133285 | 414 | { |
WiredHome | 43:3becae133285 | 415 | if ((ReadCommand(0x10) & 0x0C) == 0x04) |
WiredHome | 43:3becae133285 | 416 | return 16; |
WiredHome | 43:3becae133285 | 417 | else |
WiredHome | 43:3becae133285 | 418 | return 8; |
WiredHome | 43:3becae133285 | 419 | } |
WiredHome | 43:3becae133285 | 420 | |
WiredHome | 44:207594dece70 | 421 | |
WiredHome | 37:f19b7e7449dc | 422 | RetCode_t RA8875::SetTextCursor(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 423 | { |
WiredHome | 29:422616aa04bd | 424 | cursor_x = x; cursor_y = y; // for non-internal fonts |
WiredHome | 38:38d503b4fad6 | 425 | WriteCommandW(0x2A, x); |
WiredHome | 38:38d503b4fad6 | 426 | WriteCommandW(0x2C, y); |
WiredHome | 19:3f82c1161fd2 | 427 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 428 | } |
WiredHome | 19:3f82c1161fd2 | 429 | |
WiredHome | 44:207594dece70 | 430 | |
WiredHome | 37:f19b7e7449dc | 431 | loc_t RA8875::GetTextCursor_Y(void) |
WiredHome | 29:422616aa04bd | 432 | { |
WiredHome | 29:422616aa04bd | 433 | if (font == NULL) |
WiredHome | 29:422616aa04bd | 434 | return ReadCommand(0x2C) | (ReadCommand(0x2D) << 8); |
WiredHome | 29:422616aa04bd | 435 | else |
WiredHome | 29:422616aa04bd | 436 | return cursor_y; |
WiredHome | 29:422616aa04bd | 437 | } |
WiredHome | 29:422616aa04bd | 438 | |
WiredHome | 44:207594dece70 | 439 | |
WiredHome | 37:f19b7e7449dc | 440 | loc_t RA8875::GetTextCursor_X(void) |
WiredHome | 29:422616aa04bd | 441 | { |
WiredHome | 29:422616aa04bd | 442 | if (font == NULL) |
WiredHome | 29:422616aa04bd | 443 | return ReadCommand(0x2A) | (ReadCommand(0x2B) << 8); |
WiredHome | 29:422616aa04bd | 444 | else |
WiredHome | 29:422616aa04bd | 445 | return cursor_x; |
WiredHome | 29:422616aa04bd | 446 | } |
WiredHome | 29:422616aa04bd | 447 | |
WiredHome | 44:207594dece70 | 448 | |
WiredHome | 24:8ca861acf12d | 449 | RetCode_t RA8875::SetTextCursorControl(cursor_t cursor, bool blink) |
WiredHome | 23:a50ded45dbaf | 450 | { |
WiredHome | 23:a50ded45dbaf | 451 | unsigned char mwcr0 = ReadCommand(0x40) & 0x0F; // retain direction, auto-increase |
WiredHome | 43:3becae133285 | 452 | unsigned char mwcr1 = ReadCommand(0x41) & 0x01; // retain currently selected layer |
WiredHome | 24:8ca861acf12d | 453 | unsigned char horz = 0; |
WiredHome | 24:8ca861acf12d | 454 | unsigned char vert = 0; |
WiredHome | 23:a50ded45dbaf | 455 | |
WiredHome | 24:8ca861acf12d | 456 | mwcr0 |= 0x80; // text mode |
WiredHome | 24:8ca861acf12d | 457 | if (cursor != NOCURSOR) |
WiredHome | 24:8ca861acf12d | 458 | mwcr0 |= 0x40; // visible |
WiredHome | 23:a50ded45dbaf | 459 | if (blink) |
WiredHome | 24:8ca861acf12d | 460 | mwcr0 |= 0x20; // blink |
WiredHome | 23:a50ded45dbaf | 461 | WriteCommand(0x40, mwcr0); // configure the cursor |
WiredHome | 43:3becae133285 | 462 | WriteCommand(0x41, mwcr1); // close the graphics cursor |
WiredHome | 24:8ca861acf12d | 463 | WriteCommand(0x44, 0x1f); // The cursor flashing cycle |
WiredHome | 24:8ca861acf12d | 464 | switch (cursor) { |
WiredHome | 24:8ca861acf12d | 465 | case IBEAM: |
WiredHome | 24:8ca861acf12d | 466 | horz = 0x01; |
WiredHome | 24:8ca861acf12d | 467 | vert = 0x1F; |
WiredHome | 24:8ca861acf12d | 468 | break; |
WiredHome | 24:8ca861acf12d | 469 | case UNDER: |
WiredHome | 24:8ca861acf12d | 470 | horz = 0x07; |
WiredHome | 24:8ca861acf12d | 471 | vert = 0x01; |
WiredHome | 24:8ca861acf12d | 472 | break; |
WiredHome | 24:8ca861acf12d | 473 | case BLOCK: |
WiredHome | 24:8ca861acf12d | 474 | horz = 0x07; |
WiredHome | 24:8ca861acf12d | 475 | vert = 0x1F; |
WiredHome | 24:8ca861acf12d | 476 | break; |
WiredHome | 24:8ca861acf12d | 477 | case NOCURSOR: |
WiredHome | 24:8ca861acf12d | 478 | default: |
WiredHome | 24:8ca861acf12d | 479 | break; |
WiredHome | 24:8ca861acf12d | 480 | } |
WiredHome | 24:8ca861acf12d | 481 | WriteCommand(0x4e, horz); // The cursor size horz |
WiredHome | 24:8ca861acf12d | 482 | WriteCommand(0x4f, vert); // The cursor size vert |
WiredHome | 23:a50ded45dbaf | 483 | return noerror; |
WiredHome | 23:a50ded45dbaf | 484 | } |
WiredHome | 23:a50ded45dbaf | 485 | |
WiredHome | 44:207594dece70 | 486 | |
WiredHome | 19:3f82c1161fd2 | 487 | RetCode_t RA8875::SetTextFont(RA8875::font_t font) |
WiredHome | 19:3f82c1161fd2 | 488 | { |
WiredHome | 19:3f82c1161fd2 | 489 | if (/*font >= RA8875::ISO8859_1 && */ font <= RA8875::ISO8859_4) { |
WiredHome | 19:3f82c1161fd2 | 490 | WriteCommand(0x21, (unsigned int)(font)); |
WiredHome | 19:3f82c1161fd2 | 491 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 492 | } else { |
WiredHome | 19:3f82c1161fd2 | 493 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 494 | } |
WiredHome | 19:3f82c1161fd2 | 495 | } |
WiredHome | 19:3f82c1161fd2 | 496 | |
WiredHome | 44:207594dece70 | 497 | |
WiredHome | 19:3f82c1161fd2 | 498 | RetCode_t RA8875::SetTextFontControl(fill_t fillit, |
WiredHome | 19:3f82c1161fd2 | 499 | RA8875::font_angle_t angle, |
WiredHome | 19:3f82c1161fd2 | 500 | RA8875::HorizontalScale hScale, |
WiredHome | 19:3f82c1161fd2 | 501 | RA8875::VerticalScale vScale, |
WiredHome | 19:3f82c1161fd2 | 502 | RA8875::alignment_t alignment) |
WiredHome | 19:3f82c1161fd2 | 503 | { |
WiredHome | 19:3f82c1161fd2 | 504 | if (hScale >= 1 && hScale <= 4 && |
WiredHome | 19:3f82c1161fd2 | 505 | vScale >= 1 && vScale <= 4) { |
WiredHome | 19:3f82c1161fd2 | 506 | unsigned char x = 0; |
WiredHome | 19:3f82c1161fd2 | 507 | |
WiredHome | 19:3f82c1161fd2 | 508 | if (alignment == align_full) |
WiredHome | 19:3f82c1161fd2 | 509 | x |= 0x80; |
WiredHome | 19:3f82c1161fd2 | 510 | if (fillit == NOFILL) |
WiredHome | 19:3f82c1161fd2 | 511 | x |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 512 | if (angle == rotated) |
WiredHome | 19:3f82c1161fd2 | 513 | x |= 0x10; |
WiredHome | 19:3f82c1161fd2 | 514 | x |= ((hScale - 1) << 2); |
WiredHome | 19:3f82c1161fd2 | 515 | x |= ((vScale - 1) << 0); |
WiredHome | 19:3f82c1161fd2 | 516 | WriteCommand(0x22, x); |
WiredHome | 19:3f82c1161fd2 | 517 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 518 | } else { |
WiredHome | 19:3f82c1161fd2 | 519 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 520 | } |
WiredHome | 19:3f82c1161fd2 | 521 | } |
WiredHome | 19:3f82c1161fd2 | 522 | |
WiredHome | 44:207594dece70 | 523 | |
WiredHome | 19:3f82c1161fd2 | 524 | RetCode_t RA8875::SetTextFontSize(RA8875::HorizontalScale hScale, RA8875::VerticalScale vScale) |
WiredHome | 19:3f82c1161fd2 | 525 | { |
WiredHome | 19:3f82c1161fd2 | 526 | unsigned char reg = ReadCommand(0x22); |
WiredHome | 19:3f82c1161fd2 | 527 | |
WiredHome | 40:04aa280dfa39 | 528 | if (vScale == -1) |
WiredHome | 40:04aa280dfa39 | 529 | vScale = hScale; |
WiredHome | 19:3f82c1161fd2 | 530 | if (hScale >= 1 && hScale <= 4 && vScale >= 1 && vScale <= 4) { |
WiredHome | 19:3f82c1161fd2 | 531 | reg &= 0xF0; // keep the high nibble as is. |
WiredHome | 19:3f82c1161fd2 | 532 | reg |= ((hScale - 1) << 2); |
WiredHome | 19:3f82c1161fd2 | 533 | reg |= ((vScale - 1) << 0); |
WiredHome | 19:3f82c1161fd2 | 534 | WriteCommand(0x22, reg); |
WiredHome | 19:3f82c1161fd2 | 535 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 536 | } else { |
WiredHome | 19:3f82c1161fd2 | 537 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 538 | } |
WiredHome | 19:3f82c1161fd2 | 539 | } |
WiredHome | 19:3f82c1161fd2 | 540 | |
WiredHome | 44:207594dece70 | 541 | |
WiredHome | 19:3f82c1161fd2 | 542 | int RA8875::_putc(int c) |
WiredHome | 19:3f82c1161fd2 | 543 | { |
WiredHome | 29:422616aa04bd | 544 | if (font == NULL) { |
WiredHome | 29:422616aa04bd | 545 | return _internal_putc(c); |
WiredHome | 29:422616aa04bd | 546 | } else { |
WiredHome | 29:422616aa04bd | 547 | return _external_putc(c); |
WiredHome | 29:422616aa04bd | 548 | } |
WiredHome | 29:422616aa04bd | 549 | } |
WiredHome | 29:422616aa04bd | 550 | |
WiredHome | 44:207594dece70 | 551 | |
WiredHome | 29:422616aa04bd | 552 | int RA8875::_external_putc(int c) |
WiredHome | 29:422616aa04bd | 553 | { |
WiredHome | 19:3f82c1161fd2 | 554 | if (c) { |
WiredHome | 19:3f82c1161fd2 | 555 | if (c == '\r') { |
WiredHome | 29:422616aa04bd | 556 | cursor_x = 0; |
WiredHome | 29:422616aa04bd | 557 | } else if (c == '\n') { |
WiredHome | 29:422616aa04bd | 558 | cursor_y += font[2]; |
WiredHome | 29:422616aa04bd | 559 | } else { |
WiredHome | 29:422616aa04bd | 560 | int advance = character(cursor_x, cursor_y, c); // advance tells us how many pixels we advanced |
WiredHome | 37:f19b7e7449dc | 561 | //INFO("x,y,advance %d,%d,%d", cursor_x, cursor_y, advance); |
WiredHome | 29:422616aa04bd | 562 | if (advance) { |
WiredHome | 29:422616aa04bd | 563 | cursor_x += advance; |
WiredHome | 29:422616aa04bd | 564 | if (cursor_x >= width()) { |
WiredHome | 29:422616aa04bd | 565 | cursor_x = 0; |
WiredHome | 29:422616aa04bd | 566 | cursor_y += font[2]; |
WiredHome | 29:422616aa04bd | 567 | if (cursor_y >= height()) { |
WiredHome | 29:422616aa04bd | 568 | cursor_y = 0; // @todo Should it scroll? |
WiredHome | 29:422616aa04bd | 569 | } |
WiredHome | 29:422616aa04bd | 570 | } |
WiredHome | 29:422616aa04bd | 571 | } |
WiredHome | 29:422616aa04bd | 572 | } |
WiredHome | 29:422616aa04bd | 573 | } |
WiredHome | 29:422616aa04bd | 574 | return c; |
WiredHome | 29:422616aa04bd | 575 | } |
WiredHome | 29:422616aa04bd | 576 | |
WiredHome | 44:207594dece70 | 577 | |
WiredHome | 29:422616aa04bd | 578 | int RA8875::_internal_putc(int c) |
WiredHome | 29:422616aa04bd | 579 | { |
WiredHome | 29:422616aa04bd | 580 | if (c) { |
WiredHome | 29:422616aa04bd | 581 | unsigned char mwcr0; |
WiredHome | 29:422616aa04bd | 582 | |
WiredHome | 29:422616aa04bd | 583 | mwcr0 = ReadCommand(0x40); |
WiredHome | 29:422616aa04bd | 584 | if ((mwcr0 & 0x80) == 0x00) { |
WiredHome | 29:422616aa04bd | 585 | WriteCommand(0x40, 0x80 | mwcr0); // Put in Text mode if not already |
WiredHome | 29:422616aa04bd | 586 | } |
WiredHome | 29:422616aa04bd | 587 | if (c == '\r') { |
WiredHome | 37:f19b7e7449dc | 588 | loc_t x; |
WiredHome | 19:3f82c1161fd2 | 589 | x = ReadCommand(0x30) | (ReadCommand(0x31) << 8); // Left edge of active window |
WiredHome | 38:38d503b4fad6 | 590 | WriteCommandW(0x2A, x); |
WiredHome | 19:3f82c1161fd2 | 591 | } else if (c == '\n') { |
WiredHome | 37:f19b7e7449dc | 592 | loc_t y; |
WiredHome | 19:3f82c1161fd2 | 593 | y = ReadCommand(0x2C) | (ReadCommand(0x2D) << 8); // current y location |
WiredHome | 19:3f82c1161fd2 | 594 | y += fontheight(); |
WiredHome | 47:d96a09269f91 | 595 | if (y >= height()) // @TODO after bottom of active window, then scroll window? |
WiredHome | 19:3f82c1161fd2 | 596 | y = 0; |
WiredHome | 38:38d503b4fad6 | 597 | WriteCommandW(0x2C, y); |
WiredHome | 19:3f82c1161fd2 | 598 | } else { |
WiredHome | 29:422616aa04bd | 599 | WriteCommand(0x02); // RA8875 Internal Fonts |
WiredHome | 29:422616aa04bd | 600 | select(true); |
WiredHome | 29:422616aa04bd | 601 | WriteData(c); |
WiredHome | 29:422616aa04bd | 602 | while (ReadStatus() & 0x80) |
WiredHome | 29:422616aa04bd | 603 | wait_us(POLLWAITuSec); // Chk_Busy(); |
WiredHome | 29:422616aa04bd | 604 | select(false); |
WiredHome | 19:3f82c1161fd2 | 605 | } |
WiredHome | 19:3f82c1161fd2 | 606 | } |
WiredHome | 19:3f82c1161fd2 | 607 | return c; |
WiredHome | 19:3f82c1161fd2 | 608 | } |
WiredHome | 19:3f82c1161fd2 | 609 | |
WiredHome | 44:207594dece70 | 610 | |
WiredHome | 32:0e4f2ae512e2 | 611 | RetCode_t RA8875::_StartGraphicsStream(void) |
WiredHome | 32:0e4f2ae512e2 | 612 | { |
WiredHome | 32:0e4f2ae512e2 | 613 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 32:0e4f2ae512e2 | 614 | WriteCommand(0x02); // Prepare for streaming data |
WiredHome | 32:0e4f2ae512e2 | 615 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 616 | } |
WiredHome | 32:0e4f2ae512e2 | 617 | |
WiredHome | 44:207594dece70 | 618 | |
WiredHome | 32:0e4f2ae512e2 | 619 | RetCode_t RA8875::_EndGraphicsStream(void) |
WiredHome | 32:0e4f2ae512e2 | 620 | { |
WiredHome | 32:0e4f2ae512e2 | 621 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 622 | } |
WiredHome | 32:0e4f2ae512e2 | 623 | |
WiredHome | 44:207594dece70 | 624 | |
WiredHome | 55:dfbabef7003e | 625 | RetCode_t RA8875::_putp(color_t pixel) |
WiredHome | 32:0e4f2ae512e2 | 626 | { |
WiredHome | 38:38d503b4fad6 | 627 | WriteDataW((pixel>>8) | (pixel<<8)); |
WiredHome | 32:0e4f2ae512e2 | 628 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 629 | } |
WiredHome | 29:422616aa04bd | 630 | |
WiredHome | 44:207594dece70 | 631 | |
WiredHome | 37:f19b7e7449dc | 632 | void RA8875::puts(loc_t x, loc_t y, const char * string) |
WiredHome | 19:3f82c1161fd2 | 633 | { |
WiredHome | 19:3f82c1161fd2 | 634 | SetTextCursor(x,y); |
WiredHome | 19:3f82c1161fd2 | 635 | puts(string); |
WiredHome | 19:3f82c1161fd2 | 636 | } |
WiredHome | 19:3f82c1161fd2 | 637 | |
WiredHome | 44:207594dece70 | 638 | |
WiredHome | 19:3f82c1161fd2 | 639 | void RA8875::puts(const char * string) |
WiredHome | 19:3f82c1161fd2 | 640 | { |
WiredHome | 29:422616aa04bd | 641 | unsigned char mwcr0 = ReadCommand(0x40); |
WiredHome | 37:f19b7e7449dc | 642 | |
WiredHome | 37:f19b7e7449dc | 643 | if (font == NULL) { |
WiredHome | 37:f19b7e7449dc | 644 | if ((mwcr0 & 0x80) == 0x00) |
WiredHome | 37:f19b7e7449dc | 645 | WriteCommand(0x40,0x80); // Put in Text mode if not already |
WiredHome | 37:f19b7e7449dc | 646 | } else { |
WiredHome | 37:f19b7e7449dc | 647 | _StartGraphicsStream(); |
WiredHome | 37:f19b7e7449dc | 648 | } |
WiredHome | 19:3f82c1161fd2 | 649 | if (*string != '\0') { |
WiredHome | 19:3f82c1161fd2 | 650 | #if 1 |
WiredHome | 29:422616aa04bd | 651 | while (*string) { // @TODO calling individual _putc is slower... optimizations? |
WiredHome | 19:3f82c1161fd2 | 652 | _putc(*string++); |
WiredHome | 19:3f82c1161fd2 | 653 | } |
WiredHome | 19:3f82c1161fd2 | 654 | #else |
WiredHome | 19:3f82c1161fd2 | 655 | WriteCommand(0x02); |
WiredHome | 19:3f82c1161fd2 | 656 | select(true); |
WiredHome | 19:3f82c1161fd2 | 657 | while (*string != '\0') { |
WiredHome | 19:3f82c1161fd2 | 658 | WriteData(*string); |
WiredHome | 19:3f82c1161fd2 | 659 | ++string; |
WiredHome | 19:3f82c1161fd2 | 660 | while (ReadStatus() & 0x80) |
WiredHome | 19:3f82c1161fd2 | 661 | wait_us(POLLWAITuSec); // Chk_Busy(); |
WiredHome | 19:3f82c1161fd2 | 662 | } |
WiredHome | 19:3f82c1161fd2 | 663 | select(false); |
WiredHome | 19:3f82c1161fd2 | 664 | #endif |
WiredHome | 19:3f82c1161fd2 | 665 | } |
WiredHome | 37:f19b7e7449dc | 666 | if (font) |
WiredHome | 37:f19b7e7449dc | 667 | _EndGraphicsStream(); |
WiredHome | 19:3f82c1161fd2 | 668 | } |
WiredHome | 19:3f82c1161fd2 | 669 | |
WiredHome | 44:207594dece70 | 670 | |
WiredHome | 37:f19b7e7449dc | 671 | RetCode_t RA8875::SetGraphicsCursor(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 672 | { |
WiredHome | 38:38d503b4fad6 | 673 | WriteCommandW(0x46, x); |
WiredHome | 38:38d503b4fad6 | 674 | WriteCommandW(0x48, y); |
WiredHome | 19:3f82c1161fd2 | 675 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 676 | } |
WiredHome | 19:3f82c1161fd2 | 677 | |
WiredHome | 44:207594dece70 | 678 | |
WiredHome | 41:2956a0a221e5 | 679 | RetCode_t RA8875::SetGraphicsCursorRead(loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 680 | { |
WiredHome | 41:2956a0a221e5 | 681 | //WriteCommand(0x40, 0); // Graphics mode |
WiredHome | 41:2956a0a221e5 | 682 | //WriteCommand(0x45, 0); // left->right, top->bottom |
WiredHome | 41:2956a0a221e5 | 683 | WriteCommandW(0x4A, x); |
WiredHome | 41:2956a0a221e5 | 684 | WriteCommandW(0x4C, y); |
WiredHome | 41:2956a0a221e5 | 685 | return noerror; |
WiredHome | 41:2956a0a221e5 | 686 | } |
WiredHome | 41:2956a0a221e5 | 687 | |
WiredHome | 44:207594dece70 | 688 | |
WiredHome | 37:f19b7e7449dc | 689 | RetCode_t RA8875::window(loc_t x, loc_t y, dim_t width, dim_t height) |
WiredHome | 19:3f82c1161fd2 | 690 | { |
WiredHome | 37:f19b7e7449dc | 691 | GraphicsDisplay::window(x,y, width,height); |
WiredHome | 38:38d503b4fad6 | 692 | WriteCommandW(0x30, x); |
WiredHome | 38:38d503b4fad6 | 693 | WriteCommandW(0x32, y); |
WiredHome | 38:38d503b4fad6 | 694 | WriteCommandW(0x34, (x+width-1)); |
WiredHome | 38:38d503b4fad6 | 695 | WriteCommandW(0x36, (y+height-1)); |
WiredHome | 37:f19b7e7449dc | 696 | SetGraphicsCursor(x,y); |
WiredHome | 19:3f82c1161fd2 | 697 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 698 | } |
WiredHome | 19:3f82c1161fd2 | 699 | |
WiredHome | 44:207594dece70 | 700 | |
WiredHome | 61:8f3153bf0baa | 701 | RetCode_t RA8875::cls(uint16_t layers) |
WiredHome | 19:3f82c1161fd2 | 702 | { |
WiredHome | 61:8f3153bf0baa | 703 | RetCode_t ret; |
WiredHome | 61:8f3153bf0baa | 704 | |
WiredHome | 19:3f82c1161fd2 | 705 | PERFORMANCE_RESET; |
WiredHome | 61:8f3153bf0baa | 706 | if (layers == 0) { |
WiredHome | 61:8f3153bf0baa | 707 | ret = clsw(FULLWINDOW); |
WiredHome | 61:8f3153bf0baa | 708 | ret = SetTextCursor(0,0); |
WiredHome | 61:8f3153bf0baa | 709 | } else if (layers > 3) { |
WiredHome | 61:8f3153bf0baa | 710 | ret = bad_parameter; |
WiredHome | 61:8f3153bf0baa | 711 | } else { |
WiredHome | 61:8f3153bf0baa | 712 | uint16_t prevLayer = GetDrawingLayer(); |
WiredHome | 61:8f3153bf0baa | 713 | if (layers & 1) { |
WiredHome | 61:8f3153bf0baa | 714 | SelectDrawingLayer(0); |
WiredHome | 61:8f3153bf0baa | 715 | clsw(FULLWINDOW); |
WiredHome | 61:8f3153bf0baa | 716 | } |
WiredHome | 61:8f3153bf0baa | 717 | if (layers & 2) { |
WiredHome | 61:8f3153bf0baa | 718 | SelectDrawingLayer(1); |
WiredHome | 61:8f3153bf0baa | 719 | clsw(FULLWINDOW); |
WiredHome | 61:8f3153bf0baa | 720 | } |
WiredHome | 61:8f3153bf0baa | 721 | ret = SelectDrawingLayer(prevLayer); |
WiredHome | 61:8f3153bf0baa | 722 | } |
WiredHome | 19:3f82c1161fd2 | 723 | REGISTERPERFORMANCE(PRF_CLS); |
WiredHome | 61:8f3153bf0baa | 724 | return ret; |
WiredHome | 19:3f82c1161fd2 | 725 | } |
WiredHome | 19:3f82c1161fd2 | 726 | |
WiredHome | 44:207594dece70 | 727 | |
WiredHome | 19:3f82c1161fd2 | 728 | RetCode_t RA8875::clsw(RA8875::Region_t region) |
WiredHome | 19:3f82c1161fd2 | 729 | { |
WiredHome | 19:3f82c1161fd2 | 730 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 731 | WriteCommand(0x8E, (region == ACTIVEWINDOW) ? 0xC0 : 0x80); |
WiredHome | 19:3f82c1161fd2 | 732 | while (ReadCommand(0x8E) & 0x80) |
WiredHome | 19:3f82c1161fd2 | 733 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 734 | REGISTERPERFORMANCE(PRF_CLS); |
WiredHome | 19:3f82c1161fd2 | 735 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 736 | } |
WiredHome | 19:3f82c1161fd2 | 737 | |
WiredHome | 44:207594dece70 | 738 | |
WiredHome | 37:f19b7e7449dc | 739 | RetCode_t RA8875::pixel(loc_t x, loc_t y, color_t color) |
WiredHome | 19:3f82c1161fd2 | 740 | { |
WiredHome | 62:ba5d33438fda | 741 | RetCode_t ret; |
WiredHome | 62:ba5d33438fda | 742 | |
WiredHome | 62:ba5d33438fda | 743 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 744 | #if 1 |
WiredHome | 62:ba5d33438fda | 745 | ret = pixelStream(&color, 1, x,y); |
WiredHome | 41:2956a0a221e5 | 746 | #else |
WiredHome | 19:3f82c1161fd2 | 747 | foreground(color); |
WiredHome | 62:ba5d33438fda | 748 | ret = pixel(x,y); |
WiredHome | 41:2956a0a221e5 | 749 | #endif |
WiredHome | 62:ba5d33438fda | 750 | REGISTERPERFORMANCE(PRF_DRAWPIXEL); |
WiredHome | 62:ba5d33438fda | 751 | return ret; |
WiredHome | 19:3f82c1161fd2 | 752 | } |
WiredHome | 19:3f82c1161fd2 | 753 | |
WiredHome | 44:207594dece70 | 754 | |
WiredHome | 37:f19b7e7449dc | 755 | RetCode_t RA8875::pixel(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 756 | { |
WiredHome | 19:3f82c1161fd2 | 757 | RetCode_t ret; |
WiredHome | 19:3f82c1161fd2 | 758 | |
WiredHome | 19:3f82c1161fd2 | 759 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 760 | color_t color = GetForeColor(); |
WiredHome | 62:ba5d33438fda | 761 | #if 1 |
WiredHome | 62:ba5d33438fda | 762 | ret = pixelStream(&color, 1, x, y); |
WiredHome | 62:ba5d33438fda | 763 | #else |
WiredHome | 19:3f82c1161fd2 | 764 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 32:0e4f2ae512e2 | 765 | SetGraphicsCursor(x, y); |
WiredHome | 38:38d503b4fad6 | 766 | WriteCommand(0x02); |
WiredHome | 38:38d503b4fad6 | 767 | WriteDataW(color); |
WiredHome | 19:3f82c1161fd2 | 768 | ret = noerror; |
WiredHome | 62:ba5d33438fda | 769 | #endif |
WiredHome | 41:2956a0a221e5 | 770 | REGISTERPERFORMANCE(PRF_DRAWPIXEL); |
WiredHome | 19:3f82c1161fd2 | 771 | return ret; |
WiredHome | 19:3f82c1161fd2 | 772 | } |
WiredHome | 19:3f82c1161fd2 | 773 | |
WiredHome | 44:207594dece70 | 774 | |
WiredHome | 41:2956a0a221e5 | 775 | RetCode_t RA8875::pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 776 | { |
WiredHome | 41:2956a0a221e5 | 777 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 778 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 41:2956a0a221e5 | 779 | SetGraphicsCursor(x, y); |
WiredHome | 41:2956a0a221e5 | 780 | WriteCommand(0x02); |
WiredHome | 41:2956a0a221e5 | 781 | select(true); |
WiredHome | 41:2956a0a221e5 | 782 | spiwrite(0x00); // Cmd: write data |
WiredHome | 41:2956a0a221e5 | 783 | while (count--) { |
WiredHome | 41:2956a0a221e5 | 784 | spiwrite(*p >> 8); |
WiredHome | 41:2956a0a221e5 | 785 | spiwrite(*p & 0xFF); |
WiredHome | 41:2956a0a221e5 | 786 | p++; |
WiredHome | 41:2956a0a221e5 | 787 | } |
WiredHome | 41:2956a0a221e5 | 788 | select(false); |
WiredHome | 41:2956a0a221e5 | 789 | REGISTERPERFORMANCE(PRF_PIXELSTREAM); |
WiredHome | 41:2956a0a221e5 | 790 | return(noerror); |
WiredHome | 41:2956a0a221e5 | 791 | } |
WiredHome | 41:2956a0a221e5 | 792 | |
WiredHome | 44:207594dece70 | 793 | |
WiredHome | 41:2956a0a221e5 | 794 | color_t RA8875::getPixel(loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 795 | { |
WiredHome | 41:2956a0a221e5 | 796 | color_t pixel; |
WiredHome | 41:2956a0a221e5 | 797 | |
WiredHome | 41:2956a0a221e5 | 798 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 799 | //WriteCommand(0x45,0x00); // read left->right, top->bottom |
WiredHome | 41:2956a0a221e5 | 800 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 41:2956a0a221e5 | 801 | SetGraphicsCursorRead(x, y); |
WiredHome | 41:2956a0a221e5 | 802 | WriteCommand(0x02); |
WiredHome | 41:2956a0a221e5 | 803 | select(true); |
WiredHome | 41:2956a0a221e5 | 804 | spiwrite(0x40); // Cmd: read data |
WiredHome | 41:2956a0a221e5 | 805 | spiwrite(0x00); // dummy read |
WiredHome | 41:2956a0a221e5 | 806 | pixel = spiread(); |
WiredHome | 41:2956a0a221e5 | 807 | pixel |= (spiread() << 8); |
WiredHome | 41:2956a0a221e5 | 808 | select(false); |
WiredHome | 41:2956a0a221e5 | 809 | REGISTERPERFORMANCE(PRF_READPIXEL); |
WiredHome | 41:2956a0a221e5 | 810 | return pixel; |
WiredHome | 41:2956a0a221e5 | 811 | } |
WiredHome | 41:2956a0a221e5 | 812 | |
WiredHome | 44:207594dece70 | 813 | |
WiredHome | 41:2956a0a221e5 | 814 | RetCode_t RA8875::getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) |
WiredHome | 41:2956a0a221e5 | 815 | { |
WiredHome | 41:2956a0a221e5 | 816 | color_t pixel; |
WiredHome | 41:2956a0a221e5 | 817 | |
WiredHome | 41:2956a0a221e5 | 818 | PERFORMANCE_RESET; |
WiredHome | 41:2956a0a221e5 | 819 | //WriteCommand(0x45,0x00); // read left->right, top->bottom |
WiredHome | 41:2956a0a221e5 | 820 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 41:2956a0a221e5 | 821 | SetGraphicsCursorRead(x, y); |
WiredHome | 41:2956a0a221e5 | 822 | WriteCommand(0x02); |
WiredHome | 41:2956a0a221e5 | 823 | select(true); |
WiredHome | 41:2956a0a221e5 | 824 | spiwrite(0x40); // Cmd: read data |
WiredHome | 41:2956a0a221e5 | 825 | spiwrite(0x00); // dummy read |
WiredHome | 41:2956a0a221e5 | 826 | while (count--) { |
WiredHome | 41:2956a0a221e5 | 827 | pixel = spiread(); |
WiredHome | 41:2956a0a221e5 | 828 | pixel |= (spiread() << 8); |
WiredHome | 41:2956a0a221e5 | 829 | *p++ = pixel; |
WiredHome | 41:2956a0a221e5 | 830 | } |
WiredHome | 41:2956a0a221e5 | 831 | select(false); |
WiredHome | 41:2956a0a221e5 | 832 | REGISTERPERFORMANCE(PRF_READPIXELSTREAM); |
WiredHome | 41:2956a0a221e5 | 833 | return noerror; |
WiredHome | 41:2956a0a221e5 | 834 | } |
WiredHome | 41:2956a0a221e5 | 835 | |
WiredHome | 44:207594dece70 | 836 | |
WiredHome | 37:f19b7e7449dc | 837 | RetCode_t RA8875::line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color) |
WiredHome | 19:3f82c1161fd2 | 838 | { |
WiredHome | 19:3f82c1161fd2 | 839 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 840 | return line(x1,y1,x2,y2); |
WiredHome | 19:3f82c1161fd2 | 841 | } |
WiredHome | 19:3f82c1161fd2 | 842 | |
WiredHome | 44:207594dece70 | 843 | |
WiredHome | 37:f19b7e7449dc | 844 | RetCode_t RA8875::line(loc_t x1, loc_t y1, loc_t x2, loc_t y2) |
WiredHome | 19:3f82c1161fd2 | 845 | { |
WiredHome | 19:3f82c1161fd2 | 846 | PERFORMANCE_RESET; |
WiredHome | 62:ba5d33438fda | 847 | if (x1 == x2 && y1 == y2) { |
WiredHome | 60:2dfd574f63bd | 848 | pixel(x1, y1); |
WiredHome | 62:ba5d33438fda | 849 | } else { |
WiredHome | 60:2dfd574f63bd | 850 | WriteCommandW(0x91, x1); |
WiredHome | 60:2dfd574f63bd | 851 | WriteCommandW(0x93, y1); |
WiredHome | 60:2dfd574f63bd | 852 | WriteCommandW(0x95, x2); |
WiredHome | 60:2dfd574f63bd | 853 | WriteCommandW(0x97, y2); |
WiredHome | 60:2dfd574f63bd | 854 | unsigned char drawCmd = 0x00; // Line |
WiredHome | 60:2dfd574f63bd | 855 | WriteCommand(0x90, drawCmd); |
WiredHome | 60:2dfd574f63bd | 856 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 60:2dfd574f63bd | 857 | while (ReadCommand(0x90) & 0x80) // await completion. |
WiredHome | 60:2dfd574f63bd | 858 | wait_us(POLLWAITuSec); |
WiredHome | 60:2dfd574f63bd | 859 | } |
WiredHome | 19:3f82c1161fd2 | 860 | REGISTERPERFORMANCE(PRF_DRAWLINE); |
WiredHome | 19:3f82c1161fd2 | 861 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 862 | } |
WiredHome | 19:3f82c1161fd2 | 863 | |
WiredHome | 44:207594dece70 | 864 | |
WiredHome | 37:f19b7e7449dc | 865 | RetCode_t RA8875::fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 19:3f82c1161fd2 | 866 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 867 | { |
WiredHome | 19:3f82c1161fd2 | 868 | return rect(x1,y1,x2,y2,color,fillit); |
WiredHome | 19:3f82c1161fd2 | 869 | } |
WiredHome | 19:3f82c1161fd2 | 870 | |
WiredHome | 44:207594dece70 | 871 | |
WiredHome | 37:f19b7e7449dc | 872 | RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 19:3f82c1161fd2 | 873 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 874 | { |
WiredHome | 19:3f82c1161fd2 | 875 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 876 | return rect(x1,y1,x2,y2,fillit); |
WiredHome | 19:3f82c1161fd2 | 877 | } |
WiredHome | 19:3f82c1161fd2 | 878 | |
WiredHome | 44:207594dece70 | 879 | |
WiredHome | 37:f19b7e7449dc | 880 | RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 19:3f82c1161fd2 | 881 | fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 882 | { |
WiredHome | 19:3f82c1161fd2 | 883 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 884 | if (x1 == x2 && y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 885 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 886 | } else if (x1 == x2) { |
WiredHome | 19:3f82c1161fd2 | 887 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 888 | } else if (y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 889 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 890 | } else { |
WiredHome | 38:38d503b4fad6 | 891 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 892 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 893 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 894 | WriteCommandW(0x97, y2); |
WiredHome | 19:3f82c1161fd2 | 895 | unsigned char drawCmd = 0x10; // Rectangle |
WiredHome | 19:3f82c1161fd2 | 896 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 897 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 898 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 899 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 900 | while (ReadCommand(0x90) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 901 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 902 | } |
WiredHome | 19:3f82c1161fd2 | 903 | REGISTERPERFORMANCE(PRF_DRAWRECTANGLE); |
WiredHome | 19:3f82c1161fd2 | 904 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 905 | } |
WiredHome | 19:3f82c1161fd2 | 906 | |
WiredHome | 44:207594dece70 | 907 | |
WiredHome | 37:f19b7e7449dc | 908 | RetCode_t RA8875::fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 909 | dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 910 | { |
WiredHome | 19:3f82c1161fd2 | 911 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 912 | return roundrect(x1,y1,x2,y2,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 913 | } |
WiredHome | 19:3f82c1161fd2 | 914 | |
WiredHome | 44:207594dece70 | 915 | |
WiredHome | 37:f19b7e7449dc | 916 | RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 917 | dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 918 | { |
WiredHome | 19:3f82c1161fd2 | 919 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 920 | return roundrect(x1,y1,x2,y2,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 921 | } |
WiredHome | 19:3f82c1161fd2 | 922 | |
WiredHome | 44:207594dece70 | 923 | |
WiredHome | 37:f19b7e7449dc | 924 | RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 925 | dim_t radius1, dim_t radius2, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 926 | { |
WiredHome | 19:3f82c1161fd2 | 927 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 928 | |
WiredHome | 19:3f82c1161fd2 | 929 | PERFORMANCE_RESET; |
WiredHome | 21:3c1efb192927 | 930 | if (x1 > x2 || y1 > y2 || (radius1 > (x2-x1)/2) || (radius2 > (y2-y1)/2) ) { |
WiredHome | 21:3c1efb192927 | 931 | ret = bad_parameter; |
WiredHome | 21:3c1efb192927 | 932 | } else if (x1 == x2 && y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 933 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 934 | } else if (x1 == x2) { |
WiredHome | 19:3f82c1161fd2 | 935 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 936 | } else if (y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 937 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 938 | } else { |
WiredHome | 38:38d503b4fad6 | 939 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 940 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 941 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 942 | WriteCommandW(0x97, y2); |
WiredHome | 38:38d503b4fad6 | 943 | WriteCommandW(0xA1, radius1); |
WiredHome | 38:38d503b4fad6 | 944 | WriteCommandW(0xA3, radius2); |
WiredHome | 21:3c1efb192927 | 945 | // Should not need this... |
WiredHome | 38:38d503b4fad6 | 946 | WriteCommandW(0xA5, 0); |
WiredHome | 38:38d503b4fad6 | 947 | WriteCommandW(0xA7, 0); |
WiredHome | 19:3f82c1161fd2 | 948 | unsigned char drawCmd = 0x20; // Rounded Rectangle |
WiredHome | 19:3f82c1161fd2 | 949 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 950 | drawCmd |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 951 | WriteCommand(0xA0, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 952 | WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 953 | while (ReadCommand(0xA0) & 0x80) { // await completion. |
WiredHome | 19:3f82c1161fd2 | 954 | wait_us(POLLWAITuSec); |
WiredHome | 21:3c1efb192927 | 955 | } |
WiredHome | 19:3f82c1161fd2 | 956 | } |
WiredHome | 19:3f82c1161fd2 | 957 | REGISTERPERFORMANCE(PRF_DRAWROUNDEDRECTANGLE); |
WiredHome | 19:3f82c1161fd2 | 958 | return ret; |
WiredHome | 19:3f82c1161fd2 | 959 | } |
WiredHome | 19:3f82c1161fd2 | 960 | |
WiredHome | 44:207594dece70 | 961 | |
WiredHome | 37:f19b7e7449dc | 962 | RetCode_t RA8875::triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 963 | loc_t x3, loc_t y3, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 964 | { |
WiredHome | 20:6e2e4a8372eb | 965 | RetCode_t ret; |
WiredHome | 20:6e2e4a8372eb | 966 | |
WiredHome | 19:3f82c1161fd2 | 967 | foreground(color); |
WiredHome | 20:6e2e4a8372eb | 968 | ret = triangle(x1,y1,x2,y2,x3,y3,fillit); |
WiredHome | 20:6e2e4a8372eb | 969 | return ret; |
WiredHome | 19:3f82c1161fd2 | 970 | } |
WiredHome | 19:3f82c1161fd2 | 971 | |
WiredHome | 44:207594dece70 | 972 | |
WiredHome | 37:f19b7e7449dc | 973 | RetCode_t RA8875::filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 974 | loc_t x3, loc_t y3, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 975 | { |
WiredHome | 20:6e2e4a8372eb | 976 | RetCode_t ret; |
WiredHome | 20:6e2e4a8372eb | 977 | |
WiredHome | 19:3f82c1161fd2 | 978 | foreground(color); |
WiredHome | 20:6e2e4a8372eb | 979 | ret = triangle(x1,y1,x2,y2,x3,y3,fillit); |
WiredHome | 20:6e2e4a8372eb | 980 | return ret; |
WiredHome | 19:3f82c1161fd2 | 981 | } |
WiredHome | 19:3f82c1161fd2 | 982 | |
WiredHome | 44:207594dece70 | 983 | |
WiredHome | 37:f19b7e7449dc | 984 | RetCode_t RA8875::triangle(loc_t x1, loc_t y1 ,loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 985 | loc_t x3, loc_t y3, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 986 | { |
WiredHome | 19:3f82c1161fd2 | 987 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 988 | |
WiredHome | 19:3f82c1161fd2 | 989 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 990 | if (x1 == x2 && y1 == y2 && x1 == x3 && y1 == y3) { |
WiredHome | 19:3f82c1161fd2 | 991 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 992 | } else { |
WiredHome | 38:38d503b4fad6 | 993 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 994 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 995 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 996 | WriteCommandW(0x97, y2); |
WiredHome | 38:38d503b4fad6 | 997 | WriteCommandW(0xA9, x3); |
WiredHome | 38:38d503b4fad6 | 998 | WriteCommandW(0xAB, y3); |
WiredHome | 19:3f82c1161fd2 | 999 | unsigned char drawCmd = 0x01; // Triangle |
WiredHome | 19:3f82c1161fd2 | 1000 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1001 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 1002 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1003 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 1004 | while (ReadCommand(0x90) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 1005 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 1006 | } |
WiredHome | 19:3f82c1161fd2 | 1007 | REGISTERPERFORMANCE(PRF_DRAWTRIANGLE); |
WiredHome | 19:3f82c1161fd2 | 1008 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1009 | } |
WiredHome | 19:3f82c1161fd2 | 1010 | |
WiredHome | 37:f19b7e7449dc | 1011 | RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, |
WiredHome | 19:3f82c1161fd2 | 1012 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1013 | { |
WiredHome | 19:3f82c1161fd2 | 1014 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1015 | return circle(x,y,radius,fillit); |
WiredHome | 19:3f82c1161fd2 | 1016 | } |
WiredHome | 19:3f82c1161fd2 | 1017 | |
WiredHome | 44:207594dece70 | 1018 | |
WiredHome | 37:f19b7e7449dc | 1019 | RetCode_t RA8875::fillcircle(loc_t x, loc_t y, dim_t radius, |
WiredHome | 19:3f82c1161fd2 | 1020 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1021 | { |
WiredHome | 19:3f82c1161fd2 | 1022 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1023 | return circle(x,y,radius,fillit); |
WiredHome | 19:3f82c1161fd2 | 1024 | } |
WiredHome | 19:3f82c1161fd2 | 1025 | |
WiredHome | 44:207594dece70 | 1026 | |
WiredHome | 37:f19b7e7449dc | 1027 | RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1028 | { |
WiredHome | 19:3f82c1161fd2 | 1029 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 1030 | |
WiredHome | 19:3f82c1161fd2 | 1031 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 1032 | if (radius <= 0) { |
WiredHome | 19:3f82c1161fd2 | 1033 | ret = bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 1034 | } else if (radius == 1) { |
WiredHome | 19:3f82c1161fd2 | 1035 | pixel(x,y); |
WiredHome | 19:3f82c1161fd2 | 1036 | } else { |
WiredHome | 38:38d503b4fad6 | 1037 | WriteCommandW(0x99, x); |
WiredHome | 38:38d503b4fad6 | 1038 | WriteCommandW(0x9B, y); |
WiredHome | 19:3f82c1161fd2 | 1039 | WriteCommand(0x9d, radius & 0xFF); |
WiredHome | 19:3f82c1161fd2 | 1040 | unsigned char drawCmd = 0x00; // Circle |
WiredHome | 19:3f82c1161fd2 | 1041 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1042 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 1043 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1044 | WriteCommand(0x90, 0x40 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 1045 | while (ReadCommand(0x90) & 0x40) // await completion. |
WiredHome | 19:3f82c1161fd2 | 1046 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 1047 | } |
WiredHome | 19:3f82c1161fd2 | 1048 | REGISTERPERFORMANCE(PRF_DRAWCIRCLE); |
WiredHome | 19:3f82c1161fd2 | 1049 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1050 | } |
WiredHome | 19:3f82c1161fd2 | 1051 | |
WiredHome | 44:207594dece70 | 1052 | |
WiredHome | 37:f19b7e7449dc | 1053 | 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 | 1054 | { |
WiredHome | 19:3f82c1161fd2 | 1055 | foreground(color); |
WiredHome | 25:9556a3a9b7cc | 1056 | return ellipse(x,y,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 1057 | } |
WiredHome | 19:3f82c1161fd2 | 1058 | |
WiredHome | 44:207594dece70 | 1059 | |
WiredHome | 37:f19b7e7449dc | 1060 | 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 | 1061 | { |
WiredHome | 25:9556a3a9b7cc | 1062 | foreground(color); |
WiredHome | 25:9556a3a9b7cc | 1063 | return ellipse(x,y,radius1,radius2,fillit); |
WiredHome | 25:9556a3a9b7cc | 1064 | } |
WiredHome | 44:207594dece70 | 1065 | |
WiredHome | 25:9556a3a9b7cc | 1066 | |
WiredHome | 37:f19b7e7449dc | 1067 | RetCode_t RA8875::ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 1068 | { |
WiredHome | 19:3f82c1161fd2 | 1069 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 1070 | |
WiredHome | 19:3f82c1161fd2 | 1071 | PERFORMANCE_RESET; |
WiredHome | 25:9556a3a9b7cc | 1072 | if (radius1 <= 0 || radius2 <= 0) { |
WiredHome | 19:3f82c1161fd2 | 1073 | ; // do nothing |
WiredHome | 25:9556a3a9b7cc | 1074 | } else if (radius1 == 1 && radius2 == 1) { |
WiredHome | 19:3f82c1161fd2 | 1075 | pixel(x, y); |
WiredHome | 19:3f82c1161fd2 | 1076 | } else { |
WiredHome | 38:38d503b4fad6 | 1077 | WriteCommandW(0xA5, x); |
WiredHome | 38:38d503b4fad6 | 1078 | WriteCommandW(0xA7, y); |
WiredHome | 38:38d503b4fad6 | 1079 | WriteCommandW(0xA1, radius1); |
WiredHome | 38:38d503b4fad6 | 1080 | WriteCommandW(0xA3, radius2); |
WiredHome | 19:3f82c1161fd2 | 1081 | unsigned char drawCmd = 0x00; // Ellipse |
WiredHome | 19:3f82c1161fd2 | 1082 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 1083 | drawCmd |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 1084 | WriteCommand(0xA0, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 1085 | WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 1086 | while (ReadCommand(0xA0) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 1087 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 1088 | } |
WiredHome | 19:3f82c1161fd2 | 1089 | REGISTERPERFORMANCE(PRF_DRAWELLIPSE); |
WiredHome | 19:3f82c1161fd2 | 1090 | return ret; |
WiredHome | 19:3f82c1161fd2 | 1091 | } |
WiredHome | 19:3f82c1161fd2 | 1092 | |
WiredHome | 44:207594dece70 | 1093 | |
WiredHome | 19:3f82c1161fd2 | 1094 | RetCode_t RA8875::frequency(unsigned long Hz) |
WiredHome | 19:3f82c1161fd2 | 1095 | { |
WiredHome | 19:3f82c1161fd2 | 1096 | spi.frequency(Hz); |
WiredHome | 19:3f82c1161fd2 | 1097 | // __ ___ |
WiredHome | 19:3f82c1161fd2 | 1098 | // Clock ___A Rising edge latched |
WiredHome | 19:3f82c1161fd2 | 1099 | // ___ ____ |
WiredHome | 19:3f82c1161fd2 | 1100 | // Data ___X____ |
WiredHome | 19:3f82c1161fd2 | 1101 | spi.format(8, 3); // 8 bits and clock to data phase 0 |
WiredHome | 19:3f82c1161fd2 | 1102 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1103 | } |
WiredHome | 19:3f82c1161fd2 | 1104 | |
WiredHome | 44:207594dece70 | 1105 | |
WiredHome | 19:3f82c1161fd2 | 1106 | RetCode_t RA8875::Power(bool on) |
WiredHome | 19:3f82c1161fd2 | 1107 | { |
WiredHome | 19:3f82c1161fd2 | 1108 | WriteCommand(0x01, (on) ? 0x80 : 0x00); |
WiredHome | 19:3f82c1161fd2 | 1109 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1110 | } |
WiredHome | 19:3f82c1161fd2 | 1111 | |
WiredHome | 44:207594dece70 | 1112 | |
WiredHome | 19:3f82c1161fd2 | 1113 | RetCode_t RA8875::Reset(void) |
WiredHome | 19:3f82c1161fd2 | 1114 | { |
WiredHome | 19:3f82c1161fd2 | 1115 | WriteCommand(0x01, 0x01); // Apply Display Off, Reset |
WiredHome | 19:3f82c1161fd2 | 1116 | wait_ms(2); // no idea if I need to wait, or how long |
WiredHome | 19:3f82c1161fd2 | 1117 | WriteCommand(0x01, 0x00); // Display off, Remove reset |
WiredHome | 19:3f82c1161fd2 | 1118 | wait_ms(2); // no idea if I need to wait, or how long |
WiredHome | 43:3becae133285 | 1119 | init(RA8875_DISPLAY_WIDTH, RA8875_DISPLAY_HEIGHT, RA8875_COLORDEPTH_BPP); |
WiredHome | 19:3f82c1161fd2 | 1120 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1121 | } |
WiredHome | 19:3f82c1161fd2 | 1122 | |
WiredHome | 19:3f82c1161fd2 | 1123 | |
WiredHome | 19:3f82c1161fd2 | 1124 | RetCode_t RA8875::Backlight_u8(unsigned char brightness) |
WiredHome | 19:3f82c1161fd2 | 1125 | { |
WiredHome | 19:3f82c1161fd2 | 1126 | static bool is_enabled = false; |
WiredHome | 19:3f82c1161fd2 | 1127 | if (brightness == 0) { |
WiredHome | 19:3f82c1161fd2 | 1128 | WriteCommand(0x8a); // Disable the PWM |
WiredHome | 19:3f82c1161fd2 | 1129 | WriteData(0x00); |
WiredHome | 19:3f82c1161fd2 | 1130 | is_enabled = false; |
WiredHome | 19:3f82c1161fd2 | 1131 | } else if (!is_enabled) { |
WiredHome | 19:3f82c1161fd2 | 1132 | WriteCommand(0x8a); // Enable the PWM |
WiredHome | 19:3f82c1161fd2 | 1133 | WriteData(0x80); |
WiredHome | 19:3f82c1161fd2 | 1134 | WriteCommand(0x8a); // Not sure why this is needed, but following the pattern |
WiredHome | 19:3f82c1161fd2 | 1135 | WriteData(0x81); // open PWM (SYS_CLK / 2 as best I can tell) |
WiredHome | 19:3f82c1161fd2 | 1136 | is_enabled = true; |
WiredHome | 19:3f82c1161fd2 | 1137 | } |
WiredHome | 19:3f82c1161fd2 | 1138 | WriteCommand(0x8b, brightness); // Brightness parameter 0xff-0x00 |
WiredHome | 19:3f82c1161fd2 | 1139 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1140 | } |
WiredHome | 19:3f82c1161fd2 | 1141 | |
WiredHome | 44:207594dece70 | 1142 | |
WiredHome | 19:3f82c1161fd2 | 1143 | RetCode_t RA8875::Backlight(float brightness) |
WiredHome | 19:3f82c1161fd2 | 1144 | { |
WiredHome | 19:3f82c1161fd2 | 1145 | unsigned char b; |
WiredHome | 19:3f82c1161fd2 | 1146 | |
WiredHome | 29:422616aa04bd | 1147 | if (brightness >= 1.0) |
WiredHome | 19:3f82c1161fd2 | 1148 | b = 255; |
WiredHome | 29:422616aa04bd | 1149 | else if (brightness <= 0.0) |
WiredHome | 19:3f82c1161fd2 | 1150 | b = 0; |
WiredHome | 19:3f82c1161fd2 | 1151 | else |
WiredHome | 19:3f82c1161fd2 | 1152 | b = (unsigned char)(brightness * 255); |
WiredHome | 19:3f82c1161fd2 | 1153 | return Backlight_u8(b); |
WiredHome | 19:3f82c1161fd2 | 1154 | } |
WiredHome | 19:3f82c1161fd2 | 1155 | |
WiredHome | 44:207594dece70 | 1156 | |
WiredHome | 19:3f82c1161fd2 | 1157 | RetCode_t RA8875::set_font(const unsigned char * _font) |
WiredHome | 19:3f82c1161fd2 | 1158 | { |
WiredHome | 37:f19b7e7449dc | 1159 | if (font && ! _font) { |
WiredHome | 37:f19b7e7449dc | 1160 | SetTextCursor(cursor_x, cursor_y); // soft-font cursor -> hw cursor |
WiredHome | 37:f19b7e7449dc | 1161 | } |
WiredHome | 19:3f82c1161fd2 | 1162 | font = _font; |
WiredHome | 29:422616aa04bd | 1163 | GraphicsDisplay::set_font(_font); |
WiredHome | 29:422616aa04bd | 1164 | return noerror; // trusting them, but it might be good to put some checks in here... |
WiredHome | 19:3f82c1161fd2 | 1165 | } |
WiredHome | 19:3f82c1161fd2 | 1166 | |
WiredHome | 44:207594dece70 | 1167 | |
WiredHome | 19:3f82c1161fd2 | 1168 | RetCode_t RA8875::background(color_t color) |
WiredHome | 19:3f82c1161fd2 | 1169 | { |
WiredHome | 37:f19b7e7449dc | 1170 | GraphicsDisplay::background(color); |
WiredHome | 19:3f82c1161fd2 | 1171 | WriteCommand(0x60, (color>>11)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 1172 | WriteCommand(0x61, (unsigned char)(color>>5)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 1173 | WriteCommand(0x62, (unsigned char)(color)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 1174 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1175 | } |
WiredHome | 19:3f82c1161fd2 | 1176 | |
WiredHome | 44:207594dece70 | 1177 | |
WiredHome | 19:3f82c1161fd2 | 1178 | RetCode_t RA8875::background(unsigned char r, unsigned char g, unsigned char b) |
WiredHome | 19:3f82c1161fd2 | 1179 | { |
WiredHome | 37:f19b7e7449dc | 1180 | background(RGB(r,g,b)); |
WiredHome | 37:f19b7e7449dc | 1181 | // WriteCommand(0x60, r); |
WiredHome | 37:f19b7e7449dc | 1182 | // WriteCommand(0x61, g); |
WiredHome | 37:f19b7e7449dc | 1183 | // WriteCommand(0x62, b); |
WiredHome | 19:3f82c1161fd2 | 1184 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1185 | } |
WiredHome | 19:3f82c1161fd2 | 1186 | |
WiredHome | 44:207594dece70 | 1187 | |
WiredHome | 19:3f82c1161fd2 | 1188 | RetCode_t RA8875::foreground(color_t color) |
WiredHome | 19:3f82c1161fd2 | 1189 | { |
WiredHome | 37:f19b7e7449dc | 1190 | GraphicsDisplay::foreground(color); |
WiredHome | 19:3f82c1161fd2 | 1191 | WriteCommand(0x63, (unsigned char)(color>>11)); |
WiredHome | 19:3f82c1161fd2 | 1192 | WriteCommand(0x64, (unsigned char)(color>>5)); |
WiredHome | 19:3f82c1161fd2 | 1193 | WriteCommand(0x65, (unsigned char)(color)); |
WiredHome | 19:3f82c1161fd2 | 1194 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1195 | } |
WiredHome | 19:3f82c1161fd2 | 1196 | |
WiredHome | 44:207594dece70 | 1197 | |
WiredHome | 37:f19b7e7449dc | 1198 | RetCode_t RA8875::foreground(unsigned char r, unsigned char g, unsigned char b) |
WiredHome | 19:3f82c1161fd2 | 1199 | { |
WiredHome | 37:f19b7e7449dc | 1200 | foreground(RGB(r,g,b)); |
WiredHome | 37:f19b7e7449dc | 1201 | // WriteCommand(0x63, r); |
WiredHome | 37:f19b7e7449dc | 1202 | // WriteCommand(0x64, g); |
WiredHome | 37:f19b7e7449dc | 1203 | // WriteCommand(0x65, b); |
WiredHome | 19:3f82c1161fd2 | 1204 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1205 | } |
WiredHome | 19:3f82c1161fd2 | 1206 | |
WiredHome | 44:207594dece70 | 1207 | |
WiredHome | 37:f19b7e7449dc | 1208 | color_t RA8875::GetForeColor(void) |
WiredHome | 19:3f82c1161fd2 | 1209 | { |
WiredHome | 19:3f82c1161fd2 | 1210 | color_t color; |
WiredHome | 19:3f82c1161fd2 | 1211 | |
WiredHome | 19:3f82c1161fd2 | 1212 | color = (ReadCommand(0x63) & 0x1F) << 11; |
WiredHome | 19:3f82c1161fd2 | 1213 | color |= (ReadCommand(0x64) & 0x3F) << 5; |
WiredHome | 19:3f82c1161fd2 | 1214 | color |= (ReadCommand(0x65) & 0x1F); |
WiredHome | 19:3f82c1161fd2 | 1215 | return color; |
WiredHome | 19:3f82c1161fd2 | 1216 | } |
WiredHome | 19:3f82c1161fd2 | 1217 | |
WiredHome | 44:207594dece70 | 1218 | |
WiredHome | 19:3f82c1161fd2 | 1219 | color_t RA8875::DOSColor(int i) |
WiredHome | 19:3f82c1161fd2 | 1220 | { |
WiredHome | 19:3f82c1161fd2 | 1221 | const color_t colors[16] = |
WiredHome | 19:3f82c1161fd2 | 1222 | { |
WiredHome | 19:3f82c1161fd2 | 1223 | Black, Blue, Green, Cyan, |
WiredHome | 19:3f82c1161fd2 | 1224 | Red, Magenta, Brown, Gray, |
WiredHome | 19:3f82c1161fd2 | 1225 | Charcoal, BrightBlue, BrightGreen, BrightCyan, |
WiredHome | 19:3f82c1161fd2 | 1226 | Orange, Pink, Yellow, White |
WiredHome | 19:3f82c1161fd2 | 1227 | }; |
WiredHome | 19:3f82c1161fd2 | 1228 | if (i < 16) |
WiredHome | 19:3f82c1161fd2 | 1229 | return colors[i]; |
WiredHome | 19:3f82c1161fd2 | 1230 | else |
WiredHome | 19:3f82c1161fd2 | 1231 | return 0; |
WiredHome | 19:3f82c1161fd2 | 1232 | } |
WiredHome | 19:3f82c1161fd2 | 1233 | |
WiredHome | 44:207594dece70 | 1234 | |
WiredHome | 19:3f82c1161fd2 | 1235 | const char * RA8875::DOSColorNames(int i) |
WiredHome | 19:3f82c1161fd2 | 1236 | { |
WiredHome | 19:3f82c1161fd2 | 1237 | const char * names[16] = |
WiredHome | 19:3f82c1161fd2 | 1238 | { |
WiredHome | 19:3f82c1161fd2 | 1239 | "Black", "Blue", "Green", "Cyan", |
WiredHome | 19:3f82c1161fd2 | 1240 | "Red", "Magenta", "Brown", "Gray", |
WiredHome | 19:3f82c1161fd2 | 1241 | "Charcoal", "BrightBlue", "BrightGreen", "BrightCyan", |
WiredHome | 19:3f82c1161fd2 | 1242 | "Orange", "Pink", "Yellow", "White" |
WiredHome | 19:3f82c1161fd2 | 1243 | }; |
WiredHome | 19:3f82c1161fd2 | 1244 | if (i < 16) |
WiredHome | 19:3f82c1161fd2 | 1245 | return names[i]; |
WiredHome | 19:3f82c1161fd2 | 1246 | else |
WiredHome | 19:3f82c1161fd2 | 1247 | return NULL; |
WiredHome | 19:3f82c1161fd2 | 1248 | } |
WiredHome | 19:3f82c1161fd2 | 1249 | |
WiredHome | 19:3f82c1161fd2 | 1250 | |
WiredHome | 19:3f82c1161fd2 | 1251 | /////////////////////////////////////////////////////////////// |
WiredHome | 19:3f82c1161fd2 | 1252 | // Private functions |
WiredHome | 19:3f82c1161fd2 | 1253 | |
WiredHome | 19:3f82c1161fd2 | 1254 | unsigned char RA8875::spiwrite(unsigned char data) |
WiredHome | 19:3f82c1161fd2 | 1255 | { |
WiredHome | 19:3f82c1161fd2 | 1256 | unsigned char retval; |
WiredHome | 19:3f82c1161fd2 | 1257 | |
WiredHome | 19:3f82c1161fd2 | 1258 | retval = spi.write(data); |
WiredHome | 19:3f82c1161fd2 | 1259 | return retval; |
WiredHome | 19:3f82c1161fd2 | 1260 | } |
WiredHome | 19:3f82c1161fd2 | 1261 | |
WiredHome | 44:207594dece70 | 1262 | |
WiredHome | 19:3f82c1161fd2 | 1263 | unsigned char RA8875::spiread(void) |
WiredHome | 19:3f82c1161fd2 | 1264 | { |
WiredHome | 19:3f82c1161fd2 | 1265 | unsigned char retval; |
WiredHome | 19:3f82c1161fd2 | 1266 | unsigned char data = 0; |
WiredHome | 19:3f82c1161fd2 | 1267 | |
WiredHome | 19:3f82c1161fd2 | 1268 | retval = spi.write(data); |
WiredHome | 19:3f82c1161fd2 | 1269 | return retval; |
WiredHome | 19:3f82c1161fd2 | 1270 | } |
WiredHome | 19:3f82c1161fd2 | 1271 | |
WiredHome | 44:207594dece70 | 1272 | |
WiredHome | 19:3f82c1161fd2 | 1273 | RetCode_t RA8875::select(bool chipsel) |
WiredHome | 19:3f82c1161fd2 | 1274 | { |
WiredHome | 19:3f82c1161fd2 | 1275 | cs = (chipsel == true) ? 0 : 1; |
WiredHome | 19:3f82c1161fd2 | 1276 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1277 | } |
WiredHome | 19:3f82c1161fd2 | 1278 | |
WiredHome | 44:207594dece70 | 1279 | |
WiredHome | 43:3becae133285 | 1280 | RetCode_t RA8875::init(int width, int height, int color_bpp) |
WiredHome | 19:3f82c1161fd2 | 1281 | { |
WiredHome | 19:3f82c1161fd2 | 1282 | Backlight_u8(0); |
WiredHome | 37:f19b7e7449dc | 1283 | WriteCommand(0x88, 0x0a); // PLLC1 - Phase Lock Loop registers |
WiredHome | 19:3f82c1161fd2 | 1284 | wait_ms(1); |
WiredHome | 19:3f82c1161fd2 | 1285 | WriteCommand(0x89, 0x02); |
WiredHome | 19:3f82c1161fd2 | 1286 | wait_ms(1); |
WiredHome | 19:3f82c1161fd2 | 1287 | |
WiredHome | 23:a50ded45dbaf | 1288 | // System Config Register (SYSR) |
WiredHome | 43:3becae133285 | 1289 | if (color_bpp == 16) { |
WiredHome | 43:3becae133285 | 1290 | WriteCommand(0x10, 0x0C); // 16-bpp (65K colors) color depth, 8-bit interface |
WiredHome | 43:3becae133285 | 1291 | } else { // color_bpp == 8 |
WiredHome | 43:3becae133285 | 1292 | WriteCommand(0x10, 0x00); // 8-bpp (256 colors) |
WiredHome | 43:3becae133285 | 1293 | } |
WiredHome | 23:a50ded45dbaf | 1294 | // Pixel Clock Setting Register (PCSR) |
WiredHome | 37:f19b7e7449dc | 1295 | WriteCommand(0x04, 0x82); // PDAT on PCLK falling edge, PCLK = 4 x System Clock |
WiredHome | 19:3f82c1161fd2 | 1296 | wait_ms(1); |
WiredHome | 19:3f82c1161fd2 | 1297 | |
WiredHome | 19:3f82c1161fd2 | 1298 | // Horizontal Settings |
WiredHome | 43:3becae133285 | 1299 | WriteCommand(0x14, width/8 - 1); //HDWR//Horizontal Display Width Setting Bit[6:0] |
WiredHome | 43:3becae133285 | 1300 | WriteCommand(0x15, 0x02); //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0] |
WiredHome | 43:3becae133285 | 1301 | WriteCommand(0x16, 0x03); //HNDR//Horizontal Non-Display Period Bit[4:0] |
WiredHome | 43:3becae133285 | 1302 | WriteCommand(0x17, 0x01); //HSTR//HSYNC Start Position[4:0] |
WiredHome | 43:3becae133285 | 1303 | WriteCommand(0x18, 0x03); //HPWR//HSYNC Polarity ,The period width of HSYNC. |
WiredHome | 19:3f82c1161fd2 | 1304 | |
WiredHome | 19:3f82c1161fd2 | 1305 | // Vertical Settings |
WiredHome | 43:3becae133285 | 1306 | WriteCommand(0x19, (height-1)&0xFF); //VDHR0 //Vertical Display Height Bit [7:0] |
WiredHome | 43:3becae133285 | 1307 | WriteCommand(0x1a, (height-1)>>8); //VDHR1 //Vertical Display Height Bit [8] |
WiredHome | 43:3becae133285 | 1308 | WriteCommand(0x1b, 0x0F); //VNDR0 //Vertical Non-Display Period Bit [7:0] |
WiredHome | 43:3becae133285 | 1309 | WriteCommand(0x1c, 0x00); //VNDR1 //Vertical Non-Display Period Bit [8] |
WiredHome | 43:3becae133285 | 1310 | WriteCommand(0x1d, 0x0e); //VSTR0 //VSYNC Start Position[7:0] |
WiredHome | 43:3becae133285 | 1311 | WriteCommand(0x1e, 0x06); //VSTR1 //VSYNC Start Position[8] |
WiredHome | 43:3becae133285 | 1312 | WriteCommand(0x1f, 0x01); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0] |
WiredHome | 19:3f82c1161fd2 | 1313 | |
WiredHome | 43:3becae133285 | 1314 | if (width >= 800 && height >= 480 && color_bpp > 8) { |
WiredHome | 43:3becae133285 | 1315 | WriteCommand(0x20, 0x00); // DPCR - 1-layer mode when the resolution is too high |
WiredHome | 43:3becae133285 | 1316 | } else { |
WiredHome | 43:3becae133285 | 1317 | WriteCommand(0x20, 0x80); // DPCR - 2-layer mode |
WiredHome | 43:3becae133285 | 1318 | } |
WiredHome | 43:3becae133285 | 1319 | |
WiredHome | 50:2c4f474a2453 | 1320 | // Set display image to Blue on Black as default |
WiredHome | 43:3becae133285 | 1321 | window(0,0, width, height); // Initialize to full screen |
WiredHome | 24:8ca861acf12d | 1322 | SetTextCursorControl(); |
WiredHome | 28:ed102fc442c4 | 1323 | foreground(Blue); |
WiredHome | 19:3f82c1161fd2 | 1324 | background(Black); |
WiredHome | 50:2c4f474a2453 | 1325 | SelectDrawingLayer(1); |
WiredHome | 50:2c4f474a2453 | 1326 | cls(); |
WiredHome | 50:2c4f474a2453 | 1327 | SelectDrawingLayer(0); |
WiredHome | 19:3f82c1161fd2 | 1328 | cls(); |
WiredHome | 19:3f82c1161fd2 | 1329 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 1330 | } |
WiredHome | 19:3f82c1161fd2 | 1331 | |
WiredHome | 23:a50ded45dbaf | 1332 | #ifdef TESTENABLE |
WiredHome | 23:a50ded45dbaf | 1333 | |
WiredHome | 37:f19b7e7449dc | 1334 | #include "Arial12x12.h" |
WiredHome | 37:f19b7e7449dc | 1335 | #include "Small_6.h" |
WiredHome | 37:f19b7e7449dc | 1336 | |
WiredHome | 23:a50ded45dbaf | 1337 | // ______________ ______________ ______________ _______________ |
WiredHome | 23:a50ded45dbaf | 1338 | // /_____ _____/ / ___________/ / ___________/ /_____ ______/ |
WiredHome | 23:a50ded45dbaf | 1339 | // / / / / / / / / |
WiredHome | 23:a50ded45dbaf | 1340 | // / / / /___ / /__________ / / |
WiredHome | 23:a50ded45dbaf | 1341 | // / / / ____/ /__________ / / / |
WiredHome | 23:a50ded45dbaf | 1342 | // / / / / / / / / |
WiredHome | 23:a50ded45dbaf | 1343 | // / / / /__________ ___________/ / / / |
WiredHome | 23:a50ded45dbaf | 1344 | // /__/ /_____________/ /_____________/ /__/ |
WiredHome | 23:a50ded45dbaf | 1345 | // |
WiredHome | 23:a50ded45dbaf | 1346 | // Everything from here down is test code. |
WiredHome | 41:2956a0a221e5 | 1347 | bool SuppressSlowStuff = false; |
WiredHome | 23:a50ded45dbaf | 1348 | |
WiredHome | 44:207594dece70 | 1349 | |
WiredHome | 49:c5182231d1b9 | 1350 | void TextWrapTest(RA8875 & display, Serial & pc) |
WiredHome | 49:c5182231d1b9 | 1351 | { |
WiredHome | 49:c5182231d1b9 | 1352 | if (!SuppressSlowStuff) |
WiredHome | 49:c5182231d1b9 | 1353 | pc.printf("Text Wrap Test\r\n"); |
WiredHome | 49:c5182231d1b9 | 1354 | display.background(Black); |
WiredHome | 49:c5182231d1b9 | 1355 | display.foreground(Blue); |
WiredHome | 49:c5182231d1b9 | 1356 | display.cls(); |
WiredHome | 49:c5182231d1b9 | 1357 | display.Backlight_u8(255); |
WiredHome | 49:c5182231d1b9 | 1358 | display.puts(0,0, "Text Wrap Test.\r\n"); |
WiredHome | 52:e6039a823420 | 1359 | for (int i=1; i<60; i++) { |
WiredHome | 52:e6039a823420 | 1360 | display.printf("L%2d\n", i % 17); |
WiredHome | 49:c5182231d1b9 | 1361 | if (!SuppressSlowStuff) |
WiredHome | 52:e6039a823420 | 1362 | wait_ms(100); |
WiredHome | 49:c5182231d1b9 | 1363 | } |
WiredHome | 49:c5182231d1b9 | 1364 | if (!SuppressSlowStuff) |
WiredHome | 49:c5182231d1b9 | 1365 | wait_ms(3000); |
WiredHome | 49:c5182231d1b9 | 1366 | } |
WiredHome | 49:c5182231d1b9 | 1367 | |
WiredHome | 23:a50ded45dbaf | 1368 | void TextCursorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1369 | { |
WiredHome | 37:f19b7e7449dc | 1370 | const char * iCursor = "The I-Beam cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 1371 | const char * uCursor = "The Underscore cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 1372 | const char * bCursor = "The Block cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 1373 | const char * bbCursor = "The Blinking Block cursor should be visible for this text.\r\n"; |
WiredHome | 23:a50ded45dbaf | 1374 | const char * p; |
WiredHome | 41:2956a0a221e5 | 1375 | int delay = 100; |
WiredHome | 23:a50ded45dbaf | 1376 | |
WiredHome | 41:2956a0a221e5 | 1377 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1378 | pc.printf("Text Cursor Test\r\n"); |
WiredHome | 41:2956a0a221e5 | 1379 | else |
WiredHome | 41:2956a0a221e5 | 1380 | delay = 0; |
WiredHome | 23:a50ded45dbaf | 1381 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1382 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1383 | display.cls(); |
WiredHome | 25:9556a3a9b7cc | 1384 | display.Backlight_u8(255); |
WiredHome | 23:a50ded45dbaf | 1385 | display.puts(0,0, "Text Cursor Test."); |
WiredHome | 23:a50ded45dbaf | 1386 | |
WiredHome | 23:a50ded45dbaf | 1387 | // visible, non-blinking |
WiredHome | 24:8ca861acf12d | 1388 | display.SetTextCursor(0,20); |
WiredHome | 53:86d24b9480b9 | 1389 | display.SetTextCursorControl(RA8875::IBEAM, false); |
WiredHome | 24:8ca861acf12d | 1390 | p = iCursor; |
WiredHome | 23:a50ded45dbaf | 1391 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1392 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1393 | wait_ms(delay); |
WiredHome | 24:8ca861acf12d | 1394 | } |
WiredHome | 24:8ca861acf12d | 1395 | |
WiredHome | 53:86d24b9480b9 | 1396 | display.SetTextCursorControl(RA8875::UNDER, false); |
WiredHome | 24:8ca861acf12d | 1397 | p = uCursor; |
WiredHome | 24:8ca861acf12d | 1398 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1399 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1400 | wait_ms(delay); |
WiredHome | 23:a50ded45dbaf | 1401 | } |
WiredHome | 24:8ca861acf12d | 1402 | |
WiredHome | 53:86d24b9480b9 | 1403 | display.SetTextCursorControl(RA8875::BLOCK, false); |
WiredHome | 24:8ca861acf12d | 1404 | p = bCursor; |
WiredHome | 24:8ca861acf12d | 1405 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1406 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1407 | wait_ms(delay); |
WiredHome | 24:8ca861acf12d | 1408 | } |
WiredHome | 24:8ca861acf12d | 1409 | |
WiredHome | 53:86d24b9480b9 | 1410 | display.SetTextCursorControl(RA8875::BLOCK, true); |
WiredHome | 24:8ca861acf12d | 1411 | p = bbCursor; |
WiredHome | 24:8ca861acf12d | 1412 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1413 | display._putc(*p++); |
WiredHome | 41:2956a0a221e5 | 1414 | wait_ms(delay); |
WiredHome | 24:8ca861acf12d | 1415 | } |
WiredHome | 41:2956a0a221e5 | 1416 | wait_ms(delay * 20); |
WiredHome | 53:86d24b9480b9 | 1417 | display.SetTextCursorControl(RA8875::NOCURSOR, false); |
WiredHome | 23:a50ded45dbaf | 1418 | } |
WiredHome | 23:a50ded45dbaf | 1419 | |
WiredHome | 44:207594dece70 | 1420 | |
WiredHome | 23:a50ded45dbaf | 1421 | void BacklightTest(RA8875 & display, Serial & pc, float ramptime) |
WiredHome | 23:a50ded45dbaf | 1422 | { |
WiredHome | 29:422616aa04bd | 1423 | char buf[60]; |
WiredHome | 41:2956a0a221e5 | 1424 | unsigned int w = (ramptime * 1000)/ 256; |
WiredHome | 41:2956a0a221e5 | 1425 | int delay = 200; |
WiredHome | 41:2956a0a221e5 | 1426 | |
WiredHome | 41:2956a0a221e5 | 1427 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1428 | pc.printf("Backlight Test - ramp over %f sec.\r\n", ramptime); |
WiredHome | 41:2956a0a221e5 | 1429 | else { |
WiredHome | 41:2956a0a221e5 | 1430 | delay = 0; |
WiredHome | 41:2956a0a221e5 | 1431 | w = 0; |
WiredHome | 41:2956a0a221e5 | 1432 | } |
WiredHome | 23:a50ded45dbaf | 1433 | display.Backlight_u8(0); |
WiredHome | 29:422616aa04bd | 1434 | display.background(White); |
WiredHome | 23:a50ded45dbaf | 1435 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1436 | display.cls(); |
WiredHome | 41:2956a0a221e5 | 1437 | wait_ms(delay); |
WiredHome | 23:a50ded45dbaf | 1438 | display.puts(0,0, "RA8875 Backlight Test - Ramp up."); |
WiredHome | 38:38d503b4fad6 | 1439 | for (int i=0; i <= 255; i++) { |
WiredHome | 29:422616aa04bd | 1440 | sprintf(buf, "%3d, %4d", i, w); |
WiredHome | 37:f19b7e7449dc | 1441 | display.puts(100,100,buf); |
WiredHome | 23:a50ded45dbaf | 1442 | display.Backlight_u8(i); |
WiredHome | 29:422616aa04bd | 1443 | wait_ms(w); |
WiredHome | 23:a50ded45dbaf | 1444 | } |
WiredHome | 23:a50ded45dbaf | 1445 | } |
WiredHome | 23:a50ded45dbaf | 1446 | |
WiredHome | 44:207594dece70 | 1447 | |
WiredHome | 23:a50ded45dbaf | 1448 | void BacklightTest2(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1449 | { |
WiredHome | 41:2956a0a221e5 | 1450 | int delay = 20; |
WiredHome | 41:2956a0a221e5 | 1451 | |
WiredHome | 41:2956a0a221e5 | 1452 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1453 | pc.printf("Backlight Test 2\r\n"); |
WiredHome | 41:2956a0a221e5 | 1454 | else |
WiredHome | 41:2956a0a221e5 | 1455 | delay = 0; |
WiredHome | 41:2956a0a221e5 | 1456 | |
WiredHome | 23:a50ded45dbaf | 1457 | // Dim it out at the end of the tests. |
WiredHome | 37:f19b7e7449dc | 1458 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1459 | display.puts(0,0, "Ramp Backlight down."); |
WiredHome | 23:a50ded45dbaf | 1460 | // Ramp it off |
WiredHome | 23:a50ded45dbaf | 1461 | for (int i=255; i != 0; i--) { |
WiredHome | 23:a50ded45dbaf | 1462 | display.Backlight_u8(i); |
WiredHome | 41:2956a0a221e5 | 1463 | wait_ms(delay); |
WiredHome | 23:a50ded45dbaf | 1464 | } |
WiredHome | 23:a50ded45dbaf | 1465 | display.Backlight_u8(0); |
WiredHome | 23:a50ded45dbaf | 1466 | } |
WiredHome | 23:a50ded45dbaf | 1467 | |
WiredHome | 44:207594dece70 | 1468 | |
WiredHome | 23:a50ded45dbaf | 1469 | void ExternalFontTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1470 | { |
WiredHome | 41:2956a0a221e5 | 1471 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1472 | pc.printf("External Font Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1473 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1474 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1475 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1476 | display.Backlight(1); |
WiredHome | 37:f19b7e7449dc | 1477 | display.puts(0,0, "External Font Test."); |
WiredHome | 37:f19b7e7449dc | 1478 | |
WiredHome | 37:f19b7e7449dc | 1479 | display.set_font(Small_6); |
WiredHome | 37:f19b7e7449dc | 1480 | display.puts(0,30, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n"); |
WiredHome | 37:f19b7e7449dc | 1481 | |
WiredHome | 23:a50ded45dbaf | 1482 | display.set_font(Arial12x12); |
WiredHome | 37:f19b7e7449dc | 1483 | display.puts("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n"); |
WiredHome | 37:f19b7e7449dc | 1484 | display.set_font(); // restore to internal |
WiredHome | 37:f19b7e7449dc | 1485 | |
WiredHome | 37:f19b7e7449dc | 1486 | display.puts("Normal font again."); |
WiredHome | 37:f19b7e7449dc | 1487 | //display.window(0,0, display.width(), display.height()); |
WiredHome | 23:a50ded45dbaf | 1488 | } |
WiredHome | 23:a50ded45dbaf | 1489 | |
WiredHome | 44:207594dece70 | 1490 | |
WiredHome | 23:a50ded45dbaf | 1491 | void DOSColorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1492 | { |
WiredHome | 41:2956a0a221e5 | 1493 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1494 | pc.printf("DOS Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1495 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1496 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1497 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1498 | display.puts(0,0, "DOS Colors - Fore"); |
WiredHome | 23:a50ded45dbaf | 1499 | display.puts(280,0, "Back"); |
WiredHome | 23:a50ded45dbaf | 1500 | display.background(Gray); |
WiredHome | 23:a50ded45dbaf | 1501 | for (int i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1502 | display.foreground(display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1503 | display.puts(160, i*16, display.DOSColorNames(i)); |
WiredHome | 23:a50ded45dbaf | 1504 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1505 | } |
WiredHome | 23:a50ded45dbaf | 1506 | display.foreground(White); |
WiredHome | 23:a50ded45dbaf | 1507 | for (int i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1508 | display.background(display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1509 | display.puts(360, i*16, display.DOSColorNames(i)); |
WiredHome | 23:a50ded45dbaf | 1510 | display.foreground(White); |
WiredHome | 23:a50ded45dbaf | 1511 | } |
WiredHome | 23:a50ded45dbaf | 1512 | } |
WiredHome | 23:a50ded45dbaf | 1513 | |
WiredHome | 44:207594dece70 | 1514 | |
WiredHome | 23:a50ded45dbaf | 1515 | void WebColorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1516 | { |
WiredHome | 41:2956a0a221e5 | 1517 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1518 | pc.printf("Web Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1519 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1520 | display.foreground(Blue); |
WiredHome | 32:0e4f2ae512e2 | 1521 | display.window(0,0, display.width(), display.height()); |
WiredHome | 23:a50ded45dbaf | 1522 | display.cls(); |
WiredHome | 59:fb40aad4efd4 | 1523 | display.SetTextFontSize(1,1); |
WiredHome | 59:fb40aad4efd4 | 1524 | display.puts(200,0, "Web Color Test"); |
WiredHome | 59:fb40aad4efd4 | 1525 | display.SetTextCursor(0,0); |
WiredHome | 59:fb40aad4efd4 | 1526 | display.puts(" "); |
WiredHome | 59:fb40aad4efd4 | 1527 | for (int i=0; i<16; i++) |
WiredHome | 59:fb40aad4efd4 | 1528 | display.printf("%X", i&0xF); |
WiredHome | 59:fb40aad4efd4 | 1529 | display.puts("\r\n0 "); |
WiredHome | 23:a50ded45dbaf | 1530 | for (int i=0; i<sizeof(WebColors)/sizeof(WebColors[0]); i++) { |
WiredHome | 23:a50ded45dbaf | 1531 | display.background(WebColors[i]); |
WiredHome | 23:a50ded45dbaf | 1532 | display.puts(" "); |
WiredHome | 59:fb40aad4efd4 | 1533 | if (i % 16 == 15 && i < 255) { |
WiredHome | 59:fb40aad4efd4 | 1534 | display.printf("\r\n%X ", ((i+1)/16)); |
WiredHome | 59:fb40aad4efd4 | 1535 | } |
WiredHome | 23:a50ded45dbaf | 1536 | } |
WiredHome | 23:a50ded45dbaf | 1537 | display.SetTextFontSize(1,1); |
WiredHome | 23:a50ded45dbaf | 1538 | } |
WiredHome | 23:a50ded45dbaf | 1539 | |
WiredHome | 44:207594dece70 | 1540 | |
WiredHome | 37:f19b7e7449dc | 1541 | void PixelTest(RA8875 & display, Serial & pc) |
WiredHome | 37:f19b7e7449dc | 1542 | { |
WiredHome | 37:f19b7e7449dc | 1543 | int i, c, x, y; |
WiredHome | 37:f19b7e7449dc | 1544 | |
WiredHome | 41:2956a0a221e5 | 1545 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1546 | pc.printf("Pixel Test\r\n"); |
WiredHome | 37:f19b7e7449dc | 1547 | display.background(Black); |
WiredHome | 37:f19b7e7449dc | 1548 | display.foreground(Blue); |
WiredHome | 37:f19b7e7449dc | 1549 | display.cls(); |
WiredHome | 37:f19b7e7449dc | 1550 | display.puts(0,0, "Pixel Test"); |
WiredHome | 37:f19b7e7449dc | 1551 | for (i=0; i<1000; i++) { |
WiredHome | 37:f19b7e7449dc | 1552 | x = rand() % 480; |
WiredHome | 37:f19b7e7449dc | 1553 | y = 16 + rand() % (272-16); |
WiredHome | 37:f19b7e7449dc | 1554 | c = rand() % 16; |
WiredHome | 37:f19b7e7449dc | 1555 | //pc.printf(" (%d,%d) - %d\r\n", x,y,r1); |
WiredHome | 37:f19b7e7449dc | 1556 | display.pixel(x,y, display.DOSColor(c)); |
WiredHome | 37:f19b7e7449dc | 1557 | } |
WiredHome | 37:f19b7e7449dc | 1558 | } |
WiredHome | 37:f19b7e7449dc | 1559 | |
WiredHome | 44:207594dece70 | 1560 | |
WiredHome | 23:a50ded45dbaf | 1561 | void LineTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1562 | { |
WiredHome | 23:a50ded45dbaf | 1563 | int i, x, y, x2, y2; |
WiredHome | 23:a50ded45dbaf | 1564 | |
WiredHome | 41:2956a0a221e5 | 1565 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1566 | pc.printf("Line Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1567 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1568 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1569 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1570 | display.puts(0,0, "Line Test"); |
WiredHome | 23:a50ded45dbaf | 1571 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1572 | // Lines |
WiredHome | 23:a50ded45dbaf | 1573 | x = rand() % 480; |
WiredHome | 23:a50ded45dbaf | 1574 | y = rand() % 272; |
WiredHome | 23:a50ded45dbaf | 1575 | x2 = rand() % 480; |
WiredHome | 23:a50ded45dbaf | 1576 | y2 = rand() % 272; |
WiredHome | 23:a50ded45dbaf | 1577 | display.line(x,y, x2,y2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1578 | } |
WiredHome | 62:ba5d33438fda | 1579 | display.foreground(BrightRed); |
WiredHome | 62:ba5d33438fda | 1580 | pc.printf("fg %08X %08X %08X\r\n", RGB(255,0,0), BrightRed, display.GetForeColor()); |
WiredHome | 62:ba5d33438fda | 1581 | display.foreground(BrightGreen); |
WiredHome | 62:ba5d33438fda | 1582 | pc.printf("fg %08X %08X %08X\r\n", RGB(0,255,0), BrightGreen, display.GetForeColor()); |
WiredHome | 62:ba5d33438fda | 1583 | display.foreground(BrightBlue); |
WiredHome | 62:ba5d33438fda | 1584 | pc.printf("fg %08X %08X %08X\r\n", RGB(0,0,255), BrightBlue, display.GetForeColor()); |
WiredHome | 62:ba5d33438fda | 1585 | display.line(55,50, 79,74, BrightRed); |
WiredHome | 62:ba5d33438fda | 1586 | display.line(57,50, 81,74, BrightGreen); |
WiredHome | 62:ba5d33438fda | 1587 | display.line(59,50, 83,74, BrightBlue); |
WiredHome | 62:ba5d33438fda | 1588 | // horz |
WiredHome | 62:ba5d33438fda | 1589 | display.line(30,40, 32,40, BrightRed); |
WiredHome | 62:ba5d33438fda | 1590 | display.line(30,42, 32,42, BrightGreen); |
WiredHome | 62:ba5d33438fda | 1591 | display.line(30,44, 32,44, BrightBlue); |
WiredHome | 62:ba5d33438fda | 1592 | // vert |
WiredHome | 62:ba5d33438fda | 1593 | display.line(20,40, 20,42, BrightRed); |
WiredHome | 62:ba5d33438fda | 1594 | display.line(22,40, 22,42, BrightGreen); |
WiredHome | 62:ba5d33438fda | 1595 | display.line(24,40, 24,42, BrightBlue); |
WiredHome | 62:ba5d33438fda | 1596 | // compare point to line-point |
WiredHome | 62:ba5d33438fda | 1597 | display.pixel(20,50, BrightRed); |
WiredHome | 62:ba5d33438fda | 1598 | display.pixel(22,50, BrightGreen); |
WiredHome | 62:ba5d33438fda | 1599 | display.pixel(24,50, BrightBlue); |
WiredHome | 62:ba5d33438fda | 1600 | display.line(20,52, 20,52, BrightRed); |
WiredHome | 62:ba5d33438fda | 1601 | display.line(22,52, 22,52, BrightGreen); |
WiredHome | 62:ba5d33438fda | 1602 | display.line(24,52, 24,52, BrightBlue); |
WiredHome | 62:ba5d33438fda | 1603 | |
WiredHome | 62:ba5d33438fda | 1604 | // point |
WiredHome | 62:ba5d33438fda | 1605 | display.line(50,50, 50,50, Red); |
WiredHome | 62:ba5d33438fda | 1606 | display.line(52,52, 52,52, Green); |
WiredHome | 62:ba5d33438fda | 1607 | display.line(54,54, 54,54, Blue); |
WiredHome | 62:ba5d33438fda | 1608 | display.line(60,60, 60,60, BrightRed); |
WiredHome | 62:ba5d33438fda | 1609 | display.line(62,62, 62,62, BrightGreen); |
WiredHome | 62:ba5d33438fda | 1610 | display.line(64,64, 64,64, BrightBlue); |
WiredHome | 62:ba5d33438fda | 1611 | display.line(70,70, 70,70, DarkRed); |
WiredHome | 62:ba5d33438fda | 1612 | display.line(72,72, 72,72, DarkGreen); |
WiredHome | 62:ba5d33438fda | 1613 | display.line(74,74, 74,74, DarkBlue); |
WiredHome | 23:a50ded45dbaf | 1614 | } |
WiredHome | 23:a50ded45dbaf | 1615 | |
WiredHome | 44:207594dece70 | 1616 | |
WiredHome | 23:a50ded45dbaf | 1617 | void RectangleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1618 | { |
WiredHome | 23:a50ded45dbaf | 1619 | int i, x1,y1, x2,y2; |
WiredHome | 23:a50ded45dbaf | 1620 | |
WiredHome | 41:2956a0a221e5 | 1621 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1622 | pc.printf("Rectangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1623 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1624 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1625 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1626 | display.puts(0,0, "Rectangle Test"); |
WiredHome | 23:a50ded45dbaf | 1627 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1628 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1629 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1630 | x2 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1631 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1632 | display.rect(x1,y1, x2,y2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1633 | |
WiredHome | 23:a50ded45dbaf | 1634 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1635 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1636 | x2 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1637 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1638 | display.rect(x1,y1, x2,y2, FILL); |
WiredHome | 23:a50ded45dbaf | 1639 | } |
WiredHome | 23:a50ded45dbaf | 1640 | } |
WiredHome | 23:a50ded45dbaf | 1641 | |
WiredHome | 44:207594dece70 | 1642 | |
WiredHome | 44:207594dece70 | 1643 | void LayerTest(RA8875 & display, Serial & pc) |
WiredHome | 44:207594dece70 | 1644 | { |
WiredHome | 44:207594dece70 | 1645 | loc_t i, x1,y1, x2,y2, r1,r2; |
WiredHome | 44:207594dece70 | 1646 | |
WiredHome | 44:207594dece70 | 1647 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1648 | pc.printf("Layer Test\r\n"); |
WiredHome | 44:207594dece70 | 1649 | |
WiredHome | 50:2c4f474a2453 | 1650 | display.SelectDrawingLayer(0); |
WiredHome | 44:207594dece70 | 1651 | display.background(Black); |
WiredHome | 44:207594dece70 | 1652 | display.foreground(Blue); |
WiredHome | 44:207594dece70 | 1653 | display.cls(); |
WiredHome | 44:207594dece70 | 1654 | display.puts(0,0, "Layer 0"); |
WiredHome | 44:207594dece70 | 1655 | for (i=0; i<16; i++) { |
WiredHome | 44:207594dece70 | 1656 | x1 = rand() % 240; |
WiredHome | 44:207594dece70 | 1657 | y1 = 50 + rand() % 200; |
WiredHome | 44:207594dece70 | 1658 | x2 = x1 + rand() % 100; |
WiredHome | 44:207594dece70 | 1659 | y2 = y1 + rand() % 100; |
WiredHome | 44:207594dece70 | 1660 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 44:207594dece70 | 1661 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 44:207594dece70 | 1662 | display.roundrect(x1,y1, x2,y2, r1,r2, display.DOSColor(i)); |
WiredHome | 44:207594dece70 | 1663 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1664 | wait_ms(20); |
WiredHome | 44:207594dece70 | 1665 | } |
WiredHome | 44:207594dece70 | 1666 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1667 | wait_ms(1000); |
WiredHome | 44:207594dece70 | 1668 | |
WiredHome | 50:2c4f474a2453 | 1669 | display.SelectDrawingLayer(1); |
WiredHome | 44:207594dece70 | 1670 | display.background(Black); |
WiredHome | 44:207594dece70 | 1671 | display.foreground(Yellow); |
WiredHome | 44:207594dece70 | 1672 | display.cls(); |
WiredHome | 44:207594dece70 | 1673 | display.puts(240,0, "Layer 1"); |
WiredHome | 44:207594dece70 | 1674 | for (i=0; i<16; i++) { |
WiredHome | 44:207594dece70 | 1675 | x1 = 300 + rand() % 100; |
WiredHome | 44:207594dece70 | 1676 | y1 = 70 + rand() % 200; |
WiredHome | 44:207594dece70 | 1677 | r1 = rand() % min(y1 - 20, 100); |
WiredHome | 44:207594dece70 | 1678 | display.circle(x1,y1,r1, display.DOSColor(i)); |
WiredHome | 44:207594dece70 | 1679 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1680 | wait_ms(20); |
WiredHome | 44:207594dece70 | 1681 | } |
WiredHome | 56:7a85d226ad0d | 1682 | display.SetLayerMode(RA8875::ShowLayer1); // Show it after the build-up |
WiredHome | 44:207594dece70 | 1683 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1684 | wait_ms(2000); |
WiredHome | 44:207594dece70 | 1685 | |
WiredHome | 50:2c4f474a2453 | 1686 | display.SelectDrawingLayer(0); |
WiredHome | 56:7a85d226ad0d | 1687 | display.SetLayerMode(RA8875::ShowLayer0); // Show Layer 0 again |
WiredHome | 44:207594dece70 | 1688 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1689 | wait_ms(1000); |
WiredHome | 53:86d24b9480b9 | 1690 | display.SetLayerMode(RA8875::TransparentMode); // Transparent mode |
WiredHome | 44:207594dece70 | 1691 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1692 | wait_ms(1000); |
WiredHome | 44:207594dece70 | 1693 | for (i=0; i<=8; i++) { |
WiredHome | 44:207594dece70 | 1694 | display.SetLayerTransparency(i, 8-i); |
WiredHome | 44:207594dece70 | 1695 | if (!SuppressSlowStuff) |
WiredHome | 44:207594dece70 | 1696 | wait_ms(200); |
WiredHome | 44:207594dece70 | 1697 | } |
WiredHome | 44:207594dece70 | 1698 | |
WiredHome | 44:207594dece70 | 1699 | // Restore before we exit |
WiredHome | 44:207594dece70 | 1700 | display.SetLayerTransparency(0, 0); |
WiredHome | 56:7a85d226ad0d | 1701 | display.SetLayerMode(RA8875::ShowLayer0); // Restore to layer 0 |
WiredHome | 44:207594dece70 | 1702 | } |
WiredHome | 44:207594dece70 | 1703 | |
WiredHome | 44:207594dece70 | 1704 | |
WiredHome | 23:a50ded45dbaf | 1705 | void RoundRectTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1706 | { |
WiredHome | 37:f19b7e7449dc | 1707 | loc_t i, x1,y1, x2,y2, r1,r2; |
WiredHome | 23:a50ded45dbaf | 1708 | |
WiredHome | 41:2956a0a221e5 | 1709 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1710 | pc.printf("Round Rectangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1711 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1712 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1713 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1714 | display.puts(0,0, "Rounded Rectangle Test"); |
WiredHome | 23:a50ded45dbaf | 1715 | |
WiredHome | 23:a50ded45dbaf | 1716 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1717 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1718 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1719 | x2 = x1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1720 | y2 = y1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1721 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 23:a50ded45dbaf | 1722 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 23:a50ded45dbaf | 1723 | display.roundrect(x1,y1, x2,y2, 5,8, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1724 | |
WiredHome | 23:a50ded45dbaf | 1725 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1726 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1727 | x2 = x1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1728 | y2 = y1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1729 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 23:a50ded45dbaf | 1730 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 23:a50ded45dbaf | 1731 | display.roundrect(x1,y1, x2,y2, r1,r2, FILL); |
WiredHome | 23:a50ded45dbaf | 1732 | } |
WiredHome | 23:a50ded45dbaf | 1733 | } |
WiredHome | 23:a50ded45dbaf | 1734 | |
WiredHome | 44:207594dece70 | 1735 | |
WiredHome | 23:a50ded45dbaf | 1736 | void TriangleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1737 | { |
WiredHome | 23:a50ded45dbaf | 1738 | int i, x1, y1, x2, y2, x3, y3; |
WiredHome | 23:a50ded45dbaf | 1739 | |
WiredHome | 41:2956a0a221e5 | 1740 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1741 | pc.printf("Triangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1742 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1743 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1744 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1745 | display.puts(0,0, "Triangle Test"); |
WiredHome | 23:a50ded45dbaf | 1746 | |
WiredHome | 23:a50ded45dbaf | 1747 | x1 = 150; |
WiredHome | 23:a50ded45dbaf | 1748 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1749 | x2 = 190; |
WiredHome | 23:a50ded45dbaf | 1750 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1751 | x3 = 170; |
WiredHome | 23:a50ded45dbaf | 1752 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1753 | display.triangle(x1,y1, x2,y2, x3,y3); |
WiredHome | 23:a50ded45dbaf | 1754 | |
WiredHome | 23:a50ded45dbaf | 1755 | x1 = 200; |
WiredHome | 23:a50ded45dbaf | 1756 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1757 | x2 = 240; |
WiredHome | 23:a50ded45dbaf | 1758 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1759 | x3 = 220; |
WiredHome | 23:a50ded45dbaf | 1760 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1761 | display.filltriangle(x1,y1, x2,y2, x3,y3, BrightRed); |
WiredHome | 23:a50ded45dbaf | 1762 | |
WiredHome | 23:a50ded45dbaf | 1763 | x1 = 300; |
WiredHome | 23:a50ded45dbaf | 1764 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1765 | x2 = 340; |
WiredHome | 23:a50ded45dbaf | 1766 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1767 | x3 = 320; |
WiredHome | 23:a50ded45dbaf | 1768 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1769 | display.triangle(x1,y1, x2,y2, x3,y3, NOFILL); |
WiredHome | 23:a50ded45dbaf | 1770 | |
WiredHome | 23:a50ded45dbaf | 1771 | x1 = 400; |
WiredHome | 23:a50ded45dbaf | 1772 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1773 | x2 = 440; |
WiredHome | 23:a50ded45dbaf | 1774 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1775 | x3 = 420; |
WiredHome | 23:a50ded45dbaf | 1776 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1777 | display.triangle(x1,y1, x2,y2, x3,y3, Blue); |
WiredHome | 23:a50ded45dbaf | 1778 | |
WiredHome | 23:a50ded45dbaf | 1779 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1780 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1781 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1782 | x2 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1783 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1784 | x3 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1785 | y3 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1786 | display.triangle(x1,y1, x2,y2, x3,y3, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1787 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1788 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1789 | x2 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1790 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1791 | x3 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1792 | y3 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1793 | display.triangle(x1,y1, x2,y2, x3,y3, FILL); |
WiredHome | 23:a50ded45dbaf | 1794 | } |
WiredHome | 23:a50ded45dbaf | 1795 | } |
WiredHome | 23:a50ded45dbaf | 1796 | |
WiredHome | 44:207594dece70 | 1797 | |
WiredHome | 23:a50ded45dbaf | 1798 | void CircleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1799 | { |
WiredHome | 23:a50ded45dbaf | 1800 | int i, x, y, r1; |
WiredHome | 23:a50ded45dbaf | 1801 | |
WiredHome | 41:2956a0a221e5 | 1802 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1803 | pc.printf("Circle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1804 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1805 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1806 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1807 | display.puts(0,0, "Circle Test"); |
WiredHome | 23:a50ded45dbaf | 1808 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1809 | x = 100 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1810 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1811 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1812 | //pc.printf(" (%d,%d) - %d\r\n", x,y,r1); |
WiredHome | 23:a50ded45dbaf | 1813 | display.circle(x,y,r1, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1814 | |
WiredHome | 23:a50ded45dbaf | 1815 | x = 300 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1816 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1817 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1818 | //pc.printf(" (%d,%d) - %d FILL\r\n", x,y,r1); |
WiredHome | 23:a50ded45dbaf | 1819 | display.circle(x,y,r1, display.DOSColor(i), FILL); |
WiredHome | 23:a50ded45dbaf | 1820 | } |
WiredHome | 23:a50ded45dbaf | 1821 | } |
WiredHome | 23:a50ded45dbaf | 1822 | |
WiredHome | 44:207594dece70 | 1823 | |
WiredHome | 23:a50ded45dbaf | 1824 | void EllipseTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1825 | { |
WiredHome | 23:a50ded45dbaf | 1826 | int i,x,y,r1,r2; |
WiredHome | 23:a50ded45dbaf | 1827 | |
WiredHome | 41:2956a0a221e5 | 1828 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1829 | pc.printf("Ellipse Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1830 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1831 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1832 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1833 | display.puts(0,0, "Ellipse Test"); |
WiredHome | 23:a50ded45dbaf | 1834 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1835 | x = 100 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1836 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1837 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1838 | r2 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1839 | display.ellipse(x,y,r1,r2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1840 | |
WiredHome | 23:a50ded45dbaf | 1841 | x = 300 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1842 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1843 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1844 | r2 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1845 | display.ellipse(x,y,r1,r2, FILL); |
WiredHome | 23:a50ded45dbaf | 1846 | } |
WiredHome | 23:a50ded45dbaf | 1847 | } |
WiredHome | 23:a50ded45dbaf | 1848 | |
WiredHome | 44:207594dece70 | 1849 | |
WiredHome | 37:f19b7e7449dc | 1850 | void TestGraphicsBitmap(RA8875 & display, Serial & pc) |
WiredHome | 37:f19b7e7449dc | 1851 | { |
WiredHome | 37:f19b7e7449dc | 1852 | LocalFileSystem local("local"); |
WiredHome | 41:2956a0a221e5 | 1853 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1854 | pc.printf("Bitmap File Load\r\n"); |
WiredHome | 37:f19b7e7449dc | 1855 | display.background(Black); |
WiredHome | 37:f19b7e7449dc | 1856 | display.foreground(Blue); |
WiredHome | 37:f19b7e7449dc | 1857 | display.cls(); |
WiredHome | 37:f19b7e7449dc | 1858 | display.puts(0,0, "Graphics Test, loading /local/TestPat.bmp"); |
WiredHome | 37:f19b7e7449dc | 1859 | wait(3); |
WiredHome | 37:f19b7e7449dc | 1860 | |
WiredHome | 37:f19b7e7449dc | 1861 | int r = display.RenderBitmapFile(0,0, "/local/TestPat.bmp"); |
WiredHome | 59:fb40aad4efd4 | 1862 | if (!SuppressSlowStuff) |
WiredHome | 59:fb40aad4efd4 | 1863 | pc.printf(" returned %d\r\n", r); |
WiredHome | 37:f19b7e7449dc | 1864 | } |
WiredHome | 37:f19b7e7449dc | 1865 | |
WiredHome | 44:207594dece70 | 1866 | |
WiredHome | 41:2956a0a221e5 | 1867 | void SpeedTest(RA8875 & display, Serial & pc) |
WiredHome | 41:2956a0a221e5 | 1868 | { |
WiredHome | 41:2956a0a221e5 | 1869 | Timer t; |
WiredHome | 41:2956a0a221e5 | 1870 | SuppressSlowStuff = true; |
WiredHome | 41:2956a0a221e5 | 1871 | pc.printf("\r\nSpeedTest disables delays, runs tests, reports overall time.\r\n"); |
WiredHome | 41:2956a0a221e5 | 1872 | t.start(); |
WiredHome | 41:2956a0a221e5 | 1873 | // do stuff fast |
WiredHome | 41:2956a0a221e5 | 1874 | TextCursorTest(display, pc); |
WiredHome | 49:c5182231d1b9 | 1875 | TextWrapTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1876 | BacklightTest(display, pc, 0); |
WiredHome | 41:2956a0a221e5 | 1877 | BacklightTest2(display, pc); |
WiredHome | 41:2956a0a221e5 | 1878 | ExternalFontTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1879 | DOSColorTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1880 | WebColorTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1881 | PixelTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1882 | LineTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1883 | RectangleTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1884 | RoundRectTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1885 | TriangleTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1886 | CircleTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1887 | EllipseTest(display, pc); |
WiredHome | 44:207594dece70 | 1888 | LayerTest(display, pc); |
WiredHome | 41:2956a0a221e5 | 1889 | //TestGraphicsBitmap(display, pc); |
WiredHome | 41:2956a0a221e5 | 1890 | pc.printf("SpeedTest completed in %d msec\r\n", t.read_ms()); |
WiredHome | 44:207594dece70 | 1891 | #ifdef PERF_METRICS |
WiredHome | 41:2956a0a221e5 | 1892 | display.ReportPerformance(pc); |
WiredHome | 41:2956a0a221e5 | 1893 | #endif |
WiredHome | 41:2956a0a221e5 | 1894 | SuppressSlowStuff = false; |
WiredHome | 41:2956a0a221e5 | 1895 | } |
WiredHome | 41:2956a0a221e5 | 1896 | |
WiredHome | 44:207594dece70 | 1897 | |
WiredHome | 41:2956a0a221e5 | 1898 | void PrintScreen(RA8875 & display, Serial & pc) |
WiredHome | 41:2956a0a221e5 | 1899 | { |
WiredHome | 41:2956a0a221e5 | 1900 | LocalFileSystem local("local"); |
WiredHome | 41:2956a0a221e5 | 1901 | if (!SuppressSlowStuff) |
WiredHome | 41:2956a0a221e5 | 1902 | pc.printf("PrintScreen\r\n"); |
WiredHome | 41:2956a0a221e5 | 1903 | display.PrintScreen( 0,0, 480,272, "/local/Capture.bmp"); |
WiredHome | 41:2956a0a221e5 | 1904 | } |
WiredHome | 41:2956a0a221e5 | 1905 | |
WiredHome | 44:207594dece70 | 1906 | |
WiredHome | 23:a50ded45dbaf | 1907 | void RunTestSet(RA8875 & lcd, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1908 | { |
WiredHome | 23:a50ded45dbaf | 1909 | int q = 0; |
WiredHome | 23:a50ded45dbaf | 1910 | int automode = 0; |
WiredHome | 49:c5182231d1b9 | 1911 | const unsigned char modelist[] = "BDWtGLlFROTPCEbw"; // auto-test in this order. |
WiredHome | 23:a50ded45dbaf | 1912 | |
WiredHome | 23:a50ded45dbaf | 1913 | while(1) { |
WiredHome | 23:a50ded45dbaf | 1914 | pc.printf("\r\n" |
WiredHome | 41:2956a0a221e5 | 1915 | "B - Backlight up b - backlight dim\r\n" |
WiredHome | 41:2956a0a221e5 | 1916 | "D - DOS Colors W - Web Colors\r\n" |
WiredHome | 41:2956a0a221e5 | 1917 | "t - text cursor G - Graphics Bitmap\r\n" |
WiredHome | 41:2956a0a221e5 | 1918 | "L - Lines F - external Font\r\n" |
WiredHome | 41:2956a0a221e5 | 1919 | "R - Rectangles O - rOund rectangles\r\n" |
WiredHome | 41:2956a0a221e5 | 1920 | "T - Triangles P - Pixels \r\n" |
WiredHome | 41:2956a0a221e5 | 1921 | "C - Circles E - Ellipses\r\n" |
WiredHome | 41:2956a0a221e5 | 1922 | "A - Auto Test mode S - Speed Test\r\n" |
WiredHome | 41:2956a0a221e5 | 1923 | "p - print screen r - reset \r\n" |
WiredHome | 49:c5182231d1b9 | 1924 | "l - layer test w - wrapping text \r\n" |
WiredHome | 58:26658a56112a | 1925 | #ifdef PERF_METRICS |
WiredHome | 41:2956a0a221e5 | 1926 | "0 - clear performance 1 - report performance\r\n" |
WiredHome | 41:2956a0a221e5 | 1927 | #endif |
WiredHome | 23:a50ded45dbaf | 1928 | "> "); |
WiredHome | 23:a50ded45dbaf | 1929 | if (automode == -1 || pc.readable()) { |
WiredHome | 23:a50ded45dbaf | 1930 | automode = -1; |
WiredHome | 37:f19b7e7449dc | 1931 | q = pc.getc(); |
WiredHome | 37:f19b7e7449dc | 1932 | while (pc.readable()) |
WiredHome | 37:f19b7e7449dc | 1933 | pc.getc(); |
WiredHome | 23:a50ded45dbaf | 1934 | } else if (automode >= 0) { |
WiredHome | 23:a50ded45dbaf | 1935 | q = modelist[automode]; |
WiredHome | 23:a50ded45dbaf | 1936 | } |
WiredHome | 23:a50ded45dbaf | 1937 | switch(q) { |
WiredHome | 58:26658a56112a | 1938 | #ifdef PERF_METRICS |
WiredHome | 41:2956a0a221e5 | 1939 | case '0': |
WiredHome | 41:2956a0a221e5 | 1940 | lcd.ClearPerformance(); |
WiredHome | 41:2956a0a221e5 | 1941 | break; |
WiredHome | 41:2956a0a221e5 | 1942 | case '1': |
WiredHome | 41:2956a0a221e5 | 1943 | lcd.ReportPerformance(pc); |
WiredHome | 41:2956a0a221e5 | 1944 | break; |
WiredHome | 41:2956a0a221e5 | 1945 | #endif |
WiredHome | 23:a50ded45dbaf | 1946 | case 'A': |
WiredHome | 23:a50ded45dbaf | 1947 | automode = 0; |
WiredHome | 23:a50ded45dbaf | 1948 | break; |
WiredHome | 23:a50ded45dbaf | 1949 | case 'B': |
WiredHome | 41:2956a0a221e5 | 1950 | BacklightTest(lcd, pc, 2); |
WiredHome | 23:a50ded45dbaf | 1951 | break; |
WiredHome | 23:a50ded45dbaf | 1952 | case 'b': |
WiredHome | 23:a50ded45dbaf | 1953 | BacklightTest2(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1954 | break; |
WiredHome | 23:a50ded45dbaf | 1955 | case 'D': |
WiredHome | 23:a50ded45dbaf | 1956 | DOSColorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1957 | break; |
WiredHome | 23:a50ded45dbaf | 1958 | case 'W': |
WiredHome | 23:a50ded45dbaf | 1959 | WebColorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1960 | break; |
WiredHome | 23:a50ded45dbaf | 1961 | case 't': |
WiredHome | 23:a50ded45dbaf | 1962 | TextCursorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1963 | break; |
WiredHome | 49:c5182231d1b9 | 1964 | case 'w': |
WiredHome | 49:c5182231d1b9 | 1965 | TextWrapTest(lcd, pc); |
WiredHome | 49:c5182231d1b9 | 1966 | break; |
WiredHome | 23:a50ded45dbaf | 1967 | case 'F': |
WiredHome | 23:a50ded45dbaf | 1968 | ExternalFontTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1969 | break; |
WiredHome | 23:a50ded45dbaf | 1970 | case 'L': |
WiredHome | 23:a50ded45dbaf | 1971 | LineTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1972 | break; |
WiredHome | 44:207594dece70 | 1973 | case 'l': |
WiredHome | 44:207594dece70 | 1974 | LayerTest(lcd, pc); |
WiredHome | 44:207594dece70 | 1975 | break; |
WiredHome | 23:a50ded45dbaf | 1976 | case 'R': |
WiredHome | 23:a50ded45dbaf | 1977 | RectangleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1978 | break; |
WiredHome | 23:a50ded45dbaf | 1979 | case 'O': |
WiredHome | 23:a50ded45dbaf | 1980 | RoundRectTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1981 | break; |
WiredHome | 41:2956a0a221e5 | 1982 | case 'p': |
WiredHome | 41:2956a0a221e5 | 1983 | PrintScreen(lcd, pc); |
WiredHome | 41:2956a0a221e5 | 1984 | break; |
WiredHome | 41:2956a0a221e5 | 1985 | case 'S': |
WiredHome | 41:2956a0a221e5 | 1986 | SpeedTest(lcd, pc); |
WiredHome | 41:2956a0a221e5 | 1987 | break; |
WiredHome | 23:a50ded45dbaf | 1988 | case 'T': |
WiredHome | 23:a50ded45dbaf | 1989 | TriangleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1990 | break; |
WiredHome | 37:f19b7e7449dc | 1991 | case 'P': |
WiredHome | 37:f19b7e7449dc | 1992 | PixelTest(lcd, pc); |
WiredHome | 37:f19b7e7449dc | 1993 | break; |
WiredHome | 37:f19b7e7449dc | 1994 | case 'G': |
WiredHome | 37:f19b7e7449dc | 1995 | TestGraphicsBitmap(lcd, pc); |
WiredHome | 37:f19b7e7449dc | 1996 | break; |
WiredHome | 23:a50ded45dbaf | 1997 | case 'C': |
WiredHome | 23:a50ded45dbaf | 1998 | CircleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1999 | break; |
WiredHome | 23:a50ded45dbaf | 2000 | case 'E': |
WiredHome | 23:a50ded45dbaf | 2001 | EllipseTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 2002 | break; |
WiredHome | 23:a50ded45dbaf | 2003 | case 'r': |
WiredHome | 23:a50ded45dbaf | 2004 | pc.printf("Resetting ...\r\n"); |
WiredHome | 23:a50ded45dbaf | 2005 | wait_ms(20); |
WiredHome | 23:a50ded45dbaf | 2006 | mbed_reset(); |
WiredHome | 23:a50ded45dbaf | 2007 | break; |
WiredHome | 23:a50ded45dbaf | 2008 | default: |
WiredHome | 23:a50ded45dbaf | 2009 | printf("huh?\n"); |
WiredHome | 23:a50ded45dbaf | 2010 | break; |
WiredHome | 23:a50ded45dbaf | 2011 | } |
WiredHome | 23:a50ded45dbaf | 2012 | if (automode >= 0) { |
WiredHome | 23:a50ded45dbaf | 2013 | automode++; |
WiredHome | 23:a50ded45dbaf | 2014 | if (automode >= sizeof(modelist)) |
WiredHome | 23:a50ded45dbaf | 2015 | automode = 0; |
WiredHome | 23:a50ded45dbaf | 2016 | wait_ms(2000); |
WiredHome | 23:a50ded45dbaf | 2017 | } |
WiredHome | 23:a50ded45dbaf | 2018 | wait_ms(200); |
WiredHome | 23:a50ded45dbaf | 2019 | } |
WiredHome | 23:a50ded45dbaf | 2020 | } |
WiredHome | 23:a50ded45dbaf | 2021 | |
WiredHome | 23:a50ded45dbaf | 2022 | #endif // TESTENABLE |