Behrooz Abdi
/
Tiger_LCD
Landtiger (LPC1768) graphics LCD demo.
main.cpp@2:43ede88fb5a3, 2012-11-06 (annotated)
- Committer:
- wim
- Date:
- Tue Nov 06 21:39:33 2012 +0000
- Revision:
- 2:43ede88fb5a3
- Parent:
- 1:ea0f7b1c5daf
- Child:
- 3:2dccfa0121de
cpp version and graphics test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:a8090b59eb05 | 1 | #include "mbed.h" |
wim | 0:a8090b59eb05 | 2 | #include "GLCD.h" |
wim | 0:a8090b59eb05 | 3 | |
wim | 0:a8090b59eb05 | 4 | #include "Bg_16bpp_t.h" |
wim | 0:a8090b59eb05 | 5 | #include "Bg_16bpp_l.h" |
wim | 0:a8090b59eb05 | 6 | #include "Bg_16bpp_r.h" |
wim | 0:a8090b59eb05 | 7 | #include "Bg_16bpp_b.h" |
wim | 0:a8090b59eb05 | 8 | #include "ARM_Ani_16bpp.h" |
wim | 0:a8090b59eb05 | 9 | |
wim | 0:a8090b59eb05 | 10 | //Host PC Baudrate (Virtual Com Port on USB) |
wim | 0:a8090b59eb05 | 11 | #define D_BAUDRATE 9600 |
wim | 0:a8090b59eb05 | 12 | //#define D_BAUDRATE 57600 |
wim | 0:a8090b59eb05 | 13 | |
wim | 0:a8090b59eb05 | 14 | //extern unsigned short driverCode; |
wim | 0:a8090b59eb05 | 15 | |
wim | 0:a8090b59eb05 | 16 | #define LANDTIGER 1 |
wim | 0:a8090b59eb05 | 17 | |
wim | 0:a8090b59eb05 | 18 | // Variables for Heartbeat and Status monitoring |
wim | 0:a8090b59eb05 | 19 | #ifdef LANDTIGER |
wim | 0:a8090b59eb05 | 20 | DigitalOut myled1(P2_0); |
wim | 0:a8090b59eb05 | 21 | DigitalOut myled2(P2_1); |
wim | 0:a8090b59eb05 | 22 | DigitalOut myled3(P2_2); |
wim | 0:a8090b59eb05 | 23 | DigitalOut myled4(P2_3); |
wim | 0:a8090b59eb05 | 24 | DigitalOut myled5(P2_4); |
wim | 0:a8090b59eb05 | 25 | DigitalOut myled6(P2_5); |
wim | 0:a8090b59eb05 | 26 | DigitalOut myled7(P2_6); |
wim | 0:a8090b59eb05 | 27 | DigitalOut myled8(P2_7); |
wim | 0:a8090b59eb05 | 28 | |
wim | 0:a8090b59eb05 | 29 | |
wim | 0:a8090b59eb05 | 30 | //DigitalOut heartbeatLED(LED4); |
wim | 0:a8090b59eb05 | 31 | DigitalOut heartbeatLED(P3_26); //SD_PWR, active low |
wim | 0:a8090b59eb05 | 32 | //DigitalOut USB_Host_Power(P1_19); //USB Power, active low |
wim | 0:a8090b59eb05 | 33 | |
wim | 0:a8090b59eb05 | 34 | // Need this override function on non-mbed hardware to provide the MAC address. |
wim | 0:a8090b59eb05 | 35 | // |
wim | 0:a8090b59eb05 | 36 | // The mbed Ethernet library sets the MAC address by calling a weak function |
wim | 0:a8090b59eb05 | 37 | // extern "C" void mbed_mac_address(char * mac) to copy in a 6 Byte (12 character) MAC address. |
wim | 0:a8090b59eb05 | 38 | // This function performs a semihosting request to the mbed interface to get the serial number, |
wim | 0:a8090b59eb05 | 39 | // which contains a MAC address unique to every mbed device. |
wim | 0:a8090b59eb05 | 40 | // If you are using the eth library on your own board (i.e. not an mbed board), |
wim | 0:a8090b59eb05 | 41 | // you should implement your own extern "C" void mbed_mac_address(char * mac) function |
wim | 0:a8090b59eb05 | 42 | // to overwrite the existing one and avoid a call to the interface (which doesnt exist). |
wim | 0:a8090b59eb05 | 43 | |
wim | 0:a8090b59eb05 | 44 | |
wim | 0:a8090b59eb05 | 45 | extern "C" void mbed_mac_address(char * mac) { |
wim | 0:a8090b59eb05 | 46 | |
wim | 0:a8090b59eb05 | 47 | //mbed module clone |
wim | 0:a8090b59eb05 | 48 | // mac[0] = 0x00; |
wim | 0:a8090b59eb05 | 49 | // mac[1] = 0x02; |
wim | 0:a8090b59eb05 | 50 | // mac[2] = 0xF7; |
wim | 0:a8090b59eb05 | 51 | // mac[3] = 0xF0; |
wim | 0:a8090b59eb05 | 52 | // mac[4] = 0x56; |
wim | 0:a8090b59eb05 | 53 | // mac[5] = 0x90; |
wim | 0:a8090b59eb05 | 54 | |
wim | 0:a8090b59eb05 | 55 | //KPN Experia |
wim | 0:a8090b59eb05 | 56 | mac[0] = 0x00; |
wim | 0:a8090b59eb05 | 57 | mac[1] = 0x01; |
wim | 0:a8090b59eb05 | 58 | mac[2] = 0xE3; |
wim | 0:a8090b59eb05 | 59 | mac[3] = 0x55; |
wim | 0:a8090b59eb05 | 60 | mac[4] = 0xA1; |
wim | 0:a8090b59eb05 | 61 | mac[5] = 0xC7; |
wim | 0:a8090b59eb05 | 62 | |
wim | 0:a8090b59eb05 | 63 | }; |
wim | 0:a8090b59eb05 | 64 | |
wim | 0:a8090b59eb05 | 65 | #else |
wim | 0:a8090b59eb05 | 66 | DigitalOut myled1(LED1); |
wim | 0:a8090b59eb05 | 67 | DigitalOut myled2(LED2); |
wim | 0:a8090b59eb05 | 68 | DigitalOut myled3(LED3); |
wim | 0:a8090b59eb05 | 69 | DigitalOut heartbeatLED(LED4); |
wim | 0:a8090b59eb05 | 70 | #endif |
wim | 0:a8090b59eb05 | 71 | |
wim | 0:a8090b59eb05 | 72 | |
wim | 0:a8090b59eb05 | 73 | // Host PC Communication channels |
wim | 0:a8090b59eb05 | 74 | Serial pc(USBTX, USBRX); // tx, rx |
wim | 0:a8090b59eb05 | 75 | |
wim | 0:a8090b59eb05 | 76 | // Variables for Heartbeat and Status monitoring |
wim | 0:a8090b59eb05 | 77 | Ticker heartbeat; |
wim | 0:a8090b59eb05 | 78 | bool heartbeatflag=false; |
wim | 0:a8090b59eb05 | 79 | |
wim | 2:43ede88fb5a3 | 80 | Ticker GLCD_Ani; |
wim | 0:a8090b59eb05 | 81 | |
wim | 0:a8090b59eb05 | 82 | void clear_screen() { |
wim | 0:a8090b59eb05 | 83 | //ANSI Terminal Commands |
wim | 0:a8090b59eb05 | 84 | pc.printf("\x1B[2J"); |
wim | 0:a8090b59eb05 | 85 | pc.printf("\x1B[H"); |
wim | 0:a8090b59eb05 | 86 | } |
wim | 0:a8090b59eb05 | 87 | |
wim | 0:a8090b59eb05 | 88 | void init_interfaces() { |
wim | 0:a8090b59eb05 | 89 | // Init Host PC communication, default is 9600 |
wim | 0:a8090b59eb05 | 90 | pc.baud(D_BAUDRATE); |
wim | 0:a8090b59eb05 | 91 | |
wim | 0:a8090b59eb05 | 92 | //Done, Tell me about it |
wim | 0:a8090b59eb05 | 93 | // show_LEDS(); |
wim | 0:a8090b59eb05 | 94 | } |
wim | 0:a8090b59eb05 | 95 | |
wim | 0:a8090b59eb05 | 96 | |
wim | 0:a8090b59eb05 | 97 | // Heartbeat monitor |
wim | 0:a8090b59eb05 | 98 | void pulse() { |
wim | 0:a8090b59eb05 | 99 | heartbeatLED = !heartbeatLED; |
wim | 0:a8090b59eb05 | 100 | |
wim | 0:a8090b59eb05 | 101 | #ifdef LANDTIGER |
wim | 0:a8090b59eb05 | 102 | // myled1 = heartbeatLED; |
wim | 0:a8090b59eb05 | 103 | // myled2 = heartbeatLED; |
wim | 0:a8090b59eb05 | 104 | // myled3 = heartbeatLED; |
wim | 0:a8090b59eb05 | 105 | // myled4 = heartbeatLED; |
wim | 0:a8090b59eb05 | 106 | |
wim | 0:a8090b59eb05 | 107 | // myled5 = !heartbeatLED; |
wim | 0:a8090b59eb05 | 108 | // myled6 = !heartbeatLED; |
wim | 0:a8090b59eb05 | 109 | // myled7 = !heartbeatLED; |
wim | 0:a8090b59eb05 | 110 | // myled8 = !heartbeatLED; |
wim | 0:a8090b59eb05 | 111 | |
wim | 0:a8090b59eb05 | 112 | #endif |
wim | 0:a8090b59eb05 | 113 | |
wim | 0:a8090b59eb05 | 114 | } |
wim | 0:a8090b59eb05 | 115 | |
wim | 0:a8090b59eb05 | 116 | void heartbeat_start() { |
wim | 0:a8090b59eb05 | 117 | heartbeatLED = 1; |
wim | 0:a8090b59eb05 | 118 | heartbeat.attach(&pulse, 0.5); |
wim | 0:a8090b59eb05 | 119 | } |
wim | 0:a8090b59eb05 | 120 | |
wim | 0:a8090b59eb05 | 121 | void heartbeat_stop() { |
wim | 0:a8090b59eb05 | 122 | heartbeat.detach(); |
wim | 0:a8090b59eb05 | 123 | } |
wim | 0:a8090b59eb05 | 124 | |
wim | 0:a8090b59eb05 | 125 | |
wim | 2:43ede88fb5a3 | 126 | // GLCD |
wim | 2:43ede88fb5a3 | 127 | GLCD myGLCD; |
wim | 2:43ede88fb5a3 | 128 | |
wim | 0:a8090b59eb05 | 129 | // LCD Animation |
wim | 2:43ede88fb5a3 | 130 | #if(0) |
wim | 2:43ede88fb5a3 | 131 | void GLCD_pulse() { |
wim | 0:a8090b59eb05 | 132 | static int pic = 0; |
wim | 2:43ede88fb5a3 | 133 | static int x2 = 0; |
wim | 2:43ede88fb5a3 | 134 | static int y2 = 200; |
wim | 2:43ede88fb5a3 | 135 | |
wim | 2:43ede88fb5a3 | 136 | if (pic++ > 8) pic = 0; |
wim | 2:43ede88fb5a3 | 137 | myGLCD.Bmp (99, 99, 120, 45, (unsigned char*) &ARM_Ani_16bpp[pic*(120*45*2)]); |
wim | 2:43ede88fb5a3 | 138 | |
wim | 2:43ede88fb5a3 | 139 | myGLCD.drawLine(0, 0, x2, y2); |
wim | 0:a8090b59eb05 | 140 | |
wim | 2:43ede88fb5a3 | 141 | x2=x2+5; |
wim | 2:43ede88fb5a3 | 142 | y2=y2-5; |
wim | 2:43ede88fb5a3 | 143 | if (y2 <= 0) { |
wim | 2:43ede88fb5a3 | 144 | x2 = 0; |
wim | 2:43ede88fb5a3 | 145 | y2 = 200; |
wim | 2:43ede88fb5a3 | 146 | myGLCD.setTextColor(~glcd._textColor); |
wim | 2:43ede88fb5a3 | 147 | } |
wim | 2:43ede88fb5a3 | 148 | } |
wim | 2:43ede88fb5a3 | 149 | #else |
wim | 2:43ede88fb5a3 | 150 | void GLCD_pulse() { |
wim | 2:43ede88fb5a3 | 151 | static int pic = 0; |
wim | 2:43ede88fb5a3 | 152 | |
wim | 0:a8090b59eb05 | 153 | if (pic++ > 8) pic = 0; |
wim | 2:43ede88fb5a3 | 154 | myGLCD.Bmp (99, 99, 120, 45, (unsigned char*) &ARM_Ani_16bpp[pic*(120*45*2)]); |
wim | 2:43ede88fb5a3 | 155 | } |
wim | 2:43ede88fb5a3 | 156 | #endif |
wim | 2:43ede88fb5a3 | 157 | |
wim | 2:43ede88fb5a3 | 158 | void GLCD_Ani_start() { |
wim | 2:43ede88fb5a3 | 159 | // GLCD_Ani.attach(&GLCD_pulse, 0.05); |
wim | 2:43ede88fb5a3 | 160 | GLCD_Ani.attach(&GLCD_pulse, 0.25); |
wim | 2:43ede88fb5a3 | 161 | } |
wim | 2:43ede88fb5a3 | 162 | |
wim | 2:43ede88fb5a3 | 163 | void GLCD_Ani_stop() { |
wim | 2:43ede88fb5a3 | 164 | GLCD_Ani.detach(); |
wim | 2:43ede88fb5a3 | 165 | } |
wim | 2:43ede88fb5a3 | 166 | |
wim | 2:43ede88fb5a3 | 167 | void delay(int ms) { |
wim | 2:43ede88fb5a3 | 168 | wait_ms(ms); |
wim | 2:43ede88fb5a3 | 169 | } |
wim | 2:43ede88fb5a3 | 170 | |
wim | 2:43ede88fb5a3 | 171 | |
wim | 2:43ede88fb5a3 | 172 | int random(int max) { |
wim | 2:43ede88fb5a3 | 173 | int rnd = rand() % max; |
wim | 2:43ede88fb5a3 | 174 | |
wim | 2:43ede88fb5a3 | 175 | return rnd; |
wim | 0:a8090b59eb05 | 176 | } |
wim | 0:a8090b59eb05 | 177 | |
wim | 2:43ede88fb5a3 | 178 | void loop() |
wim | 2:43ede88fb5a3 | 179 | { |
wim | 2:43ede88fb5a3 | 180 | int buf[318]; |
wim | 2:43ede88fb5a3 | 181 | int x, x2; |
wim | 2:43ede88fb5a3 | 182 | int y, y2; |
wim | 2:43ede88fb5a3 | 183 | int r; |
wim | 2:43ede88fb5a3 | 184 | |
wim | 2:43ede88fb5a3 | 185 | // Clear the screen and draw the frame |
wim | 2:43ede88fb5a3 | 186 | myGLCD.clearScreen(White); |
wim | 2:43ede88fb5a3 | 187 | |
wim | 2:43ede88fb5a3 | 188 | myGLCD.setColor(255, 0, 0); |
wim | 2:43ede88fb5a3 | 189 | myGLCD.fillRect(0, 0, 319, 13); |
wim | 2:43ede88fb5a3 | 190 | myGLCD.setColor(64, 64, 64); |
wim | 2:43ede88fb5a3 | 191 | myGLCD.fillRect(0, 226, 319, 239); |
wim | 2:43ede88fb5a3 | 192 | myGLCD.setColor(255, 255, 255); |
wim | 2:43ede88fb5a3 | 193 | myGLCD.setBackColor(255, 0, 0); |
wim | 2:43ede88fb5a3 | 194 | // myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1); |
wim | 2:43ede88fb5a3 | 195 | myGLCD.setBackColor(64, 64, 64); |
wim | 2:43ede88fb5a3 | 196 | myGLCD.setColor(255,255,0); |
wim | 2:43ede88fb5a3 | 197 | // myGLCD.print("<http://electronics.henningkarlsen.com>", CENTER, 227); |
wim | 2:43ede88fb5a3 | 198 | |
wim | 2:43ede88fb5a3 | 199 | myGLCD.setColor(0, 0, 255); |
wim | 2:43ede88fb5a3 | 200 | myGLCD.drawRect(0, 14, 319, 225); |
wim | 2:43ede88fb5a3 | 201 | |
wim | 2:43ede88fb5a3 | 202 | // Draw crosshairs |
wim | 2:43ede88fb5a3 | 203 | myGLCD.setColor(0, 0, 255); |
wim | 2:43ede88fb5a3 | 204 | myGLCD.setBackColor(0, 0, 0); |
wim | 2:43ede88fb5a3 | 205 | myGLCD.drawLine(159, 15, 159, 224); |
wim | 2:43ede88fb5a3 | 206 | myGLCD.drawLine(1, 119, 318, 119); |
wim | 2:43ede88fb5a3 | 207 | for (int i=9; i<310; i+=10) |
wim | 2:43ede88fb5a3 | 208 | myGLCD.drawLine(i, 117, i, 121); |
wim | 2:43ede88fb5a3 | 209 | for (int i=19; i<220; i+=10) |
wim | 2:43ede88fb5a3 | 210 | myGLCD.drawLine(157, i, 161, i); |
wim | 2:43ede88fb5a3 | 211 | |
wim | 2:43ede88fb5a3 | 212 | // Draw sin-, cos- and tan-lines |
wim | 2:43ede88fb5a3 | 213 | myGLCD.setColor(0,255,255); |
wim | 2:43ede88fb5a3 | 214 | // myGLCD.print("Sin", 5, 15); |
wim | 2:43ede88fb5a3 | 215 | for (int i=1; i<318; i++) |
wim | 2:43ede88fb5a3 | 216 | { |
wim | 2:43ede88fb5a3 | 217 | myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95)); |
wim | 2:43ede88fb5a3 | 218 | } |
wim | 2:43ede88fb5a3 | 219 | |
wim | 2:43ede88fb5a3 | 220 | myGLCD.setColor(255,0,0); |
wim | 2:43ede88fb5a3 | 221 | // myGLCD.print("Cos", 5, 27); |
wim | 2:43ede88fb5a3 | 222 | for (int i=1; i<318; i++) |
wim | 2:43ede88fb5a3 | 223 | { |
wim | 2:43ede88fb5a3 | 224 | myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95)); |
wim | 2:43ede88fb5a3 | 225 | } |
wim | 2:43ede88fb5a3 | 226 | |
wim | 2:43ede88fb5a3 | 227 | myGLCD.setColor(255,255,0); |
wim | 2:43ede88fb5a3 | 228 | // myGLCD.print("Tan", 5, 39); |
wim | 2:43ede88fb5a3 | 229 | for (int i=1; i<318; i++) |
wim | 2:43ede88fb5a3 | 230 | { |
wim | 2:43ede88fb5a3 | 231 | myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180))); |
wim | 2:43ede88fb5a3 | 232 | } |
wim | 2:43ede88fb5a3 | 233 | |
wim | 2:43ede88fb5a3 | 234 | delay(2000); |
wim | 2:43ede88fb5a3 | 235 | |
wim | 2:43ede88fb5a3 | 236 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 237 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 238 | myGLCD.setColor(0, 0, 255); |
wim | 2:43ede88fb5a3 | 239 | myGLCD.setBackColor(0, 0, 0); |
wim | 2:43ede88fb5a3 | 240 | myGLCD.drawLine(159, 15, 159, 224); |
wim | 2:43ede88fb5a3 | 241 | myGLCD.drawLine(1, 119, 318, 119); |
wim | 2:43ede88fb5a3 | 242 | |
wim | 2:43ede88fb5a3 | 243 | // Draw a moving sinewave |
wim | 2:43ede88fb5a3 | 244 | x=1; |
wim | 2:43ede88fb5a3 | 245 | for (int i=1; i<(318*20); i++) |
wim | 2:43ede88fb5a3 | 246 | { |
wim | 2:43ede88fb5a3 | 247 | x++; |
wim | 2:43ede88fb5a3 | 248 | if (x==319) |
wim | 2:43ede88fb5a3 | 249 | x=1; |
wim | 2:43ede88fb5a3 | 250 | if (i>319) |
wim | 2:43ede88fb5a3 | 251 | { |
wim | 2:43ede88fb5a3 | 252 | if ((x==159)||(buf[x-1]==119)) |
wim | 2:43ede88fb5a3 | 253 | myGLCD.setColor(0,0,255); |
wim | 2:43ede88fb5a3 | 254 | else |
wim | 2:43ede88fb5a3 | 255 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 256 | myGLCD.drawPixel(x,buf[x-1]); |
wim | 2:43ede88fb5a3 | 257 | } |
wim | 2:43ede88fb5a3 | 258 | myGLCD.setColor(0,255,255); |
wim | 2:43ede88fb5a3 | 259 | y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100))); |
wim | 2:43ede88fb5a3 | 260 | myGLCD.drawPixel(x,y); |
wim | 2:43ede88fb5a3 | 261 | buf[x-1]=y; |
wim | 2:43ede88fb5a3 | 262 | } |
wim | 2:43ede88fb5a3 | 263 | |
wim | 2:43ede88fb5a3 | 264 | delay(2000); |
wim | 2:43ede88fb5a3 | 265 | |
wim | 2:43ede88fb5a3 | 266 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 267 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 268 | |
wim | 2:43ede88fb5a3 | 269 | // Draw some filled rectangles |
wim | 2:43ede88fb5a3 | 270 | for (int i=1; i<6; i++) |
wim | 2:43ede88fb5a3 | 271 | { |
wim | 2:43ede88fb5a3 | 272 | switch (i) |
wim | 2:43ede88fb5a3 | 273 | { |
wim | 2:43ede88fb5a3 | 274 | case 1: |
wim | 2:43ede88fb5a3 | 275 | myGLCD.setColor(255,0,255); |
wim | 2:43ede88fb5a3 | 276 | break; |
wim | 2:43ede88fb5a3 | 277 | case 2: |
wim | 2:43ede88fb5a3 | 278 | myGLCD.setColor(255,0,0); |
wim | 2:43ede88fb5a3 | 279 | break; |
wim | 2:43ede88fb5a3 | 280 | case 3: |
wim | 2:43ede88fb5a3 | 281 | myGLCD.setColor(0,255,0); |
wim | 2:43ede88fb5a3 | 282 | break; |
wim | 2:43ede88fb5a3 | 283 | case 4: |
wim | 2:43ede88fb5a3 | 284 | myGLCD.setColor(0,0,255); |
wim | 2:43ede88fb5a3 | 285 | break; |
wim | 2:43ede88fb5a3 | 286 | case 5: |
wim | 2:43ede88fb5a3 | 287 | myGLCD.setColor(255,255,0); |
wim | 2:43ede88fb5a3 | 288 | break; |
wim | 2:43ede88fb5a3 | 289 | } |
wim | 2:43ede88fb5a3 | 290 | myGLCD.fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20)); |
wim | 2:43ede88fb5a3 | 291 | } |
wim | 2:43ede88fb5a3 | 292 | |
wim | 2:43ede88fb5a3 | 293 | delay(2000); |
wim | 2:43ede88fb5a3 | 294 | |
wim | 2:43ede88fb5a3 | 295 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 296 | myGLCD.fillRect(1,15,318,224); |
wim | 0:a8090b59eb05 | 297 | |
wim | 2:43ede88fb5a3 | 298 | // Draw some filled, rounded rectangles |
wim | 2:43ede88fb5a3 | 299 | for (int i=1; i<6; i++) |
wim | 2:43ede88fb5a3 | 300 | { |
wim | 2:43ede88fb5a3 | 301 | switch (i) |
wim | 2:43ede88fb5a3 | 302 | { |
wim | 2:43ede88fb5a3 | 303 | case 1: |
wim | 2:43ede88fb5a3 | 304 | myGLCD.setColor(255,0,255); |
wim | 2:43ede88fb5a3 | 305 | break; |
wim | 2:43ede88fb5a3 | 306 | case 2: |
wim | 2:43ede88fb5a3 | 307 | myGLCD.setColor(255,0,0); |
wim | 2:43ede88fb5a3 | 308 | break; |
wim | 2:43ede88fb5a3 | 309 | case 3: |
wim | 2:43ede88fb5a3 | 310 | myGLCD.setColor(0,255,0); |
wim | 2:43ede88fb5a3 | 311 | break; |
wim | 2:43ede88fb5a3 | 312 | case 4: |
wim | 2:43ede88fb5a3 | 313 | myGLCD.setColor(0,0,255); |
wim | 2:43ede88fb5a3 | 314 | break; |
wim | 2:43ede88fb5a3 | 315 | case 5: |
wim | 2:43ede88fb5a3 | 316 | myGLCD.setColor(255,255,0); |
wim | 2:43ede88fb5a3 | 317 | break; |
wim | 2:43ede88fb5a3 | 318 | } |
wim | 2:43ede88fb5a3 | 319 | myGLCD.fillRoundRect(190-(i*20), 30+(i*20), 250-(i*20), 90+(i*20)); |
wim | 2:43ede88fb5a3 | 320 | } |
wim | 2:43ede88fb5a3 | 321 | |
wim | 2:43ede88fb5a3 | 322 | delay(2000); |
wim | 2:43ede88fb5a3 | 323 | |
wim | 2:43ede88fb5a3 | 324 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 325 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 326 | |
wim | 2:43ede88fb5a3 | 327 | // Draw some filled circles |
wim | 2:43ede88fb5a3 | 328 | for (int i=1; i<6; i++) |
wim | 2:43ede88fb5a3 | 329 | { |
wim | 2:43ede88fb5a3 | 330 | switch (i) |
wim | 2:43ede88fb5a3 | 331 | { |
wim | 2:43ede88fb5a3 | 332 | case 1: |
wim | 2:43ede88fb5a3 | 333 | myGLCD.setColor(255,0,255); |
wim | 2:43ede88fb5a3 | 334 | break; |
wim | 2:43ede88fb5a3 | 335 | case 2: |
wim | 2:43ede88fb5a3 | 336 | myGLCD.setColor(255,0,0); |
wim | 2:43ede88fb5a3 | 337 | break; |
wim | 2:43ede88fb5a3 | 338 | case 3: |
wim | 2:43ede88fb5a3 | 339 | myGLCD.setColor(0,255,0); |
wim | 2:43ede88fb5a3 | 340 | break; |
wim | 2:43ede88fb5a3 | 341 | case 4: |
wim | 2:43ede88fb5a3 | 342 | myGLCD.setColor(0,0,255); |
wim | 2:43ede88fb5a3 | 343 | break; |
wim | 2:43ede88fb5a3 | 344 | case 5: |
wim | 2:43ede88fb5a3 | 345 | myGLCD.setColor(255,255,0); |
wim | 2:43ede88fb5a3 | 346 | break; |
wim | 2:43ede88fb5a3 | 347 | } |
wim | 2:43ede88fb5a3 | 348 | myGLCD.fillCircle(100+(i*20),60+(i*20), 30); |
wim | 2:43ede88fb5a3 | 349 | } |
wim | 2:43ede88fb5a3 | 350 | |
wim | 2:43ede88fb5a3 | 351 | delay(2000); |
wim | 2:43ede88fb5a3 | 352 | |
wim | 2:43ede88fb5a3 | 353 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 354 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 355 | |
wim | 2:43ede88fb5a3 | 356 | // Draw some lines in a pattern |
wim | 2:43ede88fb5a3 | 357 | myGLCD.setColor (255,0,0); |
wim | 2:43ede88fb5a3 | 358 | for (int i=15; i<224; i+=5) |
wim | 2:43ede88fb5a3 | 359 | { |
wim | 2:43ede88fb5a3 | 360 | myGLCD.drawLine(1, i, (i*1.44)-10, 224); |
wim | 2:43ede88fb5a3 | 361 | } |
wim | 2:43ede88fb5a3 | 362 | myGLCD.setColor (255,0,0); |
wim | 2:43ede88fb5a3 | 363 | for (int i=224; i>15; i-=5) |
wim | 2:43ede88fb5a3 | 364 | { |
wim | 2:43ede88fb5a3 | 365 | myGLCD.drawLine(318, i, (i*1.44)-11, 15); |
wim | 2:43ede88fb5a3 | 366 | } |
wim | 2:43ede88fb5a3 | 367 | myGLCD.setColor (0,255,255); |
wim | 2:43ede88fb5a3 | 368 | for (int i=224; i>15; i-=5) |
wim | 2:43ede88fb5a3 | 369 | { |
wim | 2:43ede88fb5a3 | 370 | myGLCD.drawLine(1, i, 331-(i*1.44), 15); |
wim | 2:43ede88fb5a3 | 371 | } |
wim | 2:43ede88fb5a3 | 372 | myGLCD.setColor (0,255,255); |
wim | 2:43ede88fb5a3 | 373 | for (int i=15; i<224; i+=5) |
wim | 2:43ede88fb5a3 | 374 | { |
wim | 2:43ede88fb5a3 | 375 | myGLCD.drawLine(318, i, 330-(i*1.44), 224); |
wim | 2:43ede88fb5a3 | 376 | } |
wim | 2:43ede88fb5a3 | 377 | |
wim | 2:43ede88fb5a3 | 378 | delay(2000); |
wim | 2:43ede88fb5a3 | 379 | |
wim | 2:43ede88fb5a3 | 380 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 381 | myGLCD.fillRect(1,15,318,225); |
wim | 2:43ede88fb5a3 | 382 | |
wim | 2:43ede88fb5a3 | 383 | // Draw some random circles |
wim | 2:43ede88fb5a3 | 384 | for (int i=0; i<100; i++) |
wim | 2:43ede88fb5a3 | 385 | { |
wim | 2:43ede88fb5a3 | 386 | myGLCD.setColor(random(255), random(255), random(255)); |
wim | 2:43ede88fb5a3 | 387 | x=32+random(256); |
wim | 2:43ede88fb5a3 | 388 | y=45+random(146); |
wim | 2:43ede88fb5a3 | 389 | r=random(30); |
wim | 2:43ede88fb5a3 | 390 | myGLCD.drawCircle(x, y, r); |
wim | 2:43ede88fb5a3 | 391 | } |
wim | 2:43ede88fb5a3 | 392 | |
wim | 2:43ede88fb5a3 | 393 | delay(2000); |
wim | 2:43ede88fb5a3 | 394 | |
wim | 2:43ede88fb5a3 | 395 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 396 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 397 | |
wim | 2:43ede88fb5a3 | 398 | // Draw some random rectangles |
wim | 2:43ede88fb5a3 | 399 | for (int i=0; i<100; i++) |
wim | 2:43ede88fb5a3 | 400 | { |
wim | 2:43ede88fb5a3 | 401 | myGLCD.setColor(random(255), random(255), random(255)); |
wim | 2:43ede88fb5a3 | 402 | x=2+random(316); |
wim | 2:43ede88fb5a3 | 403 | y=16+random(207); |
wim | 2:43ede88fb5a3 | 404 | x2=2+random(316); |
wim | 2:43ede88fb5a3 | 405 | y2=16+random(207); |
wim | 2:43ede88fb5a3 | 406 | myGLCD.drawRect(x, y, x2, y2); |
wim | 2:43ede88fb5a3 | 407 | } |
wim | 2:43ede88fb5a3 | 408 | |
wim | 2:43ede88fb5a3 | 409 | delay(2000); |
wim | 2:43ede88fb5a3 | 410 | |
wim | 2:43ede88fb5a3 | 411 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 412 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 413 | |
wim | 2:43ede88fb5a3 | 414 | // Draw some random rounded rectangles |
wim | 2:43ede88fb5a3 | 415 | for (int i=0; i<100; i++) |
wim | 2:43ede88fb5a3 | 416 | { |
wim | 2:43ede88fb5a3 | 417 | myGLCD.setColor(random(255), random(255), random(255)); |
wim | 2:43ede88fb5a3 | 418 | x=2+random(316); |
wim | 2:43ede88fb5a3 | 419 | y=16+random(207); |
wim | 2:43ede88fb5a3 | 420 | x2=2+random(316); |
wim | 2:43ede88fb5a3 | 421 | y2=16+random(207); |
wim | 2:43ede88fb5a3 | 422 | myGLCD.drawRoundRect(x, y, x2, y2); |
wim | 2:43ede88fb5a3 | 423 | } |
wim | 2:43ede88fb5a3 | 424 | |
wim | 2:43ede88fb5a3 | 425 | delay(2000); |
wim | 2:43ede88fb5a3 | 426 | |
wim | 2:43ede88fb5a3 | 427 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 428 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 429 | |
wim | 2:43ede88fb5a3 | 430 | for (int i=0; i<100; i++) |
wim | 2:43ede88fb5a3 | 431 | { |
wim | 2:43ede88fb5a3 | 432 | myGLCD.setColor(random(255), random(255), random(255)); |
wim | 2:43ede88fb5a3 | 433 | x=2+random(316); |
wim | 2:43ede88fb5a3 | 434 | y=16+random(209); |
wim | 2:43ede88fb5a3 | 435 | x2=2+random(316); |
wim | 2:43ede88fb5a3 | 436 | y2=16+random(209); |
wim | 2:43ede88fb5a3 | 437 | myGLCD.drawLine(x, y, x2, y2); |
wim | 2:43ede88fb5a3 | 438 | } |
wim | 2:43ede88fb5a3 | 439 | |
wim | 2:43ede88fb5a3 | 440 | delay(2000); |
wim | 2:43ede88fb5a3 | 441 | |
wim | 2:43ede88fb5a3 | 442 | myGLCD.setColor(0,0,0); |
wim | 2:43ede88fb5a3 | 443 | myGLCD.fillRect(1,15,318,224); |
wim | 2:43ede88fb5a3 | 444 | |
wim | 2:43ede88fb5a3 | 445 | for (int i=0; i<10000; i++) |
wim | 2:43ede88fb5a3 | 446 | { |
wim | 2:43ede88fb5a3 | 447 | myGLCD.setColor(random(255), random(255), random(255)); |
wim | 2:43ede88fb5a3 | 448 | myGLCD.drawPixel(2+random(316), 16+random(209)); |
wim | 2:43ede88fb5a3 | 449 | } |
wim | 2:43ede88fb5a3 | 450 | |
wim | 2:43ede88fb5a3 | 451 | delay(2000); |
wim | 2:43ede88fb5a3 | 452 | |
wim | 2:43ede88fb5a3 | 453 | // myGLCD.fillScr(0, 0, 255); |
wim | 2:43ede88fb5a3 | 454 | myGLCD.clearScreen(Blue); |
wim | 2:43ede88fb5a3 | 455 | |
wim | 2:43ede88fb5a3 | 456 | myGLCD.setColor(255, 0, 0); |
wim | 2:43ede88fb5a3 | 457 | myGLCD.fillRoundRect(80, 70, 239, 169); |
wim | 2:43ede88fb5a3 | 458 | |
wim | 2:43ede88fb5a3 | 459 | myGLCD.setColor(255, 255, 255); |
wim | 2:43ede88fb5a3 | 460 | myGLCD.setBackColor(255, 0, 0); |
wim | 2:43ede88fb5a3 | 461 | // myGLCD.print("That's it!", CENTER, 93); |
wim | 2:43ede88fb5a3 | 462 | // myGLCD.print("Restarting in a", CENTER, 119); |
wim | 2:43ede88fb5a3 | 463 | // myGLCD.print("few seconds...", CENTER, 132); |
wim | 2:43ede88fb5a3 | 464 | |
wim | 2:43ede88fb5a3 | 465 | myGLCD.setColor(0, 255, 0); |
wim | 2:43ede88fb5a3 | 466 | myGLCD.setBackColor(0, 0, 255); |
wim | 2:43ede88fb5a3 | 467 | // myGLCD.print("Runtime: (msecs)", CENTER, 210); |
wim | 2:43ede88fb5a3 | 468 | // myGLCD.printNumI(millis(), CENTER, 225); |
wim | 2:43ede88fb5a3 | 469 | |
wim | 2:43ede88fb5a3 | 470 | delay (3000); |
wim | 0:a8090b59eb05 | 471 | } |
wim | 0:a8090b59eb05 | 472 | |
wim | 0:a8090b59eb05 | 473 | |
wim | 0:a8090b59eb05 | 474 | |
wim | 0:a8090b59eb05 | 475 | int main() { |
wim | 0:a8090b59eb05 | 476 | init_interfaces(); |
wim | 0:a8090b59eb05 | 477 | |
wim | 0:a8090b59eb05 | 478 | heartbeat_start(); |
wim | 0:a8090b59eb05 | 479 | |
wim | 0:a8090b59eb05 | 480 | clear_screen(); |
wim | 0:a8090b59eb05 | 481 | |
wim | 0:a8090b59eb05 | 482 | pc.printf("Hello World!\n\r"); |
wim | 0:a8090b59eb05 | 483 | |
wim | 2:43ede88fb5a3 | 484 | myGLCD.Init(); |
wim | 2:43ede88fb5a3 | 485 | myGLCD.clearScreen(White); |
wim | 2:43ede88fb5a3 | 486 | // GLCD_clearScreen(Blue); |
wim | 0:a8090b59eb05 | 487 | // GLCD_Bmp( 0, 0, 320, 69, (unsigned char*) Bg_16bpp_t+70); |
wim | 0:a8090b59eb05 | 488 | // GLCD_Bmp( 0, 69, 4, 102, (unsigned char*) Bg_16bpp_l+70); |
wim | 0:a8090b59eb05 | 489 | // GLCD_Bmp(316, 69, 4, 102, (unsigned char*) Bg_16bpp_r+70); |
wim | 0:a8090b59eb05 | 490 | // GLCD_Bmp( 0, 171, 320, 69, (unsigned char*) Bg_16bpp_b+70); |
wim | 0:a8090b59eb05 | 491 | // GLCD_Bmp( 0, 171, 320, 69, (unsigned char*) Bg_16bpp_t+70); |
wim | 0:a8090b59eb05 | 492 | |
wim | 2:43ede88fb5a3 | 493 | myGLCD.setColor (Red); |
wim | 2:43ede88fb5a3 | 494 | myGLCD.setBackColor (White); |
wim | 2:43ede88fb5a3 | 495 | myGLCD.DisplayString (8, 1, (unsigned char*) "Hi Willem"); |
wim | 0:a8090b59eb05 | 496 | |
wim | 2:43ede88fb5a3 | 497 | // GLCD_Ani_start(); |
wim | 2:43ede88fb5a3 | 498 | |
wim | 2:43ede88fb5a3 | 499 | myGLCD.drawRect (10, 10, 100, 100); |
wim | 0:a8090b59eb05 | 500 | |
wim | 2:43ede88fb5a3 | 501 | myGLCD.setColor (Green); |
wim | 2:43ede88fb5a3 | 502 | myGLCD.drawHLine (20, 20, 50); |
wim | 2:43ede88fb5a3 | 503 | myGLCD.drawVLine (30, 30, 50); |
wim | 2:43ede88fb5a3 | 504 | |
wim | 2:43ede88fb5a3 | 505 | myGLCD.setColor (Blue); |
wim | 2:43ede88fb5a3 | 506 | myGLCD.fillRoundRect (40, 40, 100, 100); |
wim | 2:43ede88fb5a3 | 507 | myGLCD.setColor (Cyan); |
wim | 2:43ede88fb5a3 | 508 | myGLCD.drawCircle (60, 60, 40); |
wim | 2:43ede88fb5a3 | 509 | |
wim | 2:43ede88fb5a3 | 510 | |
wim | 2:43ede88fb5a3 | 511 | pc.printf("LCD Controller ID = 0x%04X\n\r", myGLCD.getDriverCode()); |
wim | 0:a8090b59eb05 | 512 | |
wim | 2:43ede88fb5a3 | 513 | loop(); |
wim | 0:a8090b59eb05 | 514 | |
wim | 0:a8090b59eb05 | 515 | while(1) { |
wim | 0:a8090b59eb05 | 516 | pc.printf("+"); |
wim | 2:43ede88fb5a3 | 517 | |
wim | 2:43ede88fb5a3 | 518 | |
wim | 0:a8090b59eb05 | 519 | wait(0.1); |
wim | 0:a8090b59eb05 | 520 | }; |
wim | 0:a8090b59eb05 | 521 | |
wim | 0:a8090b59eb05 | 522 | pc.printf("Bye World!\n\r"); |
wim | 0:a8090b59eb05 | 523 | } |