|
Post by qmac2011 on Apr 5, 2016 16:26:41 GMT -8
I am trying to display some simple GPS Data on my gameduino and I am running into some problems with the output. The code compiles fine , but the screen is blank. I tested the code on the serial monitor and it comes out fine. Any ideas would be appreciated. Here is my code:
# include <TinyGPS.h>
# include <SoftwareSerial.h>
TinyGPS gps;
SoftwareSerial gpsserial(2,3);
float flat, flon;
unsigned long fix_age;
void getgps(TinyGPS &gps);
void setup()
{
Serial.begin(57600);
gpsserial.begin(9600); GD.begin(); }
//Gather gps data
void getgps(TinyGPS &gps)
{
if(gpsserial.available() > 0) {
int c = gpsserial.read();
if(gps.encode(c))
{
gps.f_get_position(&flat, &flon, &fix_age);
float fmph = gps.f_speed_mph();
GD.ColorRGB(0x000000);
GD.cmd_number( 5, 0, 28, OPT_CENTERX, flat);
GD.cmd_number(35, 0, 28, OPT_CENTERX, flon);
GD.cmd_number(220, 100, 28, OPT_CENTERX, fmph);
delay(3000);
}
}
GD.swap(); }
void loop()
{
getgps(gps); GD.swap(); GD.finish(); }
|
|
|
Post by Rev. Rick on Feb 26, 2021 8:00:18 GMT -8
I have used an Adafruit GPS Logging Shield and an UNO R3.
I had the same issue until I changed the RX line to D4, I left the TX on D7. Then it worked like a champ.I also considered cutting the trace on D10 CSS on the GPS board but found that it did not interfere with the processings of data. The Dazzler wants to use D8-D13 for various signals and so I found that changing it on the GPS was easier.
|
|
|
Post by tftlcdcyg on Feb 26, 2021 11:38:13 GMT -8
As you have shared the sketch, before the instructions:
#include <TinyGPS.h> #include <SoftwareSerial.h> You must include these lines:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h> The GD.cmd_number instruction only works with integers. You must perform an intermediate operation to be able to display decimal numbers on the screen
|
|
|
Post by tftlcdcyg on Feb 26, 2021 18:11:16 GMT -8
A new function could be incorporated within the library itself. In the GD2.h file, we can add this line:
void printNfloat2 (int16_t x, int16_t y, float f, int16_t Presc, byte font);
After of (for example):
void cmd_number (int16_t x, int16_t y, byte font, uint16_t options, uint32_t n); In the GD2.ccp file, after cmd_number, we can add the class:
void GDClass :: printNfloat2 (int16_t x, int16_t y, float f, int16_t Presc, byte font) { char floatNumber [50]; char bufNum [15];
dtostrf (f, 3, Presc, bufNum); sprintf (floatNumber, "% s", bufNum);
cmd_text (x, y, font, 0, floatNumber); } Which would allow us to present floating numbers with several decimal places. The call to print some floating number on the screen could be:
GD.printNfloat2(GD.w / 2, 200, gps.location.lat(), 6, 28);
|
|