Forked para SNOCC
Fork of RA8875 by
RA8875.cpp@40:04aa280dfa39, 2014-02-04 (annotated)
- Committer:
- WiredHome
- Date:
- Tue Feb 04 02:58:06 2014 +0000
- Revision:
- 40:04aa280dfa39
- Parent:
- 39:805cee56872d
- Child:
- 41:2956a0a221e5
Revise SetTextFontSize( ) to require only 1 parameter, and change the type from unsigned to signed to permit easier default detection.
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 | 19:3f82c1161fd2 | 4 | /// which is 480 x xxx. It has other attributes (like display controller |
WiredHome | 19:3f82c1161fd2 | 5 | /// managed backlight brightness. So, there are expectations and some |
WiredHome | 19:3f82c1161fd2 | 6 | /// defined constants based on that specific display. |
WiredHome | 19:3f82c1161fd2 | 7 | /// |
WiredHome | 19:3f82c1161fd2 | 8 | #include "RA8875.h" |
WiredHome | 19:3f82c1161fd2 | 9 | |
WiredHome | 20:6e2e4a8372eb | 10 | DigitalOut zz1(LED1); |
WiredHome | 20:6e2e4a8372eb | 11 | DigitalOut zz2(LED2); |
WiredHome | 20:6e2e4a8372eb | 12 | DigitalOut zz3(LED3); |
WiredHome | 20:6e2e4a8372eb | 13 | DigitalOut zz4(LED4); |
WiredHome | 20:6e2e4a8372eb | 14 | |
WiredHome | 29:422616aa04bd | 15 | #define DEBUG "RAIO" |
WiredHome | 19:3f82c1161fd2 | 16 | // ... |
WiredHome | 19:3f82c1161fd2 | 17 | // INFO("Stuff to show %d", var); // new-line is automatically appended |
WiredHome | 19:3f82c1161fd2 | 18 | // |
WiredHome | 19:3f82c1161fd2 | 19 | #if (defined(DEBUG) && !defined(TARGET_LPC11U24)) |
WiredHome | 19:3f82c1161fd2 | 20 | #define INFO(x, ...) std::printf("[INF %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 21 | #define WARN(x, ...) std::printf("[WRN %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 22 | #define ERR(x, ...) std::printf("[ERR %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 19:3f82c1161fd2 | 23 | #else |
WiredHome | 19:3f82c1161fd2 | 24 | #define INFO(x, ...) |
WiredHome | 19:3f82c1161fd2 | 25 | #define WARN(x, ...) |
WiredHome | 19:3f82c1161fd2 | 26 | #define ERR(x, ...) |
WiredHome | 19:3f82c1161fd2 | 27 | #endif |
WiredHome | 19:3f82c1161fd2 | 28 | |
WiredHome | 19:3f82c1161fd2 | 29 | |
WiredHome | 19:3f82c1161fd2 | 30 | #define RA8875_DISPLAY_WIDTH 480 |
WiredHome | 19:3f82c1161fd2 | 31 | #define RA8875_DISPLAY_HEIGHT 272 |
WiredHome | 19:3f82c1161fd2 | 32 | |
WiredHome | 19:3f82c1161fd2 | 33 | |
WiredHome | 19:3f82c1161fd2 | 34 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 35 | #define PERFORMANCE_RESET performance.reset() |
WiredHome | 19:3f82c1161fd2 | 36 | #define REGISTERPERFORMANCE(a) RegisterPerformance(a) |
WiredHome | 19:3f82c1161fd2 | 37 | static const char *metricsName[] = |
WiredHome | 19:3f82c1161fd2 | 38 | { |
WiredHome | 19:3f82c1161fd2 | 39 | "Point", "Line", "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 | 19:3f82c1161fd2 | 69 | //RA8875::~RA8875() |
WiredHome | 19:3f82c1161fd2 | 70 | //{ |
WiredHome | 19:3f82c1161fd2 | 71 | //} |
WiredHome | 19:3f82c1161fd2 | 72 | |
WiredHome | 19:3f82c1161fd2 | 73 | #ifdef PERF_METRICS |
WiredHome | 19:3f82c1161fd2 | 74 | void RA8875::ClearPerformance() |
WiredHome | 19:3f82c1161fd2 | 75 | { |
WiredHome | 19:3f82c1161fd2 | 76 | for (int i=0; i<METRICCOUNT; i++) |
WiredHome | 19:3f82c1161fd2 | 77 | metrics[i] = 0; |
WiredHome | 19:3f82c1161fd2 | 78 | } |
WiredHome | 19:3f82c1161fd2 | 79 | |
WiredHome | 19:3f82c1161fd2 | 80 | void RA8875::RegisterPerformance(method_e method) |
WiredHome | 19:3f82c1161fd2 | 81 | { |
WiredHome | 19:3f82c1161fd2 | 82 | unsigned long elapsed = performance.read_us(); |
WiredHome | 19:3f82c1161fd2 | 83 | |
WiredHome | 19:3f82c1161fd2 | 84 | if (method < METRICCOUNT && elapsed > metrics[method]) |
WiredHome | 19:3f82c1161fd2 | 85 | metrics[method] = elapsed; |
WiredHome | 19:3f82c1161fd2 | 86 | } |
WiredHome | 19:3f82c1161fd2 | 87 | |
WiredHome | 19:3f82c1161fd2 | 88 | void RA8875::ReportPerformance() |
WiredHome | 19:3f82c1161fd2 | 89 | { |
WiredHome | 19:3f82c1161fd2 | 90 | for (int i=0; i<METRICCOUNT; i++) { |
WiredHome | 19:3f82c1161fd2 | 91 | printf("%10d uS %s\r\n", metrics[i], metricsName[i]); |
WiredHome | 19:3f82c1161fd2 | 92 | } |
WiredHome | 19:3f82c1161fd2 | 93 | } |
WiredHome | 19:3f82c1161fd2 | 94 | #endif |
WiredHome | 19:3f82c1161fd2 | 95 | |
WiredHome | 38:38d503b4fad6 | 96 | RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t data) |
WiredHome | 38:38d503b4fad6 | 97 | { |
WiredHome | 38:38d503b4fad6 | 98 | #if 1 |
WiredHome | 38:38d503b4fad6 | 99 | WriteCommand(command, data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 100 | WriteCommand(command+1, data >> 8); |
WiredHome | 38:38d503b4fad6 | 101 | #else |
WiredHome | 38:38d503b4fad6 | 102 | INFO("WriteCommandW(%02X, %04X)", command, data); |
WiredHome | 38:38d503b4fad6 | 103 | select(true); |
WiredHome | 38:38d503b4fad6 | 104 | spiwrite(0x80); |
WiredHome | 38:38d503b4fad6 | 105 | spiwrite(command); |
WiredHome | 38:38d503b4fad6 | 106 | // spiwrite(0x00); |
WiredHome | 38:38d503b4fad6 | 107 | spiwrite(data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 108 | spiwrite(data >> 8); |
WiredHome | 38:38d503b4fad6 | 109 | select(false); |
WiredHome | 38:38d503b4fad6 | 110 | #endif |
WiredHome | 38:38d503b4fad6 | 111 | return noerror; |
WiredHome | 38:38d503b4fad6 | 112 | } |
WiredHome | 38:38d503b4fad6 | 113 | |
WiredHome | 19:3f82c1161fd2 | 114 | RetCode_t RA8875::WriteCommand(unsigned char command, unsigned int data) |
WiredHome | 19:3f82c1161fd2 | 115 | { |
WiredHome | 19:3f82c1161fd2 | 116 | select(true); |
WiredHome | 19:3f82c1161fd2 | 117 | spiwrite(0x80); |
WiredHome | 19:3f82c1161fd2 | 118 | spiwrite(command); |
WiredHome | 19:3f82c1161fd2 | 119 | if (data <= 0xFF) { // only if in the valid range |
WiredHome | 19:3f82c1161fd2 | 120 | spiwrite(0x00); |
WiredHome | 19:3f82c1161fd2 | 121 | spiwrite(data); |
WiredHome | 19:3f82c1161fd2 | 122 | } |
WiredHome | 19:3f82c1161fd2 | 123 | select(false); |
WiredHome | 19:3f82c1161fd2 | 124 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 125 | } |
WiredHome | 19:3f82c1161fd2 | 126 | |
WiredHome | 38:38d503b4fad6 | 127 | RetCode_t RA8875::WriteDataW(uint16_t data) |
WiredHome | 38:38d503b4fad6 | 128 | { |
WiredHome | 38:38d503b4fad6 | 129 | select(true); |
WiredHome | 38:38d503b4fad6 | 130 | spiwrite(0x00); |
WiredHome | 38:38d503b4fad6 | 131 | spiwrite(data & 0xFF); |
WiredHome | 38:38d503b4fad6 | 132 | spiwrite(data >> 8); |
WiredHome | 38:38d503b4fad6 | 133 | select(false); |
WiredHome | 38:38d503b4fad6 | 134 | return noerror; |
WiredHome | 38:38d503b4fad6 | 135 | } |
WiredHome | 38:38d503b4fad6 | 136 | |
WiredHome | 19:3f82c1161fd2 | 137 | RetCode_t RA8875::WriteData(unsigned char data) |
WiredHome | 19:3f82c1161fd2 | 138 | { |
WiredHome | 19:3f82c1161fd2 | 139 | select(true); |
WiredHome | 19:3f82c1161fd2 | 140 | spiwrite(0x00); |
WiredHome | 19:3f82c1161fd2 | 141 | spiwrite(data); |
WiredHome | 19:3f82c1161fd2 | 142 | select(false); |
WiredHome | 19:3f82c1161fd2 | 143 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 144 | } |
WiredHome | 19:3f82c1161fd2 | 145 | |
WiredHome | 19:3f82c1161fd2 | 146 | unsigned char RA8875::ReadCommand(unsigned char command) |
WiredHome | 19:3f82c1161fd2 | 147 | { |
WiredHome | 19:3f82c1161fd2 | 148 | WriteCommand(command); |
WiredHome | 19:3f82c1161fd2 | 149 | return ReadData(); |
WiredHome | 19:3f82c1161fd2 | 150 | } |
WiredHome | 19:3f82c1161fd2 | 151 | |
WiredHome | 19:3f82c1161fd2 | 152 | unsigned char RA8875::ReadData(void) |
WiredHome | 19:3f82c1161fd2 | 153 | { |
WiredHome | 19:3f82c1161fd2 | 154 | unsigned char data; |
WiredHome | 19:3f82c1161fd2 | 155 | |
WiredHome | 19:3f82c1161fd2 | 156 | select(true); |
WiredHome | 19:3f82c1161fd2 | 157 | spiwrite(0x40); |
WiredHome | 19:3f82c1161fd2 | 158 | data = spiread(); |
WiredHome | 19:3f82c1161fd2 | 159 | select(false); |
WiredHome | 19:3f82c1161fd2 | 160 | return data; |
WiredHome | 19:3f82c1161fd2 | 161 | } |
WiredHome | 19:3f82c1161fd2 | 162 | |
WiredHome | 19:3f82c1161fd2 | 163 | unsigned char RA8875::ReadStatus(void) |
WiredHome | 19:3f82c1161fd2 | 164 | { |
WiredHome | 19:3f82c1161fd2 | 165 | unsigned char data; |
WiredHome | 19:3f82c1161fd2 | 166 | |
WiredHome | 19:3f82c1161fd2 | 167 | select(true); |
WiredHome | 19:3f82c1161fd2 | 168 | spiwrite(0xC0); |
WiredHome | 19:3f82c1161fd2 | 169 | data = spiread(); |
WiredHome | 19:3f82c1161fd2 | 170 | select(false); |
WiredHome | 19:3f82c1161fd2 | 171 | return data; |
WiredHome | 19:3f82c1161fd2 | 172 | } |
WiredHome | 19:3f82c1161fd2 | 173 | |
WiredHome | 37:f19b7e7449dc | 174 | dim_t RA8875::fontwidth(void) |
WiredHome | 19:3f82c1161fd2 | 175 | { |
WiredHome | 19:3f82c1161fd2 | 176 | if (font == NULL) |
WiredHome | 23:a50ded45dbaf | 177 | return (((ReadCommand(0x22) >> 2) & 0x3) + 1) * 16; |
WiredHome | 19:3f82c1161fd2 | 178 | else |
WiredHome | 29:422616aa04bd | 179 | return font[1]; |
WiredHome | 19:3f82c1161fd2 | 180 | } |
WiredHome | 19:3f82c1161fd2 | 181 | |
WiredHome | 37:f19b7e7449dc | 182 | dim_t RA8875::fontheight(void) |
WiredHome | 19:3f82c1161fd2 | 183 | { |
WiredHome | 19:3f82c1161fd2 | 184 | if (font == NULL) |
WiredHome | 23:a50ded45dbaf | 185 | return (((ReadCommand(0x22) >> 0) & 0x3) + 1) * 16; |
WiredHome | 19:3f82c1161fd2 | 186 | else |
WiredHome | 29:422616aa04bd | 187 | return font[2]; |
WiredHome | 19:3f82c1161fd2 | 188 | } |
WiredHome | 19:3f82c1161fd2 | 189 | |
WiredHome | 37:f19b7e7449dc | 190 | RetCode_t RA8875::locate(textloc_t column, textloc_t row) |
WiredHome | 19:3f82c1161fd2 | 191 | { |
WiredHome | 32:0e4f2ae512e2 | 192 | return SetTextCursor(column * fontwidth(), row * fontheight()); |
WiredHome | 19:3f82c1161fd2 | 193 | } |
WiredHome | 19:3f82c1161fd2 | 194 | |
WiredHome | 19:3f82c1161fd2 | 195 | int RA8875::columns(void) |
WiredHome | 19:3f82c1161fd2 | 196 | { |
WiredHome | 19:3f82c1161fd2 | 197 | return width() / fontwidth(); |
WiredHome | 19:3f82c1161fd2 | 198 | } |
WiredHome | 19:3f82c1161fd2 | 199 | |
WiredHome | 19:3f82c1161fd2 | 200 | int RA8875::rows(void) |
WiredHome | 19:3f82c1161fd2 | 201 | { |
WiredHome | 19:3f82c1161fd2 | 202 | return height() / fontheight(); |
WiredHome | 19:3f82c1161fd2 | 203 | } |
WiredHome | 19:3f82c1161fd2 | 204 | |
WiredHome | 38:38d503b4fad6 | 205 | dim_t RA8875::width(void) |
WiredHome | 19:3f82c1161fd2 | 206 | { |
WiredHome | 29:422616aa04bd | 207 | return (ReadCommand(0x14) + 1) * 8; |
WiredHome | 19:3f82c1161fd2 | 208 | } |
WiredHome | 19:3f82c1161fd2 | 209 | |
WiredHome | 38:38d503b4fad6 | 210 | dim_t RA8875::height(void) |
WiredHome | 19:3f82c1161fd2 | 211 | { |
WiredHome | 29:422616aa04bd | 212 | return (ReadCommand(0x19) | (ReadCommand(0x1A) << 8)) + 1; |
WiredHome | 19:3f82c1161fd2 | 213 | } |
WiredHome | 19:3f82c1161fd2 | 214 | |
WiredHome | 37:f19b7e7449dc | 215 | RetCode_t RA8875::SetTextCursor(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 216 | { |
WiredHome | 29:422616aa04bd | 217 | cursor_x = x; cursor_y = y; // for non-internal fonts |
WiredHome | 38:38d503b4fad6 | 218 | WriteCommandW(0x2A, x); |
WiredHome | 38:38d503b4fad6 | 219 | WriteCommandW(0x2C, y); |
WiredHome | 19:3f82c1161fd2 | 220 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 221 | } |
WiredHome | 19:3f82c1161fd2 | 222 | |
WiredHome | 37:f19b7e7449dc | 223 | loc_t RA8875::GetTextCursor_Y(void) |
WiredHome | 29:422616aa04bd | 224 | { |
WiredHome | 29:422616aa04bd | 225 | if (font == NULL) |
WiredHome | 29:422616aa04bd | 226 | return ReadCommand(0x2C) | (ReadCommand(0x2D) << 8); |
WiredHome | 29:422616aa04bd | 227 | else |
WiredHome | 29:422616aa04bd | 228 | return cursor_y; |
WiredHome | 29:422616aa04bd | 229 | } |
WiredHome | 29:422616aa04bd | 230 | |
WiredHome | 37:f19b7e7449dc | 231 | loc_t RA8875::GetTextCursor_X(void) |
WiredHome | 29:422616aa04bd | 232 | { |
WiredHome | 29:422616aa04bd | 233 | if (font == NULL) |
WiredHome | 29:422616aa04bd | 234 | return ReadCommand(0x2A) | (ReadCommand(0x2B) << 8); |
WiredHome | 29:422616aa04bd | 235 | else |
WiredHome | 29:422616aa04bd | 236 | return cursor_x; |
WiredHome | 29:422616aa04bd | 237 | } |
WiredHome | 29:422616aa04bd | 238 | |
WiredHome | 24:8ca861acf12d | 239 | RetCode_t RA8875::SetTextCursorControl(cursor_t cursor, bool blink) |
WiredHome | 23:a50ded45dbaf | 240 | { |
WiredHome | 23:a50ded45dbaf | 241 | unsigned char mwcr0 = ReadCommand(0x40) & 0x0F; // retain direction, auto-increase |
WiredHome | 24:8ca861acf12d | 242 | unsigned char horz = 0; |
WiredHome | 24:8ca861acf12d | 243 | unsigned char vert = 0; |
WiredHome | 23:a50ded45dbaf | 244 | |
WiredHome | 24:8ca861acf12d | 245 | mwcr0 |= 0x80; // text mode |
WiredHome | 24:8ca861acf12d | 246 | if (cursor != NOCURSOR) |
WiredHome | 24:8ca861acf12d | 247 | mwcr0 |= 0x40; // visible |
WiredHome | 23:a50ded45dbaf | 248 | if (blink) |
WiredHome | 24:8ca861acf12d | 249 | mwcr0 |= 0x20; // blink |
WiredHome | 23:a50ded45dbaf | 250 | WriteCommand(0x40, mwcr0); // configure the cursor |
WiredHome | 23:a50ded45dbaf | 251 | WriteCommand(0x41, 0x00); // close the graphics cursor |
WiredHome | 24:8ca861acf12d | 252 | WriteCommand(0x44, 0x1f); // The cursor flashing cycle |
WiredHome | 24:8ca861acf12d | 253 | switch (cursor) { |
WiredHome | 24:8ca861acf12d | 254 | case IBEAM: |
WiredHome | 24:8ca861acf12d | 255 | horz = 0x01; |
WiredHome | 24:8ca861acf12d | 256 | vert = 0x1F; |
WiredHome | 24:8ca861acf12d | 257 | break; |
WiredHome | 24:8ca861acf12d | 258 | case UNDER: |
WiredHome | 24:8ca861acf12d | 259 | horz = 0x07; |
WiredHome | 24:8ca861acf12d | 260 | vert = 0x01; |
WiredHome | 24:8ca861acf12d | 261 | break; |
WiredHome | 24:8ca861acf12d | 262 | case BLOCK: |
WiredHome | 24:8ca861acf12d | 263 | horz = 0x07; |
WiredHome | 24:8ca861acf12d | 264 | vert = 0x1F; |
WiredHome | 24:8ca861acf12d | 265 | break; |
WiredHome | 24:8ca861acf12d | 266 | case NOCURSOR: |
WiredHome | 24:8ca861acf12d | 267 | default: |
WiredHome | 24:8ca861acf12d | 268 | break; |
WiredHome | 24:8ca861acf12d | 269 | } |
WiredHome | 24:8ca861acf12d | 270 | WriteCommand(0x4e, horz); // The cursor size horz |
WiredHome | 24:8ca861acf12d | 271 | WriteCommand(0x4f, vert); // The cursor size vert |
WiredHome | 23:a50ded45dbaf | 272 | return noerror; |
WiredHome | 23:a50ded45dbaf | 273 | } |
WiredHome | 23:a50ded45dbaf | 274 | |
WiredHome | 19:3f82c1161fd2 | 275 | RetCode_t RA8875::SetTextFont(RA8875::font_t font) |
WiredHome | 19:3f82c1161fd2 | 276 | { |
WiredHome | 19:3f82c1161fd2 | 277 | if (/*font >= RA8875::ISO8859_1 && */ font <= RA8875::ISO8859_4) { |
WiredHome | 19:3f82c1161fd2 | 278 | WriteCommand(0x21, (unsigned int)(font)); |
WiredHome | 19:3f82c1161fd2 | 279 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 280 | } else { |
WiredHome | 19:3f82c1161fd2 | 281 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 282 | } |
WiredHome | 19:3f82c1161fd2 | 283 | } |
WiredHome | 19:3f82c1161fd2 | 284 | |
WiredHome | 19:3f82c1161fd2 | 285 | RetCode_t RA8875::SetTextFontControl(fill_t fillit, |
WiredHome | 19:3f82c1161fd2 | 286 | RA8875::font_angle_t angle, |
WiredHome | 19:3f82c1161fd2 | 287 | RA8875::HorizontalScale hScale, |
WiredHome | 19:3f82c1161fd2 | 288 | RA8875::VerticalScale vScale, |
WiredHome | 19:3f82c1161fd2 | 289 | RA8875::alignment_t alignment) |
WiredHome | 19:3f82c1161fd2 | 290 | { |
WiredHome | 19:3f82c1161fd2 | 291 | if (hScale >= 1 && hScale <= 4 && |
WiredHome | 19:3f82c1161fd2 | 292 | vScale >= 1 && vScale <= 4) { |
WiredHome | 19:3f82c1161fd2 | 293 | unsigned char x = 0; |
WiredHome | 19:3f82c1161fd2 | 294 | |
WiredHome | 19:3f82c1161fd2 | 295 | if (alignment == align_full) |
WiredHome | 19:3f82c1161fd2 | 296 | x |= 0x80; |
WiredHome | 19:3f82c1161fd2 | 297 | if (fillit == NOFILL) |
WiredHome | 19:3f82c1161fd2 | 298 | x |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 299 | if (angle == rotated) |
WiredHome | 19:3f82c1161fd2 | 300 | x |= 0x10; |
WiredHome | 19:3f82c1161fd2 | 301 | x |= ((hScale - 1) << 2); |
WiredHome | 19:3f82c1161fd2 | 302 | x |= ((vScale - 1) << 0); |
WiredHome | 19:3f82c1161fd2 | 303 | WriteCommand(0x22, x); |
WiredHome | 19:3f82c1161fd2 | 304 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 305 | } else { |
WiredHome | 19:3f82c1161fd2 | 306 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 307 | } |
WiredHome | 19:3f82c1161fd2 | 308 | } |
WiredHome | 19:3f82c1161fd2 | 309 | |
WiredHome | 19:3f82c1161fd2 | 310 | RetCode_t RA8875::SetTextFontSize(RA8875::HorizontalScale hScale, RA8875::VerticalScale vScale) |
WiredHome | 19:3f82c1161fd2 | 311 | { |
WiredHome | 19:3f82c1161fd2 | 312 | unsigned char reg = ReadCommand(0x22); |
WiredHome | 19:3f82c1161fd2 | 313 | |
WiredHome | 40:04aa280dfa39 | 314 | if (vScale == -1) |
WiredHome | 40:04aa280dfa39 | 315 | vScale = hScale; |
WiredHome | 19:3f82c1161fd2 | 316 | if (hScale >= 1 && hScale <= 4 && vScale >= 1 && vScale <= 4) { |
WiredHome | 19:3f82c1161fd2 | 317 | reg &= 0xF0; // keep the high nibble as is. |
WiredHome | 19:3f82c1161fd2 | 318 | reg |= ((hScale - 1) << 2); |
WiredHome | 19:3f82c1161fd2 | 319 | reg |= ((vScale - 1) << 0); |
WiredHome | 19:3f82c1161fd2 | 320 | WriteCommand(0x22, reg); |
WiredHome | 19:3f82c1161fd2 | 321 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 322 | } else { |
WiredHome | 19:3f82c1161fd2 | 323 | return bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 324 | } |
WiredHome | 19:3f82c1161fd2 | 325 | } |
WiredHome | 19:3f82c1161fd2 | 326 | |
WiredHome | 19:3f82c1161fd2 | 327 | int RA8875::_putc(int c) |
WiredHome | 19:3f82c1161fd2 | 328 | { |
WiredHome | 29:422616aa04bd | 329 | if (font == NULL) { |
WiredHome | 29:422616aa04bd | 330 | return _internal_putc(c); |
WiredHome | 29:422616aa04bd | 331 | } else { |
WiredHome | 29:422616aa04bd | 332 | return _external_putc(c); |
WiredHome | 29:422616aa04bd | 333 | } |
WiredHome | 29:422616aa04bd | 334 | } |
WiredHome | 29:422616aa04bd | 335 | |
WiredHome | 29:422616aa04bd | 336 | int RA8875::_external_putc(int c) |
WiredHome | 29:422616aa04bd | 337 | { |
WiredHome | 19:3f82c1161fd2 | 338 | if (c) { |
WiredHome | 19:3f82c1161fd2 | 339 | if (c == '\r') { |
WiredHome | 29:422616aa04bd | 340 | cursor_x = 0; |
WiredHome | 29:422616aa04bd | 341 | } else if (c == '\n') { |
WiredHome | 29:422616aa04bd | 342 | cursor_y += font[2]; |
WiredHome | 29:422616aa04bd | 343 | } else { |
WiredHome | 29:422616aa04bd | 344 | int advance = character(cursor_x, cursor_y, c); // advance tells us how many pixels we advanced |
WiredHome | 37:f19b7e7449dc | 345 | //INFO("x,y,advance %d,%d,%d", cursor_x, cursor_y, advance); |
WiredHome | 29:422616aa04bd | 346 | if (advance) { |
WiredHome | 29:422616aa04bd | 347 | cursor_x += advance; |
WiredHome | 29:422616aa04bd | 348 | if (cursor_x >= width()) { |
WiredHome | 29:422616aa04bd | 349 | cursor_x = 0; |
WiredHome | 29:422616aa04bd | 350 | cursor_y += font[2]; |
WiredHome | 29:422616aa04bd | 351 | if (cursor_y >= height()) { |
WiredHome | 29:422616aa04bd | 352 | cursor_y = 0; // @todo Should it scroll? |
WiredHome | 29:422616aa04bd | 353 | } |
WiredHome | 29:422616aa04bd | 354 | } |
WiredHome | 29:422616aa04bd | 355 | } |
WiredHome | 29:422616aa04bd | 356 | } |
WiredHome | 29:422616aa04bd | 357 | } |
WiredHome | 29:422616aa04bd | 358 | return c; |
WiredHome | 29:422616aa04bd | 359 | } |
WiredHome | 29:422616aa04bd | 360 | |
WiredHome | 29:422616aa04bd | 361 | int RA8875::_internal_putc(int c) |
WiredHome | 29:422616aa04bd | 362 | { |
WiredHome | 29:422616aa04bd | 363 | if (c) { |
WiredHome | 29:422616aa04bd | 364 | unsigned char mwcr0; |
WiredHome | 29:422616aa04bd | 365 | |
WiredHome | 29:422616aa04bd | 366 | mwcr0 = ReadCommand(0x40); |
WiredHome | 29:422616aa04bd | 367 | if ((mwcr0 & 0x80) == 0x00) { |
WiredHome | 29:422616aa04bd | 368 | WriteCommand(0x40, 0x80 | mwcr0); // Put in Text mode if not already |
WiredHome | 29:422616aa04bd | 369 | } |
WiredHome | 29:422616aa04bd | 370 | if (c == '\r') { |
WiredHome | 37:f19b7e7449dc | 371 | loc_t x; |
WiredHome | 19:3f82c1161fd2 | 372 | x = ReadCommand(0x30) | (ReadCommand(0x31) << 8); // Left edge of active window |
WiredHome | 38:38d503b4fad6 | 373 | WriteCommandW(0x2A, x); |
WiredHome | 19:3f82c1161fd2 | 374 | } else if (c == '\n') { |
WiredHome | 37:f19b7e7449dc | 375 | loc_t y; |
WiredHome | 19:3f82c1161fd2 | 376 | y = ReadCommand(0x2C) | (ReadCommand(0x2D) << 8); // current y location |
WiredHome | 19:3f82c1161fd2 | 377 | y += fontheight(); |
WiredHome | 29:422616aa04bd | 378 | if (y > height()) // @TODO after bottom of active window, then scroll window? |
WiredHome | 19:3f82c1161fd2 | 379 | y = 0; |
WiredHome | 38:38d503b4fad6 | 380 | WriteCommandW(0x2C, y); |
WiredHome | 19:3f82c1161fd2 | 381 | } else { |
WiredHome | 29:422616aa04bd | 382 | WriteCommand(0x02); // RA8875 Internal Fonts |
WiredHome | 29:422616aa04bd | 383 | select(true); |
WiredHome | 29:422616aa04bd | 384 | WriteData(c); |
WiredHome | 29:422616aa04bd | 385 | while (ReadStatus() & 0x80) |
WiredHome | 29:422616aa04bd | 386 | wait_us(POLLWAITuSec); // Chk_Busy(); |
WiredHome | 29:422616aa04bd | 387 | select(false); |
WiredHome | 19:3f82c1161fd2 | 388 | } |
WiredHome | 19:3f82c1161fd2 | 389 | } |
WiredHome | 19:3f82c1161fd2 | 390 | return c; |
WiredHome | 19:3f82c1161fd2 | 391 | } |
WiredHome | 19:3f82c1161fd2 | 392 | |
WiredHome | 32:0e4f2ae512e2 | 393 | RetCode_t RA8875::_StartGraphicsStream(void) |
WiredHome | 32:0e4f2ae512e2 | 394 | { |
WiredHome | 32:0e4f2ae512e2 | 395 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 32:0e4f2ae512e2 | 396 | WriteCommand(0x02); // Prepare for streaming data |
WiredHome | 32:0e4f2ae512e2 | 397 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 398 | } |
WiredHome | 32:0e4f2ae512e2 | 399 | |
WiredHome | 32:0e4f2ae512e2 | 400 | RetCode_t RA8875::_EndGraphicsStream(void) |
WiredHome | 32:0e4f2ae512e2 | 401 | { |
WiredHome | 32:0e4f2ae512e2 | 402 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 403 | } |
WiredHome | 32:0e4f2ae512e2 | 404 | |
WiredHome | 32:0e4f2ae512e2 | 405 | RetCode_t RA8875::putp(color_t pixel) |
WiredHome | 32:0e4f2ae512e2 | 406 | { |
WiredHome | 38:38d503b4fad6 | 407 | WriteDataW((pixel>>8) | (pixel<<8)); |
WiredHome | 32:0e4f2ae512e2 | 408 | return noerror; |
WiredHome | 32:0e4f2ae512e2 | 409 | } |
WiredHome | 29:422616aa04bd | 410 | |
WiredHome | 37:f19b7e7449dc | 411 | void RA8875::puts(loc_t x, loc_t y, const char * string) |
WiredHome | 19:3f82c1161fd2 | 412 | { |
WiredHome | 19:3f82c1161fd2 | 413 | SetTextCursor(x,y); |
WiredHome | 19:3f82c1161fd2 | 414 | puts(string); |
WiredHome | 19:3f82c1161fd2 | 415 | } |
WiredHome | 19:3f82c1161fd2 | 416 | |
WiredHome | 19:3f82c1161fd2 | 417 | void RA8875::puts(const char * string) |
WiredHome | 19:3f82c1161fd2 | 418 | { |
WiredHome | 29:422616aa04bd | 419 | unsigned char mwcr0 = ReadCommand(0x40); |
WiredHome | 37:f19b7e7449dc | 420 | |
WiredHome | 37:f19b7e7449dc | 421 | if (font == NULL) { |
WiredHome | 37:f19b7e7449dc | 422 | if ((mwcr0 & 0x80) == 0x00) |
WiredHome | 37:f19b7e7449dc | 423 | WriteCommand(0x40,0x80); // Put in Text mode if not already |
WiredHome | 37:f19b7e7449dc | 424 | } else { |
WiredHome | 37:f19b7e7449dc | 425 | _StartGraphicsStream(); |
WiredHome | 37:f19b7e7449dc | 426 | } |
WiredHome | 19:3f82c1161fd2 | 427 | if (*string != '\0') { |
WiredHome | 19:3f82c1161fd2 | 428 | #if 1 |
WiredHome | 29:422616aa04bd | 429 | while (*string) { // @TODO calling individual _putc is slower... optimizations? |
WiredHome | 19:3f82c1161fd2 | 430 | _putc(*string++); |
WiredHome | 19:3f82c1161fd2 | 431 | } |
WiredHome | 19:3f82c1161fd2 | 432 | #else |
WiredHome | 19:3f82c1161fd2 | 433 | WriteCommand(0x02); |
WiredHome | 19:3f82c1161fd2 | 434 | select(true); |
WiredHome | 19:3f82c1161fd2 | 435 | while (*string != '\0') { |
WiredHome | 19:3f82c1161fd2 | 436 | WriteData(*string); |
WiredHome | 19:3f82c1161fd2 | 437 | ++string; |
WiredHome | 19:3f82c1161fd2 | 438 | while (ReadStatus() & 0x80) |
WiredHome | 19:3f82c1161fd2 | 439 | wait_us(POLLWAITuSec); // Chk_Busy(); |
WiredHome | 19:3f82c1161fd2 | 440 | } |
WiredHome | 19:3f82c1161fd2 | 441 | select(false); |
WiredHome | 19:3f82c1161fd2 | 442 | #endif |
WiredHome | 19:3f82c1161fd2 | 443 | } |
WiredHome | 37:f19b7e7449dc | 444 | if (font) |
WiredHome | 37:f19b7e7449dc | 445 | _EndGraphicsStream(); |
WiredHome | 19:3f82c1161fd2 | 446 | } |
WiredHome | 19:3f82c1161fd2 | 447 | |
WiredHome | 37:f19b7e7449dc | 448 | RetCode_t RA8875::SetGraphicsCursor(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 449 | { |
WiredHome | 38:38d503b4fad6 | 450 | WriteCommandW(0x46, x); |
WiredHome | 38:38d503b4fad6 | 451 | WriteCommandW(0x48, y); |
WiredHome | 19:3f82c1161fd2 | 452 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 453 | } |
WiredHome | 19:3f82c1161fd2 | 454 | |
WiredHome | 37:f19b7e7449dc | 455 | RetCode_t RA8875::window(loc_t x, loc_t y, dim_t width, dim_t height) |
WiredHome | 19:3f82c1161fd2 | 456 | { |
WiredHome | 37:f19b7e7449dc | 457 | GraphicsDisplay::window(x,y, width,height); |
WiredHome | 38:38d503b4fad6 | 458 | WriteCommandW(0x30, x); |
WiredHome | 38:38d503b4fad6 | 459 | WriteCommandW(0x32, y); |
WiredHome | 38:38d503b4fad6 | 460 | WriteCommandW(0x34, (x+width-1)); |
WiredHome | 38:38d503b4fad6 | 461 | WriteCommandW(0x36, (y+height-1)); |
WiredHome | 37:f19b7e7449dc | 462 | SetGraphicsCursor(x,y); |
WiredHome | 19:3f82c1161fd2 | 463 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 464 | } |
WiredHome | 19:3f82c1161fd2 | 465 | |
WiredHome | 19:3f82c1161fd2 | 466 | RetCode_t RA8875::cls(void) |
WiredHome | 19:3f82c1161fd2 | 467 | { |
WiredHome | 19:3f82c1161fd2 | 468 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 469 | clsw(FULLWINDOW); |
WiredHome | 37:f19b7e7449dc | 470 | SetTextCursor(0,0); |
WiredHome | 19:3f82c1161fd2 | 471 | REGISTERPERFORMANCE(PRF_CLS); |
WiredHome | 19:3f82c1161fd2 | 472 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 473 | } |
WiredHome | 19:3f82c1161fd2 | 474 | |
WiredHome | 19:3f82c1161fd2 | 475 | RetCode_t RA8875::clsw(RA8875::Region_t region) |
WiredHome | 19:3f82c1161fd2 | 476 | { |
WiredHome | 19:3f82c1161fd2 | 477 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 478 | WriteCommand(0x8E, (region == ACTIVEWINDOW) ? 0xC0 : 0x80); |
WiredHome | 19:3f82c1161fd2 | 479 | while (ReadCommand(0x8E) & 0x80) |
WiredHome | 19:3f82c1161fd2 | 480 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 481 | REGISTERPERFORMANCE(PRF_CLS); |
WiredHome | 19:3f82c1161fd2 | 482 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 483 | } |
WiredHome | 19:3f82c1161fd2 | 484 | |
WiredHome | 37:f19b7e7449dc | 485 | RetCode_t RA8875::pixel(loc_t x, loc_t y, color_t color) |
WiredHome | 19:3f82c1161fd2 | 486 | { |
WiredHome | 39:805cee56872d | 487 | //INFO("pixel(%d,%d, %04X)", x,y, color); |
WiredHome | 19:3f82c1161fd2 | 488 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 489 | return pixel(x,y); |
WiredHome | 19:3f82c1161fd2 | 490 | } |
WiredHome | 19:3f82c1161fd2 | 491 | |
WiredHome | 37:f19b7e7449dc | 492 | RetCode_t RA8875::pixel(loc_t x, loc_t y) |
WiredHome | 19:3f82c1161fd2 | 493 | { |
WiredHome | 19:3f82c1161fd2 | 494 | RetCode_t ret; |
WiredHome | 19:3f82c1161fd2 | 495 | |
WiredHome | 19:3f82c1161fd2 | 496 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 497 | color_t color = GetForeColor(); |
WiredHome | 19:3f82c1161fd2 | 498 | WriteCommand(0x40,0x00); // Graphics write mode |
WiredHome | 32:0e4f2ae512e2 | 499 | SetGraphicsCursor(x, y); |
WiredHome | 38:38d503b4fad6 | 500 | WriteCommand(0x02); |
WiredHome | 38:38d503b4fad6 | 501 | WriteDataW(color); |
WiredHome | 19:3f82c1161fd2 | 502 | ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 503 | REGISTERPERFORMANCE(PRF_DRAWPOINT); |
WiredHome | 19:3f82c1161fd2 | 504 | return ret; |
WiredHome | 19:3f82c1161fd2 | 505 | } |
WiredHome | 19:3f82c1161fd2 | 506 | |
WiredHome | 37:f19b7e7449dc | 507 | RetCode_t RA8875::line(loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color) |
WiredHome | 19:3f82c1161fd2 | 508 | { |
WiredHome | 19:3f82c1161fd2 | 509 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 510 | return line(x1,y1,x2,y2); |
WiredHome | 19:3f82c1161fd2 | 511 | } |
WiredHome | 19:3f82c1161fd2 | 512 | |
WiredHome | 37:f19b7e7449dc | 513 | RetCode_t RA8875::line(loc_t x1, loc_t y1, loc_t x2, loc_t y2) |
WiredHome | 19:3f82c1161fd2 | 514 | { |
WiredHome | 19:3f82c1161fd2 | 515 | PERFORMANCE_RESET; |
WiredHome | 38:38d503b4fad6 | 516 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 517 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 518 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 519 | WriteCommandW(0x97, y2); |
WiredHome | 19:3f82c1161fd2 | 520 | unsigned char drawCmd = 0x00; // Line |
WiredHome | 19:3f82c1161fd2 | 521 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 522 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 523 | while (ReadCommand(0x90) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 524 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 525 | REGISTERPERFORMANCE(PRF_DRAWLINE); |
WiredHome | 19:3f82c1161fd2 | 526 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 527 | } |
WiredHome | 19:3f82c1161fd2 | 528 | |
WiredHome | 37:f19b7e7449dc | 529 | RetCode_t RA8875::fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 19:3f82c1161fd2 | 530 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 531 | { |
WiredHome | 19:3f82c1161fd2 | 532 | return rect(x1,y1,x2,y2,color,fillit); |
WiredHome | 19:3f82c1161fd2 | 533 | } |
WiredHome | 19:3f82c1161fd2 | 534 | |
WiredHome | 37:f19b7e7449dc | 535 | RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 19:3f82c1161fd2 | 536 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 537 | { |
WiredHome | 19:3f82c1161fd2 | 538 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 539 | return rect(x1,y1,x2,y2,fillit); |
WiredHome | 19:3f82c1161fd2 | 540 | } |
WiredHome | 19:3f82c1161fd2 | 541 | |
WiredHome | 37:f19b7e7449dc | 542 | RetCode_t RA8875::rect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 19:3f82c1161fd2 | 543 | fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 544 | { |
WiredHome | 19:3f82c1161fd2 | 545 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 546 | if (x1 == x2 && y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 547 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 548 | } else if (x1 == x2) { |
WiredHome | 19:3f82c1161fd2 | 549 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 550 | } else if (y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 551 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 552 | } else { |
WiredHome | 38:38d503b4fad6 | 553 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 554 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 555 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 556 | WriteCommandW(0x97, y2); |
WiredHome | 19:3f82c1161fd2 | 557 | unsigned char drawCmd = 0x10; // Rectangle |
WiredHome | 19:3f82c1161fd2 | 558 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 559 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 560 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 561 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 562 | while (ReadCommand(0x90) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 563 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 564 | } |
WiredHome | 19:3f82c1161fd2 | 565 | REGISTERPERFORMANCE(PRF_DRAWRECTANGLE); |
WiredHome | 19:3f82c1161fd2 | 566 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 567 | } |
WiredHome | 19:3f82c1161fd2 | 568 | |
WiredHome | 37:f19b7e7449dc | 569 | RetCode_t RA8875::fillroundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 570 | dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 571 | { |
WiredHome | 19:3f82c1161fd2 | 572 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 573 | return roundrect(x1,y1,x2,y2,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 574 | } |
WiredHome | 19:3f82c1161fd2 | 575 | |
WiredHome | 37:f19b7e7449dc | 576 | RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 577 | dim_t radius1, dim_t radius2, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 578 | { |
WiredHome | 19:3f82c1161fd2 | 579 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 580 | return roundrect(x1,y1,x2,y2,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 581 | } |
WiredHome | 19:3f82c1161fd2 | 582 | |
WiredHome | 37:f19b7e7449dc | 583 | RetCode_t RA8875::roundrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 584 | dim_t radius1, dim_t radius2, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 585 | { |
WiredHome | 19:3f82c1161fd2 | 586 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 587 | |
WiredHome | 19:3f82c1161fd2 | 588 | PERFORMANCE_RESET; |
WiredHome | 21:3c1efb192927 | 589 | if (x1 > x2 || y1 > y2 || (radius1 > (x2-x1)/2) || (radius2 > (y2-y1)/2) ) { |
WiredHome | 21:3c1efb192927 | 590 | ret = bad_parameter; |
WiredHome | 21:3c1efb192927 | 591 | } else if (x1 == x2 && y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 592 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 593 | } else if (x1 == x2) { |
WiredHome | 19:3f82c1161fd2 | 594 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 595 | } else if (y1 == y2) { |
WiredHome | 19:3f82c1161fd2 | 596 | line(x1, y1, x2, y2); |
WiredHome | 19:3f82c1161fd2 | 597 | } else { |
WiredHome | 38:38d503b4fad6 | 598 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 599 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 600 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 601 | WriteCommandW(0x97, y2); |
WiredHome | 38:38d503b4fad6 | 602 | WriteCommandW(0xA1, radius1); |
WiredHome | 38:38d503b4fad6 | 603 | WriteCommandW(0xA3, radius2); |
WiredHome | 21:3c1efb192927 | 604 | // Should not need this... |
WiredHome | 38:38d503b4fad6 | 605 | WriteCommandW(0xA5, 0); |
WiredHome | 38:38d503b4fad6 | 606 | WriteCommandW(0xA7, 0); |
WiredHome | 19:3f82c1161fd2 | 607 | unsigned char drawCmd = 0x20; // Rounded Rectangle |
WiredHome | 19:3f82c1161fd2 | 608 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 609 | drawCmd |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 610 | WriteCommand(0xA0, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 611 | WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 612 | while (ReadCommand(0xA0) & 0x80) { // await completion. |
WiredHome | 19:3f82c1161fd2 | 613 | wait_us(POLLWAITuSec); |
WiredHome | 21:3c1efb192927 | 614 | } |
WiredHome | 19:3f82c1161fd2 | 615 | } |
WiredHome | 19:3f82c1161fd2 | 616 | REGISTERPERFORMANCE(PRF_DRAWROUNDEDRECTANGLE); |
WiredHome | 19:3f82c1161fd2 | 617 | return ret; |
WiredHome | 19:3f82c1161fd2 | 618 | } |
WiredHome | 19:3f82c1161fd2 | 619 | |
WiredHome | 37:f19b7e7449dc | 620 | RetCode_t RA8875::triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 621 | loc_t x3, loc_t y3, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 622 | { |
WiredHome | 20:6e2e4a8372eb | 623 | RetCode_t ret; |
WiredHome | 20:6e2e4a8372eb | 624 | |
WiredHome | 19:3f82c1161fd2 | 625 | foreground(color); |
WiredHome | 20:6e2e4a8372eb | 626 | ret = triangle(x1,y1,x2,y2,x3,y3,fillit); |
WiredHome | 20:6e2e4a8372eb | 627 | return ret; |
WiredHome | 19:3f82c1161fd2 | 628 | } |
WiredHome | 19:3f82c1161fd2 | 629 | |
WiredHome | 37:f19b7e7449dc | 630 | RetCode_t RA8875::filltriangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 631 | loc_t x3, loc_t y3, color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 632 | { |
WiredHome | 20:6e2e4a8372eb | 633 | RetCode_t ret; |
WiredHome | 20:6e2e4a8372eb | 634 | |
WiredHome | 19:3f82c1161fd2 | 635 | foreground(color); |
WiredHome | 20:6e2e4a8372eb | 636 | ret = triangle(x1,y1,x2,y2,x3,y3,fillit); |
WiredHome | 20:6e2e4a8372eb | 637 | return ret; |
WiredHome | 19:3f82c1161fd2 | 638 | } |
WiredHome | 19:3f82c1161fd2 | 639 | |
WiredHome | 37:f19b7e7449dc | 640 | RetCode_t RA8875::triangle(loc_t x1, loc_t y1 ,loc_t x2, loc_t y2, |
WiredHome | 37:f19b7e7449dc | 641 | loc_t x3, loc_t y3, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 642 | { |
WiredHome | 19:3f82c1161fd2 | 643 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 644 | |
WiredHome | 19:3f82c1161fd2 | 645 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 646 | if (x1 == x2 && y1 == y2 && x1 == x3 && y1 == y3) { |
WiredHome | 19:3f82c1161fd2 | 647 | pixel(x1, y1); |
WiredHome | 19:3f82c1161fd2 | 648 | } else { |
WiredHome | 38:38d503b4fad6 | 649 | WriteCommandW(0x91, x1); |
WiredHome | 38:38d503b4fad6 | 650 | WriteCommandW(0x93, y1); |
WiredHome | 38:38d503b4fad6 | 651 | WriteCommandW(0x95, x2); |
WiredHome | 38:38d503b4fad6 | 652 | WriteCommandW(0x97, y2); |
WiredHome | 38:38d503b4fad6 | 653 | WriteCommandW(0xA9, x3); |
WiredHome | 38:38d503b4fad6 | 654 | WriteCommandW(0xAB, y3); |
WiredHome | 19:3f82c1161fd2 | 655 | unsigned char drawCmd = 0x01; // Triangle |
WiredHome | 19:3f82c1161fd2 | 656 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 657 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 658 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 659 | WriteCommand(0x90, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 660 | while (ReadCommand(0x90) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 661 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 662 | } |
WiredHome | 19:3f82c1161fd2 | 663 | REGISTERPERFORMANCE(PRF_DRAWTRIANGLE); |
WiredHome | 19:3f82c1161fd2 | 664 | return ret; |
WiredHome | 19:3f82c1161fd2 | 665 | } |
WiredHome | 19:3f82c1161fd2 | 666 | |
WiredHome | 37:f19b7e7449dc | 667 | RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, |
WiredHome | 19:3f82c1161fd2 | 668 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 669 | { |
WiredHome | 19:3f82c1161fd2 | 670 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 671 | return circle(x,y,radius,fillit); |
WiredHome | 19:3f82c1161fd2 | 672 | } |
WiredHome | 19:3f82c1161fd2 | 673 | |
WiredHome | 37:f19b7e7449dc | 674 | RetCode_t RA8875::fillcircle(loc_t x, loc_t y, dim_t radius, |
WiredHome | 19:3f82c1161fd2 | 675 | color_t color, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 676 | { |
WiredHome | 19:3f82c1161fd2 | 677 | foreground(color); |
WiredHome | 19:3f82c1161fd2 | 678 | return circle(x,y,radius,fillit); |
WiredHome | 19:3f82c1161fd2 | 679 | } |
WiredHome | 19:3f82c1161fd2 | 680 | |
WiredHome | 37:f19b7e7449dc | 681 | RetCode_t RA8875::circle(loc_t x, loc_t y, dim_t radius, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 682 | { |
WiredHome | 19:3f82c1161fd2 | 683 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 684 | |
WiredHome | 19:3f82c1161fd2 | 685 | PERFORMANCE_RESET; |
WiredHome | 19:3f82c1161fd2 | 686 | if (radius <= 0) { |
WiredHome | 19:3f82c1161fd2 | 687 | ret = bad_parameter; |
WiredHome | 19:3f82c1161fd2 | 688 | } else if (radius == 1) { |
WiredHome | 19:3f82c1161fd2 | 689 | pixel(x,y); |
WiredHome | 19:3f82c1161fd2 | 690 | } else { |
WiredHome | 38:38d503b4fad6 | 691 | WriteCommandW(0x99, x); |
WiredHome | 38:38d503b4fad6 | 692 | WriteCommandW(0x9B, y); |
WiredHome | 19:3f82c1161fd2 | 693 | WriteCommand(0x9d, radius & 0xFF); |
WiredHome | 19:3f82c1161fd2 | 694 | unsigned char drawCmd = 0x00; // Circle |
WiredHome | 19:3f82c1161fd2 | 695 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 696 | drawCmd |= 0x20; |
WiredHome | 19:3f82c1161fd2 | 697 | WriteCommand(0x90, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 698 | WriteCommand(0x90, 0x40 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 699 | while (ReadCommand(0x90) & 0x40) // await completion. |
WiredHome | 19:3f82c1161fd2 | 700 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 701 | } |
WiredHome | 19:3f82c1161fd2 | 702 | REGISTERPERFORMANCE(PRF_DRAWCIRCLE); |
WiredHome | 19:3f82c1161fd2 | 703 | return ret; |
WiredHome | 19:3f82c1161fd2 | 704 | } |
WiredHome | 19:3f82c1161fd2 | 705 | |
WiredHome | 37:f19b7e7449dc | 706 | 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 | 707 | { |
WiredHome | 19:3f82c1161fd2 | 708 | foreground(color); |
WiredHome | 25:9556a3a9b7cc | 709 | return ellipse(x,y,radius1,radius2,fillit); |
WiredHome | 19:3f82c1161fd2 | 710 | } |
WiredHome | 19:3f82c1161fd2 | 711 | |
WiredHome | 37:f19b7e7449dc | 712 | 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 | 713 | { |
WiredHome | 25:9556a3a9b7cc | 714 | foreground(color); |
WiredHome | 25:9556a3a9b7cc | 715 | return ellipse(x,y,radius1,radius2,fillit); |
WiredHome | 25:9556a3a9b7cc | 716 | } |
WiredHome | 25:9556a3a9b7cc | 717 | |
WiredHome | 37:f19b7e7449dc | 718 | RetCode_t RA8875::ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit) |
WiredHome | 19:3f82c1161fd2 | 719 | { |
WiredHome | 19:3f82c1161fd2 | 720 | RetCode_t ret = noerror; |
WiredHome | 19:3f82c1161fd2 | 721 | |
WiredHome | 19:3f82c1161fd2 | 722 | PERFORMANCE_RESET; |
WiredHome | 25:9556a3a9b7cc | 723 | if (radius1 <= 0 || radius2 <= 0) { |
WiredHome | 19:3f82c1161fd2 | 724 | ; // do nothing |
WiredHome | 25:9556a3a9b7cc | 725 | } else if (radius1 == 1 && radius2 == 1) { |
WiredHome | 19:3f82c1161fd2 | 726 | pixel(x, y); |
WiredHome | 19:3f82c1161fd2 | 727 | } else { |
WiredHome | 38:38d503b4fad6 | 728 | WriteCommandW(0xA5, x); |
WiredHome | 38:38d503b4fad6 | 729 | WriteCommandW(0xA7, y); |
WiredHome | 38:38d503b4fad6 | 730 | WriteCommandW(0xA1, radius1); |
WiredHome | 38:38d503b4fad6 | 731 | WriteCommandW(0xA3, radius2); |
WiredHome | 19:3f82c1161fd2 | 732 | unsigned char drawCmd = 0x00; // Ellipse |
WiredHome | 19:3f82c1161fd2 | 733 | if (fillit == FILL) |
WiredHome | 19:3f82c1161fd2 | 734 | drawCmd |= 0x40; |
WiredHome | 19:3f82c1161fd2 | 735 | WriteCommand(0xA0, drawCmd); |
WiredHome | 19:3f82c1161fd2 | 736 | WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing. |
WiredHome | 19:3f82c1161fd2 | 737 | while (ReadCommand(0xA0) & 0x80) // await completion. |
WiredHome | 19:3f82c1161fd2 | 738 | wait_us(POLLWAITuSec); |
WiredHome | 19:3f82c1161fd2 | 739 | } |
WiredHome | 19:3f82c1161fd2 | 740 | REGISTERPERFORMANCE(PRF_DRAWELLIPSE); |
WiredHome | 19:3f82c1161fd2 | 741 | return ret; |
WiredHome | 19:3f82c1161fd2 | 742 | } |
WiredHome | 19:3f82c1161fd2 | 743 | |
WiredHome | 19:3f82c1161fd2 | 744 | RetCode_t RA8875::frequency(unsigned long Hz) |
WiredHome | 19:3f82c1161fd2 | 745 | { |
WiredHome | 19:3f82c1161fd2 | 746 | spi.frequency(Hz); |
WiredHome | 19:3f82c1161fd2 | 747 | // __ ___ |
WiredHome | 19:3f82c1161fd2 | 748 | // Clock ___A Rising edge latched |
WiredHome | 19:3f82c1161fd2 | 749 | // ___ ____ |
WiredHome | 19:3f82c1161fd2 | 750 | // Data ___X____ |
WiredHome | 19:3f82c1161fd2 | 751 | spi.format(8, 3); // 8 bits and clock to data phase 0 |
WiredHome | 19:3f82c1161fd2 | 752 | init(); |
WiredHome | 19:3f82c1161fd2 | 753 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 754 | } |
WiredHome | 19:3f82c1161fd2 | 755 | |
WiredHome | 19:3f82c1161fd2 | 756 | RetCode_t RA8875::Power(bool on) |
WiredHome | 19:3f82c1161fd2 | 757 | { |
WiredHome | 19:3f82c1161fd2 | 758 | WriteCommand(0x01, (on) ? 0x80 : 0x00); |
WiredHome | 19:3f82c1161fd2 | 759 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 760 | } |
WiredHome | 19:3f82c1161fd2 | 761 | |
WiredHome | 19:3f82c1161fd2 | 762 | RetCode_t RA8875::Reset(void) |
WiredHome | 19:3f82c1161fd2 | 763 | { |
WiredHome | 19:3f82c1161fd2 | 764 | WriteCommand(0x01, 0x01); // Apply Display Off, Reset |
WiredHome | 19:3f82c1161fd2 | 765 | wait_ms(2); // no idea if I need to wait, or how long |
WiredHome | 19:3f82c1161fd2 | 766 | WriteCommand(0x01, 0x00); // Display off, Remove reset |
WiredHome | 19:3f82c1161fd2 | 767 | wait_ms(2); // no idea if I need to wait, or how long |
WiredHome | 19:3f82c1161fd2 | 768 | init(); |
WiredHome | 19:3f82c1161fd2 | 769 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 770 | } |
WiredHome | 19:3f82c1161fd2 | 771 | |
WiredHome | 19:3f82c1161fd2 | 772 | |
WiredHome | 19:3f82c1161fd2 | 773 | RetCode_t RA8875::Backlight_u8(unsigned char brightness) |
WiredHome | 19:3f82c1161fd2 | 774 | { |
WiredHome | 19:3f82c1161fd2 | 775 | static bool is_enabled = false; |
WiredHome | 19:3f82c1161fd2 | 776 | if (brightness == 0) { |
WiredHome | 19:3f82c1161fd2 | 777 | WriteCommand(0x8a); // Disable the PWM |
WiredHome | 19:3f82c1161fd2 | 778 | WriteData(0x00); |
WiredHome | 19:3f82c1161fd2 | 779 | is_enabled = false; |
WiredHome | 19:3f82c1161fd2 | 780 | } else if (!is_enabled) { |
WiredHome | 19:3f82c1161fd2 | 781 | WriteCommand(0x8a); // Enable the PWM |
WiredHome | 19:3f82c1161fd2 | 782 | WriteData(0x80); |
WiredHome | 19:3f82c1161fd2 | 783 | WriteCommand(0x8a); // Not sure why this is needed, but following the pattern |
WiredHome | 19:3f82c1161fd2 | 784 | WriteData(0x81); // open PWM (SYS_CLK / 2 as best I can tell) |
WiredHome | 19:3f82c1161fd2 | 785 | is_enabled = true; |
WiredHome | 19:3f82c1161fd2 | 786 | } |
WiredHome | 19:3f82c1161fd2 | 787 | WriteCommand(0x8b, brightness); // Brightness parameter 0xff-0x00 |
WiredHome | 19:3f82c1161fd2 | 788 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 789 | } |
WiredHome | 19:3f82c1161fd2 | 790 | |
WiredHome | 19:3f82c1161fd2 | 791 | RetCode_t RA8875::Backlight(float brightness) |
WiredHome | 19:3f82c1161fd2 | 792 | { |
WiredHome | 19:3f82c1161fd2 | 793 | unsigned char b; |
WiredHome | 19:3f82c1161fd2 | 794 | |
WiredHome | 29:422616aa04bd | 795 | if (brightness >= 1.0) |
WiredHome | 19:3f82c1161fd2 | 796 | b = 255; |
WiredHome | 29:422616aa04bd | 797 | else if (brightness <= 0.0) |
WiredHome | 19:3f82c1161fd2 | 798 | b = 0; |
WiredHome | 19:3f82c1161fd2 | 799 | else |
WiredHome | 19:3f82c1161fd2 | 800 | b = (unsigned char)(brightness * 255); |
WiredHome | 19:3f82c1161fd2 | 801 | return Backlight_u8(b); |
WiredHome | 19:3f82c1161fd2 | 802 | } |
WiredHome | 19:3f82c1161fd2 | 803 | |
WiredHome | 19:3f82c1161fd2 | 804 | RetCode_t RA8875::set_font(const unsigned char * _font) |
WiredHome | 19:3f82c1161fd2 | 805 | { |
WiredHome | 37:f19b7e7449dc | 806 | if (font && ! _font) { |
WiredHome | 37:f19b7e7449dc | 807 | SetTextCursor(cursor_x, cursor_y); // soft-font cursor -> hw cursor |
WiredHome | 37:f19b7e7449dc | 808 | } |
WiredHome | 19:3f82c1161fd2 | 809 | font = _font; |
WiredHome | 29:422616aa04bd | 810 | GraphicsDisplay::set_font(_font); |
WiredHome | 29:422616aa04bd | 811 | return noerror; // trusting them, but it might be good to put some checks in here... |
WiredHome | 19:3f82c1161fd2 | 812 | } |
WiredHome | 19:3f82c1161fd2 | 813 | |
WiredHome | 19:3f82c1161fd2 | 814 | RetCode_t RA8875::background(color_t color) |
WiredHome | 19:3f82c1161fd2 | 815 | { |
WiredHome | 37:f19b7e7449dc | 816 | GraphicsDisplay::background(color); |
WiredHome | 19:3f82c1161fd2 | 817 | WriteCommand(0x60, (color>>11)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 818 | WriteCommand(0x61, (unsigned char)(color>>5)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 819 | WriteCommand(0x62, (unsigned char)(color)); // BGCR0 |
WiredHome | 19:3f82c1161fd2 | 820 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 821 | } |
WiredHome | 19:3f82c1161fd2 | 822 | |
WiredHome | 19:3f82c1161fd2 | 823 | RetCode_t RA8875::background(unsigned char r, unsigned char g, unsigned char b) |
WiredHome | 19:3f82c1161fd2 | 824 | { |
WiredHome | 37:f19b7e7449dc | 825 | background(RGB(r,g,b)); |
WiredHome | 37:f19b7e7449dc | 826 | // WriteCommand(0x60, r); |
WiredHome | 37:f19b7e7449dc | 827 | // WriteCommand(0x61, g); |
WiredHome | 37:f19b7e7449dc | 828 | // WriteCommand(0x62, b); |
WiredHome | 19:3f82c1161fd2 | 829 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 830 | } |
WiredHome | 19:3f82c1161fd2 | 831 | |
WiredHome | 19:3f82c1161fd2 | 832 | RetCode_t RA8875::foreground(color_t color) |
WiredHome | 19:3f82c1161fd2 | 833 | { |
WiredHome | 37:f19b7e7449dc | 834 | GraphicsDisplay::foreground(color); |
WiredHome | 19:3f82c1161fd2 | 835 | WriteCommand(0x63, (unsigned char)(color>>11)); |
WiredHome | 19:3f82c1161fd2 | 836 | WriteCommand(0x64, (unsigned char)(color>>5)); |
WiredHome | 19:3f82c1161fd2 | 837 | WriteCommand(0x65, (unsigned char)(color)); |
WiredHome | 19:3f82c1161fd2 | 838 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 839 | } |
WiredHome | 19:3f82c1161fd2 | 840 | |
WiredHome | 37:f19b7e7449dc | 841 | RetCode_t RA8875::foreground(unsigned char r, unsigned char g, unsigned char b) |
WiredHome | 19:3f82c1161fd2 | 842 | { |
WiredHome | 37:f19b7e7449dc | 843 | foreground(RGB(r,g,b)); |
WiredHome | 37:f19b7e7449dc | 844 | // WriteCommand(0x63, r); |
WiredHome | 37:f19b7e7449dc | 845 | // WriteCommand(0x64, g); |
WiredHome | 37:f19b7e7449dc | 846 | // WriteCommand(0x65, b); |
WiredHome | 19:3f82c1161fd2 | 847 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 848 | } |
WiredHome | 19:3f82c1161fd2 | 849 | |
WiredHome | 37:f19b7e7449dc | 850 | color_t RA8875::GetForeColor(void) |
WiredHome | 19:3f82c1161fd2 | 851 | { |
WiredHome | 19:3f82c1161fd2 | 852 | color_t color; |
WiredHome | 19:3f82c1161fd2 | 853 | |
WiredHome | 19:3f82c1161fd2 | 854 | color = (ReadCommand(0x63) & 0x1F) << 11; |
WiredHome | 19:3f82c1161fd2 | 855 | color |= (ReadCommand(0x64) & 0x3F) << 5; |
WiredHome | 19:3f82c1161fd2 | 856 | color |= (ReadCommand(0x65) & 0x1F); |
WiredHome | 19:3f82c1161fd2 | 857 | return color; |
WiredHome | 19:3f82c1161fd2 | 858 | } |
WiredHome | 19:3f82c1161fd2 | 859 | |
WiredHome | 19:3f82c1161fd2 | 860 | color_t RA8875::DOSColor(int i) |
WiredHome | 19:3f82c1161fd2 | 861 | { |
WiredHome | 19:3f82c1161fd2 | 862 | const color_t colors[16] = |
WiredHome | 19:3f82c1161fd2 | 863 | { |
WiredHome | 19:3f82c1161fd2 | 864 | Black, Blue, Green, Cyan, |
WiredHome | 19:3f82c1161fd2 | 865 | Red, Magenta, Brown, Gray, |
WiredHome | 19:3f82c1161fd2 | 866 | Charcoal, BrightBlue, BrightGreen, BrightCyan, |
WiredHome | 19:3f82c1161fd2 | 867 | Orange, Pink, Yellow, White |
WiredHome | 19:3f82c1161fd2 | 868 | }; |
WiredHome | 19:3f82c1161fd2 | 869 | if (i < 16) |
WiredHome | 19:3f82c1161fd2 | 870 | return colors[i]; |
WiredHome | 19:3f82c1161fd2 | 871 | else |
WiredHome | 19:3f82c1161fd2 | 872 | return 0; |
WiredHome | 19:3f82c1161fd2 | 873 | } |
WiredHome | 19:3f82c1161fd2 | 874 | |
WiredHome | 19:3f82c1161fd2 | 875 | const char * RA8875::DOSColorNames(int i) |
WiredHome | 19:3f82c1161fd2 | 876 | { |
WiredHome | 19:3f82c1161fd2 | 877 | const char * names[16] = |
WiredHome | 19:3f82c1161fd2 | 878 | { |
WiredHome | 19:3f82c1161fd2 | 879 | "Black", "Blue", "Green", "Cyan", |
WiredHome | 19:3f82c1161fd2 | 880 | "Red", "Magenta", "Brown", "Gray", |
WiredHome | 19:3f82c1161fd2 | 881 | "Charcoal", "BrightBlue", "BrightGreen", "BrightCyan", |
WiredHome | 19:3f82c1161fd2 | 882 | "Orange", "Pink", "Yellow", "White" |
WiredHome | 19:3f82c1161fd2 | 883 | }; |
WiredHome | 19:3f82c1161fd2 | 884 | if (i < 16) |
WiredHome | 19:3f82c1161fd2 | 885 | return names[i]; |
WiredHome | 19:3f82c1161fd2 | 886 | else |
WiredHome | 19:3f82c1161fd2 | 887 | return NULL; |
WiredHome | 19:3f82c1161fd2 | 888 | } |
WiredHome | 19:3f82c1161fd2 | 889 | |
WiredHome | 19:3f82c1161fd2 | 890 | |
WiredHome | 19:3f82c1161fd2 | 891 | /////////////////////////////////////////////////////////////// |
WiredHome | 19:3f82c1161fd2 | 892 | // Private functions |
WiredHome | 19:3f82c1161fd2 | 893 | |
WiredHome | 19:3f82c1161fd2 | 894 | unsigned char RA8875::spiwrite(unsigned char data) |
WiredHome | 19:3f82c1161fd2 | 895 | { |
WiredHome | 19:3f82c1161fd2 | 896 | unsigned char retval; |
WiredHome | 19:3f82c1161fd2 | 897 | |
WiredHome | 19:3f82c1161fd2 | 898 | retval = spi.write(data); |
WiredHome | 19:3f82c1161fd2 | 899 | return retval; |
WiredHome | 19:3f82c1161fd2 | 900 | } |
WiredHome | 19:3f82c1161fd2 | 901 | |
WiredHome | 19:3f82c1161fd2 | 902 | unsigned char RA8875::spiread(void) |
WiredHome | 19:3f82c1161fd2 | 903 | { |
WiredHome | 19:3f82c1161fd2 | 904 | unsigned char retval; |
WiredHome | 19:3f82c1161fd2 | 905 | unsigned char data = 0; |
WiredHome | 19:3f82c1161fd2 | 906 | |
WiredHome | 19:3f82c1161fd2 | 907 | retval = spi.write(data); |
WiredHome | 19:3f82c1161fd2 | 908 | return retval; |
WiredHome | 19:3f82c1161fd2 | 909 | } |
WiredHome | 19:3f82c1161fd2 | 910 | |
WiredHome | 19:3f82c1161fd2 | 911 | RetCode_t RA8875::select(bool chipsel) |
WiredHome | 19:3f82c1161fd2 | 912 | { |
WiredHome | 19:3f82c1161fd2 | 913 | cs = (chipsel == true) ? 0 : 1; |
WiredHome | 19:3f82c1161fd2 | 914 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 915 | } |
WiredHome | 19:3f82c1161fd2 | 916 | |
WiredHome | 19:3f82c1161fd2 | 917 | RetCode_t RA8875::init(void) |
WiredHome | 19:3f82c1161fd2 | 918 | { |
WiredHome | 19:3f82c1161fd2 | 919 | Backlight_u8(0); |
WiredHome | 37:f19b7e7449dc | 920 | WriteCommand(0x88, 0x0a); // PLLC1 - Phase Lock Loop registers |
WiredHome | 19:3f82c1161fd2 | 921 | wait_ms(1); |
WiredHome | 19:3f82c1161fd2 | 922 | WriteCommand(0x89, 0x02); |
WiredHome | 19:3f82c1161fd2 | 923 | wait_ms(1); |
WiredHome | 19:3f82c1161fd2 | 924 | |
WiredHome | 23:a50ded45dbaf | 925 | // System Config Register (SYSR) |
WiredHome | 37:f19b7e7449dc | 926 | WriteCommand(0x10, 0x0C); // 16-bpp (65K colors) color depth, 8-bit interface |
WiredHome | 23:a50ded45dbaf | 927 | // Pixel Clock Setting Register (PCSR) |
WiredHome | 37:f19b7e7449dc | 928 | WriteCommand(0x04, 0x82); // PDAT on PCLK falling edge, PCLK = 4 x System Clock |
WiredHome | 19:3f82c1161fd2 | 929 | wait_ms(1); |
WiredHome | 19:3f82c1161fd2 | 930 | |
WiredHome | 19:3f82c1161fd2 | 931 | // Horizontal Settings |
WiredHome | 23:a50ded45dbaf | 932 | WriteCommand(0x14, RA8875_DISPLAY_WIDTH/8 - 1); //HDWR//Horizontal Display Width Setting Bit[6:0] |
WiredHome | 19:3f82c1161fd2 | 933 | WriteCommand(0x15, 0x02); //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0] |
WiredHome | 19:3f82c1161fd2 | 934 | WriteCommand(0x16, 0x03); //HNDR//Horizontal Non-Display Period Bit[4:0] |
WiredHome | 19:3f82c1161fd2 | 935 | WriteCommand(0x17, 0x01); //HSTR//HSYNC Start Position[4:0] |
WiredHome | 19:3f82c1161fd2 | 936 | WriteCommand(0x18, 0x03); //HPWR//HSYNC Polarity ,The period width of HSYNC. |
WiredHome | 19:3f82c1161fd2 | 937 | |
WiredHome | 19:3f82c1161fd2 | 938 | // Vertical Settings |
WiredHome | 23:a50ded45dbaf | 939 | WriteCommand(0x19, (RA8875_DISPLAY_HEIGHT-1)&0xFF); //VDHR0 //Vertical Display Height Bit [7:0] |
WiredHome | 23:a50ded45dbaf | 940 | WriteCommand(0x1a, (RA8875_DISPLAY_HEIGHT-1)>>8); //VDHR1 //Vertical Display Height Bit [8] |
WiredHome | 19:3f82c1161fd2 | 941 | WriteCommand(0x1b, 0x0F); //VNDR0 //Vertical Non-Display Period Bit [7:0] |
WiredHome | 19:3f82c1161fd2 | 942 | WriteCommand(0x1c, 0x00); //VNDR1 //Vertical Non-Display Period Bit [8] |
WiredHome | 19:3f82c1161fd2 | 943 | WriteCommand(0x1d, 0x0e); //VSTR0 //VSYNC Start Position[7:0] |
WiredHome | 19:3f82c1161fd2 | 944 | WriteCommand(0x1e, 0x06); //VSTR1 //VSYNC Start Position[8] |
WiredHome | 19:3f82c1161fd2 | 945 | WriteCommand(0x1f, 0x01); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0] |
WiredHome | 19:3f82c1161fd2 | 946 | |
WiredHome | 19:3f82c1161fd2 | 947 | // Clear ram image |
WiredHome | 37:f19b7e7449dc | 948 | window(0,0, width(), height()); // Initialize to full screen |
WiredHome | 24:8ca861acf12d | 949 | SetTextCursorControl(); |
WiredHome | 28:ed102fc442c4 | 950 | foreground(Blue); |
WiredHome | 19:3f82c1161fd2 | 951 | background(Black); |
WiredHome | 19:3f82c1161fd2 | 952 | cls(); |
WiredHome | 19:3f82c1161fd2 | 953 | return noerror; |
WiredHome | 19:3f82c1161fd2 | 954 | } |
WiredHome | 19:3f82c1161fd2 | 955 | |
WiredHome | 23:a50ded45dbaf | 956 | #ifdef TESTENABLE |
WiredHome | 23:a50ded45dbaf | 957 | |
WiredHome | 37:f19b7e7449dc | 958 | #include "Arial12x12.h" |
WiredHome | 37:f19b7e7449dc | 959 | #include "Small_6.h" |
WiredHome | 37:f19b7e7449dc | 960 | |
WiredHome | 23:a50ded45dbaf | 961 | // ______________ ______________ ______________ _______________ |
WiredHome | 23:a50ded45dbaf | 962 | // /_____ _____/ / ___________/ / ___________/ /_____ ______/ |
WiredHome | 23:a50ded45dbaf | 963 | // / / / / / / / / |
WiredHome | 23:a50ded45dbaf | 964 | // / / / /___ / /__________ / / |
WiredHome | 23:a50ded45dbaf | 965 | // / / / ____/ /__________ / / / |
WiredHome | 23:a50ded45dbaf | 966 | // / / / / / / / / |
WiredHome | 23:a50ded45dbaf | 967 | // / / / /__________ ___________/ / / / |
WiredHome | 23:a50ded45dbaf | 968 | // /__/ /_____________/ /_____________/ /__/ |
WiredHome | 23:a50ded45dbaf | 969 | // |
WiredHome | 23:a50ded45dbaf | 970 | // Everything from here down is test code. |
WiredHome | 23:a50ded45dbaf | 971 | |
WiredHome | 23:a50ded45dbaf | 972 | void TextCursorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 973 | { |
WiredHome | 37:f19b7e7449dc | 974 | const char * iCursor = "The I-Beam cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 975 | const char * uCursor = "The Underscore cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 976 | const char * bCursor = "The Block cursor should be visible for this text.\r\n"; |
WiredHome | 37:f19b7e7449dc | 977 | const char * bbCursor = "The Blinking Block cursor should be visible for this text.\r\n"; |
WiredHome | 23:a50ded45dbaf | 978 | const char * p; |
WiredHome | 23:a50ded45dbaf | 979 | |
WiredHome | 23:a50ded45dbaf | 980 | pc.printf("Text Cursor Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 981 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 982 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 983 | display.cls(); |
WiredHome | 25:9556a3a9b7cc | 984 | display.Backlight_u8(255); |
WiredHome | 23:a50ded45dbaf | 985 | display.puts(0,0, "Text Cursor Test."); |
WiredHome | 23:a50ded45dbaf | 986 | |
WiredHome | 23:a50ded45dbaf | 987 | // visible, non-blinking |
WiredHome | 24:8ca861acf12d | 988 | display.SetTextCursor(0,20); |
WiredHome | 24:8ca861acf12d | 989 | display.SetTextCursorControl(IBEAM, false); |
WiredHome | 24:8ca861acf12d | 990 | p = iCursor; |
WiredHome | 23:a50ded45dbaf | 991 | while (*p) { |
WiredHome | 24:8ca861acf12d | 992 | display._putc(*p++); |
WiredHome | 24:8ca861acf12d | 993 | wait_ms(100); |
WiredHome | 24:8ca861acf12d | 994 | } |
WiredHome | 24:8ca861acf12d | 995 | |
WiredHome | 24:8ca861acf12d | 996 | display.SetTextCursorControl(UNDER, false); |
WiredHome | 24:8ca861acf12d | 997 | p = uCursor; |
WiredHome | 24:8ca861acf12d | 998 | while (*p) { |
WiredHome | 24:8ca861acf12d | 999 | display._putc(*p++); |
WiredHome | 23:a50ded45dbaf | 1000 | wait_ms(100); |
WiredHome | 23:a50ded45dbaf | 1001 | } |
WiredHome | 24:8ca861acf12d | 1002 | |
WiredHome | 24:8ca861acf12d | 1003 | display.SetTextCursorControl(BLOCK, false); |
WiredHome | 24:8ca861acf12d | 1004 | p = bCursor; |
WiredHome | 24:8ca861acf12d | 1005 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1006 | display._putc(*p++); |
WiredHome | 24:8ca861acf12d | 1007 | wait_ms(100); |
WiredHome | 24:8ca861acf12d | 1008 | } |
WiredHome | 24:8ca861acf12d | 1009 | |
WiredHome | 24:8ca861acf12d | 1010 | display.SetTextCursorControl(BLOCK, true); |
WiredHome | 24:8ca861acf12d | 1011 | p = bbCursor; |
WiredHome | 24:8ca861acf12d | 1012 | while (*p) { |
WiredHome | 24:8ca861acf12d | 1013 | display._putc(*p++); |
WiredHome | 24:8ca861acf12d | 1014 | wait_ms(100); |
WiredHome | 24:8ca861acf12d | 1015 | } |
WiredHome | 24:8ca861acf12d | 1016 | wait_ms(2000); |
WiredHome | 24:8ca861acf12d | 1017 | display.SetTextCursorControl(NOCURSOR, false); |
WiredHome | 23:a50ded45dbaf | 1018 | } |
WiredHome | 23:a50ded45dbaf | 1019 | |
WiredHome | 23:a50ded45dbaf | 1020 | void BacklightTest(RA8875 & display, Serial & pc, float ramptime) |
WiredHome | 23:a50ded45dbaf | 1021 | { |
WiredHome | 29:422616aa04bd | 1022 | char buf[60]; |
WiredHome | 29:422616aa04bd | 1023 | |
WiredHome | 23:a50ded45dbaf | 1024 | pc.printf("Backlight Test - ramp over %f sec.\r\n", ramptime); |
WiredHome | 23:a50ded45dbaf | 1025 | display.Backlight_u8(0); |
WiredHome | 29:422616aa04bd | 1026 | display.background(White); |
WiredHome | 23:a50ded45dbaf | 1027 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1028 | display.cls(); |
WiredHome | 29:422616aa04bd | 1029 | wait_ms(200); |
WiredHome | 23:a50ded45dbaf | 1030 | display.puts(0,0, "RA8875 Backlight Test - Ramp up."); |
WiredHome | 38:38d503b4fad6 | 1031 | for (int i=0; i <= 255; i++) { |
WiredHome | 29:422616aa04bd | 1032 | unsigned int w = (ramptime * 1000)/ 256; |
WiredHome | 29:422616aa04bd | 1033 | sprintf(buf, "%3d, %4d", i, w); |
WiredHome | 37:f19b7e7449dc | 1034 | display.puts(100,100,buf); |
WiredHome | 23:a50ded45dbaf | 1035 | display.Backlight_u8(i); |
WiredHome | 29:422616aa04bd | 1036 | wait_ms(w); |
WiredHome | 23:a50ded45dbaf | 1037 | } |
WiredHome | 23:a50ded45dbaf | 1038 | } |
WiredHome | 23:a50ded45dbaf | 1039 | |
WiredHome | 23:a50ded45dbaf | 1040 | void BacklightTest2(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1041 | { |
WiredHome | 23:a50ded45dbaf | 1042 | pc.printf("Backlight Test 2\r\n"); |
WiredHome | 23:a50ded45dbaf | 1043 | // Dim it out at the end of the tests. |
WiredHome | 37:f19b7e7449dc | 1044 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1045 | display.puts(0,0, "Ramp Backlight down."); |
WiredHome | 23:a50ded45dbaf | 1046 | // Ramp it off |
WiredHome | 23:a50ded45dbaf | 1047 | for (int i=255; i != 0; i--) { |
WiredHome | 23:a50ded45dbaf | 1048 | display.Backlight_u8(i); |
WiredHome | 23:a50ded45dbaf | 1049 | wait_ms(20); |
WiredHome | 23:a50ded45dbaf | 1050 | } |
WiredHome | 23:a50ded45dbaf | 1051 | display.Backlight_u8(0); |
WiredHome | 23:a50ded45dbaf | 1052 | } |
WiredHome | 23:a50ded45dbaf | 1053 | |
WiredHome | 23:a50ded45dbaf | 1054 | void ExternalFontTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1055 | { |
WiredHome | 23:a50ded45dbaf | 1056 | pc.printf("External Font Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1057 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1058 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1059 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1060 | display.Backlight(1); |
WiredHome | 37:f19b7e7449dc | 1061 | display.puts(0,0, "External Font Test."); |
WiredHome | 37:f19b7e7449dc | 1062 | |
WiredHome | 37:f19b7e7449dc | 1063 | display.set_font(Small_6); |
WiredHome | 37:f19b7e7449dc | 1064 | display.puts(0,30, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n"); |
WiredHome | 37:f19b7e7449dc | 1065 | |
WiredHome | 23:a50ded45dbaf | 1066 | display.set_font(Arial12x12); |
WiredHome | 37:f19b7e7449dc | 1067 | display.puts("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\r\n"); |
WiredHome | 37:f19b7e7449dc | 1068 | display.set_font(); // restore to internal |
WiredHome | 37:f19b7e7449dc | 1069 | |
WiredHome | 37:f19b7e7449dc | 1070 | display.puts("Normal font again."); |
WiredHome | 37:f19b7e7449dc | 1071 | //display.window(0,0, display.width(), display.height()); |
WiredHome | 23:a50ded45dbaf | 1072 | } |
WiredHome | 23:a50ded45dbaf | 1073 | |
WiredHome | 23:a50ded45dbaf | 1074 | void DOSColorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1075 | { |
WiredHome | 23:a50ded45dbaf | 1076 | pc.printf("DOS Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1077 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1078 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1079 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1080 | display.puts(0,0, "DOS Colors - Fore"); |
WiredHome | 23:a50ded45dbaf | 1081 | display.puts(280,0, "Back"); |
WiredHome | 23:a50ded45dbaf | 1082 | display.background(Gray); |
WiredHome | 23:a50ded45dbaf | 1083 | for (int i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1084 | display.foreground(display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1085 | display.puts(160, i*16, display.DOSColorNames(i)); |
WiredHome | 23:a50ded45dbaf | 1086 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1087 | } |
WiredHome | 23:a50ded45dbaf | 1088 | display.foreground(White); |
WiredHome | 23:a50ded45dbaf | 1089 | for (int i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1090 | display.background(display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1091 | display.puts(360, i*16, display.DOSColorNames(i)); |
WiredHome | 23:a50ded45dbaf | 1092 | display.foreground(White); |
WiredHome | 23:a50ded45dbaf | 1093 | } |
WiredHome | 23:a50ded45dbaf | 1094 | } |
WiredHome | 23:a50ded45dbaf | 1095 | |
WiredHome | 23:a50ded45dbaf | 1096 | void WebColorTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1097 | { |
WiredHome | 23:a50ded45dbaf | 1098 | pc.printf("Web Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1099 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1100 | display.foreground(Blue); |
WiredHome | 32:0e4f2ae512e2 | 1101 | display.window(0,0, display.width(), display.height()); |
WiredHome | 23:a50ded45dbaf | 1102 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1103 | display.puts(0,0, "Web Color Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1104 | display.SetTextFontSize(1,2); |
WiredHome | 23:a50ded45dbaf | 1105 | for (int i=0; i<sizeof(WebColors)/sizeof(WebColors[0]); i++) { |
WiredHome | 23:a50ded45dbaf | 1106 | display.background(WebColors[i]); |
WiredHome | 23:a50ded45dbaf | 1107 | display.puts(" "); |
WiredHome | 23:a50ded45dbaf | 1108 | if (i % 36 == 35) |
WiredHome | 23:a50ded45dbaf | 1109 | display.puts("\r\n"); |
WiredHome | 23:a50ded45dbaf | 1110 | } |
WiredHome | 23:a50ded45dbaf | 1111 | display.SetTextFontSize(1,1); |
WiredHome | 23:a50ded45dbaf | 1112 | } |
WiredHome | 23:a50ded45dbaf | 1113 | |
WiredHome | 37:f19b7e7449dc | 1114 | void PixelTest(RA8875 & display, Serial & pc) |
WiredHome | 37:f19b7e7449dc | 1115 | { |
WiredHome | 37:f19b7e7449dc | 1116 | int i, c, x, y; |
WiredHome | 37:f19b7e7449dc | 1117 | |
WiredHome | 37:f19b7e7449dc | 1118 | pc.printf("Pixel Test\r\n"); |
WiredHome | 37:f19b7e7449dc | 1119 | display.background(Black); |
WiredHome | 37:f19b7e7449dc | 1120 | display.foreground(Blue); |
WiredHome | 37:f19b7e7449dc | 1121 | display.cls(); |
WiredHome | 37:f19b7e7449dc | 1122 | display.puts(0,0, "Pixel Test"); |
WiredHome | 37:f19b7e7449dc | 1123 | for (i=0; i<1000; i++) { |
WiredHome | 37:f19b7e7449dc | 1124 | x = rand() % 480; |
WiredHome | 37:f19b7e7449dc | 1125 | y = 16 + rand() % (272-16); |
WiredHome | 37:f19b7e7449dc | 1126 | c = rand() % 16; |
WiredHome | 37:f19b7e7449dc | 1127 | //pc.printf(" (%d,%d) - %d\r\n", x,y,r1); |
WiredHome | 37:f19b7e7449dc | 1128 | display.pixel(x,y, display.DOSColor(c)); |
WiredHome | 37:f19b7e7449dc | 1129 | } |
WiredHome | 37:f19b7e7449dc | 1130 | } |
WiredHome | 37:f19b7e7449dc | 1131 | |
WiredHome | 23:a50ded45dbaf | 1132 | void LineTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1133 | { |
WiredHome | 23:a50ded45dbaf | 1134 | int i, x, y, x2, y2; |
WiredHome | 23:a50ded45dbaf | 1135 | |
WiredHome | 23:a50ded45dbaf | 1136 | pc.printf("Line Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1137 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1138 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1139 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1140 | display.puts(0,0, "Line Test"); |
WiredHome | 23:a50ded45dbaf | 1141 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1142 | // Lines |
WiredHome | 23:a50ded45dbaf | 1143 | x = rand() % 480; |
WiredHome | 23:a50ded45dbaf | 1144 | y = rand() % 272; |
WiredHome | 23:a50ded45dbaf | 1145 | x2 = rand() % 480; |
WiredHome | 23:a50ded45dbaf | 1146 | y2 = rand() % 272; |
WiredHome | 23:a50ded45dbaf | 1147 | display.line(x,y, x2,y2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1148 | } |
WiredHome | 23:a50ded45dbaf | 1149 | } |
WiredHome | 23:a50ded45dbaf | 1150 | |
WiredHome | 23:a50ded45dbaf | 1151 | void RectangleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1152 | { |
WiredHome | 23:a50ded45dbaf | 1153 | int i, x1,y1, x2,y2; |
WiredHome | 23:a50ded45dbaf | 1154 | |
WiredHome | 23:a50ded45dbaf | 1155 | pc.printf("Rectangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1156 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1157 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1158 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1159 | display.puts(0,0, "Rectangle Test"); |
WiredHome | 23:a50ded45dbaf | 1160 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1161 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1162 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1163 | x2 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1164 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1165 | display.rect(x1,y1, x2,y2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1166 | |
WiredHome | 23:a50ded45dbaf | 1167 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1168 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1169 | x2 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1170 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1171 | display.rect(x1,y1, x2,y2, FILL); |
WiredHome | 23:a50ded45dbaf | 1172 | } |
WiredHome | 23:a50ded45dbaf | 1173 | } |
WiredHome | 23:a50ded45dbaf | 1174 | |
WiredHome | 23:a50ded45dbaf | 1175 | void RoundRectTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1176 | { |
WiredHome | 37:f19b7e7449dc | 1177 | loc_t i, x1,y1, x2,y2, r1,r2; |
WiredHome | 23:a50ded45dbaf | 1178 | |
WiredHome | 23:a50ded45dbaf | 1179 | pc.printf("Round Rectangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1180 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1181 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1182 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1183 | display.puts(0,0, "Rounded Rectangle Test"); |
WiredHome | 23:a50ded45dbaf | 1184 | |
WiredHome | 23:a50ded45dbaf | 1185 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1186 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1187 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1188 | x2 = x1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1189 | y2 = y1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1190 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 23:a50ded45dbaf | 1191 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 23:a50ded45dbaf | 1192 | display.roundrect(x1,y1, x2,y2, 5,8, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1193 | |
WiredHome | 23:a50ded45dbaf | 1194 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1195 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1196 | x2 = x1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1197 | y2 = y1 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1198 | r1 = rand() % (x2 - x1)/2; |
WiredHome | 23:a50ded45dbaf | 1199 | r2 = rand() % (y2 - y1)/2; |
WiredHome | 23:a50ded45dbaf | 1200 | display.roundrect(x1,y1, x2,y2, r1,r2, FILL); |
WiredHome | 23:a50ded45dbaf | 1201 | } |
WiredHome | 23:a50ded45dbaf | 1202 | } |
WiredHome | 23:a50ded45dbaf | 1203 | |
WiredHome | 23:a50ded45dbaf | 1204 | void TriangleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1205 | { |
WiredHome | 23:a50ded45dbaf | 1206 | int i, x1, y1, x2, y2, x3, y3; |
WiredHome | 23:a50ded45dbaf | 1207 | |
WiredHome | 23:a50ded45dbaf | 1208 | pc.printf("Triangle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1209 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1210 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1211 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1212 | display.puts(0,0, "Triangle Test"); |
WiredHome | 23:a50ded45dbaf | 1213 | |
WiredHome | 23:a50ded45dbaf | 1214 | x1 = 150; |
WiredHome | 23:a50ded45dbaf | 1215 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1216 | x2 = 190; |
WiredHome | 23:a50ded45dbaf | 1217 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1218 | x3 = 170; |
WiredHome | 23:a50ded45dbaf | 1219 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1220 | display.triangle(x1,y1, x2,y2, x3,y3); |
WiredHome | 23:a50ded45dbaf | 1221 | |
WiredHome | 23:a50ded45dbaf | 1222 | x1 = 200; |
WiredHome | 23:a50ded45dbaf | 1223 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1224 | x2 = 240; |
WiredHome | 23:a50ded45dbaf | 1225 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1226 | x3 = 220; |
WiredHome | 23:a50ded45dbaf | 1227 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1228 | display.filltriangle(x1,y1, x2,y2, x3,y3, BrightRed); |
WiredHome | 23:a50ded45dbaf | 1229 | |
WiredHome | 23:a50ded45dbaf | 1230 | x1 = 300; |
WiredHome | 23:a50ded45dbaf | 1231 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1232 | x2 = 340; |
WiredHome | 23:a50ded45dbaf | 1233 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1234 | x3 = 320; |
WiredHome | 23:a50ded45dbaf | 1235 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1236 | display.triangle(x1,y1, x2,y2, x3,y3, NOFILL); |
WiredHome | 23:a50ded45dbaf | 1237 | |
WiredHome | 23:a50ded45dbaf | 1238 | x1 = 400; |
WiredHome | 23:a50ded45dbaf | 1239 | y1 = 2; |
WiredHome | 23:a50ded45dbaf | 1240 | x2 = 440; |
WiredHome | 23:a50ded45dbaf | 1241 | y2 = 7; |
WiredHome | 23:a50ded45dbaf | 1242 | x3 = 420; |
WiredHome | 23:a50ded45dbaf | 1243 | y3 = 16; |
WiredHome | 23:a50ded45dbaf | 1244 | display.triangle(x1,y1, x2,y2, x3,y3, Blue); |
WiredHome | 23:a50ded45dbaf | 1245 | |
WiredHome | 23:a50ded45dbaf | 1246 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1247 | x1 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1248 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1249 | x2 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1250 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1251 | x3 = rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1252 | y3 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1253 | display.triangle(x1,y1, x2,y2, x3,y3, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1254 | x1 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1255 | y1 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1256 | x2 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1257 | y2 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1258 | x3 = 240 + rand() % 240; |
WiredHome | 23:a50ded45dbaf | 1259 | y3 = 50 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1260 | display.triangle(x1,y1, x2,y2, x3,y3, FILL); |
WiredHome | 23:a50ded45dbaf | 1261 | } |
WiredHome | 23:a50ded45dbaf | 1262 | } |
WiredHome | 23:a50ded45dbaf | 1263 | |
WiredHome | 23:a50ded45dbaf | 1264 | void CircleTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1265 | { |
WiredHome | 23:a50ded45dbaf | 1266 | int i, x, y, r1; |
WiredHome | 23:a50ded45dbaf | 1267 | |
WiredHome | 23:a50ded45dbaf | 1268 | pc.printf("Circle Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1269 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1270 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1271 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1272 | display.puts(0,0, "Circle Test"); |
WiredHome | 23:a50ded45dbaf | 1273 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1274 | x = 100 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1275 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1276 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1277 | //pc.printf(" (%d,%d) - %d\r\n", x,y,r1); |
WiredHome | 23:a50ded45dbaf | 1278 | display.circle(x,y,r1, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1279 | |
WiredHome | 23:a50ded45dbaf | 1280 | x = 300 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1281 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1282 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1283 | //pc.printf(" (%d,%d) - %d FILL\r\n", x,y,r1); |
WiredHome | 23:a50ded45dbaf | 1284 | display.circle(x,y,r1, display.DOSColor(i), FILL); |
WiredHome | 23:a50ded45dbaf | 1285 | } |
WiredHome | 23:a50ded45dbaf | 1286 | } |
WiredHome | 23:a50ded45dbaf | 1287 | |
WiredHome | 23:a50ded45dbaf | 1288 | void EllipseTest(RA8875 & display, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1289 | { |
WiredHome | 23:a50ded45dbaf | 1290 | int i,x,y,r1,r2; |
WiredHome | 23:a50ded45dbaf | 1291 | |
WiredHome | 23:a50ded45dbaf | 1292 | pc.printf("Ellipse Test\r\n"); |
WiredHome | 23:a50ded45dbaf | 1293 | display.background(Black); |
WiredHome | 23:a50ded45dbaf | 1294 | display.foreground(Blue); |
WiredHome | 23:a50ded45dbaf | 1295 | display.cls(); |
WiredHome | 23:a50ded45dbaf | 1296 | display.puts(0,0, "Ellipse Test"); |
WiredHome | 23:a50ded45dbaf | 1297 | for (i=0; i<16; i++) { |
WiredHome | 23:a50ded45dbaf | 1298 | x = 100 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1299 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1300 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1301 | r2 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1302 | display.ellipse(x,y,r1,r2, display.DOSColor(i)); |
WiredHome | 23:a50ded45dbaf | 1303 | |
WiredHome | 23:a50ded45dbaf | 1304 | x = 300 + rand() % 100; |
WiredHome | 23:a50ded45dbaf | 1305 | y = 70 + rand() % 200; |
WiredHome | 23:a50ded45dbaf | 1306 | r1 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1307 | r2 = rand() % min(y - 20, 100); |
WiredHome | 23:a50ded45dbaf | 1308 | display.ellipse(x,y,r1,r2, FILL); |
WiredHome | 23:a50ded45dbaf | 1309 | } |
WiredHome | 23:a50ded45dbaf | 1310 | } |
WiredHome | 23:a50ded45dbaf | 1311 | |
WiredHome | 37:f19b7e7449dc | 1312 | void TestGraphicsBitmap(RA8875 & display, Serial & pc) |
WiredHome | 37:f19b7e7449dc | 1313 | { |
WiredHome | 37:f19b7e7449dc | 1314 | LocalFileSystem local("local"); |
WiredHome | 37:f19b7e7449dc | 1315 | display.background(Black); |
WiredHome | 37:f19b7e7449dc | 1316 | display.foreground(Blue); |
WiredHome | 37:f19b7e7449dc | 1317 | display.cls(); |
WiredHome | 37:f19b7e7449dc | 1318 | display.puts(0,0, "Graphics Test, loading /local/TestPat.bmp"); |
WiredHome | 37:f19b7e7449dc | 1319 | wait(3); |
WiredHome | 37:f19b7e7449dc | 1320 | |
WiredHome | 37:f19b7e7449dc | 1321 | int r = display.RenderBitmapFile(0,0, "/local/TestPat.bmp"); |
WiredHome | 37:f19b7e7449dc | 1322 | } |
WiredHome | 37:f19b7e7449dc | 1323 | |
WiredHome | 23:a50ded45dbaf | 1324 | void RunTestSet(RA8875 & lcd, Serial & pc) |
WiredHome | 23:a50ded45dbaf | 1325 | { |
WiredHome | 23:a50ded45dbaf | 1326 | int q = 0; |
WiredHome | 23:a50ded45dbaf | 1327 | int automode = 0; |
WiredHome | 37:f19b7e7449dc | 1328 | const unsigned char modelist[] = "BDWtGLFROTPCEb"; // auto-test in this order. |
WiredHome | 23:a50ded45dbaf | 1329 | |
WiredHome | 23:a50ded45dbaf | 1330 | while(1) { |
WiredHome | 23:a50ded45dbaf | 1331 | pc.printf("\r\n" |
WiredHome | 23:a50ded45dbaf | 1332 | "B - Backlight up b - backlight dim\r\n" |
WiredHome | 23:a50ded45dbaf | 1333 | "D - DOS Colors W - Web Colors\r\n" |
WiredHome | 37:f19b7e7449dc | 1334 | "t - text cursor G - Graphics Bitmap\r\n" |
WiredHome | 23:a50ded45dbaf | 1335 | "L - Lines F - external Font\r\n" |
WiredHome | 23:a50ded45dbaf | 1336 | "R - Rectangles O - rOund rectangles\r\n" |
WiredHome | 37:f19b7e7449dc | 1337 | "T - Triangles P - Pixels \r\n" |
WiredHome | 23:a50ded45dbaf | 1338 | "C - Circles E - Ellipses\r\n" |
WiredHome | 25:9556a3a9b7cc | 1339 | "A - Auto Test mode r - reset \r\n" |
WiredHome | 23:a50ded45dbaf | 1340 | "> "); |
WiredHome | 23:a50ded45dbaf | 1341 | if (automode == -1 || pc.readable()) { |
WiredHome | 23:a50ded45dbaf | 1342 | automode = -1; |
WiredHome | 37:f19b7e7449dc | 1343 | q = pc.getc(); |
WiredHome | 37:f19b7e7449dc | 1344 | while (pc.readable()) |
WiredHome | 37:f19b7e7449dc | 1345 | pc.getc(); |
WiredHome | 23:a50ded45dbaf | 1346 | } else if (automode >= 0) { |
WiredHome | 23:a50ded45dbaf | 1347 | q = modelist[automode]; |
WiredHome | 23:a50ded45dbaf | 1348 | } |
WiredHome | 23:a50ded45dbaf | 1349 | switch(q) { |
WiredHome | 23:a50ded45dbaf | 1350 | case 'A': |
WiredHome | 23:a50ded45dbaf | 1351 | automode = 0; |
WiredHome | 23:a50ded45dbaf | 1352 | break; |
WiredHome | 23:a50ded45dbaf | 1353 | case 'B': |
WiredHome | 29:422616aa04bd | 1354 | BacklightTest(lcd, pc, 4); |
WiredHome | 23:a50ded45dbaf | 1355 | break; |
WiredHome | 23:a50ded45dbaf | 1356 | case 'b': |
WiredHome | 23:a50ded45dbaf | 1357 | BacklightTest2(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1358 | break; |
WiredHome | 23:a50ded45dbaf | 1359 | case 'D': |
WiredHome | 23:a50ded45dbaf | 1360 | DOSColorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1361 | break; |
WiredHome | 23:a50ded45dbaf | 1362 | case 'W': |
WiredHome | 23:a50ded45dbaf | 1363 | WebColorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1364 | break; |
WiredHome | 23:a50ded45dbaf | 1365 | case 't': |
WiredHome | 23:a50ded45dbaf | 1366 | TextCursorTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1367 | break; |
WiredHome | 23:a50ded45dbaf | 1368 | case 'F': |
WiredHome | 23:a50ded45dbaf | 1369 | ExternalFontTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1370 | break; |
WiredHome | 23:a50ded45dbaf | 1371 | case 'L': |
WiredHome | 23:a50ded45dbaf | 1372 | LineTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1373 | break; |
WiredHome | 23:a50ded45dbaf | 1374 | case 'R': |
WiredHome | 23:a50ded45dbaf | 1375 | RectangleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1376 | break; |
WiredHome | 23:a50ded45dbaf | 1377 | case 'O': |
WiredHome | 23:a50ded45dbaf | 1378 | RoundRectTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1379 | break; |
WiredHome | 23:a50ded45dbaf | 1380 | case 'T': |
WiredHome | 23:a50ded45dbaf | 1381 | TriangleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1382 | break; |
WiredHome | 37:f19b7e7449dc | 1383 | case 'P': |
WiredHome | 37:f19b7e7449dc | 1384 | PixelTest(lcd, pc); |
WiredHome | 37:f19b7e7449dc | 1385 | break; |
WiredHome | 37:f19b7e7449dc | 1386 | case 'G': |
WiredHome | 37:f19b7e7449dc | 1387 | TestGraphicsBitmap(lcd, pc); |
WiredHome | 37:f19b7e7449dc | 1388 | break; |
WiredHome | 23:a50ded45dbaf | 1389 | case 'C': |
WiredHome | 23:a50ded45dbaf | 1390 | CircleTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1391 | break; |
WiredHome | 23:a50ded45dbaf | 1392 | case 'E': |
WiredHome | 23:a50ded45dbaf | 1393 | EllipseTest(lcd, pc); |
WiredHome | 23:a50ded45dbaf | 1394 | break; |
WiredHome | 23:a50ded45dbaf | 1395 | case 'r': |
WiredHome | 23:a50ded45dbaf | 1396 | pc.printf("Resetting ...\r\n"); |
WiredHome | 23:a50ded45dbaf | 1397 | wait_ms(20); |
WiredHome | 23:a50ded45dbaf | 1398 | mbed_reset(); |
WiredHome | 23:a50ded45dbaf | 1399 | break; |
WiredHome | 23:a50ded45dbaf | 1400 | default: |
WiredHome | 23:a50ded45dbaf | 1401 | printf("huh?\n"); |
WiredHome | 23:a50ded45dbaf | 1402 | break; |
WiredHome | 23:a50ded45dbaf | 1403 | } |
WiredHome | 23:a50ded45dbaf | 1404 | if (automode >= 0) { |
WiredHome | 23:a50ded45dbaf | 1405 | automode++; |
WiredHome | 23:a50ded45dbaf | 1406 | if (automode >= sizeof(modelist)) |
WiredHome | 23:a50ded45dbaf | 1407 | automode = 0; |
WiredHome | 23:a50ded45dbaf | 1408 | wait_ms(2000); |
WiredHome | 23:a50ded45dbaf | 1409 | } |
WiredHome | 23:a50ded45dbaf | 1410 | wait_ms(200); |
WiredHome | 23:a50ded45dbaf | 1411 | } |
WiredHome | 23:a50ded45dbaf | 1412 | } |
WiredHome | 23:a50ded45dbaf | 1413 | |
WiredHome | 23:a50ded45dbaf | 1414 | #endif // TESTENABLE |