Based on the combination of TFT module and Arduino UNO fram Banggood and the GPS module from the same supplier I built a basic GPS navigation system that uses the topographical maps of The Netherlands (top25raster). In total there are 304 bmp files on an SD card, so the images are very detailed! In principle any 8 bit bmp map can be used. The maps were obtained from www.kadaster.nl, the software is based upon modules from Adafruit.
Sketch plus explanation are available on Github: middelbh/GPSnavigator.
Enjoy and please inform me about optimisations!
I now have the software completely running! The next step is to connect the GPS module and do some tests.
I hope someone can help me in further optimizing the sketch, it's about 99% of the maximum size for my UNO, and displaying the map still takes 1-2 seconds. That must be faster I think. I am a relative beginner with Arduino, so any help is greatly appreciated!
Other question is, where shall I put the source of the sketch??
Hey, nice project and very interesting. I'm trying to adopt your idea, however i can't find topo maps of my country (greece). Do you have any idea what should i do in order to work? Thanks in advance
hi Antonio. The map I am using covers all over the Netherlands, so not just Amsterdam. In the Netherlands these topo maps are publicly available. You should check youself for topo maps in Spain, I do not know if they are available freely.. Otherwise you could scan a map of the area you are interested in and georeference that yourself using Google Earth. Regards and success, let me know
Also, as I noticed, a couple of things you might want to fix:
- your handling around FileNameMap/FileNameString looks a little fragile. You build up the file name in a loop, incrementally adding a character to the String type. You then copy the resulting String to a char array, but use not the size of the char array but the size of the String. It is fine now (as your String making loop limits the size to 8 characters) but if things ever got out of step you'd have a horrible bug to find. Probably easier to just directly write to the char buffer, perhaps.
- you are calling SD.begin() far too often. No idea if that call is idempotent or not, there could be the chance of a memory leak here - which in a system without memory management will just result in bizzare and unpredictable behaviour. Best to avoid, I've had similar before :)
Hi stoduk! Thx for your proposals! I have to admit that this program is the first somewhat more complex I wrote for Arduino. Therefore I do not have sufficient experience in converting chars to strings and all that, I originally am a VB programmer (blush)! Would it be possible you help me with that subject?
I will certainly go through the program and have a serious look at your remarks, I hope I can learn a lot of that!
Seconded regarding the libraries - the size of pulling one in can massively bloat a script. eg. just adding #include <SD.h seems to increase program storage space usage by almost 5k. No idea what the constructors in there doing, but perhaps there is a more lightweight SD library that will do what you want.
Using floats won't be doing you any favours either, http://arduiniana.org/libraries/tinygps/ claims that using floats adds 2k to program size off the bat. On top of that are the usual accuracy and speed problems - a decimal type would be far better and wouldn't be hard to define (given you only care about comparisons, you don't care about arithmetic on the values).
Regarding screen update time - I don't know what LCD you are using, but adafruit website says that if you can use the parallel data method for fastest updates. If you have to use SPI, then make sure you are using the hardware pins as it is much faster.
I also noticed you are doing updates any time you get a valid NMEA sentence from the GPS. Depending on how fast that might be you could want to avoid doing this every time - eg. perhaps just update once a second, or maybe do a quick check and only update if the lat/long have changed "enough". I found something that claimed 6 sentences/second at 4800bps - you are doing a lot of floating point arithmetic in a tight loop, so I don't know how much time you have available for each update. If you aren't quick enough then things might get messy :)
Hi ipaq3115! thx for your comments! I agree that the Teensy would give me much more capacity. It's just the fun I had trying to do this on the most basic microcontroller I could find. Your proposal to start digging in the libraries is the best I can do I think. And really, the GFX library is a monster for this simple system. I will try and see if I can do what you propose, will take some time however..
Hey there middelbeek, this project looks pretty awesome! I don't know exactly how far you want to take this but since you are running out of memory you might consider a Teensy 3.1. You'll get much faster screen writes and you'll be able to use real 8 byte doubles which is invaluable for GPS calculations.
If you really want to optimize for the UNO though I would make copies of those libraries you are using and start looking through them for things that you don't need/aren't using and start cutting stuff out. I'd start with the gfx libraries. Those tend to be a little big!
Hey, nice project and very interesting. I'm trying to adopt your idea, however i can't find topo maps of my country (greece). Do you have any idea what should i do in order to work? Thanks in advance