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