#include //Software Serial Port #include //Software Serial Port #define DEBUG #ifdef DEBUG #define debug(...) Serial.print(__VA_ARGS__) #define debugln(...) Serial.println(__VA_ARGS__) #else #define debug(...) #define debugln(...) #endif #define TFT_RX 6 //RX of Serial TFT module connect to D4 of Arduino / OPEN-SMART UNO #define TFT_TX 7 //TX of Serial TFT to D2 const int LED_ROT = 1; const int LED_GRUEN = 0; //SerialTFT oled(TFT_RX, TFT_TX); SerialTFT oled(Serial1); void setup() { /* Pins einstellen */ pinMode(LED_ROT,OUTPUT); digitalWrite(LED_ROT,1); pinMode(LED_GRUEN,OUTPUT); digitalWrite(LED_GRUEN,1); /* Debug Schnittstelle einrichten */ Serial.begin(9600); delay(500); debugln(F("Starte Xiao")); /* Display Init */ Serial1.begin(9600); oled.reset(); oled.setBacklight(250);//0~255 debugln(F("Display Init OK")); } void loop() { testText(); delay(2000); testRects(GREEN); delay(2000); testLines(CYAN); delay(2000); testFastLines(RED, BLUE); delay(2000); testFilledRects(YELLOW, MAGENTA); delay(2000); testFilledCircles(10, MAGENTA); delay(2000); testCircles(10, WHITE); delay(2000); testTriangles(); delay(2000); testFilledTriangles(); delay(2000); testRoundRects(); delay(2000); testFilledRoundRects(); } void testLines(uint16_t color) { unsigned long start, t; int x1, y1, x2, y2, w = 320, h = 240; oled.fillScreen(BLACK); x1 = y1 = 0; y2 = h - 1; for(x2=0; x20; i-=6) { i2 = i / 2; oled.fillRect(cx-i2, cy-i2, i, i, color1); // Outlines are not included in timing results oled.drawRect(cx-i2, cy-i2, i, i, color2); } } void testFilledCircles(uint8_t radius, uint16_t color) { int x, y, w = 320, h = 240, r2 = radius * 2; oled.fillScreen(BLACK); for(x=radius; x10; i-=5) { oled.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, oled.color565(0, i, i)); oled.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, oled.color565(i, i, 0)); } } void testRoundRects() { int w, i, i2, cx = 320 / 2 - 1, cy = 240 / 2 - 1; oled.fillScreen(BLACK); w = 240; for(i=0; i20; i-=6) { i2 = i / 2; oled.fillRoundRect(cx-i2, cy-i2, i, i, i/8, oled.color565(0, i, 0)); } }