• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
pozycja z gps na 1,8 tft lcd - dziwne znaki
#4
Poniżej Twój kod trochę bardziej czytelny.
Popatrz na strzałki i odpowiedz czy tak to ma wyglądać.

Kod:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <TFT.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
#define cs   10
#define dc   9
#define rst  8
TFT TFTscreen = TFT(cs, dc, rst);

char latitude_c[15];
char latitude[15];
char longitude_c[15];
char longitude[15];
char lat_c[4];
char lat[4];
char lon_c[4];
char lon[4];

void setup() {
   TFTscreen.begin();
   ss.begin(GPSBaud);
   TFTscreen.background(0, 0, 0);
   TFTscreen.stroke(0, 255, 100);
   TFTscreen.setTextSize(2);
   TFTscreen.text("DANE GPS", 2, 2);
}
void loop()
{
   {
       String latitude_b =String(gps.location.lat(),8);
       latitude_b.toCharArray(latitude_c,15);          // convert the reading to a char array
       String lat_b = String(gps.location.lat(),6);
       lat_b.toCharArray(lat_c, 10);                   // convert the reading to a char array
       latitude_b.toCharArray(latitude,25);            // convert the reading to a char array
       lat_b.toCharArray(lat, 10);                     // convert the reading to a char array

 --->  while (ss.available() > 0)
 --->      if (gps.encode(ss.read()))
               if (millis() > 5000 && gps.charsProcessed() < 10)
               {
                   TFTscreen.stroke(255, 255, 0);
                   TFTscreen.setTextSize(2);
                   TFTscreen.text("BRAK POL Z GPS",2, 80);
                   while(true);
               }
       TFTscreen.stroke(255, 255, 0);
       TFTscreen.setTextSize(2);
       if (gps.location.isValid())
       {
           TFTscreen.stroke(0, 0, 0);
           TFTscreen.text("BRAK SYGN. GPS",2, 75);
           TFTscreen.stroke(0, 255, 50);
           TFTscreen.text("GPS OK",2, 50);
           TFTscreen.text(lat,2, 90);

           delay(1500);

           TFTscreen.noStroke();
           TFTscreen.fill(0, 0, 0);
           TFTscreen.rect(0, 65, 160, 50);
           delay(5);
       }
       else
       {
           TFTscreen.text("BRAK SYGN",2, 75);
       }
   }
}

Cytat:Rozumiem że nauka C++ byłaby najlepsza, ale chodzi tu o wyłącznie jeden projekt, to trochę tak ja uczyć się języka żeby przeczytać jedną broszurę w oryginale.
Albo się uczysz albo wystawiasz zlecenie na wykonanie programu.
Pomagam za darmo więc szanuj mój czas.
Wklejaj tekst a nie jego zdjęcie.
Nie pisz następnego postu jak nie odpowiedziałeś na poprzedni.
Jak mądrze zadawać pytania
 
Odpowiedź
  


Wiadomości w tym wątku
RE: pozycja z gps na 1,8 tft lcd - dziwne znaki - przez namok - 22-11-2017, 08:19

Skocz do:


Przeglądający: 1 gości