TFT 320 x 240 Pixel
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
#ifdef ESP8266 #include "ESP8266WiFi.h" #include "WiFiUdp.h" #endif #ifdef ESP32 #include "WiFi.h" #include "WiFiUdp.h" #endif #ifdef ARDUINO_UNOR4_WIFI #include "WiFiS3.h" #include "WiFiUdp.h" #endif #ifdef ARDUINO_ARCH_SAMD #include "WiFiNINA.h" #endif #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h" // interne Schrift #include "Fonts/FreeSans24pt7b.h" #include "Fonts/FreeSans18pt7b.h" #include "Fonts/FreeSans12pt7b.h" #include "Fonts/FreeSans32pt7b.h" #include "Fonts/FreeSans40pt7b.h" #include "Fonts/FreeSans60pt7b.h" #include "NTP3.h" // SSID und Passwort des Routers char Router[] = "Router_SSID"; char Passwort[] = "xxxxxxxx"; WiFiUDP wifiUdp; NTP3 ntp(wifiUdp); // Arduino UNO R4 WiFi // #define TFT_CS 10 // #define TFT_RST 8 // #define TFT_DC 9 // XIAO // #define TFT_CS D7 // #define TFT_RST D1 // #define TFT_DC D2 // Arduino Nano ESP32 // #define TFT_CS 10 // #define TFT_RST 9 // #define TFT_DC 8 // SPI-Pins ESP32-C6 // #define TFT_CS 18 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-WROOM // #define TFT_CS 5 // #define TFT_RST 4 // #define TFT_DC 2 // ESP32-S3 // #define TFT_CS 10 // #define TFT_RST 5 // #define TFT_DC 4 // ESP32-C6-Zero // #define TFT_CS 18 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-C3 Zero/ESP32-C3 Super Mini // #define TFT_CS 7 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-C5 Zero // #define TFT_CS 6 // #define TFT_RST 5 // #define TFT_DC 4 // 1-Bit Canvas definieren GFXcanvas1 Bereich(320, 240); Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // Farben #define SCHWARZ 0x0000 #define WEISS 0xFFFF // beim Start des loop-Teils wird die Zeit einmalig synchronisiert volatile bool Start = true; unsigned long Zeitmessung = 0; int Sekunden; void setup() { Serial.begin(9600); delay(1000); // TFT starten tft.begin(); // Rotation anpassen tft.setRotation(1); // schwarzer Hintergrund tft.fillScreen(SCHWARZ); tft.setCursor(10, 40); tft.setFont(&FreeSans18pt7b); tft.print("WiFi verbinden ..."); // WiFi starten DHCP WiFi.begin(Router, Passwort); #ifdef ESP32 WiFi.mode(WIFI_MODE_STA); WiFi.setSleep(false); WiFi.setAutoReconnect(true); ntp.syncRTC(true); #endif while(WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } /* Zeitzone CEST: Central European Summertime Beginn europäische Sommerzeit letzter Sonntag im März 2 Uhr GMT + 2 Stunden */ ntp.ruleDST("CEST", Last, Sun, Mar, 2, 120); // CET: Central European Time // Beginn Normalzeit letzter Sonntag im Oktober 3 Uhr GMT + 1 Stunde ntp.ruleSTD("CET", Last, Sun, Oct, 3, 60); // ntp starten ntp.begin(); // WiFi-Daten anzeigen tft.setCursor(10, 90); tft.print("IP: "); tft.print(WiFi.localIP()); tft.setCursor(10, 140); tft.print(WiFi.SSID()); tft.setCursor(10, 190); tft.print("RSSI: "); tft.print(WiFi.RSSI()); delay(5000); Zeitmessung = millis() + 1000; } void loop() { // Start = true // -> Zeit einmalig beim Start synchronisieren // danach zur vollen Minute if (Start) { Start = false; ZeitAnzeigen(); } // Sekunden weiter zählen if (Zeitmessung < millis()) { Zeitmessung += 1000; Sekunden++; // nach 60 Sekunden Zeit aktualisieren if (Sekunden == 60) ZeitAnzeigen(); } } void ZeitAnzeigen() { if (ntp.update()) { // überprüfen ob die Zeit gültig ist if (ntp.isValid()) { Sekunden = ntp.seconds(); // Canvas erstellen Bereich.fillScreen(0x0000); Bereich.setFont(&FreeSans18pt7b); Bereich.setCursor(10, 30); switch(ntp.weekDay()) { case 0: Bereich.print("Sonntag"); break; case 1: Bereich.print("Montag"); break; case 2: Bereich.print("Dienstag"); break; case 3: Bereich.print("Mittwoch"); break; case 4: Bereich.print("Donnertag"); break; case 5: Bereich.print("Freitag"); break; case 6: Bereich.print("Samstag"); break; } // Datum Bereich.setCursor(10, 80); Bereich.print(ntp.formattedTime("%d. %m. %Y")); Bereich.drawFastHLine(1, 90, tft.width(), WEISS); Bereich.setCursor(10, 200); // Zeit Bereich.setFont(&FreeSans60pt7b); Bereich.setTextColor(WEISS); Bereich.print(ntp.formattedTime("%H:%M")); // Canvas anzeigen tft.drawBitmap(1,1, Bereich.getBuffer(), Bereich.width(), Bereich.height(), 0xFFFF, 0x0000); } // Zeit ist nicht gültig else { // prüfen, ob WiFi verbunden ist while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } Start = true; } } // WiFi ist nicht verbunden else { // prüfen, ob WiFi verbunden ist while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } Start = true; } } |
TFT 240 x 240 Pixel
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
#ifdef ESP8266 #include "ESP8266WiFi.h" #include "WiFiUdp.h" #endif #ifdef ESP32 #include "WiFi.h" #include "WiFiUdp.h" #endif #ifdef ARDUINO_UNOR4_WIFI #include "WiFiS3.h" #include "WiFiUdp.h" #endif #ifdef ARDUINO_ARCH_SAMD #include "WiFiNINA.h" #endif #include "Adafruit_GFX.h" #include "Adafruit_GC9A01A.h" // interne Schrift #include "Fonts/FreeSans24pt7b.h" #include "Fonts/FreeSans18pt7b.h" #include "Fonts/FreeSans12pt7b.h" #include "Fonts/FreeSans32pt7b.h" #include "Fonts/FreeSans40pt7b.h" #include "NTP3.h" // SSID und Passwort des Routers char Router[] = "Router_SSID"; char Passwort[] = "xxxxxxxx"; WiFiUDP wifiUdp; NTP3 ntp(wifiUdp); // Arduino UNO R4 WiFi // #define TFT_CS 10 // #define TFT_RST 8 // #define TFT_DC 9 // XIAO // #define TFT_CS D7 // #define TFT_RST D1 // #define TFT_DC D2 // Arduino Nano ESP32 // #define TFT_CS 10 // #define TFT_RST 9 // #define TFT_DC 8 // SPI-Pins ESP32-C6 // #define TFT_CS 18 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-WROOM // #define TFT_CS 5 // #define TFT_RST 4 // #define TFT_DC 2 // ESP32-S3 // #define TFT_CS 10 // #define TFT_RST 5 // #define TFT_DC 4 // ESP32-C6-Zero // #define TFT_CS 18 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-C3 Zero/ESP32-C3 Super Mini // #define TFT_CS 7 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-C5 Zero // #define TFT_CS 6 // #define TFT_RST 5 // #define TFT_DC 4 // 1-Bit Canvas definieren GFXcanvas1 Bereich(320, 240); Adafruit_GC9A01A tft(TFT_CS, TFT_DC); // Farben #define SCHWARZ 0x0000 #define WEISS 0xFFFF // beim Start des loop-Teils wird die Zeit einmalig synchronisiert volatile bool Start = true; unsigned long Zeitmessung = 0; int Sekunden; void setup() { Serial.begin(9600); delay(1000); tft.begin(); // TFT starten tft.begin(); // Rotation anpassen tft.setRotation(1); // schwarzer Hintergrund tft.fillScreen(SCHWARZ); tft.setCursor(40, 90); tft.setFont(&FreeSans12pt7b); tft.print("WiFi verbinden ..."); // WiFi starten DHCP WiFi.begin(Router, Passwort); #ifdef ESP32 WiFi.mode(WIFI_MODE_STA); WiFi.setSleep(false); WiFi.setAutoReconnect(true); ntp.syncRTC(true); #endif while(WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } /* Zeitzone CEST: Central European Summertime Beginn europäische Sommerzeit letzter Sonntag im März 2 Uhr GMT + 2 Stunden */ ntp.ruleDST("CEST", Last, Sun, Mar, 2, 120); // CET: Central European Time // Beginn Normalzeit letzter Sonntag im Oktober 3 Uhr GMT + 1 Stunde ntp.ruleSTD("CET", Last, Sun, Oct, 3, 60); // ntp starten ntp.begin(); // WiFi-Daten anzeigen tft.setCursor(40, 120); tft.print(WiFi.localIP()); tft.setCursor(40, 150); tft.print(WiFi.RSSI()); delay(5000); Zeitmessung = millis() + 1000; } void loop() { // Start = true // -> Zeit einmalig beim Start synchronisieren // danach zur vollen Minute if (Start) { Start = false; ZeitAnzeigen(); } // Sekunden weiter zählen if (Zeitmessung < millis()) { Zeitmessung += 1000; Sekunden++; // nach 60 Sekunden Zeit aktualisieren if (Sekunden == 60) ZeitAnzeigen(); } } void ZeitAnzeigen() { if (ntp.update()) { // überprüfen ob die Zeit gültig ist if (ntp.isValid()) { Sekunden = ntp.seconds(); // Canvas erstellen Bereich.fillScreen(0x0000); Bereich.setCursor(30, 90); Bereich.setFont(&FreeSans18pt7b); Bereich.print(ntp.formattedTime("%d. %m. %Y")); Bereich.setCursor(20, 180); Bereich.setFont(&FreeSans40pt7b); Bereich.setTextColor(WEISS); Bereich.print(ntp.formattedTime("%H:%M")); // Canvas anzeigen tft.drawBitmap(1,1, Bereich.getBuffer(), Bereich.width(), Bereich.height(), 0xFFFF, 0x0000); } // Zeit ist nicht gültig else { // prüfen, ob WiFi verbunden ist while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } Start = true; } } // WiFi ist nicht verbunden else { // prüfen, ob WiFi verbunden ist while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } Start = true; } } |
TFT 160 x 128 Pixel
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
#ifdef ESP8266 #include "ESP8266WiFi.h" #include "WiFiUdp.h" #endif #ifdef ESP32 #include "WiFi.h" #include "WiFiUdp.h" #endif #ifdef ARDUINO_UNOR4_WIFI #include "WiFiS3.h" #include "WiFiUdp.h" #endif #ifdef ARDUINO_ARCH_SAMD #include "WiFiNINA.h" #endif #include "Adafruit_GFX.h" #include "Adafruit_ST7735.h" // interne Schrift #include "Fonts/FreeSans24pt7b.h" #include "Fonts/FreeSans18pt7b.h" #include "Fonts/FreeSans12pt7b.h" #include "Fonts/FreeSans32pt7b.h" #include "Fonts/FreeSans40pt7b.h" #include "Fonts/FreeSans60pt7b.h" #include "Fonts/FreeSans9pt7b.h" #include "NTP3.h" // SSID und Passwort des Routers char Router[] = "Router_SSID"; char Passwort[] = "xxxxxxxx"; WiFiUDP wifiUdp; NTP3 ntp(wifiUdp); // Arduino UNO R4 WiFi // #define TFT_CS 10 // #define TFT_RST 8 // #define TFT_DC 9 // XIAO // #define TFT_CS D7 // #define TFT_RST D1 // #define TFT_DC D2 // Arduino Nano ESP32 // #define TFT_CS 10 // #define TFT_RST 9 // #define TFT_DC 8 // SPI-Pins ESP32-C6 // #define TFT_CS 18 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-WROOM // #define TFT_CS 5 // #define TFT_RST 4 // #define TFT_DC 2 // ESP32-S3 // #define TFT_CS 10 // #define TFT_RST 5 // #define TFT_DC 4 // ESP32-C6-Zero // #define TFT_CS 18 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-C3 Zero/ESP32-C3 Super Mini // #define TFT_CS 7 // #define TFT_RST 3 // #define TFT_DC 2 // ESP32-C5 Zero // #define TFT_CS 6 // #define TFT_RST 5 // #define TFT_DC 4 // 1-Bit Canvas definieren GFXcanvas1 Bereich(320, 240); Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); // Farben #define SCHWARZ 0x0000 #define WEISS 0xFFFF // beim Start des loop-Teils wird die Zeit einmalig synchronisiert volatile bool Start = true; unsigned long Zeitmessung = 0; int Sekunden; void setup() { Serial.begin(9600); delay(1000); // TFT starten tft.initR(INITR_BLACKTAB); // Rotation anpassen tft.setRotation(1); // schwarzer Hintergrund tft.fillScreen(SCHWARZ); tft.setCursor(1, 10); tft.setFont(&FreeSans9pt7b); tft.print("WiFi verbinden ..."); // WiFi starten DHCP WiFi.begin(Router, Passwort); #ifdef ESP32 WiFi.mode(WIFI_MODE_STA); WiFi.setSleep(false); WiFi.setAutoReconnect(true); ntp.syncRTC(true); #endif while(WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } /* Zeitzone CEST: Central European Summertime Beginn europäische Sommerzeit letzter Sonntag im März 2 Uhr GMT + 2 Stunden */ ntp.ruleDST("CEST", Last, Sun, Mar, 2, 120); // CET: Central European Time // Beginn Normalzeit letzter Sonntag im Oktober 3 Uhr GMT + 1 Stunde ntp.ruleSTD("CET", Last, Sun, Oct, 3, 60); // ntp starten ntp.begin(); // WiFi-Daten anzeigen tft.setCursor(10, 40); tft.print("IP: "); tft.print(WiFi.localIP()); tft.setCursor(10, 70); tft.print(WiFi.SSID()); tft.setCursor(1, 100); tft.print("RSSI: "); tft.print(WiFi.RSSI()); delay(5000); Zeitmessung = millis() + 1000; } void loop() { // Start = true // -> Zeit einmalig beim Start synchronisieren // danach zur vollen Minute if (Start) { Start = false; ZeitAnzeigen(); } // Sekunden weiter zählen if (Zeitmessung < millis()) { Zeitmessung += 1000; Sekunden++; // nach 60 Sekunden Zeit aktualisieren if (Sekunden == 60) ZeitAnzeigen(); } } void ZeitAnzeigen() { if (ntp.update()) { // überprüfen ob die Zeit gültig ist if (ntp.isValid()) { Sekunden = ntp.seconds(); // Canvas erstellen Bereich.fillScreen(0x0000); Bereich.setFont(&FreeSans12pt7b); Bereich.setCursor(1, 20); switch(ntp.weekDay()) { case 0: Bereich.print("Sonntag"); break; case 1: Bereich.print("Montag"); break; case 2: Bereich.print("Dienstag"); break; case 3: Bereich.print("Mittwoch"); break; case 4: Bereich.print("Donnertag"); break; case 5: Bereich.print("Freitag"); break; case 6: Bereich.print("Samstag"); break; } // Datum Bereich.setCursor(1, 50); Bereich.print(ntp.formattedTime("%d. %m. %Y")); Bereich.drawFastHLine(1, 55, tft.width(), WEISS); Bereich.setCursor(10, 110); // Zeit Bereich.setFont(&FreeSans24pt7b); Bereich.setTextColor(WEISS); Bereich.print(ntp.formattedTime("%H:%M")); // Canvas anzeigen tft.drawBitmap(1,1, Bereich.getBuffer(), Bereich.width(), Bereich.height(), 0xFFFF, 0x0000); } // Zeit ist nicht gültig else { // prüfen, ob WiFi verbunden ist while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } Start = true; } } // WiFi ist nicht verbunden else { // prüfen, ob WiFi verbunden ist while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print("."); } Start = true; } } |
Letzte Aktualisierung: