Behrooz Abdi
/
Tiger_LCD
Landtiger (LPC1768) graphics LCD demo.
main.cpp
- Committer:
- wim
- Date:
- 2012-11-04
- Revision:
- 0:a8090b59eb05
- Child:
- 1:ea0f7b1c5daf
File content as of revision 0:a8090b59eb05:
#include "mbed.h" #include "GLCD.h" #include "Bg_16bpp_t.h" #include "Bg_16bpp_l.h" #include "Bg_16bpp_r.h" #include "Bg_16bpp_b.h" #include "ARM_Ani_16bpp.h" //Host PC Baudrate (Virtual Com Port on USB) #define D_BAUDRATE 9600 //#define D_BAUDRATE 57600 //extern unsigned short driverCode; #define LANDTIGER 1 // Variables for Heartbeat and Status monitoring #ifdef LANDTIGER DigitalOut myled1(P2_0); DigitalOut myled2(P2_1); DigitalOut myled3(P2_2); DigitalOut myled4(P2_3); DigitalOut myled5(P2_4); DigitalOut myled6(P2_5); DigitalOut myled7(P2_6); DigitalOut myled8(P2_7); //DigitalOut heartbeatLED(LED4); DigitalOut heartbeatLED(P3_26); //SD_PWR, active low //DigitalOut USB_Host_Power(P1_19); //USB Power, active low // Need this override function on non-mbed hardware to provide the MAC address. // // The mbed Ethernet library sets the MAC address by calling a weak function // extern "C" void mbed_mac_address(char * mac) to copy in a 6 Byte (12 character) MAC address. // This function performs a semihosting request to the mbed interface to get the serial number, // which contains a MAC address unique to every mbed device. // If you are using the eth library on your own board (i.e. not an mbed board), // you should implement your own extern "C" void mbed_mac_address(char * mac) function // to overwrite the existing one and avoid a call to the interface (which doesnt exist). extern "C" void mbed_mac_address(char * mac) { //mbed module clone // mac[0] = 0x00; // mac[1] = 0x02; // mac[2] = 0xF7; // mac[3] = 0xF0; // mac[4] = 0x56; // mac[5] = 0x90; //KPN Experia mac[0] = 0x00; mac[1] = 0x01; mac[2] = 0xE3; mac[3] = 0x55; mac[4] = 0xA1; mac[5] = 0xC7; }; #else DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); DigitalOut heartbeatLED(LED4); #endif // Host PC Communication channels Serial pc(USBTX, USBRX); // tx, rx // Variables for Heartbeat and Status monitoring Ticker heartbeat; bool heartbeatflag=false; Ticker LCD_Ani; void clear_screen() { //ANSI Terminal Commands pc.printf("\x1B[2J"); pc.printf("\x1B[H"); } void init_interfaces() { // Init Host PC communication, default is 9600 pc.baud(D_BAUDRATE); //Done, Tell me about it // show_LEDS(); } // Heartbeat monitor void pulse() { heartbeatLED = !heartbeatLED; #ifdef LANDTIGER // myled1 = heartbeatLED; // myled2 = heartbeatLED; // myled3 = heartbeatLED; // myled4 = heartbeatLED; // myled5 = !heartbeatLED; // myled6 = !heartbeatLED; // myled7 = !heartbeatLED; // myled8 = !heartbeatLED; #endif } void heartbeat_start() { heartbeatLED = 1; heartbeat.attach(&pulse, 0.5); } void heartbeat_stop() { heartbeat.detach(); } // LCD Animation void LCD_pulse() { static int pic = 0; if (pic++ > 8) pic = 0; GLCD_Bmp (99, 99, 120, 45, (unsigned char*) &ARM_Ani_16bpp[pic*(120*45*2)]); } void LCD_Ani_start() { // LCD_Ani.attach(&LCD_pulse, 0.05); LCD_Ani.attach(&LCD_pulse, 0.25); } void LCD_Ani_stop() { LCD_Ani.detach(); } int main() { init_interfaces(); heartbeat_start(); clear_screen(); pc.printf("Hello World!\n\r"); GLCD_Init(); GLCD_Clear(White); // GLCD_Clear(Blue); // GLCD_Bmp( 0, 0, 320, 69, (unsigned char*) Bg_16bpp_t+70); // GLCD_Bmp( 0, 69, 4, 102, (unsigned char*) Bg_16bpp_l+70); // GLCD_Bmp(316, 69, 4, 102, (unsigned char*) Bg_16bpp_r+70); // GLCD_Bmp( 0, 171, 320, 69, (unsigned char*) Bg_16bpp_b+70); // GLCD_Bmp( 0, 171, 320, 69, (unsigned char*) Bg_16bpp_t+70); GLCD_SetTextColor (Red); GLCD_SetBackColor (White); GLCD_DisplayString (0, 0, (unsigned char*) "Hi Willem"); LCD_Ani_start(); GLCD_drawRect (20, 20, 100, 100); GLCD_SetTextColor (Green); GLCD_drawHLine (10, 10, 50); GLCD_drawVLine (30, 30, 50); pc.printf("LCD Controller ID = 0x%04X\n\r", GLCD_DriverCode()); while(1) { pc.printf("+"); wait(0.1); }; pc.printf("Bye World!\n\r"); }