a

Dependencies:   mbed 4DGL-uLCD-SE

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // uLCD-144-G2 demo program for uLCD-4GL LCD driver library
00002 //
00003 #include "mbed.h"
00004 #include "uLCD_4DGL.h"
00005 
00006 uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin;
00007 Serial pc(USBTX, USBRX);
00008 int main()
00009 {
00010     // basic printf demo = 16 by 18 characters on screen
00011     uLCD.printf("\nHello uLCD World\n"); //Default Green on black text
00012     uLCD.printf("\n  Starting Demo...");
00013     uLCD.text_width(4); //4X size text
00014     uLCD.text_height(4);
00015     uLCD.color(RED);
00016     for (int i=10; i>=0; --i) {
00017         uLCD.locate(1,2);
00018         uLCD.printf("%2D",i);
00019         wait(.5);
00020     }
00021     uLCD.cls();
00022     uLCD.printf("Change baudrate......");
00023     uLCD.baudrate(3000000); //jack up baud rate to max for fast display
00024     //if demo hangs here - try lower baud rates
00025     //
00026     // printf text only full screen mode demo
00027     uLCD.background_color(BLUE);
00028     uLCD.cls();
00029     uLCD.locate(0,0);
00030     uLCD.color(WHITE);
00031     uLCD.textbackground_color(BLUE);
00032     uLCD.set_font(FONT_7X8);
00033     uLCD.text_mode(OPAQUE);
00034     int i=0;
00035     while(i<64) {
00036         if(i%16==0) uLCD.cls();
00037         uLCD.printf("TxtLine %2D Page %D\n",i%16,i/16 );
00038         i++; //16 lines with 18 charaters per line
00039     }
00040     wait(0.5);
00041     //demo graphics commands
00042     uLCD.background_color(BLACK);
00043     uLCD.cls();
00044     uLCD.background_color(DGREY);
00045     uLCD.filled_circle(60, 50, 30, 0xFF00FF);
00046     uLCD.triangle(120, 100, 40, 40, 10, 100, 0x0000FF);
00047     uLCD.line(0, 0, 80, 60, 0xFF0000);
00048     uLCD.filled_rectangle(50, 50, 100, 90, 0x00FF00);
00049     uLCD.pixel(60, 60, BLACK);
00050     uLCD.read_pixel(120, 70);
00051     uLCD.circle(120, 60, 10, BLACK);
00052     uLCD.set_font(FONT_7X8);
00053     uLCD.text_mode(TRANSPARENT);
00054     uLCD.text_bold(ON);
00055     uLCD.text_char('B', 9, 8, BLACK);
00056     uLCD.text_char('I',10, 8, BLACK);
00057     uLCD.text_char('G',11, 8, BLACK);
00058     uLCD.text_italic(ON);
00059     uLCD.text_string("This is a test of string", 1, 4, FONT_7X8, WHITE);
00060     wait(2);
00061 }
00062 
00063 
00064