Skip to content

Commit 8ae0814

Browse files
Added basic example code
1 parent 11a27ef commit 8ae0814

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <Arduino.h>
2+
#include <WiFi.h>
3+
4+
#define LGFX_M5STACK_CORE2 // for supported devices see
5+
// https://github.com/lovyan03/LovyanGFX
6+
7+
#include <LGFX_AUTODETECT.hpp>
8+
#include <LovyanGFX.hpp>
9+
10+
#include <OpenStreetMap-esp32.h>
11+
12+
const char *ssid = "xxx";
13+
const char *password = "xxx";
14+
15+
LGFX display;
16+
OpenStreetMap osm;
17+
18+
double longitude = 5.9;
19+
double latitude = 51.5;
20+
int zoom = 5;
21+
22+
void setup()
23+
{
24+
Serial.begin(115200);
25+
Serial.printf("WiFi connecting to %s\n", ssid);
26+
27+
WiFi.begin(ssid, password);
28+
while (WiFi.status() != WL_CONNECTED)
29+
{
30+
delay(10);
31+
Serial.print(".");
32+
}
33+
34+
Serial.println("\nWiFi connected");
35+
36+
display.begin();
37+
display.setRotation(1);
38+
display.setBrightness(110);
39+
40+
// create a sprite to store the map
41+
LGFX_Sprite map(&display);
42+
43+
// returned map is 320px by 240px by default
44+
const bool success = osm.fetchMap(map, longitude, latitude, zoom);
45+
46+
if (success)
47+
map.pushSprite(0, 0);
48+
else
49+
Serial.println("Failed to fetch map.");
50+
}
51+
52+
void loop()
53+
{
54+
delay(1000);
55+
}

0 commit comments

Comments
 (0)