Rihards Balass / 4DGL-mbed-32PTU

demo.cpp

Committer:
CaptainR
Date:
2016-09-08
Revision:
0:a5ef6bc3c2e8
Child:
2:81eaaa491a02

File content as of revision 0:a5ef6bc3c2e8:


#include "mbed.h"
#include "Picaso_4DGL-32PTU.h"

#define SHORT_WAIT 500
#define LONG_WAIT 2000

//**************************************************************************
// Demo program that goes through graphics based functions
//**************************************************************************
void TFT_4DGL :: graphicsDemo() {

    cls();
    screenOrientation(1); // set orientation to landscape
    puts("This is the Graphics functions demo");
    wait_ms(LONG_WAIT);
    cls();
    
    puts("\nLets change all the ");
    textFgColor(PURPLE_MSB, PURPLE_LSB);
    puts("PURPLE");
    textFgColor(YELLOW_MSB, YELLOW_LSB);
    puts(" bits to yellow");
    textFgColor(GREEN_MSB, GREEN_LSB); // set color back to green
    wait_ms(LONG_WAIT);
    changeColor(PURPLE_MSB, PURPLE_LSB, YELLOW_MSB, YELLOW_LSB);
    wait_ms(LONG_WAIT);
    cls();
    
    puts("Lets draw some shapes:");
    wait_ms(LONG_WAIT);
    cls();
    drawCircle(100, 100, 20, RED_MSB, RED_LSB);
    
} 

//**************************************************************************
// Demo program that goes through main functions
//**************************************************************************
void TFT_4DGL :: mainDemo() {

    cls();
    puts("This is the main functions demo");
    wait_ms(LONG_WAIT);
    cls();
    
    puts("\nBaudrates:");
    wait_ms(LONG_WAIT);
    cls();
    baudrate(4800);
    puts("\n4800");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(9600);
    puts("\n9600");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(14400);
    puts("\n14400");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(19200);
    puts("\n19200");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(38400);
    puts("\n38400");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(56000);
    puts("\n56000");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(57600);
    puts("\n57600");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(115200);
    puts("\n115200");
    wait_ms(SHORT_WAIT);
    cls();
    baudrate(9600);
    puts("\nSet back to 9600");
    wait_ms(LONG_WAIT);
    cls();
    
    puts("\nOrientation:");
    wait_ms(LONG_WAIT);
    cls();
    screenOrientation(1);
    puts("landscape");
    wait_ms(SHORT_WAIT);
    cls();
    screenOrientation(2);
    puts("landscape rewersed");
    wait_ms(SHORT_WAIT);
    cls();
    screenOrientation(3);
    puts("portrait");
    wait_ms(SHORT_WAIT);
    cls();
    screenOrientation(4);
    puts("portrait rewersed");
    wait_ms(LONG_WAIT);
    screenOrientation(1); // set back screen to landscape
    cls();
    
}

//**************************************************************************
// Demo program that goes through text based functions
//**************************************************************************
void TFT_4DGL :: textDemo() {
    
    cls();
    screenOrientation(1); // set screen to landscape
    puts("This is the Text functions demo");
    wait_ms(LONG_WAIT);
    cls();

    puts("\nText attributes:");
    wait_ms(LONG_WAIT);
    //cls();
    puts("\n\n");
    textAttributes(16);
    puts("\nBOLD");
    wait_ms(SHORT_WAIT);
    textAttributes(16 + 32);
    puts("\nBOLD & ITALIC");
    wait_ms(SHORT_WAIT);
    textAttributes(16 + 32 + 64);
    puts("\nBOLD & ITALIC & INVERSE");
    wait_ms(SHORT_WAIT);
    textAttributes(16 + 32 + 64 + 128);
    puts("\nBOLD & ITALIC & INVERSE & UNDERLINE");
    wait_ms(LONG_WAIT);
    textAttributes(0); // set everything back to normal
    cls();
    
    puts("\nText modes:");
    wait_ms(LONG_WAIT);
    cls();
    textBold(1);
    puts("\nBOLD:");
    wait_ms(SHORT_WAIT);
    textBold(0);
    textInverse(1);
    puts("\nINVERSE:");
    wait_ms(SHORT_WAIT);
    textInverse(0);
    textItalic(1);
    puts("\nITALIC:");
    wait_ms(SHORT_WAIT);
    textItalic(0);
    textUnderline(1);
    puts("\nUNDERLINE:");
    wait_ms(SHORT_WAIT);
    textUnderline(0);
    wait_ms(LONG_WAIT);
    cls();
    
    puts("\nText gaps:");
    wait_ms(LONG_WAIT);
    cls();
    if (textXGap(0) == 1) puts("\nX gap: 0");
    wait_ms(SHORT_WAIT);
    if (textXGap(1) == 1) puts("\nX gap: 1");
    wait_ms(SHORT_WAIT);
    if (textXGap(2) == 1) puts("\nX gap: 2");
    wait_ms(SHORT_WAIT);
    if (textXGap(3) == 1) puts("\nX gap: 3");
    wait_ms(SHORT_WAIT);
    if (textXGap(4) == 1) puts("\nX gap: 4");
    wait_ms(SHORT_WAIT);
    if (textXGap(5) == 1) puts("\nX gap: 5");
    wait_ms(SHORT_WAIT);
    if (textXGap(6) == 1) puts("\nX gap: 6");
    wait_ms(SHORT_WAIT);
    puts("\n");
    textXGap(0);
    if (textYGap(0) == 1) puts("\nY gap: 0");
    wait_ms(SHORT_WAIT);
    if (textYGap(1) == 1) puts("\nY gap: 1");
    wait_ms(SHORT_WAIT);
    if (textYGap(2) == 1) puts("\nY gap: 2");
    wait_ms(SHORT_WAIT);
    if (textYGap(3) == 1) puts("\nY gap: 3");
    wait_ms(SHORT_WAIT);
    if (textYGap(4) == 1) puts("\nY gap: 4");
    wait_ms(SHORT_WAIT);
    if (textYGap(5) == 1) puts("\nY gap: 5");
    wait_ms(SHORT_WAIT);
    if (textYGap(6) == 1) puts("\nY gap: 6");
    wait_ms(LONG_WAIT);
    textYGap(0);
    cls();
    
    puts("Text width:");
    wait_ms(LONG_WAIT);
    if (textWidth(1) == 1) puts("\nWidth: 1");
    wait_ms(SHORT_WAIT);
    if (textWidth(2) == 1) puts("\nWidth: 2");
    wait_ms(SHORT_WAIT);
    if (textWidth(3) == 1) puts("\nWidth: 3");
    wait_ms(SHORT_WAIT);
    if (textWidth(4) == 1) puts("\nWidth: 4");
    wait_ms(SHORT_WAIT);
    textWidth(1);
    puts("\nText height:");
    wait_ms(LONG_WAIT);
    //cls();
    if (textHeight(1) == 1) puts("\nHeight: 1");
    wait_ms(SHORT_WAIT);
    if (textHeight(2) == 1) puts("\nHeight: 2");
    wait_ms(SHORT_WAIT);
    if (textHeight(3) == 1) puts("\nHeight: 3");
    wait_ms(SHORT_WAIT);
    if (textHeight(4) == 1) puts("\nHeight: 4");
    wait_ms(LONG_WAIT);
    textHeight(1);
    cls();
    
    puts("Fonts:");
    wait_ms(LONG_WAIT);
    cls();
    setFont(1);
    puts("\nThis is Font 1");
    wait_ms(SHORT_WAIT);
    setFont(2);
    puts("\nThis is Font 2");
    wait_ms(SHORT_WAIT);
    setFont(3);
    puts("\nThis is Font 3");
    wait_ms(LONG_WAIT);
    cls();

    
    screenOrientation(3);
    puts("\nText Background colors:");
    wait_ms(LONG_WAIT);
    cls();
    textBgColor(BLACK_MSB, BLACK_LSB);
    puts("\nBG color = BLACK");
    wait_ms(SHORT_WAIT);
    textBgColor(NAVY_MSB, NAVY_LSB);
    puts("\nBG color = NAVY");
    wait_ms(SHORT_WAIT);
    textFgColor(BLACK_MSB, BLACK_LSB);
    textBgColor(DGREEN_MSB, DGREEN_LSB);
    puts("\nBG color = DARK GREEN");
    wait_ms(SHORT_WAIT);
    textBgColor(DCYAN_MSB, DCYAN_LSB);
    puts("\nBG color = DARK CYAN");
    wait_ms(SHORT_WAIT);
    textBgColor(PURPLE_MSB, PURPLE_LSB);
    puts("\nBG color = PURPLE");
    wait_ms(SHORT_WAIT);
    textBgColor(OLIVE_MSB, OLIVE_LSB);
    puts("\nBG color = OLIVE");
    wait_ms(SHORT_WAIT);
    textBgColor(GREY_MSB, GREY_LSB);
    puts("\nBG color = GREY");
    wait_ms(SHORT_WAIT);
    textBgColor(BLUE_MSB, BLUE_LSB);
    puts("\nBG color = BLUE");
    wait_ms(SHORT_WAIT);
    textBgColor(GREEN_MSB, GREEN_LSB);
    puts("\nBG color = GREEN");
    wait_ms(SHORT_WAIT);
    textBgColor(RED_MSB, RED_LSB);
    puts("\nBG color = RED");
    wait_ms(SHORT_WAIT);
    textBgColor(YELLOW_MSB, YELLOW_LSB);
    puts("\nBG color = YELLOW");
    wait_ms(SHORT_WAIT);
    textBgColor(G_YELLOW_MSB, G_YELLOW_LSB);
    puts("\nBG color = GREEN YELLOW");
    wait_ms(SHORT_WAIT);
    textBgColor(WHITE_MSB, WHITE_LSB);
    puts("\nBG color = WHITE");
    wait_ms(SHORT_WAIT);
    textBgColor(ORANGE_MSB, ORANGE_LSB);
    puts("\nBG color = ORANGE");
    wait_ms(SHORT_WAIT);
    textBgColor(PINK_MSB, PINK_LSB);
    puts("\nBG color = PINK");    
    wait_ms(SHORT_WAIT);
    textBgColor(VIOLET_MSB, VIOLET_LSB);
    puts("\nBG color = VIOLET");
    wait_ms(SHORT_WAIT);
    textBgColor(AQUA_MSB, AQUA_LSB);
    puts("\nBG color = AQUA");
    wait_ms(SHORT_WAIT);
    textBgColor(CREAM_MSB, CREAM_LSB);
    puts("\nBG color = CREAM");
    wait_ms(LONG_WAIT);
    textBgColor(BLACK_MSB, BLACK_LSB); // set color back
    textFgColor(GREEN_MSB, GREEN_LSB); // set color back
    cls();
    
    puts("Lets try moving cursor...");
    wait_ms(LONG_WAIT);
    cls();
    if (moveCursor(5, 5) == 1) puts("+");
    wait_ms(SHORT_WAIT);
    if (moveCursor(10, 10) == 1) puts("+");
    wait_ms(SHORT_WAIT);
    screenOrientation(4);
    if (moveCursor(50, 50) == 1) puts("+");
    wait_ms(SHORT_WAIT);
    if (moveCursor(19, 29) == 1) puts("+");
    wait_ms(LONG_WAIT);
    cls();


    screenOrientation(3);
    puts("\nText Foreground colors:");
    wait_ms(LONG_WAIT);
    cls();
    textBgColor(WHITE_MSB, WHITE_LSB);
    textFgColor(BLACK_MSB, BLACK_LSB);
    puts("\nFG color = BLACK");
    textBgColor(BLACK_MSB, BLACK_LSB);
    wait_ms(SHORT_WAIT);
    textFgColor(NAVY_MSB, NAVY_LSB);
    puts("\nFG color = NAVY");
    wait_ms(SHORT_WAIT);
    textFgColor(DGREEN_MSB, DGREEN_LSB);
    puts("\nFG color = DARK GREEN");
    wait_ms(SHORT_WAIT);
    textFgColor(DCYAN_MSB, DCYAN_LSB);
    puts("\nFG color = DARK CYAN");
    wait_ms(SHORT_WAIT);
    textFgColor(PURPLE_MSB, PURPLE_LSB);
    puts("\nFG color = PURPLE");
    wait_ms(SHORT_WAIT);
    textFgColor(OLIVE_MSB, OLIVE_LSB);
    puts("\nFG color = OLIVE");
    wait_ms(SHORT_WAIT);
    textFgColor(GREY_MSB, GREY_LSB);
    puts("\nFG color = GREY");
    wait_ms(SHORT_WAIT);
    textFgColor(BLUE_MSB, BLUE_LSB);
    puts("\nFG color = BLUE");
    wait_ms(SHORT_WAIT);
    textFgColor(GREEN_MSB, GREEN_LSB);
    puts("\nFG color = GREEN");
    wait_ms(SHORT_WAIT);
    textFgColor(RED_MSB, RED_LSB);
    puts("\nFG color = RED");
    wait_ms(SHORT_WAIT);
    textFgColor(YELLOW_MSB, YELLOW_LSB);
    puts("\nFG color = YELLOW");
    wait_ms(SHORT_WAIT);
    textFgColor(G_YELLOW_MSB, G_YELLOW_LSB);
    puts("\nFG color = GREEN YELLOW");
    wait_ms(SHORT_WAIT);
    textFgColor(WHITE_MSB, WHITE_LSB);
    puts("\nFG color = WHITE");
    wait_ms(SHORT_WAIT);
    textFgColor(ORANGE_MSB, ORANGE_LSB);
    puts("\nFG color = ORANGE");
    wait_ms(SHORT_WAIT);
    textFgColor(PINK_MSB, PINK_LSB);
    puts("\nFG color = PINK");    
    wait_ms(SHORT_WAIT);
    textFgColor(VIOLET_MSB, VIOLET_LSB);
    puts("\nFG color = VIOLET");
    wait_ms(SHORT_WAIT);
    textFgColor(AQUA_MSB, AQUA_LSB);
    puts("\nFG color = AQUA");
    wait_ms(SHORT_WAIT);
    textFgColor(CREAM_MSB, CREAM_LSB);
    puts("\nFG color = CREAM");
    wait_ms(SHORT_WAIT);
    textFgColor(GREEN_MSB, GREEN_LSB); // set color back
}