We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Guys, One question, my code has a serial comunication between gps module and Processing using serial library. The gps module provide the latitude and longitude in the processing scketch( figure) and I need to declarate it for a variable. Anyone can help me ?
Answers
and here is my code :
import processing.serial.*;
import de.fhpotsdam.unfolding.mapdisplay.*; import de.fhpotsdam.unfolding.utils.*; import de.fhpotsdam.unfolding.marker.*; import de.fhpotsdam.unfolding.tiles.*; import de.fhpotsdam.unfolding.interactions.*; import de.fhpotsdam.unfolding.ui.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.core.*; import de.fhpotsdam.unfolding.mapdisplay.shaders.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.texture.*; import de.fhpotsdam.unfolding.events.*; import de.fhpotsdam.utils.*; import de.fhpotsdam.unfolding.providers.*;
Serial portaserial; // objeto criado da classe serial. String dadosgps; // var. q ira armazenar os dados recebidos da porta serial. UnfoldingMap map;
void setup() { String portName = Serial.list()[0]; // porta no qual o arduino ira se comunicar portaserial = new Serial(this, portName, 9600);
}
void draw() { if ( portaserial.available() > 0) {
dadosgps = portaserial.readString();
} println(dadosgps); delay(100);
// Create point markers for locations SimplePointMarker berlinMarker = new SimplePointMarker(berlinLocation);
// Adapt style berlinMarker.setColor(color(255, 0, 0, 100)); berlinMarker.setStrokeColor(color(255, 0, 0)); berlinMarker.setStrokeWeight(3);
// Add markers to the map map.addMarkers(berlinMarker); }
You need to parse the raw data from the serial port, i.e. converting the String into a Location.
But before you can use that it is necessary you translate the coordinates of your GPS device into ones you can use in Unfolding. Currently, the coordinates from the serial port seem to be in some other system than WGS-84. So, not sure how to do that (as I don't know which system they are in), but in principle it goes like this:
I got this error. What'sthe wrong with my code ??
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
Null.PointerException. I can't resolve it. Can you help me ?
How I can declarate the variable latStr for example ?? latStr = null ; ????