├── .gitattributes ├── ESP32_Rec └── ESP32_Rec.ino ├── NodeMCU_rec └── NodeMCU_rec.ino └── ESP32_ONE2MANY_Transmitter └── ESP32_ONE2MANY_Transmitter.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /ESP32_Rec/ESP32_Rec.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | #define R1 15 7 | #define R2 2 8 | #define R3 4 9 | #define R4 22 10 | 11 | 12 | //Structure example to send data 13 | //Must match the receiver structure 14 | typedef struct struct_message { 15 | bool sw1; 16 | bool sw2; 17 | bool sw3; 18 | bool sw4; 19 | } struct_message; 20 | 21 | struct_message incomingReadings; 22 | 23 | // Variable to store if sending data was successful 24 | String success; 25 | 26 | 27 | // Callback when data is received 28 | void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) 29 | { 30 | memcpy(&incomingReadings, incomingData, sizeof(incomingReadings)); 31 | Serial.print("Bytes received: "); 32 | Serial.println(len); 33 | Serial.print("Switch 1: ");Serial.println(incomingReadings.sw1); 34 | Serial.print("Switch 2: ");Serial.println(incomingReadings.sw2); 35 | Serial.print("Switch 3: ");Serial.println(incomingReadings.sw3); 36 | Serial.print("Switch 4: ");Serial.println(incomingReadings.sw4); 37 | digitalWrite(R1,!incomingReadings.sw1); 38 | digitalWrite(R2,!incomingReadings.sw2); 39 | digitalWrite(R3,!incomingReadings.sw3); 40 | digitalWrite(R4,!incomingReadings.sw4); 41 | } 42 | 43 | void setup() 44 | { 45 | // Init Serial Monitor 46 | Serial.begin(115200); 47 | Serial.println("Code start"); 48 | 49 | pinMode(R1,OUTPUT); 50 | pinMode(R2,OUTPUT); 51 | pinMode(R3,OUTPUT); 52 | pinMode(R4,OUTPUT); 53 | 54 | // Set device as a Wi-Fi Station 55 | WiFi.mode(WIFI_STA); 56 | 57 | // Init ESP-NOW 58 | if (esp_now_init() != ESP_OK) { 59 | Serial.println("Error initializing ESP-NOW"); 60 | return; 61 | } 62 | 63 | // Register peer 64 | esp_now_peer_info_t peerInfo; 65 | memset(&peerInfo, 0, sizeof(peerInfo)); 66 | for (int ii = 0; ii < 6; ++ii ) 67 | { 68 | peerInfo.peer_addr[ii] = (uint8_t) broadcastAddress[ii]; 69 | } 70 | peerInfo.channel = 0; 71 | peerInfo.encrypt = false; 72 | 73 | // Add peer 74 | if (esp_now_add_peer(&peerInfo) != ESP_OK) { 75 | Serial.println("Failed to add peer"); 76 | return; 77 | } 78 | 79 | // Register for a callback function that will be called when data is received 80 | esp_now_register_recv_cb(OnDataRecv); 81 | 82 | } 83 | 84 | void loop() 85 | { 86 | 87 | } 88 | -------------------------------------------------------------------------------- /NodeMCU_rec/NodeMCU_rec.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | 6 | #define Relay1 D6 7 | #define Relay2 D2 8 | #define Relay3 D1 9 | #define Relay4 D5 10 | 11 | 12 | // Define variables to store DHT readings to be sent 13 | bool sw; 14 | 15 | // Define variables to store incoming readings 16 | bool incomingSW1; 17 | bool incomingSW2; 18 | bool incomingSW3; 19 | bool incomingSW4; 20 | 21 | // Variable to store if sending data was successful 22 | String success; 23 | 24 | //Structure example to send data 25 | //Must match the receiver structure 26 | typedef struct struct_message { 27 | bool sw1; 28 | bool sw2; 29 | bool sw3; 30 | bool sw4; 31 | } struct_message; 32 | 33 | 34 | // Create a struct_message to hold incoming sensor readings 35 | struct_message incomingReadings; 36 | 37 | 38 | // Callback when data is received 39 | void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) { 40 | memcpy(&incomingReadings, incomingData, sizeof(incomingReadings)); 41 | Serial.print("Bytes received: "); 42 | Serial.println(len); 43 | Serial.print("Switch 1: ");Serial.println(incomingReadings.sw1); 44 | Serial.print("Switch 2: ");Serial.println(incomingReadings.sw2); 45 | Serial.print("Switch 3: ");Serial.println(incomingReadings.sw3); 46 | Serial.print("Switch 4: ");Serial.println(incomingReadings.sw4); 47 | digitalWrite(Relay1,incomingReadings.sw1); 48 | digitalWrite(Relay2,incomingReadings.sw2); 49 | digitalWrite(Relay3,incomingReadings.sw3); 50 | digitalWrite(Relay4,incomingReadings.sw4); 51 | } 52 | 53 | 54 | 55 | 56 | void setup() { 57 | // Init Serial Monitor 58 | Serial.begin(115200); 59 | 60 | pinMode(Relay1,OUTPUT); 61 | pinMode(Relay2,OUTPUT); 62 | pinMode(Relay3,OUTPUT); 63 | pinMode(Relay4,OUTPUT); 64 | 65 | // Set device as a Wi-Fi Station 66 | WiFi.mode(WIFI_STA); 67 | WiFi.disconnect(); 68 | 69 | // Init ESP-NOW 70 | if (esp_now_init() != 0) { 71 | Serial.println("Error initializing ESP-NOW"); 72 | return; 73 | } 74 | 75 | // Set ESP-NOW Role 76 | esp_now_set_self_role(ESP_NOW_ROLE_COMBO); 77 | 78 | // Register peer 79 | esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_COMBO, 1, NULL, 0); 80 | 81 | // Register for a callback function that will be called when data is received 82 | esp_now_register_recv_cb(OnDataRecv); 83 | } 84 | 85 | void loop() { 86 | 87 | } 88 | -------------------------------------------------------------------------------- /ESP32_ONE2MANY_Transmitter/ESP32_ONE2MANY_Transmitter.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "xbm.h" 4 | #include // Hardware-specific library 5 | 6 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 7 | 8 | // REPLACE WITH THE MAC Address of your receiver 9 | uint8_t broadcastAddress0[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // Universal 10 | uint8_t broadcastAddress1[] = {0x80, 0x7D, 0x3A, 0x6E, 0x8D, 0x23}; // NodeMCU 11 | uint8_t broadcastAddress2[] = {0x84, 0xCC, 0xA8, 0x5E, 0x5D, 0x3C}; // ESP32 12 | 13 | uint16_t calData[5] = { 520, 3372, 831, 2476, 7 }; // callibration point for touch screen 14 | 15 | int board = 0; // Setting board settings to both devices 16 | 17 | // Switch position and size 18 | #define FRAME_X 20 19 | #define FRAME_Y 10 20 | #define FRAME_W 120 21 | #define FRAME_H 50 22 | 23 | // Red zone size 24 | #define REDBUTTON_X FRAME_X 25 | #define REDBUTTON_Y FRAME_Y 26 | #define REDBUTTON_W (FRAME_W/2) 27 | #define REDBUTTON_H FRAME_H 28 | 29 | // Green zone size 30 | #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W) 31 | #define GREENBUTTON_Y FRAME_Y 32 | #define GREENBUTTON_W (FRAME_W/2) 33 | #define GREENBUTTON_H FRAME_H 34 | 35 | #define X_Button_Margin 150 36 | #define Y_Button_Margin 100 37 | 38 | 39 | // Variable to store if sending data was successful 40 | String success; 41 | 42 | //Structure example to send data 43 | //Must match the receiver structure 44 | typedef struct struct_message 45 | { 46 | bool sw1; 47 | bool sw2; 48 | bool sw3; 49 | bool sw4; 50 | } struct_message; 51 | 52 | // Create a struct_message called switch_reading to hold sensor readings 53 | struct_message both; 54 | struct_message nodemcu; 55 | struct_message esp32; 56 | 57 | 58 | // Callback when data is sent 59 | void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { 60 | Serial.print("\r\nLast Packet Send Status:\t"); 61 | Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail"); 62 | if (status == 0) { 63 | success = "Delivery Success :)"; 64 | } 65 | else { 66 | success = "Delivery Fail :("; 67 | } 68 | } 69 | 70 | 71 | void setup() 72 | { 73 | // Init Serial Monitor 74 | Serial.begin(115200); 75 | Serial.println("Code start"); 76 | 77 | // Set device as a Wi-Fi Station 78 | WiFi.mode(WIFI_STA); 79 | 80 | // Init ESP-NOW 81 | if (esp_now_init() != ESP_OK) { 82 | Serial.println("Error initializing ESP-NOW"); 83 | return; 84 | } 85 | 86 | // Once ESPNow is successfully Init, we will register for Send CB to 87 | // get the status of Trasnmitted packet 88 | esp_now_register_send_cb(OnDataSent); 89 | 90 | // Register peer 91 | esp_now_peer_info_t peerInfo; 92 | memset(&peerInfo, 0, sizeof(peerInfo)); 93 | for (int ii = 0; ii < 6; ++ii ) 94 | { 95 | peerInfo.peer_addr[ii] = (uint8_t) broadcastAddress0[ii]; 96 | } 97 | peerInfo.channel = 0; 98 | peerInfo.encrypt = false; 99 | 100 | // Add peer 101 | if (esp_now_add_peer(&peerInfo) != ESP_OK) { 102 | Serial.println("Failed to add peer"); 103 | return; 104 | } 105 | 106 | for (int ii = 0; ii < 6; ++ii ) 107 | { 108 | peerInfo.peer_addr[ii] = (uint8_t) broadcastAddress1[ii]; 109 | } 110 | // Add peer 111 | if (esp_now_add_peer(&peerInfo) != ESP_OK) { 112 | Serial.println("Failed to add peer"); 113 | return; 114 | } 115 | 116 | for (int ii = 0; ii < 6; ++ii ) 117 | { 118 | peerInfo.peer_addr[ii] = (uint8_t) broadcastAddress2[ii]; 119 | } 120 | 121 | // Add peer 122 | if (esp_now_add_peer(&peerInfo) != ESP_OK) { 123 | Serial.println("Failed to add peer"); 124 | return; 125 | } 126 | 127 | tft.init(); 128 | 129 | tft.setRotation(3); 130 | 131 | // clear screen 132 | tft.fillScreen(TFT_BLACK); 133 | 134 | buttons(); // print buttons on screen 135 | } 136 | 137 | void loop() { 138 | 139 | uint16_t x, y; 140 | 141 | // See if there's any touch data for us 142 | if (tft.getTouch(&x, &y)) 143 | { 144 | 145 | 146 | Serial.print("x - "); Serial.println(x); 147 | Serial.println("y - "); Serial.println(y); 148 | 149 | 150 | if ((x > REDBUTTON_X + X_Button_Margin) && (x < (REDBUTTON_X + REDBUTTON_W + X_Button_Margin ) )) { 151 | if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) { 152 | Serial.println("Switch 1 OFF"); 153 | 154 | // Send message via ESP-NOW 155 | if (board == 0) 156 | { 157 | both.sw1 = 0; 158 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 159 | } 160 | if (board == 1) 161 | { 162 | nodemcu.sw1 = 0; 163 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 164 | } 165 | if (board == 2) 166 | { 167 | esp32.sw1 = 0; 168 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 169 | } 170 | } 171 | } 172 | 173 | if ((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) { 174 | if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) { 175 | Serial.println("Switch 2 OFF"); 176 | // Send message via ESP-NOW 177 | if (board == 0) 178 | { 179 | both.sw2 = 0; 180 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 181 | } 182 | if (board == 1) 183 | { 184 | nodemcu.sw2 = 0; 185 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 186 | } 187 | if (board == 2) 188 | { 189 | esp32.sw2 = 0; 190 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 191 | } 192 | } 193 | } 194 | 195 | if ((x > REDBUTTON_X + X_Button_Margin) && (x < (REDBUTTON_X + REDBUTTON_W + X_Button_Margin ) )) { 196 | if ((y > REDBUTTON_Y + Y_Button_Margin ) && (y <= ((REDBUTTON_Y + Y_Button_Margin) + REDBUTTON_H))) { 197 | Serial.println("Switch 3 OFF"); 198 | // Send message via ESP-NOW 199 | if (board == 0) 200 | { 201 | both.sw3 = 0; 202 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 203 | } 204 | if (board == 1) 205 | { 206 | nodemcu.sw3 = 0; 207 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 208 | } 209 | if (board == 2) 210 | { 211 | esp32.sw3 = 0; 212 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 213 | } 214 | } 215 | } 216 | 217 | if ((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) { 218 | if ((y > REDBUTTON_Y + Y_Button_Margin ) && (y <= (REDBUTTON_Y + REDBUTTON_H + Y_Button_Margin))) { 219 | Serial.println("Switch 4 OFF"); 220 | // Send message via ESP-NOW 221 | if (board == 0) 222 | { 223 | both.sw4 = 0; 224 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 225 | } 226 | if (board == 1) 227 | { 228 | nodemcu.sw4 = 0; 229 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 230 | } 231 | if (board == 2) 232 | { 233 | esp32.sw4 = 0; 234 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 235 | } 236 | } 237 | } 238 | 239 | { 240 | if ((x > GREENBUTTON_X + X_Button_Margin ) && (x < (GREENBUTTON_X + GREENBUTTON_W + X_Button_Margin ))) { 241 | if ((y > GREENBUTTON_Y) && (y <= (REDBUTTON_Y + GREENBUTTON_H))) { 242 | Serial.println("Switch 1 ON"); 243 | // Send message via ESP-NOW 244 | if (board == 0) 245 | { 246 | both.sw1 = 1; 247 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 248 | } 249 | if (board == 1) 250 | { 251 | nodemcu.sw1 = 1; 252 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 253 | } 254 | if (board == 2) 255 | { 256 | esp32.sw1 = 1; 257 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 258 | } 259 | 260 | } 261 | } 262 | 263 | if ((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) { 264 | if ((y > GREENBUTTON_Y) && (y <= (REDBUTTON_Y + GREENBUTTON_H))) { 265 | Serial.println("Switch 2 ON"); 266 | // Send message via ESP-NOW 267 | if (board == 0) 268 | { 269 | both.sw2 = 1; 270 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 271 | } 272 | if (board == 1) 273 | { 274 | nodemcu.sw2 = 1; 275 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 276 | } 277 | if (board == 2) 278 | { 279 | esp32.sw2 = 1; 280 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 281 | } 282 | 283 | } 284 | } 285 | 286 | if ((x > GREENBUTTON_X + X_Button_Margin ) && (x < (GREENBUTTON_X + GREENBUTTON_W + X_Button_Margin ))) { 287 | if ((y > GREENBUTTON_Y + Y_Button_Margin) && (y <= (REDBUTTON_Y + GREENBUTTON_H + Y_Button_Margin))) { 288 | Serial.println("Switch 3 ON"); 289 | // Send message via ESP-NOW 290 | if (board == 0) 291 | { 292 | both.sw3 = 1; 293 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 294 | } 295 | if (board == 1) 296 | { 297 | nodemcu.sw3 = 1; 298 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 299 | } 300 | if (board == 2) 301 | { 302 | esp32.sw3 = 1; 303 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 304 | } 305 | 306 | } 307 | } 308 | if ((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) { 309 | if ((y > GREENBUTTON_Y + Y_Button_Margin) && (y <= (REDBUTTON_Y + GREENBUTTON_H + Y_Button_Margin))) { 310 | Serial.println("Switch 4 ON"); 311 | // Send message via ESP-NOW 312 | if (board == 0) 313 | { 314 | both.sw4 = 1; 315 | esp_err_t result = esp_now_send(broadcastAddress0, (uint8_t *) &both, sizeof(struct_message)); 316 | } 317 | if (board == 1) 318 | { 319 | nodemcu.sw4 = 1; 320 | esp_err_t result = esp_now_send(broadcastAddress1, (uint8_t *) &nodemcu, sizeof(struct_message)); 321 | } 322 | if (board == 2) 323 | { 324 | esp32.sw4 = 1; 325 | esp_err_t result = esp_now_send(broadcastAddress2, (uint8_t *) &esp32, sizeof(struct_message)); 326 | } 327 | 328 | } 329 | } 330 | 331 | if ((x > 0) && (x < 107)) 332 | { 333 | if ((y > 160) && (y <= 240)) { 334 | Serial.println("Both Selected"); 335 | tft.fillRect(70, 60, 120, 30, TFT_BLACK); 336 | tft.setTextColor(TFT_WHITE); 337 | tft.drawString("Both", 150, 80); 338 | board = 0; // All devices Selected 339 | } 340 | } 341 | 342 | if ((x > 107) && (x < 210)) 343 | { 344 | if ((y > 160) && (y <= 240)) { 345 | Serial.println("NodeMCU Selected"); 346 | tft.fillRect(70, 60, 120, 30, TFT_BLACK); 347 | tft.setTextColor(TFT_WHITE); 348 | tft.drawString("NodeMCU", 140, 80); 349 | board = 1; // NodeMCU Selected 350 | } 351 | } 352 | 353 | if ((x > 210) && (x < 320)) 354 | { 355 | if ((y > 160) && (y <= 240)) { 356 | Serial.println("ESP32 Selected"); 357 | tft.fillRect(70, 60, 120, 30, TFT_BLACK); 358 | tft.setTextColor(TFT_WHITE); 359 | tft.drawString("ESP32", 150, 80); 360 | board = 2; // ESP32 Selected 361 | } 362 | } 363 | } 364 | 365 | } 366 | else 367 | { 368 | print_data_on_screen(); 369 | } 370 | } 371 | 372 | 373 | 374 | void buttons() 375 | { 376 | tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, TFT_CYAN); 377 | tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, TFT_WHITE); 378 | 379 | tft.setTextColor(TFT_BLACK); 380 | tft.setTextSize(2); 381 | tft.setTextDatum(MC_DATUM); 382 | tft.drawString("OFF", GREENBUTTON_X + (GREENBUTTON_W / 2), GREENBUTTON_Y + (GREENBUTTON_H / 2)); 383 | tft.drawString("ON", (REDBUTTON_X) + (REDBUTTON_W / 2) + 1, REDBUTTON_Y + (REDBUTTON_H / 2)); 384 | 385 | tft.fillRect((REDBUTTON_X + X_Button_Margin ), REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, TFT_CYAN); 386 | tft.fillRect((GREENBUTTON_X + X_Button_Margin), GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, TFT_WHITE); 387 | tft.setTextColor(TFT_BLACK); 388 | 389 | tft.setTextSize(2); 390 | tft.setTextDatum(MC_DATUM); 391 | tft.drawString("OFF", (GREENBUTTON_X + X_Button_Margin) + (GREENBUTTON_W / 2), GREENBUTTON_Y + (GREENBUTTON_H / 2)); 392 | tft.drawString("ON", (REDBUTTON_X + X_Button_Margin) + (REDBUTTON_W / 2) + 1, REDBUTTON_Y + (REDBUTTON_H / 2)); 393 | 394 | tft.fillRect(REDBUTTON_X, (REDBUTTON_Y + Y_Button_Margin) , REDBUTTON_W, REDBUTTON_H, TFT_CYAN); 395 | tft.fillRect(GREENBUTTON_X, (GREENBUTTON_Y + Y_Button_Margin) , GREENBUTTON_W, GREENBUTTON_H, TFT_WHITE); 396 | tft.setTextColor(TFT_BLACK); 397 | 398 | tft.setTextSize(2); 399 | tft.setTextDatum(MC_DATUM); 400 | tft.drawString("OFF", GREENBUTTON_X + (GREENBUTTON_W / 2), ( GREENBUTTON_Y + Y_Button_Margin) + (GREENBUTTON_H / 2)); 401 | tft.drawString("ON", (REDBUTTON_X) + (REDBUTTON_W / 2) + 1, (REDBUTTON_Y + Y_Button_Margin) + (REDBUTTON_H / 2)); 402 | 403 | 404 | tft.fillRect((REDBUTTON_X + X_Button_Margin ), (REDBUTTON_Y + Y_Button_Margin), REDBUTTON_W, REDBUTTON_H, TFT_CYAN); 405 | tft.fillRect((GREENBUTTON_X + X_Button_Margin), (GREENBUTTON_Y + Y_Button_Margin), GREENBUTTON_W, GREENBUTTON_H, TFT_WHITE); 406 | tft.setTextColor(TFT_BLACK); 407 | 408 | tft.setTextSize(2); 409 | tft.setTextDatum(MC_DATUM); 410 | tft.drawString("OFF", (GREENBUTTON_X + X_Button_Margin) + (GREENBUTTON_W / 2), (GREENBUTTON_Y + Y_Button_Margin) + (GREENBUTTON_H / 2)); 411 | tft.drawString("ON", (REDBUTTON_X + X_Button_Margin) + (REDBUTTON_W / 2) + 1, (REDBUTTON_Y + Y_Button_Margin) + (REDBUTTON_H / 2)); 412 | 413 | tft.setTextColor(TFT_WHITE); 414 | tft.drawString(" ", 150, 80); 415 | 416 | 417 | 418 | 419 | } 420 | 421 | void print_data_on_screen() 422 | { 423 | tft.fillRect(0, 180, 100, 60, TFT_GREEN); 424 | tft.fillRect(107, 180, 100, 60, TFT_RED); 425 | tft.fillRect(210, 180, 100, 60, TFT_BLUE); 426 | tft.setTextColor(TFT_BLACK); 427 | 428 | tft.setTextSize(2); 429 | tft.setTextDatum(MC_DATUM); 430 | tft.drawString("ESP32 " , 50, 200); 431 | tft.drawString("NodeMCU " , 165, 200); 432 | tft.drawString("Both " , 265, 200); 433 | } 434 | --------------------------------------------------------------------------------