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