Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Live Navigation
- - Source Code NOT compiled for: ESP8266 NodeMCU V1.0
- - Source Code created on: 2025-12-12 12:13:05
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* GPS display */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <TFT_eSPI.h> //https://github.com/Bodmer/TFT_eSPI
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- TFT_eSPI tft = TFT_eSPI();
- #include <BluetoothSerial.h>
- #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
- #error Bluetooth not enabled! Run `make menuconfig` to enable it
- #endif
- #define TFT_BL 32
- BluetoothSerial SerialBT;
- String currentAction = "READY";
- String currentStreet = "No BT";
- bool btConnected = false;
- void setup() {
- Serial.begin(115200);
- Serial.println("Starting...");
- // Display init
- pinMode(TFT_BL, OUTPUT);
- digitalWrite(TFT_BL, HIGH);
- tft.init();
- tft.setRotation(1); // Try 0, 1, 2, 3
- // Draw initial screen
- tft.fillScreen(TFT_BLACK);
- tft.setTextColor(TFT_WHITE);
- tft.setTextSize(2);
- tft.setCursor(10, 10);
- tft.print("ESP32 2432S028");
- tft.setCursor(10, 50);
- tft.print("Starting BT...");
- // Bluetooth init
- if (!SerialBT.begin("ESP32-Nav")) {
- Serial.println("BT Failed!");
- tft.setCursor(10, 90);
- tft.print("BT Failed!");
- } else {
- Serial.println("BT: ESP32-Nav");
- tft.setCursor(10, 90);
- tft.print("BT: ESP32-Nav");
- }
- delay(2000);
- }
- void loop() {
- // Check Bluetooth connection
- bool wasConnected = btConnected;
- btConnected = SerialBT.hasClient();
- if (wasConnected != btConnected) {
- Serial.println(btConnected ? "BT Connected" : "BT Disconnected");
- updateDisplay();
- }
- // Handle incoming data
- if (SerialBT.available()) {
- String cmd = SerialBT.readStringUntil('\n');
- Serial.print("Received: ");
- Serial.println(cmd);
- // Simple command parsing
- if (cmd == "LEFT") currentAction = "TURN LEFT";
- else if (cmd == "RIGHT") currentAction = "TURN RIGHT";
- else if (cmd == "STRAIGHT") currentAction = "GO STRAIGHT";
- else if (cmd == "ARRIVE") currentAction = "ARRIVED";
- else currentAction = cmd;
- updateDisplay();
- }
- delay(100);
- }
- void updateDisplay() {
- tft.fillScreen(TFT_BLACK);
- // Draw status
- tft.setTextColor(TFT_WHITE);
- tft.setTextSize(2);
- tft.setCursor(10, 10);
- tft.print("BT: ");
- tft.print(btConnected ? "ON" : "OFF");
- // Draw action
- tft.setTextColor(TFT_YELLOW);
- tft.setTextSize(3);
- tft.setCursor(10, 60);
- tft.print(currentAction);
- // Draw instruction
- tft.setTextColor(TFT_CYAN);
- tft.setTextSize(2);
- tft.setCursor(10, 120);
- tft.print("Send via BT:");
- tft.setCursor(10, 150);
- tft.print("LEFT, RIGHT, etc.");
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment