|
1 |
| -# OpenStreetMap-esp32 |
| 1 | +## OpenStreetMap-esp32 |
2 | 2 |
|
3 | 3 | [](https://app.codacy.com/gh/CelliesProjects/OpenStreetMap-esp32/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
4 | 4 |
|
5 |
| -## What is this |
| 5 | +### What is this |
6 | 6 |
|
7 |
| -This library provides a [OpenStreetMap](https://www.openstreetmap.org/) (OSM) map fetching and tile caching system for ESP32-based devices. |
| 7 | +This library provides a [OpenStreetMap](https://www.openstreetmap.org/) (OSM) map fetching and tile caching system for ESP32-based devices. |
8 | 8 | Under the hood it uses [LovyanGFX](https://github.com/lovyan03/LovyanGFX) and [PNGdec](https://github.com/bitbank2/PNGdec) to do the heavy lifting.
|
9 | 9 |
|
10 |
| -A map is composed from downloaded OSM tiles and returned as a LGFX sprite. |
11 |
| -The sprite can be pushed to the screen or used for further composing. |
| 10 | + |
| 11 | + |
| 12 | +A map is composed from downloaded OSM tiles and returned as a LGFX sprite. |
| 13 | +The sprite can be pushed to the screen or used for further composing. |
12 | 14 | Downloaded tiles are cached in psram for reuse.
|
13 | 15 |
|
14 | 16 | The library should work on any ESP32 type with psram and a LovyanGFX compatible display.
|
15 | 17 |
|
16 | 18 | The downloaded tile cache gets large very quickly -128kB per tile- so a ESP32 with psram is required.
|
17 | 19 |
|
18 |
| - |
19 |
| -An example 320px by 240px map |
| 20 | +### Functions |
| 21 | + |
| 22 | +#### Set map resolution |
| 23 | +```c++ |
| 24 | +void setResolution(uint16_t w, uint16_t h); |
| 25 | +``` |
| 26 | +
|
| 27 | +#### Resize cache |
| 28 | +```c++ |
| 29 | +bool resizeTilesCache(uint8_t numberOfTiles); |
| 30 | +``` |
| 31 | +**Note**: Each tile is 128 kB. |
| 32 | + |
| 33 | +#### Free the memory used by the tile cache |
| 34 | +```c++ |
| 35 | +void freeTilesCache(); |
| 36 | +``` |
| 37 | +#### Fetch a map |
| 38 | +```c++ |
| 39 | +bool fetchMap(LGFX_Sprite &map, double longitude, double latitude, uint8_t zoom); |
| 40 | +``` |
| 41 | +
|
| 42 | +#### Save a map to SD card |
20 | 43 |
|
21 |
| -### License differences between this library and the map data |
| 44 | +```c++ |
| 45 | +bool saveMap(const char *filename, LGFX_Sprite &display, String &result, uint8_t sdPin = SS) |
| 46 | +``` |
| 47 | +`filename` should start with `/` for example `/map.bmp` |
| 48 | +`sdPin` is optional and used to set a `SS/CS` pin for the SD slot. |
| 49 | +`result` returns something like `SD Card mount failed!` or `Screenshot saved`. |
| 50 | + |
| 51 | +## License differences between this library and the map data |
22 | 52 |
|
23 |
| -#### This library has a MIT license |
| 53 | +### This library has a MIT license |
24 | 54 |
|
25 | 55 | The `OpenstreetMap-esp32` library -this library- is licensed under the [MIT license](/LICENSE).
|
| 56 | +This project is not endorsed by or affiliated with the OpenStreetMap Foundation. |
26 | 57 |
|
27 |
| -#### The downloaded tile data has a Open Data Commons Open Database License (ODbL) |
| 58 | +### The downloaded tile data has a Open Data Commons Open Database License (ODbL) |
28 | 59 |
|
29 | 60 | OpenStreetMap® is open data, licensed under the [Open Data Commons Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/) by the OpenStreetMap Foundation (OSMF).
|
30 | 61 |
|
31 | 62 | Use of any OSMF provided service is governed by the [OSMF Terms of Use](https://osmfoundation.org/wiki/Terms_of_Use).
|
32 | 63 |
|
33 |
| -### Example code |
| 64 | +## Example code |
34 | 65 |
|
35 |
| -#### Example returning the default 320x240 map |
| 66 | +### Example returning the default 320x240 map |
36 | 67 |
|
37 | 68 | ```c++
|
38 | 69 | #include <Arduino.h>
|
@@ -157,14 +188,16 @@ void loop()
|
157 | 188 | delay(1000);
|
158 | 189 | }
|
159 | 190 | ```
|
160 |
| - |
161 |
| -Screenshot of a 480x800 map from a esp32-8048s050 |
162 | 191 |
|
163 |
| -### PlatformIO setup\ |
| 192 | +### Screenshot of a 480x800 map from a esp32-8048s050 |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | +### PlatformIO setup |
164 | 197 |
|
165 | 198 | ```bash
|
166 | 199 | lib_deps =
|
167 | 200 | https://github.com/CelliesProjects/OpenStreetMap-esp32
|
168 | 201 | lovyan03/LovyanGFX@^1.2.0
|
169 |
| - bitbank2/PNGdec@^1.0.3 |
| 202 | + bitbank2/PNGdec@^1.0.3 |
170 | 203 | ```
|
0 commit comments