Landtiger (LPC1768) graphics LCD demo.

Dependencies:   mbed

Committer:
wim
Date:
Fri Oct 30 01:26:40 2015 +0000
Revision:
3:2dccfa0121de
Parent:
2:43ede88fb5a3
Child:
4:cdeea87f25d8
Landtiger LCD demo (Mandelbrot). Code snippets merged from several sources.

Who changed what in which revision?

UserRevisionLine numberNew 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 3:2dccfa0121de 129 #include "Julia.h"
wim 3:2dccfa0121de 130
wim 0:a8090b59eb05 131 // LCD Animation
wim 2:43ede88fb5a3 132 #if(0)
wim 2:43ede88fb5a3 133 void GLCD_pulse() {
wim 0:a8090b59eb05 134 static int pic = 0;
wim 2:43ede88fb5a3 135 static int x2 = 0;
wim 2:43ede88fb5a3 136 static int y2 = 200;
wim 2:43ede88fb5a3 137
wim 2:43ede88fb5a3 138 if (pic++ > 8) pic = 0;
wim 2:43ede88fb5a3 139 myGLCD.Bmp (99, 99, 120, 45, (unsigned char*) &ARM_Ani_16bpp[pic*(120*45*2)]);
wim 2:43ede88fb5a3 140
wim 2:43ede88fb5a3 141 myGLCD.drawLine(0, 0, x2, y2);
wim 0:a8090b59eb05 142
wim 2:43ede88fb5a3 143 x2=x2+5;
wim 2:43ede88fb5a3 144 y2=y2-5;
wim 2:43ede88fb5a3 145 if (y2 <= 0) {
wim 2:43ede88fb5a3 146 x2 = 0;
wim 2:43ede88fb5a3 147 y2 = 200;
wim 2:43ede88fb5a3 148 myGLCD.setTextColor(~glcd._textColor);
wim 2:43ede88fb5a3 149 }
wim 2:43ede88fb5a3 150 }
wim 2:43ede88fb5a3 151 #else
wim 2:43ede88fb5a3 152 void GLCD_pulse() {
wim 2:43ede88fb5a3 153 static int pic = 0;
wim 2:43ede88fb5a3 154
wim 0:a8090b59eb05 155 if (pic++ > 8) pic = 0;
wim 2:43ede88fb5a3 156 myGLCD.Bmp (99, 99, 120, 45, (unsigned char*) &ARM_Ani_16bpp[pic*(120*45*2)]);
wim 2:43ede88fb5a3 157 }
wim 2:43ede88fb5a3 158 #endif
wim 2:43ede88fb5a3 159
wim 2:43ede88fb5a3 160 void GLCD_Ani_start() {
wim 2:43ede88fb5a3 161 // GLCD_Ani.attach(&GLCD_pulse, 0.05);
wim 2:43ede88fb5a3 162 GLCD_Ani.attach(&GLCD_pulse, 0.25);
wim 2:43ede88fb5a3 163 }
wim 2:43ede88fb5a3 164
wim 2:43ede88fb5a3 165 void GLCD_Ani_stop() {
wim 2:43ede88fb5a3 166 GLCD_Ani.detach();
wim 2:43ede88fb5a3 167 }
wim 2:43ede88fb5a3 168
wim 2:43ede88fb5a3 169 void delay(int ms) {
wim 2:43ede88fb5a3 170 wait_ms(ms);
wim 2:43ede88fb5a3 171 }
wim 2:43ede88fb5a3 172
wim 2:43ede88fb5a3 173
wim 2:43ede88fb5a3 174 int random(int max) {
wim 2:43ede88fb5a3 175 int rnd = rand() % max;
wim 2:43ede88fb5a3 176
wim 2:43ede88fb5a3 177 return rnd;
wim 0:a8090b59eb05 178 }
wim 0:a8090b59eb05 179
wim 2:43ede88fb5a3 180 void loop()
wim 2:43ede88fb5a3 181 {
wim 2:43ede88fb5a3 182 int buf[318];
wim 2:43ede88fb5a3 183 int x, x2;
wim 2:43ede88fb5a3 184 int y, y2;
wim 2:43ede88fb5a3 185 int r;
wim 2:43ede88fb5a3 186
wim 2:43ede88fb5a3 187 // Clear the screen and draw the frame
wim 2:43ede88fb5a3 188 myGLCD.clearScreen(White);
wim 2:43ede88fb5a3 189
wim 2:43ede88fb5a3 190 myGLCD.setColor(255, 0, 0);
wim 2:43ede88fb5a3 191 myGLCD.fillRect(0, 0, 319, 13);
wim 2:43ede88fb5a3 192 myGLCD.setColor(64, 64, 64);
wim 2:43ede88fb5a3 193 myGLCD.fillRect(0, 226, 319, 239);
wim 2:43ede88fb5a3 194 myGLCD.setColor(255, 255, 255);
wim 2:43ede88fb5a3 195 myGLCD.setBackColor(255, 0, 0);
wim 2:43ede88fb5a3 196 // myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
wim 2:43ede88fb5a3 197 myGLCD.setBackColor(64, 64, 64);
wim 2:43ede88fb5a3 198 myGLCD.setColor(255,255,0);
wim 2:43ede88fb5a3 199 // myGLCD.print("<http://electronics.henningkarlsen.com>", CENTER, 227);
wim 2:43ede88fb5a3 200
wim 2:43ede88fb5a3 201 myGLCD.setColor(0, 0, 255);
wim 2:43ede88fb5a3 202 myGLCD.drawRect(0, 14, 319, 225);
wim 2:43ede88fb5a3 203
wim 2:43ede88fb5a3 204 // Draw crosshairs
wim 2:43ede88fb5a3 205 myGLCD.setColor(0, 0, 255);
wim 2:43ede88fb5a3 206 myGLCD.setBackColor(0, 0, 0);
wim 2:43ede88fb5a3 207 myGLCD.drawLine(159, 15, 159, 224);
wim 2:43ede88fb5a3 208 myGLCD.drawLine(1, 119, 318, 119);
wim 2:43ede88fb5a3 209 for (int i=9; i<310; i+=10)
wim 2:43ede88fb5a3 210 myGLCD.drawLine(i, 117, i, 121);
wim 2:43ede88fb5a3 211 for (int i=19; i<220; i+=10)
wim 2:43ede88fb5a3 212 myGLCD.drawLine(157, i, 161, i);
wim 2:43ede88fb5a3 213
wim 2:43ede88fb5a3 214 // Draw sin-, cos- and tan-lines
wim 2:43ede88fb5a3 215 myGLCD.setColor(0,255,255);
wim 2:43ede88fb5a3 216 // myGLCD.print("Sin", 5, 15);
wim 2:43ede88fb5a3 217 for (int i=1; i<318; i++)
wim 2:43ede88fb5a3 218 {
wim 2:43ede88fb5a3 219 myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));
wim 2:43ede88fb5a3 220 }
wim 2:43ede88fb5a3 221
wim 2:43ede88fb5a3 222 myGLCD.setColor(255,0,0);
wim 2:43ede88fb5a3 223 // myGLCD.print("Cos", 5, 27);
wim 2:43ede88fb5a3 224 for (int i=1; i<318; i++)
wim 2:43ede88fb5a3 225 {
wim 2:43ede88fb5a3 226 myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));
wim 2:43ede88fb5a3 227 }
wim 2:43ede88fb5a3 228
wim 3:2dccfa0121de 229 myGLCD.setColor(255,0,255);
wim 2:43ede88fb5a3 230 // myGLCD.print("Tan", 5, 39);
wim 2:43ede88fb5a3 231 for (int i=1; i<318; i++)
wim 2:43ede88fb5a3 232 {
wim 2:43ede88fb5a3 233 myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));
wim 2:43ede88fb5a3 234 }
wim 2:43ede88fb5a3 235
wim 2:43ede88fb5a3 236 delay(2000);
wim 2:43ede88fb5a3 237
wim 2:43ede88fb5a3 238 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 239 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 240 myGLCD.setColor(0, 0, 255);
wim 2:43ede88fb5a3 241 myGLCD.setBackColor(0, 0, 0);
wim 2:43ede88fb5a3 242 myGLCD.drawLine(159, 15, 159, 224);
wim 2:43ede88fb5a3 243 myGLCD.drawLine(1, 119, 318, 119);
wim 2:43ede88fb5a3 244
wim 2:43ede88fb5a3 245 // Draw a moving sinewave
wim 2:43ede88fb5a3 246 x=1;
wim 2:43ede88fb5a3 247 for (int i=1; i<(318*20); i++)
wim 2:43ede88fb5a3 248 {
wim 2:43ede88fb5a3 249 x++;
wim 2:43ede88fb5a3 250 if (x==319)
wim 2:43ede88fb5a3 251 x=1;
wim 2:43ede88fb5a3 252 if (i>319)
wim 2:43ede88fb5a3 253 {
wim 2:43ede88fb5a3 254 if ((x==159)||(buf[x-1]==119))
wim 2:43ede88fb5a3 255 myGLCD.setColor(0,0,255);
wim 2:43ede88fb5a3 256 else
wim 2:43ede88fb5a3 257 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 258 myGLCD.drawPixel(x,buf[x-1]);
wim 2:43ede88fb5a3 259 }
wim 2:43ede88fb5a3 260 myGLCD.setColor(0,255,255);
wim 2:43ede88fb5a3 261 y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100)));
wim 2:43ede88fb5a3 262 myGLCD.drawPixel(x,y);
wim 2:43ede88fb5a3 263 buf[x-1]=y;
wim 2:43ede88fb5a3 264 }
wim 2:43ede88fb5a3 265
wim 2:43ede88fb5a3 266 delay(2000);
wim 2:43ede88fb5a3 267
wim 2:43ede88fb5a3 268 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 269 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 270
wim 2:43ede88fb5a3 271 // Draw some filled rectangles
wim 2:43ede88fb5a3 272 for (int i=1; i<6; i++)
wim 2:43ede88fb5a3 273 {
wim 2:43ede88fb5a3 274 switch (i)
wim 2:43ede88fb5a3 275 {
wim 2:43ede88fb5a3 276 case 1:
wim 2:43ede88fb5a3 277 myGLCD.setColor(255,0,255);
wim 2:43ede88fb5a3 278 break;
wim 2:43ede88fb5a3 279 case 2:
wim 2:43ede88fb5a3 280 myGLCD.setColor(255,0,0);
wim 2:43ede88fb5a3 281 break;
wim 2:43ede88fb5a3 282 case 3:
wim 2:43ede88fb5a3 283 myGLCD.setColor(0,255,0);
wim 2:43ede88fb5a3 284 break;
wim 2:43ede88fb5a3 285 case 4:
wim 2:43ede88fb5a3 286 myGLCD.setColor(0,0,255);
wim 2:43ede88fb5a3 287 break;
wim 2:43ede88fb5a3 288 case 5:
wim 2:43ede88fb5a3 289 myGLCD.setColor(255,255,0);
wim 2:43ede88fb5a3 290 break;
wim 2:43ede88fb5a3 291 }
wim 2:43ede88fb5a3 292 myGLCD.fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));
wim 2:43ede88fb5a3 293 }
wim 2:43ede88fb5a3 294
wim 2:43ede88fb5a3 295 delay(2000);
wim 2:43ede88fb5a3 296
wim 2:43ede88fb5a3 297 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 298 myGLCD.fillRect(1,15,318,224);
wim 0:a8090b59eb05 299
wim 2:43ede88fb5a3 300 // Draw some filled, rounded rectangles
wim 2:43ede88fb5a3 301 for (int i=1; i<6; i++)
wim 2:43ede88fb5a3 302 {
wim 2:43ede88fb5a3 303 switch (i)
wim 2:43ede88fb5a3 304 {
wim 2:43ede88fb5a3 305 case 1:
wim 2:43ede88fb5a3 306 myGLCD.setColor(255,0,255);
wim 2:43ede88fb5a3 307 break;
wim 2:43ede88fb5a3 308 case 2:
wim 2:43ede88fb5a3 309 myGLCD.setColor(255,0,0);
wim 2:43ede88fb5a3 310 break;
wim 2:43ede88fb5a3 311 case 3:
wim 2:43ede88fb5a3 312 myGLCD.setColor(0,255,0);
wim 2:43ede88fb5a3 313 break;
wim 2:43ede88fb5a3 314 case 4:
wim 2:43ede88fb5a3 315 myGLCD.setColor(0,0,255);
wim 2:43ede88fb5a3 316 break;
wim 2:43ede88fb5a3 317 case 5:
wim 2:43ede88fb5a3 318 myGLCD.setColor(255,255,0);
wim 2:43ede88fb5a3 319 break;
wim 2:43ede88fb5a3 320 }
wim 2:43ede88fb5a3 321 myGLCD.fillRoundRect(190-(i*20), 30+(i*20), 250-(i*20), 90+(i*20));
wim 2:43ede88fb5a3 322 }
wim 2:43ede88fb5a3 323
wim 2:43ede88fb5a3 324 delay(2000);
wim 2:43ede88fb5a3 325
wim 2:43ede88fb5a3 326 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 327 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 328
wim 2:43ede88fb5a3 329 // Draw some filled circles
wim 2:43ede88fb5a3 330 for (int i=1; i<6; i++)
wim 2:43ede88fb5a3 331 {
wim 2:43ede88fb5a3 332 switch (i)
wim 2:43ede88fb5a3 333 {
wim 2:43ede88fb5a3 334 case 1:
wim 2:43ede88fb5a3 335 myGLCD.setColor(255,0,255);
wim 2:43ede88fb5a3 336 break;
wim 2:43ede88fb5a3 337 case 2:
wim 2:43ede88fb5a3 338 myGLCD.setColor(255,0,0);
wim 2:43ede88fb5a3 339 break;
wim 2:43ede88fb5a3 340 case 3:
wim 2:43ede88fb5a3 341 myGLCD.setColor(0,255,0);
wim 2:43ede88fb5a3 342 break;
wim 2:43ede88fb5a3 343 case 4:
wim 2:43ede88fb5a3 344 myGLCD.setColor(0,0,255);
wim 2:43ede88fb5a3 345 break;
wim 2:43ede88fb5a3 346 case 5:
wim 2:43ede88fb5a3 347 myGLCD.setColor(255,255,0);
wim 2:43ede88fb5a3 348 break;
wim 2:43ede88fb5a3 349 }
wim 2:43ede88fb5a3 350 myGLCD.fillCircle(100+(i*20),60+(i*20), 30);
wim 2:43ede88fb5a3 351 }
wim 2:43ede88fb5a3 352
wim 2:43ede88fb5a3 353 delay(2000);
wim 2:43ede88fb5a3 354
wim 2:43ede88fb5a3 355 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 356 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 357
wim 2:43ede88fb5a3 358 // Draw some lines in a pattern
wim 2:43ede88fb5a3 359 myGLCD.setColor (255,0,0);
wim 2:43ede88fb5a3 360 for (int i=15; i<224; i+=5)
wim 2:43ede88fb5a3 361 {
wim 2:43ede88fb5a3 362 myGLCD.drawLine(1, i, (i*1.44)-10, 224);
wim 2:43ede88fb5a3 363 }
wim 2:43ede88fb5a3 364 myGLCD.setColor (255,0,0);
wim 2:43ede88fb5a3 365 for (int i=224; i>15; i-=5)
wim 2:43ede88fb5a3 366 {
wim 2:43ede88fb5a3 367 myGLCD.drawLine(318, i, (i*1.44)-11, 15);
wim 2:43ede88fb5a3 368 }
wim 2:43ede88fb5a3 369 myGLCD.setColor (0,255,255);
wim 2:43ede88fb5a3 370 for (int i=224; i>15; i-=5)
wim 2:43ede88fb5a3 371 {
wim 2:43ede88fb5a3 372 myGLCD.drawLine(1, i, 331-(i*1.44), 15);
wim 2:43ede88fb5a3 373 }
wim 2:43ede88fb5a3 374 myGLCD.setColor (0,255,255);
wim 2:43ede88fb5a3 375 for (int i=15; i<224; i+=5)
wim 2:43ede88fb5a3 376 {
wim 2:43ede88fb5a3 377 myGLCD.drawLine(318, i, 330-(i*1.44), 224);
wim 2:43ede88fb5a3 378 }
wim 2:43ede88fb5a3 379
wim 2:43ede88fb5a3 380 delay(2000);
wim 2:43ede88fb5a3 381
wim 2:43ede88fb5a3 382 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 383 myGLCD.fillRect(1,15,318,225);
wim 2:43ede88fb5a3 384
wim 2:43ede88fb5a3 385 // Draw some random circles
wim 2:43ede88fb5a3 386 for (int i=0; i<100; i++)
wim 2:43ede88fb5a3 387 {
wim 2:43ede88fb5a3 388 myGLCD.setColor(random(255), random(255), random(255));
wim 2:43ede88fb5a3 389 x=32+random(256);
wim 2:43ede88fb5a3 390 y=45+random(146);
wim 2:43ede88fb5a3 391 r=random(30);
wim 2:43ede88fb5a3 392 myGLCD.drawCircle(x, y, r);
wim 2:43ede88fb5a3 393 }
wim 2:43ede88fb5a3 394
wim 2:43ede88fb5a3 395 delay(2000);
wim 2:43ede88fb5a3 396
wim 2:43ede88fb5a3 397 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 398 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 399
wim 2:43ede88fb5a3 400 // Draw some random rectangles
wim 2:43ede88fb5a3 401 for (int i=0; i<100; i++)
wim 2:43ede88fb5a3 402 {
wim 2:43ede88fb5a3 403 myGLCD.setColor(random(255), random(255), random(255));
wim 2:43ede88fb5a3 404 x=2+random(316);
wim 2:43ede88fb5a3 405 y=16+random(207);
wim 2:43ede88fb5a3 406 x2=2+random(316);
wim 2:43ede88fb5a3 407 y2=16+random(207);
wim 2:43ede88fb5a3 408 myGLCD.drawRect(x, y, x2, y2);
wim 2:43ede88fb5a3 409 }
wim 2:43ede88fb5a3 410
wim 2:43ede88fb5a3 411 delay(2000);
wim 2:43ede88fb5a3 412
wim 2:43ede88fb5a3 413 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 414 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 415
wim 2:43ede88fb5a3 416 // Draw some random rounded rectangles
wim 2:43ede88fb5a3 417 for (int i=0; i<100; i++)
wim 2:43ede88fb5a3 418 {
wim 2:43ede88fb5a3 419 myGLCD.setColor(random(255), random(255), random(255));
wim 2:43ede88fb5a3 420 x=2+random(316);
wim 2:43ede88fb5a3 421 y=16+random(207);
wim 2:43ede88fb5a3 422 x2=2+random(316);
wim 2:43ede88fb5a3 423 y2=16+random(207);
wim 2:43ede88fb5a3 424 myGLCD.drawRoundRect(x, y, x2, y2);
wim 2:43ede88fb5a3 425 }
wim 2:43ede88fb5a3 426
wim 2:43ede88fb5a3 427 delay(2000);
wim 2:43ede88fb5a3 428
wim 2:43ede88fb5a3 429 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 430 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 431
wim 2:43ede88fb5a3 432 for (int i=0; i<100; i++)
wim 2:43ede88fb5a3 433 {
wim 2:43ede88fb5a3 434 myGLCD.setColor(random(255), random(255), random(255));
wim 2:43ede88fb5a3 435 x=2+random(316);
wim 2:43ede88fb5a3 436 y=16+random(209);
wim 2:43ede88fb5a3 437 x2=2+random(316);
wim 2:43ede88fb5a3 438 y2=16+random(209);
wim 2:43ede88fb5a3 439 myGLCD.drawLine(x, y, x2, y2);
wim 2:43ede88fb5a3 440 }
wim 2:43ede88fb5a3 441
wim 2:43ede88fb5a3 442 delay(2000);
wim 2:43ede88fb5a3 443
wim 2:43ede88fb5a3 444 myGLCD.setColor(0,0,0);
wim 2:43ede88fb5a3 445 myGLCD.fillRect(1,15,318,224);
wim 2:43ede88fb5a3 446
wim 2:43ede88fb5a3 447 for (int i=0; i<10000; i++)
wim 2:43ede88fb5a3 448 {
wim 2:43ede88fb5a3 449 myGLCD.setColor(random(255), random(255), random(255));
wim 2:43ede88fb5a3 450 myGLCD.drawPixel(2+random(316), 16+random(209));
wim 2:43ede88fb5a3 451 }
wim 2:43ede88fb5a3 452
wim 2:43ede88fb5a3 453 delay(2000);
wim 2:43ede88fb5a3 454
wim 2:43ede88fb5a3 455 // myGLCD.fillScr(0, 0, 255);
wim 2:43ede88fb5a3 456 myGLCD.clearScreen(Blue);
wim 2:43ede88fb5a3 457
wim 2:43ede88fb5a3 458 myGLCD.setColor(255, 0, 0);
wim 2:43ede88fb5a3 459 myGLCD.fillRoundRect(80, 70, 239, 169);
wim 2:43ede88fb5a3 460
wim 2:43ede88fb5a3 461 myGLCD.setColor(255, 255, 255);
wim 2:43ede88fb5a3 462 myGLCD.setBackColor(255, 0, 0);
wim 2:43ede88fb5a3 463 // myGLCD.print("That's it!", CENTER, 93);
wim 2:43ede88fb5a3 464 // myGLCD.print("Restarting in a", CENTER, 119);
wim 2:43ede88fb5a3 465 // myGLCD.print("few seconds...", CENTER, 132);
wim 2:43ede88fb5a3 466
wim 2:43ede88fb5a3 467 myGLCD.setColor(0, 255, 0);
wim 2:43ede88fb5a3 468 myGLCD.setBackColor(0, 0, 255);
wim 2:43ede88fb5a3 469 // myGLCD.print("Runtime: (msecs)", CENTER, 210);
wim 2:43ede88fb5a3 470 // myGLCD.printNumI(millis(), CENTER, 225);
wim 2:43ede88fb5a3 471
wim 2:43ede88fb5a3 472 delay (3000);
wim 0:a8090b59eb05 473 }
wim 0:a8090b59eb05 474
wim 0:a8090b59eb05 475
wim 0:a8090b59eb05 476
wim 0:a8090b59eb05 477 int main() {
wim 0:a8090b59eb05 478 init_interfaces();
wim 0:a8090b59eb05 479
wim 0:a8090b59eb05 480 heartbeat_start();
wim 0:a8090b59eb05 481
wim 0:a8090b59eb05 482 clear_screen();
wim 0:a8090b59eb05 483
wim 0:a8090b59eb05 484 pc.printf("Hello World!\n\r");
wim 0:a8090b59eb05 485
wim 3:2dccfa0121de 486 // myGLCD.init(); // done in cosntructor
wim 2:43ede88fb5a3 487 myGLCD.clearScreen(White);
wim 2:43ede88fb5a3 488 // GLCD_clearScreen(Blue);
wim 0:a8090b59eb05 489 // GLCD_Bmp( 0, 0, 320, 69, (unsigned char*) Bg_16bpp_t+70);
wim 0:a8090b59eb05 490 // GLCD_Bmp( 0, 69, 4, 102, (unsigned char*) Bg_16bpp_l+70);
wim 0:a8090b59eb05 491 // GLCD_Bmp(316, 69, 4, 102, (unsigned char*) Bg_16bpp_r+70);
wim 0:a8090b59eb05 492 // GLCD_Bmp( 0, 171, 320, 69, (unsigned char*) Bg_16bpp_b+70);
wim 0:a8090b59eb05 493 // GLCD_Bmp( 0, 171, 320, 69, (unsigned char*) Bg_16bpp_t+70);
wim 0:a8090b59eb05 494
wim 2:43ede88fb5a3 495 myGLCD.setColor (Red);
wim 2:43ede88fb5a3 496 myGLCD.setBackColor (White);
wim 2:43ede88fb5a3 497 myGLCD.DisplayString (8, 1, (unsigned char*) "Hi Willem");
wim 0:a8090b59eb05 498
wim 2:43ede88fb5a3 499 // GLCD_Ani_start();
wim 2:43ede88fb5a3 500
wim 2:43ede88fb5a3 501 myGLCD.drawRect (10, 10, 100, 100);
wim 0:a8090b59eb05 502
wim 2:43ede88fb5a3 503 myGLCD.setColor (Green);
wim 2:43ede88fb5a3 504 myGLCD.drawHLine (20, 20, 50);
wim 2:43ede88fb5a3 505 myGLCD.drawVLine (30, 30, 50);
wim 2:43ede88fb5a3 506
wim 2:43ede88fb5a3 507 myGLCD.setColor (Blue);
wim 2:43ede88fb5a3 508 myGLCD.fillRoundRect (40, 40, 100, 100);
wim 2:43ede88fb5a3 509 myGLCD.setColor (Cyan);
wim 2:43ede88fb5a3 510 myGLCD.drawCircle (60, 60, 40);
wim 2:43ede88fb5a3 511
wim 2:43ede88fb5a3 512
wim 2:43ede88fb5a3 513 pc.printf("LCD Controller ID = 0x%04X\n\r", myGLCD.getDriverCode());
wim 0:a8090b59eb05 514
wim 3:2dccfa0121de 515 loop();
wim 0:a8090b59eb05 516
wim 3:2dccfa0121de 517 // float k = 0.0;
wim 3:2dccfa0121de 518 float re_min=-0.17775;
wim 3:2dccfa0121de 519 float im_min= 0.7675;
wim 3:2dccfa0121de 520 float len= 0.32375;
wim 3:2dccfa0121de 521
wim 0:a8090b59eb05 522 while(1) {
wim 0:a8090b59eb05 523 pc.printf("+");
wim 2:43ede88fb5a3 524
wim 3:2dccfa0121de 525 pc.printf("\n\rEnter re_min: ");
wim 3:2dccfa0121de 526 pc.scanf("%f", &re_min);
wim 3:2dccfa0121de 527 pc.printf("\n\rEnter im_min: ");
wim 3:2dccfa0121de 528 pc.scanf("%f", &im_min);
wim 3:2dccfa0121de 529 pc.printf("\n\rEnter len: ");
wim 3:2dccfa0121de 530 pc.scanf("%f", &len);
wim 3:2dccfa0121de 531
wim 3:2dccfa0121de 532 pc.printf("\n\rValues: re_min=%0.5f, im_min=%0.5f, len=%0.5f\n\r", re_min, im_min, len);
wim 3:2dccfa0121de 533 mandelbrot(320, 240, 400, re_min, re_min+len, im_min, im_min+len);
wim 3:2dccfa0121de 534 // mandelbrot(150, 150, 400, re_min, re_min+len, im_min, im_min+len+k);
wim 3:2dccfa0121de 535
wim 3:2dccfa0121de 536 // k = k + 0.023;
wim 3:2dccfa0121de 537
wim 0:a8090b59eb05 538 wait(0.1);
wim 0:a8090b59eb05 539 };
wim 0:a8090b59eb05 540
wim 0:a8090b59eb05 541 pc.printf("Bye World!\n\r");
wim 0:a8090b59eb05 542 }