Fork of David Smart's RA8875 library for the purpose of adding touch screen support

Fork of RA8875 by David Smart

Committer:
hexley
Date:
Sun Mar 23 17:35:14 2014 +0000
Revision:
54:e117ad10fba6
Parent:
53:86d24b9480b9
Includes both raw and filtered TP outputs.

Who changed what in which revision?

UserRevisionLine numberNew 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 19:3f82c1161fd2 52 : spi(mosi, miso, sclk)
WiredHome 19:3f82c1161fd2 53 , cs(csel)
WiredHome 19:3f82c1161fd2 54 , res(reset)
WiredHome 19:3f82c1161fd2 55 , GraphicsDisplay(name)
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 23:a50ded45dbaf 364 return (((ReadCommand(0x22) >> 2) & 0x3) + 1) * 16;
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 32:0e4f2ae512e2 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 38:38d503b4fad6 817 WriteCommandW(0x91, x1);
WiredHome 38:38d503b4fad6 818 WriteCommandW(0x93, y1);
WiredHome 38:38d503b4fad6 819 WriteCommandW(0x95, x2);
WiredHome 38:38d503b4fad6 820 WriteCommandW(0x97, y2);
WiredHome 19:3f82c1161fd2 821 unsigned char drawCmd = 0x00; // Line
WiredHome 19:3f82c1161fd2 822 WriteCommand(0x90, drawCmd);
WiredHome 19:3f82c1161fd2 823 WriteCommand(0x90, 0x80 + drawCmd); // Start drawing.
WiredHome 19:3f82c1161fd2 824 while (ReadCommand(0x90) & 0x80) // await completion.
WiredHome 19:3f82c1161fd2 825 wait_us(POLLWAITuSec);
WiredHome 19:3f82c1161fd2 826 REGISTERPERFORMANCE(PRF_DRAWLINE);
WiredHome 19:3f82c1161fd2 827 return noerror;
WiredHome 19:3f82c1161fd2 828 }
WiredHome 19:3f82c1161fd2 829
WiredHome 44:207594dece70 830
WiredHome 37:f19b7e7449dc 831 RetCode_t RA8875::fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 832 color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 833 {
WiredHome 19:3f82c1161fd2 834 return rect(x1,y1,x2,y2,color,fillit);
WiredHome 19:3f82c1161fd2 835 }
WiredHome 19:3f82c1161fd2 836
WiredHome 44:207594dece70 837
WiredHome 37:f19b7e7449dc 838 RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 839 color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 840 {
WiredHome 19:3f82c1161fd2 841 foreground(color);
WiredHome 19:3f82c1161fd2 842 return rect(x1,y1,x2,y2,fillit);
WiredHome 19:3f82c1161fd2 843 }
WiredHome 19:3f82c1161fd2 844
WiredHome 44:207594dece70 845
WiredHome 37:f19b7e7449dc 846 RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 19:3f82c1161fd2 847 fill_t fillit)
WiredHome 19:3f82c1161fd2 848 {
WiredHome 19:3f82c1161fd2 849 PERFORMANCE_RESET;
WiredHome 19:3f82c1161fd2 850 if (x1 == x2 && y1 == y2) {
WiredHome 19:3f82c1161fd2 851 pixel(x1, y1);
WiredHome 19:3f82c1161fd2 852 } else if (x1 == x2) {
WiredHome 19:3f82c1161fd2 853 line(x1, y1, x2, y2);
WiredHome 19:3f82c1161fd2 854 } else if (y1 == y2) {
WiredHome 19:3f82c1161fd2 855 line(x1, y1, x2, y2);
WiredHome 19:3f82c1161fd2 856 } else {
WiredHome 38:38d503b4fad6 857 WriteCommandW(0x91, x1);
WiredHome 38:38d503b4fad6 858 WriteCommandW(0x93, y1);
WiredHome 38:38d503b4fad6 859 WriteCommandW(0x95, x2);
WiredHome 38:38d503b4fad6 860 WriteCommandW(0x97, y2);
WiredHome 19:3f82c1161fd2 861 unsigned char drawCmd = 0x10; // Rectangle
WiredHome 19:3f82c1161fd2 862 if (fillit == FILL)
WiredHome 19:3f82c1161fd2 863 drawCmd |= 0x20;
WiredHome 19:3f82c1161fd2 864 WriteCommand(0x90, drawCmd);
WiredHome 19:3f82c1161fd2 865 WriteCommand(0x90, 0x80 + drawCmd); // Start drawing.
WiredHome 19:3f82c1161fd2 866 while (ReadCommand(0x90) & 0x80) // await completion.
WiredHome 19:3f82c1161fd2 867 wait_us(POLLWAITuSec);
WiredHome 19:3f82c1161fd2 868 }
WiredHome 19:3f82c1161fd2 869 REGISTERPERFORMANCE(PRF_DRAWRECTANGLE);
WiredHome 19:3f82c1161fd2 870 return noerror;
WiredHome 19:3f82c1161fd2 871 }
WiredHome 19:3f82c1161fd2 872
WiredHome 44:207594dece70 873
WiredHome 37:f19b7e7449dc 874 RetCode_t RA8875::fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 875 dim_t radius1, dim_t radius2, color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 876 {
WiredHome 19:3f82c1161fd2 877 foreground(color);
WiredHome 19:3f82c1161fd2 878 return roundrect(x1,y1,x2,y2,radius1,radius2,fillit);
WiredHome 19:3f82c1161fd2 879 }
WiredHome 19:3f82c1161fd2 880
WiredHome 44:207594dece70 881
WiredHome 37:f19b7e7449dc 882 RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 883 dim_t radius1, dim_t radius2, color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 884 {
WiredHome 19:3f82c1161fd2 885 foreground(color);
WiredHome 19:3f82c1161fd2 886 return roundrect(x1,y1,x2,y2,radius1,radius2,fillit);
WiredHome 19:3f82c1161fd2 887 }
WiredHome 19:3f82c1161fd2 888
WiredHome 44:207594dece70 889
WiredHome 37:f19b7e7449dc 890 RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 891 dim_t radius1, dim_t radius2, fill_t fillit)
WiredHome 19:3f82c1161fd2 892 {
WiredHome 19:3f82c1161fd2 893 RetCode_t ret = noerror;
WiredHome 19:3f82c1161fd2 894
WiredHome 19:3f82c1161fd2 895 PERFORMANCE_RESET;
WiredHome 21:3c1efb192927 896 if (x1 > x2 || y1 > y2 || (radius1 > (x2-x1)/2) || (radius2 > (y2-y1)/2) ) {
WiredHome 21:3c1efb192927 897 ret = bad_parameter;
WiredHome 21:3c1efb192927 898 } else if (x1 == x2 && y1 == y2) {
WiredHome 19:3f82c1161fd2 899 pixel(x1, y1);
WiredHome 19:3f82c1161fd2 900 } else if (x1 == x2) {
WiredHome 19:3f82c1161fd2 901 line(x1, y1, x2, y2);
WiredHome 19:3f82c1161fd2 902 } else if (y1 == y2) {
WiredHome 19:3f82c1161fd2 903 line(x1, y1, x2, y2);
WiredHome 19:3f82c1161fd2 904 } else {
WiredHome 38:38d503b4fad6 905 WriteCommandW(0x91, x1);
WiredHome 38:38d503b4fad6 906 WriteCommandW(0x93, y1);
WiredHome 38:38d503b4fad6 907 WriteCommandW(0x95, x2);
WiredHome 38:38d503b4fad6 908 WriteCommandW(0x97, y2);
WiredHome 38:38d503b4fad6 909 WriteCommandW(0xA1, radius1);
WiredHome 38:38d503b4fad6 910 WriteCommandW(0xA3, radius2);
WiredHome 21:3c1efb192927 911 // Should not need this...
WiredHome 38:38d503b4fad6 912 WriteCommandW(0xA5, 0);
WiredHome 38:38d503b4fad6 913 WriteCommandW(0xA7, 0);
WiredHome 19:3f82c1161fd2 914 unsigned char drawCmd = 0x20; // Rounded Rectangle
WiredHome 19:3f82c1161fd2 915 if (fillit == FILL)
WiredHome 19:3f82c1161fd2 916 drawCmd |= 0x40;
WiredHome 19:3f82c1161fd2 917 WriteCommand(0xA0, drawCmd);
WiredHome 19:3f82c1161fd2 918 WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing.
WiredHome 19:3f82c1161fd2 919 while (ReadCommand(0xA0) & 0x80) { // await completion.
WiredHome 19:3f82c1161fd2 920 wait_us(POLLWAITuSec);
WiredHome 21:3c1efb192927 921 }
WiredHome 19:3f82c1161fd2 922 }
WiredHome 19:3f82c1161fd2 923 REGISTERPERFORMANCE(PRF_DRAWROUNDEDRECTANGLE);
WiredHome 19:3f82c1161fd2 924 return ret;
WiredHome 19:3f82c1161fd2 925 }
WiredHome 19:3f82c1161fd2 926
WiredHome 44:207594dece70 927
WiredHome 37:f19b7e7449dc 928 RetCode_t RA8875::triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 929 loc_t x3, loc_t y3, color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 930 {
WiredHome 20:6e2e4a8372eb 931 RetCode_t ret;
WiredHome 20:6e2e4a8372eb 932
WiredHome 19:3f82c1161fd2 933 foreground(color);
WiredHome 20:6e2e4a8372eb 934 ret = triangle(x1,y1,x2,y2,x3,y3,fillit);
WiredHome 20:6e2e4a8372eb 935 return ret;
WiredHome 19:3f82c1161fd2 936 }
WiredHome 19:3f82c1161fd2 937
WiredHome 44:207594dece70 938
WiredHome 37:f19b7e7449dc 939 RetCode_t RA8875::filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 940 loc_t x3, loc_t y3, color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 941 {
WiredHome 20:6e2e4a8372eb 942 RetCode_t ret;
WiredHome 20:6e2e4a8372eb 943
WiredHome 19:3f82c1161fd2 944 foreground(color);
WiredHome 20:6e2e4a8372eb 945 ret = triangle(x1,y1,x2,y2,x3,y3,fillit);
WiredHome 20:6e2e4a8372eb 946 return ret;
WiredHome 19:3f82c1161fd2 947 }
WiredHome 19:3f82c1161fd2 948
WiredHome 44:207594dece70 949
WiredHome 37:f19b7e7449dc 950 RetCode_t RA8875::triangle(loc_t x1, loc_t y1 ,loc_t x2, loc_t y2,
WiredHome 37:f19b7e7449dc 951 loc_t x3, loc_t y3, fill_t fillit)
WiredHome 19:3f82c1161fd2 952 {
WiredHome 19:3f82c1161fd2 953 RetCode_t ret = noerror;
WiredHome 19:3f82c1161fd2 954
WiredHome 19:3f82c1161fd2 955 PERFORMANCE_RESET;
WiredHome 19:3f82c1161fd2 956 if (x1 == x2 && y1 == y2 && x1 == x3 && y1 == y3) {
WiredHome 19:3f82c1161fd2 957 pixel(x1, y1);
WiredHome 19:3f82c1161fd2 958 } else {
WiredHome 38:38d503b4fad6 959 WriteCommandW(0x91, x1);
WiredHome 38:38d503b4fad6 960 WriteCommandW(0x93, y1);
WiredHome 38:38d503b4fad6 961 WriteCommandW(0x95, x2);
WiredHome 38:38d503b4fad6 962 WriteCommandW(0x97, y2);
WiredHome 38:38d503b4fad6 963 WriteCommandW(0xA9, x3);
WiredHome 38:38d503b4fad6 964 WriteCommandW(0xAB, y3);
WiredHome 19:3f82c1161fd2 965 unsigned char drawCmd = 0x01; // Triangle
WiredHome 19:3f82c1161fd2 966 if (fillit == FILL)
WiredHome 19:3f82c1161fd2 967 drawCmd |= 0x20;
WiredHome 19:3f82c1161fd2 968 WriteCommand(0x90, drawCmd);
WiredHome 19:3f82c1161fd2 969 WriteCommand(0x90, 0x80 + drawCmd); // Start drawing.
WiredHome 19:3f82c1161fd2 970 while (ReadCommand(0x90) & 0x80) // await completion.
WiredHome 19:3f82c1161fd2 971 wait_us(POLLWAITuSec);
WiredHome 19:3f82c1161fd2 972 }
WiredHome 19:3f82c1161fd2 973 REGISTERPERFORMANCE(PRF_DRAWTRIANGLE);
WiredHome 19:3f82c1161fd2 974 return ret;
WiredHome 19:3f82c1161fd2 975 }
WiredHome 19:3f82c1161fd2 976
WiredHome 37:f19b7e7449dc 977 RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius,
WiredHome 19:3f82c1161fd2 978 color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 979 {
WiredHome 19:3f82c1161fd2 980 foreground(color);
WiredHome 19:3f82c1161fd2 981 return circle(x,y,radius,fillit);
WiredHome 19:3f82c1161fd2 982 }
WiredHome 19:3f82c1161fd2 983
WiredHome 44:207594dece70 984
WiredHome 37:f19b7e7449dc 985 RetCode_t RA8875::fillcircle(loc_t x, loc_t y, dim_t radius,
WiredHome 19:3f82c1161fd2 986 color_t color, fill_t fillit)
WiredHome 19:3f82c1161fd2 987 {
WiredHome 19:3f82c1161fd2 988 foreground(color);
WiredHome 19:3f82c1161fd2 989 return circle(x,y,radius,fillit);
WiredHome 19:3f82c1161fd2 990 }
WiredHome 19:3f82c1161fd2 991
WiredHome 44:207594dece70 992
WiredHome 37:f19b7e7449dc 993 RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, fill_t fillit)
WiredHome 19:3f82c1161fd2 994 {
WiredHome 19:3f82c1161fd2 995 RetCode_t ret = noerror;
WiredHome 19:3f82c1161fd2 996
WiredHome 19:3f82c1161fd2 997 PERFORMANCE_RESET;
WiredHome 19:3f82c1161fd2 998 if (radius <= 0) {
WiredHome 19:3f82c1161fd2 999 ret = bad_parameter;
WiredHome 19:3f82c1161fd2 1000 } else if (radius == 1) {
WiredHome 19:3f82c1161fd2 1001 pixel(x,y);
WiredHome 19:3f82c1161fd2 1002 } else {
WiredHome 38:38d503b4fad6 1003 WriteCommandW(0x99, x);
WiredHome 38:38d503b4fad6 1004 WriteCommandW(0x9B, y);
WiredHome 19:3f82c1161fd2 1005 WriteCommand(0x9d, radius & 0xFF);
WiredHome 19:3f82c1161fd2 1006 unsigned char drawCmd = 0x00; // Circle
WiredHome 19:3f82c1161fd2 1007 if (fillit == FILL)
WiredHome 19:3f82c1161fd2 1008 drawCmd |= 0x20;
WiredHome 19:3f82c1161fd2 1009 WriteCommand(0x90, drawCmd);
WiredHome 19:3f82c1161fd2 1010 WriteCommand(0x90, 0x40 + drawCmd); // Start drawing.
WiredHome 19:3f82c1161fd2 1011 while (ReadCommand(0x90) & 0x40) // await completion.
WiredHome 19:3f82c1161fd2 1012 wait_us(POLLWAITuSec);
WiredHome 19:3f82c1161fd2 1013 }
WiredHome 19:3f82c1161fd2 1014 REGISTERPERFORMANCE(PRF_DRAWCIRCLE);
WiredHome 19:3f82c1161fd2 1015 return ret;
WiredHome 19:3f82c1161fd2 1016 }
WiredHome 19:3f82c1161fd2 1017
WiredHome 44:207594dece70 1018
WiredHome 37:f19b7e7449dc 1019 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 1020 {
WiredHome 19:3f82c1161fd2 1021 foreground(color);
WiredHome 25:9556a3a9b7cc 1022 return ellipse(x,y,radius1,radius2,fillit);
WiredHome 19:3f82c1161fd2 1023 }
WiredHome 19:3f82c1161fd2 1024
WiredHome 44:207594dece70 1025
WiredHome 37:f19b7e7449dc 1026 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 1027 {
WiredHome 25:9556a3a9b7cc 1028 foreground(color);
WiredHome 25:9556a3a9b7cc 1029 return ellipse(x,y,radius1,radius2,fillit);
WiredHome 25:9556a3a9b7cc 1030 }
WiredHome 44:207594dece70 1031
WiredHome 25:9556a3a9b7cc 1032
WiredHome 37:f19b7e7449dc 1033 RetCode_t RA8875::ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit)
WiredHome 19:3f82c1161fd2 1034 {
WiredHome 19:3f82c1161fd2 1035 RetCode_t ret = noerror;
WiredHome 19:3f82c1161fd2 1036
WiredHome 19:3f82c1161fd2 1037 PERFORMANCE_RESET;
WiredHome 25:9556a3a9b7cc 1038 if (radius1 <= 0 || radius2 <= 0) {
WiredHome 19:3f82c1161fd2 1039 ; // do nothing
WiredHome 25:9556a3a9b7cc 1040 } else if (radius1 == 1 && radius2 == 1) {
WiredHome 19:3f82c1161fd2 1041 pixel(x, y);
WiredHome 19:3f82c1161fd2 1042 } else {
WiredHome 38:38d503b4fad6 1043 WriteCommandW(0xA5, x);
WiredHome 38:38d503b4fad6 1044 WriteCommandW(0xA7, y);
WiredHome 38:38d503b4fad6 1045 WriteCommandW(0xA1, radius1);
WiredHome 38:38d503b4fad6 1046 WriteCommandW(0xA3, radius2);
WiredHome 19:3f82c1161fd2 1047 unsigned char drawCmd = 0x00; // Ellipse
WiredHome 19:3f82c1161fd2 1048 if (fillit == FILL)
WiredHome 19:3f82c1161fd2 1049 drawCmd |= 0x40;
WiredHome 19:3f82c1161fd2 1050 WriteCommand(0xA0, drawCmd);
WiredHome 19:3f82c1161fd2 1051 WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing.
WiredHome 19:3f82c1161fd2 1052 while (ReadCommand(0xA0) & 0x80) // await completion.
WiredHome 19:3f82c1161fd2 1053 wait_us(POLLWAITuSec);
WiredHome 19:3f82c1161fd2 1054 }
WiredHome 19:3f82c1161fd2 1055 REGISTERPERFORMANCE(PRF_DRAWELLIPSE);
WiredHome 19:3f82c1161fd2 1056 return ret;
WiredHome 19:3f82c1161fd2 1057 }
WiredHome 19:3f82c1161fd2 1058
WiredHome 44:207594dece70 1059
WiredHome 19:3f82c1161fd2 1060 RetCode_t RA8875::frequency(unsigned long Hz)
WiredHome 19:3f82c1161fd2 1061 {
WiredHome 19:3f82c1161fd2 1062 spi.frequency(Hz);
WiredHome 19:3f82c1161fd2 1063 // __ ___
WiredHome 19:3f82c1161fd2 1064 // Clock ___A Rising edge latched
WiredHome 19:3f82c1161fd2 1065 // ___ ____
WiredHome 19:3f82c1161fd2 1066 // Data ___X____
WiredHome 19:3f82c1161fd2 1067 spi.format(8, 3); // 8 bits and clock to data phase 0
WiredHome 19:3f82c1161fd2 1068 return noerror;
WiredHome 19:3f82c1161fd2 1069 }
WiredHome 19:3f82c1161fd2 1070
WiredHome 44:207594dece70 1071
WiredHome 19:3f82c1161fd2 1072 RetCode_t RA8875::Power(bool on)
WiredHome 19:3f82c1161fd2 1073 {
WiredHome 19:3f82c1161fd2 1074 WriteCommand(0x01, (on) ? 0x80 : 0x00);
WiredHome 19:3f82c1161fd2 1075 return noerror;
WiredHome 19:3f82c1161fd2 1076 }
WiredHome 19:3f82c1161fd2 1077
WiredHome 44:207594dece70 1078
WiredHome 19:3f82c1161fd2 1079 RetCode_t RA8875::Reset(void)
WiredHome 19:3f82c1161fd2 1080 {
WiredHome 19:3f82c1161fd2 1081 WriteCommand(0x01, 0x01); // Apply Display Off, Reset
WiredHome 19:3f82c1161fd2 1082 wait_ms(2); // no idea if I need to wait, or how long
WiredHome 19:3f82c1161fd2 1083 WriteCommand(0x01, 0x00); // Display off, Remove reset
WiredHome 19:3f82c1161fd2 1084 wait_ms(2); // no idea if I need to wait, or how long
WiredHome 43:3becae133285 1085 init(RA8875_DISPLAY_WIDTH, RA8875_DISPLAY_HEIGHT, RA8875_COLORDEPTH_BPP);
WiredHome 19:3f82c1161fd2 1086 return noerror;
WiredHome 19:3f82c1161fd2 1087 }
WiredHome 19:3f82c1161fd2 1088
WiredHome 19:3f82c1161fd2 1089
WiredHome 19:3f82c1161fd2 1090 RetCode_t RA8875::Backlight_u8(unsigned char brightness)
WiredHome 19:3f82c1161fd2 1091 {
WiredHome 19:3f82c1161fd2 1092 static bool is_enabled = false;
WiredHome 19:3f82c1161fd2 1093 if (brightness == 0) {
WiredHome 19:3f82c1161fd2 1094 WriteCommand(0x8a); // Disable the PWM
WiredHome 19:3f82c1161fd2 1095 WriteData(0x00);
WiredHome 19:3f82c1161fd2 1096 is_enabled = false;
WiredHome 19:3f82c1161fd2 1097 } else if (!is_enabled) {
WiredHome 19:3f82c1161fd2 1098 WriteCommand(0x8a); // Enable the PWM
WiredHome 19:3f82c1161fd2 1099 WriteData(0x80);
WiredHome 19:3f82c1161fd2 1100 WriteCommand(0x8a); // Not sure why this is needed, but following the pattern
WiredHome 19:3f82c1161fd2 1101 WriteData(0x81); // open PWM (SYS_CLK / 2 as best I can tell)
WiredHome 19:3f82c1161fd2 1102 is_enabled = true;
WiredHome 19:3f82c1161fd2 1103 }
WiredHome 19:3f82c1161fd2 1104 WriteCommand(0x8b, brightness); // Brightness parameter 0xff-0x00
WiredHome 19:3f82c1161fd2 1105 return noerror;
WiredHome 19:3f82c1161fd2 1106 }
WiredHome 19:3f82c1161fd2 1107
WiredHome 44:207594dece70 1108
WiredHome 19:3f82c1161fd2 1109 RetCode_t RA8875::Backlight(float brightness)
WiredHome 19:3f82c1161fd2 1110 {
WiredHome 19:3f82c1161fd2 1111 unsigned char b;
WiredHome 19:3f82c1161fd2 1112
WiredHome 29:422616aa04bd 1113 if (brightness >= 1.0)
WiredHome 19:3f82c1161fd2 1114 b = 255;
WiredHome 29:422616aa04bd 1115 else if (brightness <= 0.0)
WiredHome 19:3f82c1161fd2 1116 b = 0;
WiredHome 19:3f82c1161fd2 1117 else
WiredHome 19:3f82c1161fd2 1118 b = (unsigned char)(brightness * 255);
WiredHome 19:3f82c1161fd2 1119 return Backlight_u8(b);
WiredHome 19:3f82c1161fd2 1120 }
WiredHome 19:3f82c1161fd2 1121
WiredHome 44:207594dece70 1122
WiredHome 19:3f82c1161fd2 1123 RetCode_t RA8875::set_font(const unsigned char * _font)
WiredHome 19:3f82c1161fd2 1124 {
WiredHome 37:f19b7e7449dc 1125 if (font && ! _font) {
WiredHome 37:f19b7e7449dc 1126 SetTextCursor(cursor_x, cursor_y); // soft-font cursor -> hw cursor
WiredHome 37:f19b7e7449dc 1127 }
WiredHome 19:3f82c1161fd2 1128 font = _font;
WiredHome 29:422616aa04bd 1129 GraphicsDisplay::set_font(_font);
WiredHome 29:422616aa04bd 1130 return noerror; // trusting them, but it might be good to put some checks in here...
WiredHome 19:3f82c1161fd2 1131 }
WiredHome 19:3f82c1161fd2 1132
WiredHome 44:207594dece70 1133
WiredHome 19:3f82c1161fd2 1134 RetCode_t RA8875::background(color_t color)
WiredHome 19:3f82c1161fd2 1135 {
WiredHome 37:f19b7e7449dc 1136 GraphicsDisplay::background(color);
WiredHome 19:3f82c1161fd2 1137 WriteCommand(0x60, (color>>11)); // BGCR0
WiredHome 19:3f82c1161fd2 1138 WriteCommand(0x61, (unsigned char)(color>>5)); // BGCR0
WiredHome 19:3f82c1161fd2 1139 WriteCommand(0x62, (unsigned char)(color)); // BGCR0
WiredHome 19:3f82c1161fd2 1140 return noerror;
WiredHome 19:3f82c1161fd2 1141 }
WiredHome 19:3f82c1161fd2 1142
WiredHome 44:207594dece70 1143
WiredHome 19:3f82c1161fd2 1144 RetCode_t RA8875::background(unsigned char r, unsigned char g, unsigned char b)
WiredHome 19:3f82c1161fd2 1145 {
WiredHome 37:f19b7e7449dc 1146 background(RGB(r,g,b));
WiredHome 37:f19b7e7449dc 1147 // WriteCommand(0x60, r);
WiredHome 37:f19b7e7449dc 1148 // WriteCommand(0x61, g);
WiredHome 37:f19b7e7449dc 1149 // WriteCommand(0x62, b);
WiredHome 19:3f82c1161fd2 1150 return noerror;
WiredHome 19:3f82c1161fd2 1151 }
WiredHome 19:3f82c1161fd2 1152
WiredHome 44:207594dece70 1153
WiredHome 19:3f82c1161fd2 1154 RetCode_t RA8875::foreground(color_t color)
WiredHome 19:3f82c1161fd2 1155 {
WiredHome 37:f19b7e7449dc 1156 GraphicsDisplay::foreground(color);
WiredHome 19:3f82c1161fd2 1157 WriteCommand(0x63, (unsigned char)(color>>11));
WiredHome 19:3f82c1161fd2 1158 WriteCommand(0x64, (unsigned char)(color>>5));
WiredHome 19:3f82c1161fd2 1159 WriteCommand(0x65, (unsigned char)(color));
WiredHome 19:3f82c1161fd2 1160 return noerror;
WiredHome 19:3f82c1161fd2 1161 }
WiredHome 19:3f82c1161fd2 1162
WiredHome 44:207594dece70 1163
WiredHome 37:f19b7e7449dc 1164 RetCode_t RA8875::foreground(unsigned char r, unsigned char g, unsigned char b)
WiredHome 19:3f82c1161fd2 1165 {
WiredHome 37:f19b7e7449dc 1166 foreground(RGB(r,g,b));
WiredHome 37:f19b7e7449dc 1167 // WriteCommand(0x63, r);
WiredHome 37:f19b7e7449dc 1168 // WriteCommand(0x64, g);
WiredHome 37:f19b7e7449dc 1169 // WriteCommand(0x65, b);
WiredHome 19:3f82c1161fd2 1170 return noerror;
WiredHome 19:3f82c1161fd2 1171 }
WiredHome 19:3f82c1161fd2 1172
WiredHome 44:207594dece70 1173
WiredHome 37:f19b7e7449dc 1174 color_t RA8875::GetForeColor(void)
WiredHome 19:3f82c1161fd2 1175 {
WiredHome 19:3f82c1161fd2 1176 color_t color;
WiredHome 19:3f82c1161fd2 1177
WiredHome 19:3f82c1161fd2 1178 color = (ReadCommand(0x63) & 0x1F) << 11;
WiredHome 19:3f82c1161fd2 1179 color |= (ReadCommand(0x64) & 0x3F) << 5;
WiredHome 19:3f82c1161fd2 1180 color |= (ReadCommand(0x65) & 0x1F);
WiredHome 19:3f82c1161fd2 1181 return color;
WiredHome 19:3f82c1161fd2 1182 }
WiredHome 19:3f82c1161fd2 1183
WiredHome 44:207594dece70 1184
WiredHome 19:3f82c1161fd2 1185 color_t RA8875::DOSColor(int i)
WiredHome 19:3f82c1161fd2 1186 {
WiredHome 19:3f82c1161fd2 1187 const color_t colors[16] =
WiredHome 19:3f82c1161fd2 1188 {
WiredHome 19:3f82c1161fd2 1189 Black, Blue, Green, Cyan,
WiredHome 19:3f82c1161fd2 1190 Red, Magenta, Brown, Gray,
WiredHome 19:3f82c1161fd2 1191 Charcoal, BrightBlue, BrightGreen, BrightCyan,
WiredHome 19:3f82c1161fd2 1192 Orange, Pink, Yellow, White
WiredHome 19:3f82c1161fd2 1193 };
WiredHome 19:3f82c1161fd2 1194 if (i < 16)
WiredHome 19:3f82c1161fd2 1195 return colors[i];
WiredHome 19:3f82c1161fd2 1196 else
WiredHome 19:3f82c1161fd2 1197 return 0;
WiredHome 19:3f82c1161fd2 1198 }
WiredHome 19:3f82c1161fd2 1199
WiredHome 44:207594dece70 1200
WiredHome 19:3f82c1161fd2 1201 const char * RA8875::DOSColorNames(int i)
WiredHome 19:3f82c1161fd2 1202 {
WiredHome 19:3f82c1161fd2 1203 const char * names[16] =
WiredHome 19:3f82c1161fd2 1204 {
WiredHome 19:3f82c1161fd2 1205 "Black", "Blue", "Green", "Cyan",
WiredHome 19:3f82c1161fd2 1206 "Red", "Magenta", "Brown", "Gray",
WiredHome 19:3f82c1161fd2 1207 "Charcoal", "BrightBlue", "BrightGreen", "BrightCyan",
WiredHome 19:3f82c1161fd2 1208 "Orange", "Pink", "Yellow", "White"
WiredHome 19:3f82c1161fd2 1209 };
WiredHome 19:3f82c1161fd2 1210 if (i < 16)
WiredHome 19:3f82c1161fd2 1211 return names[i];
WiredHome 19:3f82c1161fd2 1212 else
WiredHome 19:3f82c1161fd2 1213 return NULL;
WiredHome 19:3f82c1161fd2 1214 }
WiredHome 19:3f82c1161fd2 1215
WiredHome 19:3f82c1161fd2 1216
WiredHome 19:3f82c1161fd2 1217 ///////////////////////////////////////////////////////////////
WiredHome 19:3f82c1161fd2 1218 // Private functions
WiredHome 19:3f82c1161fd2 1219
WiredHome 19:3f82c1161fd2 1220 unsigned char RA8875::spiwrite(unsigned char data)
WiredHome 19:3f82c1161fd2 1221 {
WiredHome 19:3f82c1161fd2 1222 unsigned char retval;
WiredHome 19:3f82c1161fd2 1223
WiredHome 19:3f82c1161fd2 1224 retval = spi.write(data);
WiredHome 19:3f82c1161fd2 1225 return retval;
WiredHome 19:3f82c1161fd2 1226 }
WiredHome 19:3f82c1161fd2 1227
WiredHome 44:207594dece70 1228
WiredHome 19:3f82c1161fd2 1229 unsigned char RA8875::spiread(void)
WiredHome 19:3f82c1161fd2 1230 {
WiredHome 19:3f82c1161fd2 1231 unsigned char retval;
WiredHome 19:3f82c1161fd2 1232 unsigned char data = 0;
WiredHome 19:3f82c1161fd2 1233
WiredHome 19:3f82c1161fd2 1234 retval = spi.write(data);
WiredHome 19:3f82c1161fd2 1235 return retval;
WiredHome 19:3f82c1161fd2 1236 }
WiredHome 19:3f82c1161fd2 1237
WiredHome 44:207594dece70 1238
WiredHome 19:3f82c1161fd2 1239 RetCode_t RA8875::select(bool chipsel)
WiredHome 19:3f82c1161fd2 1240 {
WiredHome 19:3f82c1161fd2 1241 cs = (chipsel == true) ? 0 : 1;
WiredHome 19:3f82c1161fd2 1242 return noerror;
WiredHome 19:3f82c1161fd2 1243 }
WiredHome 19:3f82c1161fd2 1244
WiredHome 44:207594dece70 1245
WiredHome 43:3becae133285 1246 RetCode_t RA8875::init(int width, int height, int color_bpp)
WiredHome 19:3f82c1161fd2 1247 {
WiredHome 19:3f82c1161fd2 1248 Backlight_u8(0);
WiredHome 37:f19b7e7449dc 1249 WriteCommand(0x88, 0x0a); // PLLC1 - Phase Lock Loop registers
WiredHome 19:3f82c1161fd2 1250 wait_ms(1);
WiredHome 19:3f82c1161fd2 1251 WriteCommand(0x89, 0x02);
WiredHome 19:3f82c1161fd2 1252 wait_ms(1);
WiredHome 19:3f82c1161fd2 1253
WiredHome 23:a50ded45dbaf 1254 // System Config Register (SYSR)
WiredHome 43:3becae133285 1255 if (color_bpp == 16) {
WiredHome 43:3becae133285 1256 WriteCommand(0x10, 0x0C); // 16-bpp (65K colors) color depth, 8-bit interface
WiredHome 43:3becae133285 1257 } else { // color_bpp == 8
WiredHome 43:3becae133285 1258 WriteCommand(0x10, 0x00); // 8-bpp (256 colors)
WiredHome 43:3becae133285 1259 }
WiredHome 23:a50ded45dbaf 1260 // Pixel Clock Setting Register (PCSR)
WiredHome 37:f19b7e7449dc 1261 WriteCommand(0x04, 0x82); // PDAT on PCLK falling edge, PCLK = 4 x System Clock
WiredHome 19:3f82c1161fd2 1262 wait_ms(1);
WiredHome 19:3f82c1161fd2 1263
WiredHome 19:3f82c1161fd2 1264 // Horizontal Settings
WiredHome 43:3becae133285 1265 WriteCommand(0x14, width/8 - 1); //HDWR//Horizontal Display Width Setting Bit[6:0]
WiredHome 43:3becae133285 1266 WriteCommand(0x15, 0x02); //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0]
WiredHome 43:3becae133285 1267 WriteCommand(0x16, 0x03); //HNDR//Horizontal Non-Display Period Bit[4:0]
WiredHome 43:3becae133285 1268 WriteCommand(0x17, 0x01); //HSTR//HSYNC Start Position[4:0]
WiredHome 43:3becae133285 1269 WriteCommand(0x18, 0x03); //HPWR//HSYNC Polarity ,The period width of HSYNC.
WiredHome 19:3f82c1161fd2 1270
WiredHome 19:3f82c1161fd2 1271 // Vertical Settings
WiredHome 43:3becae133285 1272 WriteCommand(0x19, (height-1)&0xFF); //VDHR0 //Vertical Display Height Bit [7:0]
WiredHome 43:3becae133285 1273 WriteCommand(0x1a, (height-1)>>8); //VDHR1 //Vertical Display Height Bit [8]
WiredHome 43:3becae133285 1274 WriteCommand(0x1b, 0x0F); //VNDR0 //Vertical Non-Display Period Bit [7:0]
WiredHome 43:3becae133285 1275 WriteCommand(0x1c, 0x00); //VNDR1 //Vertical Non-Display Period Bit [8]
WiredHome 43:3becae133285 1276 WriteCommand(0x1d, 0x0e); //VSTR0 //VSYNC Start Position[7:0]
WiredHome 43:3becae133285 1277 WriteCommand(0x1e, 0x06); //VSTR1 //VSYNC Start Position[8]
WiredHome 43:3becae133285 1278 WriteCommand(0x1f, 0x01); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0]
WiredHome 19:3f82c1161fd2 1279
WiredHome 43:3becae133285 1280 if (width >= 800 && height >= 480 && color_bpp > 8) {
WiredHome 43:3becae133285 1281 WriteCommand(0x20, 0x00); // DPCR - 1-layer mode when the resolution is too high
WiredHome 43:3becae133285 1282 } else {
WiredHome 43:3becae133285 1283 WriteCommand(0x20, 0x80); // DPCR - 2-layer mode
WiredHome 43:3becae133285 1284 }
WiredHome 43:3becae133285 1285
WiredHome 50:2c4f474a2453 1286 // Set display image to Blue on Black as default
WiredHome 43:3becae133285 1287 window(0,0, width, height); // Initialize to full screen
WiredHome 24:8ca861acf12d 1288 SetTextCursorControl();
WiredHome 28:ed102fc442c4 1289 foreground(Blue);
WiredHome 19:3f82c1161fd2 1290 background(Black);
WiredHome 50:2c4f474a2453 1291 SelectDrawingLayer(1);
WiredHome 50:2c4f474a2453 1292 cls();
WiredHome 50:2c4f474a2453 1293 SelectDrawingLayer(0);
WiredHome 19:3f82c1161fd2 1294 cls();
WiredHome 19:3f82c1161fd2 1295 return noerror;
WiredHome 19:3f82c1161fd2 1296 }
WiredHome 19:3f82c1161fd2 1297
WiredHome 23:a50ded45dbaf 1298 #ifdef TESTENABLE
WiredHome 23:a50ded45dbaf 1299
WiredHome 37:f19b7e7449dc 1300 #include "Arial12x12.h"
WiredHome 37:f19b7e7449dc 1301 #include "Small_6.h"
WiredHome 37:f19b7e7449dc 1302
WiredHome 23:a50ded45dbaf 1303 // ______________ ______________ ______________ _______________
WiredHome 23:a50ded45dbaf 1304 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 23:a50ded45dbaf 1305 // / / / / / / / /
WiredHome 23:a50ded45dbaf 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 // Everything from here down is test code.
WiredHome 41:2956a0a221e5 1313 bool SuppressSlowStuff = false;
WiredHome 23:a50ded45dbaf 1314
WiredHome 44:207594dece70 1315
WiredHome 49:c5182231d1b9 1316 void TextWrapTest(RA8875 & display, Serial & pc)
WiredHome 49:c5182231d1b9 1317 {
WiredHome 49:c5182231d1b9 1318 if (!SuppressSlowStuff)
WiredHome 49:c5182231d1b9 1319 pc.printf("Text Wrap Test\r\n");
WiredHome 49:c5182231d1b9 1320 display.background(Black);
WiredHome 49:c5182231d1b9 1321 display.foreground(Blue);
WiredHome 49:c5182231d1b9 1322 display.cls();
WiredHome 49:c5182231d1b9 1323 display.Backlight_u8(255);
WiredHome 49:c5182231d1b9 1324 display.puts(0,0, "Text Wrap Test.\r\n");
WiredHome 52:e6039a823420 1325 for (int i=1; i<60; i++) {
WiredHome 52:e6039a823420 1326 display.printf("L%2d\n", i % 17);
WiredHome 49:c5182231d1b9 1327 if (!SuppressSlowStuff)
WiredHome 52:e6039a823420 1328 wait_ms(100);
WiredHome 49:c5182231d1b9 1329 }
WiredHome 49:c5182231d1b9 1330 if (!SuppressSlowStuff)
WiredHome 49:c5182231d1b9 1331 wait_ms(3000);
WiredHome 49:c5182231d1b9 1332 }
WiredHome 49:c5182231d1b9 1333
WiredHome 23:a50ded45dbaf 1334 void TextCursorTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1335 {
WiredHome 37:f19b7e7449dc 1336 const char * iCursor = "The I-Beam cursor should be visible for this text.\r\n";
WiredHome 37:f19b7e7449dc 1337 const char * uCursor = "The Underscore cursor should be visible for this text.\r\n";
WiredHome 37:f19b7e7449dc 1338 const char * bCursor = "The Block cursor should be visible for this text.\r\n";
WiredHome 37:f19b7e7449dc 1339 const char * bbCursor = "The Blinking Block cursor should be visible for this text.\r\n";
WiredHome 23:a50ded45dbaf 1340 const char * p;
WiredHome 41:2956a0a221e5 1341 int delay = 100;
WiredHome 23:a50ded45dbaf 1342
WiredHome 41:2956a0a221e5 1343 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1344 pc.printf("Text Cursor Test\r\n");
WiredHome 41:2956a0a221e5 1345 else
WiredHome 41:2956a0a221e5 1346 delay = 0;
WiredHome 23:a50ded45dbaf 1347 display.background(Black);
WiredHome 23:a50ded45dbaf 1348 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1349 display.cls();
WiredHome 25:9556a3a9b7cc 1350 display.Backlight_u8(255);
WiredHome 23:a50ded45dbaf 1351 display.puts(0,0, "Text Cursor Test.");
WiredHome 23:a50ded45dbaf 1352
WiredHome 23:a50ded45dbaf 1353 // visible, non-blinking
WiredHome 24:8ca861acf12d 1354 display.SetTextCursor(0,20);
WiredHome 53:86d24b9480b9 1355 display.SetTextCursorControl(RA8875::IBEAM, false);
WiredHome 24:8ca861acf12d 1356 p = iCursor;
WiredHome 23:a50ded45dbaf 1357 while (*p) {
WiredHome 24:8ca861acf12d 1358 display._putc(*p++);
WiredHome 41:2956a0a221e5 1359 wait_ms(delay);
WiredHome 24:8ca861acf12d 1360 }
WiredHome 24:8ca861acf12d 1361
WiredHome 53:86d24b9480b9 1362 display.SetTextCursorControl(RA8875::UNDER, false);
WiredHome 24:8ca861acf12d 1363 p = uCursor;
WiredHome 24:8ca861acf12d 1364 while (*p) {
WiredHome 24:8ca861acf12d 1365 display._putc(*p++);
WiredHome 41:2956a0a221e5 1366 wait_ms(delay);
WiredHome 23:a50ded45dbaf 1367 }
WiredHome 24:8ca861acf12d 1368
WiredHome 53:86d24b9480b9 1369 display.SetTextCursorControl(RA8875::BLOCK, false);
WiredHome 24:8ca861acf12d 1370 p = bCursor;
WiredHome 24:8ca861acf12d 1371 while (*p) {
WiredHome 24:8ca861acf12d 1372 display._putc(*p++);
WiredHome 41:2956a0a221e5 1373 wait_ms(delay);
WiredHome 24:8ca861acf12d 1374 }
WiredHome 24:8ca861acf12d 1375
WiredHome 53:86d24b9480b9 1376 display.SetTextCursorControl(RA8875::BLOCK, true);
WiredHome 24:8ca861acf12d 1377 p = bbCursor;
WiredHome 24:8ca861acf12d 1378 while (*p) {
WiredHome 24:8ca861acf12d 1379 display._putc(*p++);
WiredHome 41:2956a0a221e5 1380 wait_ms(delay);
WiredHome 24:8ca861acf12d 1381 }
WiredHome 41:2956a0a221e5 1382 wait_ms(delay * 20);
WiredHome 53:86d24b9480b9 1383 display.SetTextCursorControl(RA8875::NOCURSOR, false);
WiredHome 23:a50ded45dbaf 1384 }
WiredHome 23:a50ded45dbaf 1385
WiredHome 44:207594dece70 1386
WiredHome 23:a50ded45dbaf 1387 void BacklightTest(RA8875 & display, Serial & pc, float ramptime)
WiredHome 23:a50ded45dbaf 1388 {
WiredHome 29:422616aa04bd 1389 char buf[60];
WiredHome 41:2956a0a221e5 1390 unsigned int w = (ramptime * 1000)/ 256;
WiredHome 41:2956a0a221e5 1391 int delay = 200;
WiredHome 41:2956a0a221e5 1392
WiredHome 41:2956a0a221e5 1393 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1394 pc.printf("Backlight Test - ramp over %f sec.\r\n", ramptime);
WiredHome 41:2956a0a221e5 1395 else {
WiredHome 41:2956a0a221e5 1396 delay = 0;
WiredHome 41:2956a0a221e5 1397 w = 0;
WiredHome 41:2956a0a221e5 1398 }
WiredHome 23:a50ded45dbaf 1399 display.Backlight_u8(0);
WiredHome 29:422616aa04bd 1400 display.background(White);
WiredHome 23:a50ded45dbaf 1401 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1402 display.cls();
WiredHome 41:2956a0a221e5 1403 wait_ms(delay);
WiredHome 23:a50ded45dbaf 1404 display.puts(0,0, "RA8875 Backlight Test - Ramp up.");
WiredHome 38:38d503b4fad6 1405 for (int i=0; i <= 255; i++) {
WiredHome 29:422616aa04bd 1406 sprintf(buf, "%3d, %4d", i, w);
WiredHome 37:f19b7e7449dc 1407 display.puts(100,100,buf);
WiredHome 23:a50ded45dbaf 1408 display.Backlight_u8(i);
WiredHome 29:422616aa04bd 1409 wait_ms(w);
WiredHome 23:a50ded45dbaf 1410 }
WiredHome 23:a50ded45dbaf 1411 }
WiredHome 23:a50ded45dbaf 1412
WiredHome 44:207594dece70 1413
WiredHome 23:a50ded45dbaf 1414 void BacklightTest2(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1415 {
WiredHome 41:2956a0a221e5 1416 int delay = 20;
WiredHome 41:2956a0a221e5 1417
WiredHome 41:2956a0a221e5 1418 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1419 pc.printf("Backlight Test 2\r\n");
WiredHome 41:2956a0a221e5 1420 else
WiredHome 41:2956a0a221e5 1421 delay = 0;
WiredHome 41:2956a0a221e5 1422
WiredHome 23:a50ded45dbaf 1423 // Dim it out at the end of the tests.
WiredHome 37:f19b7e7449dc 1424 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1425 display.puts(0,0, "Ramp Backlight down.");
WiredHome 23:a50ded45dbaf 1426 // Ramp it off
WiredHome 23:a50ded45dbaf 1427 for (int i=255; i != 0; i--) {
WiredHome 23:a50ded45dbaf 1428 display.Backlight_u8(i);
WiredHome 41:2956a0a221e5 1429 wait_ms(delay);
WiredHome 23:a50ded45dbaf 1430 }
WiredHome 23:a50ded45dbaf 1431 display.Backlight_u8(0);
WiredHome 23:a50ded45dbaf 1432 }
WiredHome 23:a50ded45dbaf 1433
WiredHome 44:207594dece70 1434
WiredHome 23:a50ded45dbaf 1435 void ExternalFontTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1436 {
WiredHome 41:2956a0a221e5 1437 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1438 pc.printf("External Font Test\r\n");
WiredHome 23:a50ded45dbaf 1439 display.background(Black);
WiredHome 23:a50ded45dbaf 1440 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1441 display.cls();
WiredHome 23:a50ded45dbaf 1442 display.Backlight(1);
WiredHome 37:f19b7e7449dc 1443 display.puts(0,0, "External Font Test.");
WiredHome 37:f19b7e7449dc 1444
WiredHome 37:f19b7e7449dc 1445 display.set_font(Small_6);
WiredHome 37:f19b7e7449dc 1446 display.puts(0,30, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n");
WiredHome 37:f19b7e7449dc 1447
WiredHome 23:a50ded45dbaf 1448 display.set_font(Arial12x12);
WiredHome 37:f19b7e7449dc 1449 display.puts("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n");
WiredHome 37:f19b7e7449dc 1450 display.set_font(); // restore to internal
WiredHome 37:f19b7e7449dc 1451
WiredHome 37:f19b7e7449dc 1452 display.puts("Normal font again.");
WiredHome 37:f19b7e7449dc 1453 //display.window(0,0, display.width(), display.height());
WiredHome 23:a50ded45dbaf 1454 }
WiredHome 23:a50ded45dbaf 1455
WiredHome 44:207594dece70 1456
WiredHome 23:a50ded45dbaf 1457 void DOSColorTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1458 {
WiredHome 41:2956a0a221e5 1459 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1460 pc.printf("DOS Color Test\r\n");
WiredHome 23:a50ded45dbaf 1461 display.background(Black);
WiredHome 23:a50ded45dbaf 1462 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1463 display.cls();
WiredHome 23:a50ded45dbaf 1464 display.puts(0,0, "DOS Colors - Fore");
WiredHome 23:a50ded45dbaf 1465 display.puts(280,0, "Back");
WiredHome 23:a50ded45dbaf 1466 display.background(Gray);
WiredHome 23:a50ded45dbaf 1467 for (int i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1468 display.foreground(display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1469 display.puts(160, i*16, display.DOSColorNames(i));
WiredHome 23:a50ded45dbaf 1470 display.background(Black);
WiredHome 23:a50ded45dbaf 1471 }
WiredHome 23:a50ded45dbaf 1472 display.foreground(White);
WiredHome 23:a50ded45dbaf 1473 for (int i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1474 display.background(display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1475 display.puts(360, i*16, display.DOSColorNames(i));
WiredHome 23:a50ded45dbaf 1476 display.foreground(White);
WiredHome 23:a50ded45dbaf 1477 }
WiredHome 23:a50ded45dbaf 1478 }
WiredHome 23:a50ded45dbaf 1479
WiredHome 44:207594dece70 1480
WiredHome 23:a50ded45dbaf 1481 void WebColorTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1482 {
WiredHome 41:2956a0a221e5 1483 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1484 pc.printf("Web Color Test\r\n");
WiredHome 23:a50ded45dbaf 1485 display.background(Black);
WiredHome 23:a50ded45dbaf 1486 display.foreground(Blue);
WiredHome 32:0e4f2ae512e2 1487 display.window(0,0, display.width(), display.height());
WiredHome 23:a50ded45dbaf 1488 display.cls();
WiredHome 23:a50ded45dbaf 1489 display.puts(0,0, "Web Color Test\r\n");
WiredHome 23:a50ded45dbaf 1490 display.SetTextFontSize(1,2);
WiredHome 23:a50ded45dbaf 1491 for (int i=0; i<sizeof(WebColors)/sizeof(WebColors[0]); i++) {
WiredHome 23:a50ded45dbaf 1492 display.background(WebColors[i]);
WiredHome 23:a50ded45dbaf 1493 display.puts(" ");
WiredHome 23:a50ded45dbaf 1494 if (i % 36 == 35)
WiredHome 23:a50ded45dbaf 1495 display.puts("\r\n");
WiredHome 23:a50ded45dbaf 1496 }
WiredHome 23:a50ded45dbaf 1497 display.SetTextFontSize(1,1);
WiredHome 23:a50ded45dbaf 1498 }
WiredHome 23:a50ded45dbaf 1499
WiredHome 44:207594dece70 1500
WiredHome 37:f19b7e7449dc 1501 void PixelTest(RA8875 & display, Serial & pc)
WiredHome 37:f19b7e7449dc 1502 {
WiredHome 37:f19b7e7449dc 1503 int i, c, x, y;
WiredHome 37:f19b7e7449dc 1504
WiredHome 41:2956a0a221e5 1505 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1506 pc.printf("Pixel Test\r\n");
WiredHome 37:f19b7e7449dc 1507 display.background(Black);
WiredHome 37:f19b7e7449dc 1508 display.foreground(Blue);
WiredHome 37:f19b7e7449dc 1509 display.cls();
WiredHome 37:f19b7e7449dc 1510 display.puts(0,0, "Pixel Test");
WiredHome 37:f19b7e7449dc 1511 for (i=0; i<1000; i++) {
WiredHome 37:f19b7e7449dc 1512 x = rand() % 480;
WiredHome 37:f19b7e7449dc 1513 y = 16 + rand() % (272-16);
WiredHome 37:f19b7e7449dc 1514 c = rand() % 16;
WiredHome 37:f19b7e7449dc 1515 //pc.printf(" (%d,%d) - %d\r\n", x,y,r1);
WiredHome 37:f19b7e7449dc 1516 display.pixel(x,y, display.DOSColor(c));
WiredHome 37:f19b7e7449dc 1517 }
WiredHome 37:f19b7e7449dc 1518 }
WiredHome 37:f19b7e7449dc 1519
WiredHome 44:207594dece70 1520
WiredHome 23:a50ded45dbaf 1521 void LineTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1522 {
WiredHome 23:a50ded45dbaf 1523 int i, x, y, x2, y2;
WiredHome 23:a50ded45dbaf 1524
WiredHome 41:2956a0a221e5 1525 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1526 pc.printf("Line Test\r\n");
WiredHome 23:a50ded45dbaf 1527 display.background(Black);
WiredHome 23:a50ded45dbaf 1528 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1529 display.cls();
WiredHome 23:a50ded45dbaf 1530 display.puts(0,0, "Line Test");
WiredHome 23:a50ded45dbaf 1531 for (i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1532 // Lines
WiredHome 23:a50ded45dbaf 1533 x = rand() % 480;
WiredHome 23:a50ded45dbaf 1534 y = rand() % 272;
WiredHome 23:a50ded45dbaf 1535 x2 = rand() % 480;
WiredHome 23:a50ded45dbaf 1536 y2 = rand() % 272;
WiredHome 23:a50ded45dbaf 1537 display.line(x,y, x2,y2, display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1538 }
WiredHome 23:a50ded45dbaf 1539 }
WiredHome 23:a50ded45dbaf 1540
WiredHome 44:207594dece70 1541
WiredHome 23:a50ded45dbaf 1542 void RectangleTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1543 {
WiredHome 23:a50ded45dbaf 1544 int i, x1,y1, x2,y2;
WiredHome 23:a50ded45dbaf 1545
WiredHome 41:2956a0a221e5 1546 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1547 pc.printf("Rectangle Test\r\n");
WiredHome 23:a50ded45dbaf 1548 display.background(Black);
WiredHome 23:a50ded45dbaf 1549 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1550 display.cls();
WiredHome 23:a50ded45dbaf 1551 display.puts(0,0, "Rectangle Test");
WiredHome 23:a50ded45dbaf 1552 for (i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1553 x1 = rand() % 240;
WiredHome 23:a50ded45dbaf 1554 y1 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1555 x2 = rand() % 240;
WiredHome 23:a50ded45dbaf 1556 y2 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1557 display.rect(x1,y1, x2,y2, display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1558
WiredHome 23:a50ded45dbaf 1559 x1 = 240 + rand() % 240;
WiredHome 23:a50ded45dbaf 1560 y1 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1561 x2 = 240 + rand() % 240;
WiredHome 23:a50ded45dbaf 1562 y2 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1563 display.rect(x1,y1, x2,y2, FILL);
WiredHome 23:a50ded45dbaf 1564 }
WiredHome 23:a50ded45dbaf 1565 }
WiredHome 23:a50ded45dbaf 1566
WiredHome 44:207594dece70 1567
WiredHome 44:207594dece70 1568 void LayerTest(RA8875 & display, Serial & pc)
WiredHome 44:207594dece70 1569 {
WiredHome 44:207594dece70 1570 loc_t i, x1,y1, x2,y2, r1,r2;
WiredHome 44:207594dece70 1571
WiredHome 44:207594dece70 1572 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1573 pc.printf("Layer Test\r\n");
WiredHome 44:207594dece70 1574
WiredHome 50:2c4f474a2453 1575 display.SelectDrawingLayer(0);
WiredHome 44:207594dece70 1576 display.background(Black);
WiredHome 44:207594dece70 1577 display.foreground(Blue);
WiredHome 44:207594dece70 1578 display.cls();
WiredHome 44:207594dece70 1579 display.puts(0,0, "Layer 0");
WiredHome 44:207594dece70 1580 for (i=0; i<16; i++) {
WiredHome 44:207594dece70 1581 x1 = rand() % 240;
WiredHome 44:207594dece70 1582 y1 = 50 + rand() % 200;
WiredHome 44:207594dece70 1583 x2 = x1 + rand() % 100;
WiredHome 44:207594dece70 1584 y2 = y1 + rand() % 100;
WiredHome 44:207594dece70 1585 r1 = rand() % (x2 - x1)/2;
WiredHome 44:207594dece70 1586 r2 = rand() % (y2 - y1)/2;
WiredHome 44:207594dece70 1587 display.roundrect(x1,y1, x2,y2, r1,r2, display.DOSColor(i));
WiredHome 44:207594dece70 1588 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1589 wait_ms(20);
WiredHome 44:207594dece70 1590 }
WiredHome 44:207594dece70 1591 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1592 wait_ms(1000);
WiredHome 44:207594dece70 1593
WiredHome 50:2c4f474a2453 1594 display.SelectDrawingLayer(1);
WiredHome 44:207594dece70 1595 display.background(Black);
WiredHome 44:207594dece70 1596 display.foreground(Yellow);
WiredHome 44:207594dece70 1597 display.cls();
WiredHome 44:207594dece70 1598 display.puts(240,0, "Layer 1");
WiredHome 44:207594dece70 1599 for (i=0; i<16; i++) {
WiredHome 44:207594dece70 1600 x1 = 300 + rand() % 100;
WiredHome 44:207594dece70 1601 y1 = 70 + rand() % 200;
WiredHome 44:207594dece70 1602 r1 = rand() % min(y1 - 20, 100);
WiredHome 44:207594dece70 1603 display.circle(x1,y1,r1, display.DOSColor(i));
WiredHome 44:207594dece70 1604 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1605 wait_ms(20);
WiredHome 44:207594dece70 1606 }
WiredHome 53:86d24b9480b9 1607 display.SetLayerMode(RA8875::OnlyLayer2); // Show it after the build-up
WiredHome 44:207594dece70 1608 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1609 wait_ms(2000);
WiredHome 44:207594dece70 1610
WiredHome 50:2c4f474a2453 1611 display.SelectDrawingLayer(0);
WiredHome 53:86d24b9480b9 1612 display.SetLayerMode(RA8875::OnlyLayer1); // Show Layer 0 again
WiredHome 44:207594dece70 1613 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1614 wait_ms(1000);
WiredHome 53:86d24b9480b9 1615 display.SetLayerMode(RA8875::TransparentMode); // Transparent mode
WiredHome 44:207594dece70 1616 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1617 wait_ms(1000);
WiredHome 44:207594dece70 1618 for (i=0; i<=8; i++) {
WiredHome 44:207594dece70 1619 display.SetLayerTransparency(i, 8-i);
WiredHome 44:207594dece70 1620 if (!SuppressSlowStuff)
WiredHome 44:207594dece70 1621 wait_ms(200);
WiredHome 44:207594dece70 1622 }
WiredHome 44:207594dece70 1623
WiredHome 44:207594dece70 1624 // Restore before we exit
WiredHome 44:207594dece70 1625 display.SetLayerTransparency(0, 0);
WiredHome 53:86d24b9480b9 1626 display.SetLayerMode(RA8875::OnlyLayer1); // Restore to layer 0
WiredHome 44:207594dece70 1627 }
WiredHome 44:207594dece70 1628
WiredHome 44:207594dece70 1629
WiredHome 23:a50ded45dbaf 1630 void RoundRectTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1631 {
WiredHome 37:f19b7e7449dc 1632 loc_t i, x1,y1, x2,y2, r1,r2;
WiredHome 23:a50ded45dbaf 1633
WiredHome 41:2956a0a221e5 1634 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1635 pc.printf("Round Rectangle Test\r\n");
WiredHome 23:a50ded45dbaf 1636 display.background(Black);
WiredHome 23:a50ded45dbaf 1637 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1638 display.cls();
WiredHome 23:a50ded45dbaf 1639 display.puts(0,0, "Rounded Rectangle Test");
WiredHome 23:a50ded45dbaf 1640
WiredHome 23:a50ded45dbaf 1641 for (i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1642 x1 = rand() % 240;
WiredHome 23:a50ded45dbaf 1643 y1 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1644 x2 = x1 + rand() % 100;
WiredHome 23:a50ded45dbaf 1645 y2 = y1 + rand() % 100;
WiredHome 23:a50ded45dbaf 1646 r1 = rand() % (x2 - x1)/2;
WiredHome 23:a50ded45dbaf 1647 r2 = rand() % (y2 - y1)/2;
WiredHome 23:a50ded45dbaf 1648 display.roundrect(x1,y1, x2,y2, 5,8, display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1649
WiredHome 23:a50ded45dbaf 1650 x1 = 240 + rand() % 240;
WiredHome 23:a50ded45dbaf 1651 y1 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1652 x2 = x1 + rand() % 100;
WiredHome 23:a50ded45dbaf 1653 y2 = y1 + rand() % 100;
WiredHome 23:a50ded45dbaf 1654 r1 = rand() % (x2 - x1)/2;
WiredHome 23:a50ded45dbaf 1655 r2 = rand() % (y2 - y1)/2;
WiredHome 23:a50ded45dbaf 1656 display.roundrect(x1,y1, x2,y2, r1,r2, FILL);
WiredHome 23:a50ded45dbaf 1657 }
WiredHome 23:a50ded45dbaf 1658 }
WiredHome 23:a50ded45dbaf 1659
WiredHome 44:207594dece70 1660
WiredHome 23:a50ded45dbaf 1661 void TriangleTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1662 {
WiredHome 23:a50ded45dbaf 1663 int i, x1, y1, x2, y2, x3, y3;
WiredHome 23:a50ded45dbaf 1664
WiredHome 41:2956a0a221e5 1665 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1666 pc.printf("Triangle Test\r\n");
WiredHome 23:a50ded45dbaf 1667 display.background(Black);
WiredHome 23:a50ded45dbaf 1668 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1669 display.cls();
WiredHome 23:a50ded45dbaf 1670 display.puts(0,0, "Triangle Test");
WiredHome 23:a50ded45dbaf 1671
WiredHome 23:a50ded45dbaf 1672 x1 = 150;
WiredHome 23:a50ded45dbaf 1673 y1 = 2;
WiredHome 23:a50ded45dbaf 1674 x2 = 190;
WiredHome 23:a50ded45dbaf 1675 y2 = 7;
WiredHome 23:a50ded45dbaf 1676 x3 = 170;
WiredHome 23:a50ded45dbaf 1677 y3 = 16;
WiredHome 23:a50ded45dbaf 1678 display.triangle(x1,y1, x2,y2, x3,y3);
WiredHome 23:a50ded45dbaf 1679
WiredHome 23:a50ded45dbaf 1680 x1 = 200;
WiredHome 23:a50ded45dbaf 1681 y1 = 2;
WiredHome 23:a50ded45dbaf 1682 x2 = 240;
WiredHome 23:a50ded45dbaf 1683 y2 = 7;
WiredHome 23:a50ded45dbaf 1684 x3 = 220;
WiredHome 23:a50ded45dbaf 1685 y3 = 16;
WiredHome 23:a50ded45dbaf 1686 display.filltriangle(x1,y1, x2,y2, x3,y3, BrightRed);
WiredHome 23:a50ded45dbaf 1687
WiredHome 23:a50ded45dbaf 1688 x1 = 300;
WiredHome 23:a50ded45dbaf 1689 y1 = 2;
WiredHome 23:a50ded45dbaf 1690 x2 = 340;
WiredHome 23:a50ded45dbaf 1691 y2 = 7;
WiredHome 23:a50ded45dbaf 1692 x3 = 320;
WiredHome 23:a50ded45dbaf 1693 y3 = 16;
WiredHome 23:a50ded45dbaf 1694 display.triangle(x1,y1, x2,y2, x3,y3, NOFILL);
WiredHome 23:a50ded45dbaf 1695
WiredHome 23:a50ded45dbaf 1696 x1 = 400;
WiredHome 23:a50ded45dbaf 1697 y1 = 2;
WiredHome 23:a50ded45dbaf 1698 x2 = 440;
WiredHome 23:a50ded45dbaf 1699 y2 = 7;
WiredHome 23:a50ded45dbaf 1700 x3 = 420;
WiredHome 23:a50ded45dbaf 1701 y3 = 16;
WiredHome 23:a50ded45dbaf 1702 display.triangle(x1,y1, x2,y2, x3,y3, Blue);
WiredHome 23:a50ded45dbaf 1703
WiredHome 23:a50ded45dbaf 1704 for (i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1705 x1 = rand() % 240;
WiredHome 23:a50ded45dbaf 1706 y1 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1707 x2 = rand() % 240;
WiredHome 23:a50ded45dbaf 1708 y2 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1709 x3 = rand() % 240;
WiredHome 23:a50ded45dbaf 1710 y3 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1711 display.triangle(x1,y1, x2,y2, x3,y3, display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1712 x1 = 240 + rand() % 240;
WiredHome 23:a50ded45dbaf 1713 y1 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1714 x2 = 240 + rand() % 240;
WiredHome 23:a50ded45dbaf 1715 y2 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1716 x3 = 240 + rand() % 240;
WiredHome 23:a50ded45dbaf 1717 y3 = 50 + rand() % 200;
WiredHome 23:a50ded45dbaf 1718 display.triangle(x1,y1, x2,y2, x3,y3, FILL);
WiredHome 23:a50ded45dbaf 1719 }
WiredHome 23:a50ded45dbaf 1720 }
WiredHome 23:a50ded45dbaf 1721
WiredHome 44:207594dece70 1722
WiredHome 23:a50ded45dbaf 1723 void CircleTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1724 {
WiredHome 23:a50ded45dbaf 1725 int i, x, y, r1;
WiredHome 23:a50ded45dbaf 1726
WiredHome 41:2956a0a221e5 1727 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1728 pc.printf("Circle Test\r\n");
WiredHome 23:a50ded45dbaf 1729 display.background(Black);
WiredHome 23:a50ded45dbaf 1730 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1731 display.cls();
WiredHome 23:a50ded45dbaf 1732 display.puts(0,0, "Circle Test");
WiredHome 23:a50ded45dbaf 1733 for (i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1734 x = 100 + rand() % 100;
WiredHome 23:a50ded45dbaf 1735 y = 70 + rand() % 200;
WiredHome 23:a50ded45dbaf 1736 r1 = rand() % min(y - 20, 100);
WiredHome 23:a50ded45dbaf 1737 //pc.printf(" (%d,%d) - %d\r\n", x,y,r1);
WiredHome 23:a50ded45dbaf 1738 display.circle(x,y,r1, display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1739
WiredHome 23:a50ded45dbaf 1740 x = 300 + rand() % 100;
WiredHome 23:a50ded45dbaf 1741 y = 70 + rand() % 200;
WiredHome 23:a50ded45dbaf 1742 r1 = rand() % min(y - 20, 100);
WiredHome 23:a50ded45dbaf 1743 //pc.printf(" (%d,%d) - %d FILL\r\n", x,y,r1);
WiredHome 23:a50ded45dbaf 1744 display.circle(x,y,r1, display.DOSColor(i), FILL);
WiredHome 23:a50ded45dbaf 1745 }
WiredHome 23:a50ded45dbaf 1746 }
WiredHome 23:a50ded45dbaf 1747
WiredHome 44:207594dece70 1748
WiredHome 23:a50ded45dbaf 1749 void EllipseTest(RA8875 & display, Serial & pc)
WiredHome 23:a50ded45dbaf 1750 {
WiredHome 23:a50ded45dbaf 1751 int i,x,y,r1,r2;
WiredHome 23:a50ded45dbaf 1752
WiredHome 41:2956a0a221e5 1753 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1754 pc.printf("Ellipse Test\r\n");
WiredHome 23:a50ded45dbaf 1755 display.background(Black);
WiredHome 23:a50ded45dbaf 1756 display.foreground(Blue);
WiredHome 23:a50ded45dbaf 1757 display.cls();
WiredHome 23:a50ded45dbaf 1758 display.puts(0,0, "Ellipse Test");
WiredHome 23:a50ded45dbaf 1759 for (i=0; i<16; i++) {
WiredHome 23:a50ded45dbaf 1760 x = 100 + rand() % 100;
WiredHome 23:a50ded45dbaf 1761 y = 70 + rand() % 200;
WiredHome 23:a50ded45dbaf 1762 r1 = rand() % min(y - 20, 100);
WiredHome 23:a50ded45dbaf 1763 r2 = rand() % min(y - 20, 100);
WiredHome 23:a50ded45dbaf 1764 display.ellipse(x,y,r1,r2, display.DOSColor(i));
WiredHome 23:a50ded45dbaf 1765
WiredHome 23:a50ded45dbaf 1766 x = 300 + rand() % 100;
WiredHome 23:a50ded45dbaf 1767 y = 70 + rand() % 200;
WiredHome 23:a50ded45dbaf 1768 r1 = rand() % min(y - 20, 100);
WiredHome 23:a50ded45dbaf 1769 r2 = rand() % min(y - 20, 100);
WiredHome 23:a50ded45dbaf 1770 display.ellipse(x,y,r1,r2, FILL);
WiredHome 23:a50ded45dbaf 1771 }
WiredHome 23:a50ded45dbaf 1772 }
WiredHome 23:a50ded45dbaf 1773
WiredHome 44:207594dece70 1774
WiredHome 37:f19b7e7449dc 1775 void TestGraphicsBitmap(RA8875 & display, Serial & pc)
WiredHome 37:f19b7e7449dc 1776 {
WiredHome 37:f19b7e7449dc 1777 LocalFileSystem local("local");
WiredHome 41:2956a0a221e5 1778 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1779 pc.printf("Bitmap File Load\r\n");
WiredHome 37:f19b7e7449dc 1780 display.background(Black);
WiredHome 37:f19b7e7449dc 1781 display.foreground(Blue);
WiredHome 37:f19b7e7449dc 1782 display.cls();
WiredHome 37:f19b7e7449dc 1783 display.puts(0,0, "Graphics Test, loading /local/TestPat.bmp");
WiredHome 37:f19b7e7449dc 1784 wait(3);
WiredHome 37:f19b7e7449dc 1785
WiredHome 37:f19b7e7449dc 1786 int r = display.RenderBitmapFile(0,0, "/local/TestPat.bmp");
WiredHome 37:f19b7e7449dc 1787 }
WiredHome 37:f19b7e7449dc 1788
WiredHome 44:207594dece70 1789
WiredHome 41:2956a0a221e5 1790 void SpeedTest(RA8875 & display, Serial & pc)
WiredHome 41:2956a0a221e5 1791 {
WiredHome 41:2956a0a221e5 1792 Timer t;
WiredHome 41:2956a0a221e5 1793 SuppressSlowStuff = true;
WiredHome 41:2956a0a221e5 1794 pc.printf("\r\nSpeedTest disables delays, runs tests, reports overall time.\r\n");
WiredHome 41:2956a0a221e5 1795 t.start();
WiredHome 41:2956a0a221e5 1796 // do stuff fast
WiredHome 41:2956a0a221e5 1797 TextCursorTest(display, pc);
WiredHome 49:c5182231d1b9 1798 TextWrapTest(display, pc);
WiredHome 41:2956a0a221e5 1799 BacklightTest(display, pc, 0);
WiredHome 41:2956a0a221e5 1800 BacklightTest2(display, pc);
WiredHome 41:2956a0a221e5 1801 ExternalFontTest(display, pc);
WiredHome 41:2956a0a221e5 1802 DOSColorTest(display, pc);
WiredHome 41:2956a0a221e5 1803 WebColorTest(display, pc);
WiredHome 41:2956a0a221e5 1804 PixelTest(display, pc);
WiredHome 41:2956a0a221e5 1805 LineTest(display, pc);
WiredHome 41:2956a0a221e5 1806 RectangleTest(display, pc);
WiredHome 41:2956a0a221e5 1807 RoundRectTest(display, pc);
WiredHome 41:2956a0a221e5 1808 TriangleTest(display, pc);
WiredHome 41:2956a0a221e5 1809 CircleTest(display, pc);
WiredHome 41:2956a0a221e5 1810 EllipseTest(display, pc);
WiredHome 44:207594dece70 1811 LayerTest(display, pc);
WiredHome 41:2956a0a221e5 1812 //TestGraphicsBitmap(display, pc);
WiredHome 41:2956a0a221e5 1813 pc.printf("SpeedTest completed in %d msec\r\n", t.read_ms());
WiredHome 44:207594dece70 1814 #ifdef PERF_METRICS
WiredHome 41:2956a0a221e5 1815 display.ReportPerformance(pc);
WiredHome 41:2956a0a221e5 1816 #endif
WiredHome 41:2956a0a221e5 1817 SuppressSlowStuff = false;
WiredHome 41:2956a0a221e5 1818 }
WiredHome 41:2956a0a221e5 1819
WiredHome 44:207594dece70 1820
WiredHome 41:2956a0a221e5 1821 void PrintScreen(RA8875 & display, Serial & pc)
WiredHome 41:2956a0a221e5 1822 {
WiredHome 41:2956a0a221e5 1823 LocalFileSystem local("local");
WiredHome 41:2956a0a221e5 1824 if (!SuppressSlowStuff)
WiredHome 41:2956a0a221e5 1825 pc.printf("PrintScreen\r\n");
WiredHome 41:2956a0a221e5 1826 display.PrintScreen( 0,0, 480,272, "/local/Capture.bmp");
WiredHome 41:2956a0a221e5 1827 }
WiredHome 41:2956a0a221e5 1828
WiredHome 44:207594dece70 1829
WiredHome 23:a50ded45dbaf 1830 void RunTestSet(RA8875 & lcd, Serial & pc)
WiredHome 23:a50ded45dbaf 1831 {
WiredHome 23:a50ded45dbaf 1832 int q = 0;
WiredHome 23:a50ded45dbaf 1833 int automode = 0;
WiredHome 49:c5182231d1b9 1834 const unsigned char modelist[] = "BDWtGLlFROTPCEbw"; // auto-test in this order.
WiredHome 23:a50ded45dbaf 1835
WiredHome 23:a50ded45dbaf 1836 while(1) {
WiredHome 23:a50ded45dbaf 1837 pc.printf("\r\n"
WiredHome 41:2956a0a221e5 1838 "B - Backlight up b - backlight dim\r\n"
WiredHome 41:2956a0a221e5 1839 "D - DOS Colors W - Web Colors\r\n"
WiredHome 41:2956a0a221e5 1840 "t - text cursor G - Graphics Bitmap\r\n"
WiredHome 41:2956a0a221e5 1841 "L - Lines F - external Font\r\n"
WiredHome 41:2956a0a221e5 1842 "R - Rectangles O - rOund rectangles\r\n"
WiredHome 41:2956a0a221e5 1843 "T - Triangles P - Pixels \r\n"
WiredHome 41:2956a0a221e5 1844 "C - Circles E - Ellipses\r\n"
WiredHome 41:2956a0a221e5 1845 "A - Auto Test mode S - Speed Test\r\n"
WiredHome 41:2956a0a221e5 1846 "p - print screen r - reset \r\n"
WiredHome 49:c5182231d1b9 1847 "l - layer test w - wrapping text \r\n"
WiredHome 41:2956a0a221e5 1848 #ifdef DEBUG
WiredHome 41:2956a0a221e5 1849 "0 - clear performance 1 - report performance\r\n"
WiredHome 41:2956a0a221e5 1850 #endif
WiredHome 23:a50ded45dbaf 1851 "> ");
WiredHome 23:a50ded45dbaf 1852 if (automode == -1 || pc.readable()) {
WiredHome 23:a50ded45dbaf 1853 automode = -1;
WiredHome 37:f19b7e7449dc 1854 q = pc.getc();
WiredHome 37:f19b7e7449dc 1855 while (pc.readable())
WiredHome 37:f19b7e7449dc 1856 pc.getc();
WiredHome 23:a50ded45dbaf 1857 } else if (automode >= 0) {
WiredHome 23:a50ded45dbaf 1858 q = modelist[automode];
WiredHome 23:a50ded45dbaf 1859 }
WiredHome 23:a50ded45dbaf 1860 switch(q) {
WiredHome 41:2956a0a221e5 1861 #ifdef DEBUG
WiredHome 41:2956a0a221e5 1862 case '0':
WiredHome 41:2956a0a221e5 1863 lcd.ClearPerformance();
WiredHome 41:2956a0a221e5 1864 break;
WiredHome 41:2956a0a221e5 1865 case '1':
WiredHome 41:2956a0a221e5 1866 lcd.ReportPerformance(pc);
WiredHome 41:2956a0a221e5 1867 break;
WiredHome 41:2956a0a221e5 1868 #endif
WiredHome 23:a50ded45dbaf 1869 case 'A':
WiredHome 23:a50ded45dbaf 1870 automode = 0;
WiredHome 23:a50ded45dbaf 1871 break;
WiredHome 23:a50ded45dbaf 1872 case 'B':
WiredHome 41:2956a0a221e5 1873 BacklightTest(lcd, pc, 2);
WiredHome 23:a50ded45dbaf 1874 break;
WiredHome 23:a50ded45dbaf 1875 case 'b':
WiredHome 23:a50ded45dbaf 1876 BacklightTest2(lcd, pc);
WiredHome 23:a50ded45dbaf 1877 break;
WiredHome 23:a50ded45dbaf 1878 case 'D':
WiredHome 23:a50ded45dbaf 1879 DOSColorTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1880 break;
WiredHome 23:a50ded45dbaf 1881 case 'W':
WiredHome 23:a50ded45dbaf 1882 WebColorTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1883 break;
WiredHome 23:a50ded45dbaf 1884 case 't':
WiredHome 23:a50ded45dbaf 1885 TextCursorTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1886 break;
WiredHome 49:c5182231d1b9 1887 case 'w':
WiredHome 49:c5182231d1b9 1888 TextWrapTest(lcd, pc);
WiredHome 49:c5182231d1b9 1889 break;
WiredHome 23:a50ded45dbaf 1890 case 'F':
WiredHome 23:a50ded45dbaf 1891 ExternalFontTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1892 break;
WiredHome 23:a50ded45dbaf 1893 case 'L':
WiredHome 23:a50ded45dbaf 1894 LineTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1895 break;
WiredHome 44:207594dece70 1896 case 'l':
WiredHome 44:207594dece70 1897 LayerTest(lcd, pc);
WiredHome 44:207594dece70 1898 break;
WiredHome 23:a50ded45dbaf 1899 case 'R':
WiredHome 23:a50ded45dbaf 1900 RectangleTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1901 break;
WiredHome 23:a50ded45dbaf 1902 case 'O':
WiredHome 23:a50ded45dbaf 1903 RoundRectTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1904 break;
WiredHome 41:2956a0a221e5 1905 case 'p':
WiredHome 41:2956a0a221e5 1906 PrintScreen(lcd, pc);
WiredHome 41:2956a0a221e5 1907 break;
WiredHome 41:2956a0a221e5 1908 case 'S':
WiredHome 41:2956a0a221e5 1909 SpeedTest(lcd, pc);
WiredHome 41:2956a0a221e5 1910 break;
WiredHome 23:a50ded45dbaf 1911 case 'T':
WiredHome 23:a50ded45dbaf 1912 TriangleTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1913 break;
WiredHome 37:f19b7e7449dc 1914 case 'P':
WiredHome 37:f19b7e7449dc 1915 PixelTest(lcd, pc);
WiredHome 37:f19b7e7449dc 1916 break;
WiredHome 37:f19b7e7449dc 1917 case 'G':
WiredHome 37:f19b7e7449dc 1918 TestGraphicsBitmap(lcd, pc);
WiredHome 37:f19b7e7449dc 1919 break;
WiredHome 23:a50ded45dbaf 1920 case 'C':
WiredHome 23:a50ded45dbaf 1921 CircleTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1922 break;
WiredHome 23:a50ded45dbaf 1923 case 'E':
WiredHome 23:a50ded45dbaf 1924 EllipseTest(lcd, pc);
WiredHome 23:a50ded45dbaf 1925 break;
WiredHome 23:a50ded45dbaf 1926 case 'r':
WiredHome 23:a50ded45dbaf 1927 pc.printf("Resetting ...\r\n");
WiredHome 23:a50ded45dbaf 1928 wait_ms(20);
WiredHome 23:a50ded45dbaf 1929 mbed_reset();
WiredHome 23:a50ded45dbaf 1930 break;
WiredHome 23:a50ded45dbaf 1931 default:
WiredHome 23:a50ded45dbaf 1932 printf("huh?\n");
WiredHome 23:a50ded45dbaf 1933 break;
WiredHome 23:a50ded45dbaf 1934 }
WiredHome 23:a50ded45dbaf 1935 if (automode >= 0) {
WiredHome 23:a50ded45dbaf 1936 automode++;
WiredHome 23:a50ded45dbaf 1937 if (automode >= sizeof(modelist))
WiredHome 23:a50ded45dbaf 1938 automode = 0;
WiredHome 23:a50ded45dbaf 1939 wait_ms(2000);
WiredHome 23:a50ded45dbaf 1940 }
WiredHome 23:a50ded45dbaf 1941 wait_ms(200);
WiredHome 23:a50ded45dbaf 1942 }
WiredHome 23:a50ded45dbaf 1943 }
WiredHome 23:a50ded45dbaf 1944
WiredHome 23:a50ded45dbaf 1945 #endif // TESTENABLE