pleasedontcode

Live Navigation rev_01

Dec 12th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Live Navigation
  13.     - Source Code NOT compiled for: ESP8266 NodeMCU V1.0
  14.     - Source Code created on: 2025-12-12 12:13:05
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* GPS display */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <TFT_eSPI.h>    //https://github.com/Bodmer/TFT_eSPI
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  34.  
  35. TFT_eSPI tft = TFT_eSPI();
  36. #include <BluetoothSerial.h>
  37.  
  38. #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
  39. #error Bluetooth not enabled! Run `make menuconfig` to enable it
  40. #endif
  41.  
  42. #define TFT_BL 32
  43.  
  44. BluetoothSerial SerialBT;
  45.  
  46. String currentAction = "READY";
  47. String currentStreet = "No BT";
  48. bool btConnected = false;
  49.  
  50. void setup() {
  51.   Serial.begin(115200);
  52.   Serial.println("Starting...");
  53.  
  54.   // Display init
  55.   pinMode(TFT_BL, OUTPUT);
  56.   digitalWrite(TFT_BL, HIGH);
  57.  
  58.   tft.init();
  59.   tft.setRotation(1);  // Try 0, 1, 2, 3
  60.  
  61.   // Draw initial screen
  62.   tft.fillScreen(TFT_BLACK);
  63.   tft.setTextColor(TFT_WHITE);
  64.   tft.setTextSize(2);
  65.   tft.setCursor(10, 10);
  66.   tft.print("ESP32 2432S028");
  67.   tft.setCursor(10, 50);
  68.   tft.print("Starting BT...");
  69.  
  70.   // Bluetooth init
  71.   if (!SerialBT.begin("ESP32-Nav")) {
  72.     Serial.println("BT Failed!");
  73.     tft.setCursor(10, 90);
  74.     tft.print("BT Failed!");
  75.   } else {
  76.     Serial.println("BT: ESP32-Nav");
  77.     tft.setCursor(10, 90);
  78.     tft.print("BT: ESP32-Nav");
  79.   }
  80.  
  81.   delay(2000);
  82. }
  83.  
  84. void loop() {
  85.   // Check Bluetooth connection
  86.   bool wasConnected = btConnected;
  87.   btConnected = SerialBT.hasClient();
  88.  
  89.   if (wasConnected != btConnected) {
  90.     Serial.println(btConnected ? "BT Connected" : "BT Disconnected");
  91.     updateDisplay();
  92.   }
  93.  
  94.   // Handle incoming data
  95.   if (SerialBT.available()) {
  96.     String cmd = SerialBT.readStringUntil('\n');
  97.     Serial.print("Received: ");
  98.     Serial.println(cmd);
  99.    
  100.     // Simple command parsing
  101.     if (cmd == "LEFT") currentAction = "TURN LEFT";
  102.     else if (cmd == "RIGHT") currentAction = "TURN RIGHT";
  103.     else if (cmd == "STRAIGHT") currentAction = "GO STRAIGHT";
  104.     else if (cmd == "ARRIVE") currentAction = "ARRIVED";
  105.     else currentAction = cmd;
  106.    
  107.     updateDisplay();
  108.   }
  109.  
  110.   delay(100);
  111. }
  112.  
  113. void updateDisplay() {
  114.   tft.fillScreen(TFT_BLACK);
  115.  
  116.   // Draw status
  117.   tft.setTextColor(TFT_WHITE);
  118.   tft.setTextSize(2);
  119.   tft.setCursor(10, 10);
  120.   tft.print("BT: ");
  121.   tft.print(btConnected ? "ON" : "OFF");
  122.  
  123.   // Draw action
  124.   tft.setTextColor(TFT_YELLOW);
  125.   tft.setTextSize(3);
  126.   tft.setCursor(10, 60);
  127.   tft.print(currentAction);
  128.  
  129.   // Draw instruction
  130.   tft.setTextColor(TFT_CYAN);
  131.   tft.setTextSize(2);
  132.   tft.setCursor(10, 120);
  133.   tft.print("Send via BT:");
  134.   tft.setCursor(10, 150);
  135.   tft.print("LEFT, RIGHT, etc.");
  136. }
  137.  
  138. /* END CODE */
  139.  
Advertisement
Add Comment
Please, Sign In to add comment