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