TFT rotation test program (ST7735) Using 1.8" Adafruit TFT Shield with Joystick and microSD v1.0 Verified by WIZwiki-W7500 platform

Dependencies:   Adafruit_GFX Adafruit_ST7735 mbed

Revision:
0:7315c6c53c24
Child:
1:b6cb79a9373d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jul 28 00:02:02 2015 +0000
@@ -0,0 +1,271 @@
+#include "mbed.h"
+#include "Adafruit_ST7735.h"
+
+Adafruit_ST7735 tft(D11, D12, D13, D10, D8, D9); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST
+Serial pc(USBTX, USBRX);
+
+void rotateLine(void);
+void rotateText(void);
+void rotatePixel(void);
+void rotateFastline(void);
+void rotateDrawrect(void);
+void rotateFillrect(void);
+void rotateDrawcircle(void);
+void rotateFillcircle(void);
+void rotateTriangle(void);
+void rotateFillTriangle(void);
+void rotateRoundRect(void);
+void rotateFillRoundRect(void);
+void rotateChar(void);
+void rotateString(void);
+
+int main(void)
+{
+    pc.printf("Hello! Adafruit ST7735 rotation test\r\n");
+
+    // Use this initializer if you're using a 1.8" TFT
+    tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
+
+    // Use this initializer (uncomment) if you're using a 1.44" TFT
+    //tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab
+
+    pc.printf("init\r\n");
+
+    tft.setTextWrap(false); // Allow text to run off right edge
+    tft.fillScreen(ST7735_BLACK);
+  
+    pc.printf("This is a test of the rotation capabilities of the TFT library!\r\n");
+    pc.printf("Press <SEND> (or type a character) to advance\r\n");
+
+    while(1)
+    {
+        rotateLine();
+        rotateText();
+        rotatePixel();
+        rotateFastline();
+        rotateDrawrect();
+        rotateFillrect();
+        rotateDrawcircle();
+        rotateFillcircle();
+        rotateTriangle();
+        rotateFillTriangle();
+        rotateRoundRect();
+        rotateFillRoundRect();
+        rotateChar();
+        rotateString();
+    }
+}
+
+void rotateLine(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawLine(tft.width()/2, tft.height()/2, 0, 0, ST7735_RED);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateText(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.setCursor(0, 30);
+        tft.setTextColor(ST7735_RED);
+        tft.setTextSize(1);
+        tft.printf("Hello World!\r\n");
+        tft.setTextColor(ST7735_YELLOW);
+        tft.setTextSize(2);
+        tft.printf("Hello World!\r\n");
+        tft.setTextColor(ST7735_GREEN);
+        tft.setTextSize(3);
+        tft.printf("Hello World!\r\n");
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+        
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotatePixel(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawPixel(10,20, ST7735_WHITE);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateFastline(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawFastHLine(0, 20, tft.width(), ST7735_RED);
+        tft.drawFastVLine(20, 0, tft.height(), ST7735_BLUE);
+    
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateDrawrect(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawRect(10, 20, 10, 20, ST7735_GREEN);
+     
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateFillrect(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.fillRect(10, 20, 10, 20, ST7735_GREEN);
+     
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateDrawcircle(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawCircle(10, 30, 10, ST7735_YELLOW);
+     
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+      
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateFillcircle(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.fillCircle(10, 30, 10, ST7735_YELLOW);
+    
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateTriangle(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawTriangle(20, 10, 10, 30, 30, 30, ST7735_GREEN);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateFillTriangle(void) {
+  char ch;
+  for (uint8_t i=0; i<4; i++) {
+    tft.fillScreen(ST7735_BLACK);
+
+    tft.fillTriangle(20, 10, 10, 30, 30, 30, ST7735_RED);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+
+    tft.setRotation(tft.getRotation()+1);
+  }
+}
+
+void rotateRoundRect(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawRoundRect(20, 10, 25, 15, 5, ST7735_BLUE);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateFillRoundRect(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.fillRoundRect(20, 10, 25, 15, 5, ST7735_CYAN);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateChar(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.drawChar(25, 15, 'A', ST7735_WHITE, ST7735_WHITE, 1);
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}
+
+void rotateString(void) {
+    char ch;
+    for (uint8_t i=0; i<4; i++) {
+        tft.fillScreen(ST7735_BLACK);
+    
+        tft.setCursor(8, 25);
+        tft.setTextSize(1);
+        tft.setTextColor(ST7735_WHITE);
+        tft.printf("Adafruit Industries");        
+        while (pc.readable());
+        ch=pc.getc();
+        pc.printf("%c\r\n",ch);
+    
+        tft.setRotation(tft.getRotation()+1);
+    }
+}