Skip to content

Commit 0ac5aee

Browse files
Update README.md
1 parent f2222fd commit 0ac5aee

File tree

1 file changed

+49
-16
lines changed

1 file changed

+49
-16
lines changed

README.md

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,69 @@
1-
# OpenStreetMap-esp32
1+
## OpenStreetMap-esp32
22

33
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/0961fc2320cd495a9411eb391d5791ca)](https://app.codacy.com/gh/CelliesProjects/OpenStreetMap-esp32/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
44

5-
## What is this
5+
### What is this
66

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.
88
Under the hood it uses [LovyanGFX](https://github.com/lovyan03/LovyanGFX) and [PNGdec](https://github.com/bitbank2/PNGdec) to do the heavy lifting.
99

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+
![map](https://github.com/user-attachments/assets/bc0534c1-b2e6-4f6e-804f-95b7db00c850)
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.
1214
Downloaded tiles are cached in psram for reuse.
1315

1416
The library should work on any ESP32 type with psram and a LovyanGFX compatible display.
1517

1618
The downloaded tile cache gets large very quickly -128kB per tile- so a ESP32 with psram is required.
1719

18-
![map](https://github.com/user-attachments/assets/bc0534c1-b2e6-4f6e-804f-95b7db00c850)
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
2043
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
2252

23-
#### This library has a MIT license
53+
### This library has a MIT license
2454

2555
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.
2657

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)
2859

2960
OpenStreetMap® is open data, licensed under the [Open Data Commons Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/) by the OpenStreetMap Foundation (OSMF).
3061

3162
Use of any OSMF provided service is governed by the [OSMF Terms of Use](https://osmfoundation.org/wiki/Terms_of_Use).
3263

33-
### Example code
64+
## Example code
3465

35-
#### Example returning the default 320x240 map
66+
### Example returning the default 320x240 map
3667

3768
```c++
3869
#include <Arduino.h>
@@ -157,14 +188,16 @@ void loop()
157188
delay(1000);
158189
}
159190
```
160-
![map](https://github.com/user-attachments/assets/9a92bbff-e96d-444d-8b34-29801744fa80)
161-
Screenshot of a 480x800 map from a esp32-8048s050
162191

163-
### PlatformIO setup\
192+
### Screenshot of a 480x800 map from a esp32-8048s050
193+
194+
![map](https://github.com/user-attachments/assets/9a92bbff-e96d-444d-8b34-29801744fa80)
195+
196+
### PlatformIO setup
164197

165198
```bash
166199
lib_deps =
167200
https://github.com/CelliesProjects/OpenStreetMap-esp32
168201
lovyan03/LovyanGFX@^1.2.0
169-
bitbank2/PNGdec@^1.0.3
202+
bitbank2/PNGdec@^1.0.3
170203
```

0 commit comments

Comments
 (0)