forked from Open-Smartwatch/lib-open-smartwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osm_render.h
57 lines (46 loc) · 1.41 KB
/
osm_render.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef OSM_RENDER_H
#define OSM_RENDER_H
#ifdef FAKE_ARDUINO
#include "FakeArduino.h"
#else
#include <Arduino.h>
#endif
#include "gfx_2d.h"
#include "math_osm.h"
#define TILE_W 256
#define TILE_H 256
#define TILE_CHUNK_H 16
typedef void (*loadTile)(Graphics2D *target, int8_t z, float tilex, float tiley, int32_t offsetx, int32_t offsety);
class BufferedTile {
public:
BufferedTile(bool inPsram) {
gfx = new Graphics2D(TILE_W, TILE_H, TILE_CHUNK_H, false /* not round */, inPsram /* but in psram*/);
lastUsed = 0;
};
~BufferedTile() { delete gfx; }
void loadTile(loadTile loadTileFn, uint32_t tileX, uint32_t tileY, uint8_t tileZ) {
loadTileFn(gfx, tileZ, tileX, tileY, 0, 0);
_tileX = tileX;
_tileY = tileY;
_tileZ = tileZ;
lastUsed = millis();
}
bool hasTile(uint32_t tileX, uint32_t tileY, uint8_t tileZ) {
return tileZ == _tileZ && tileX == _tileX && tileY == _tileY;
}
Graphics2D *getGraphics() {
lastUsed = millis();
return gfx;
}
unsigned long getLastUsed() { return lastUsed; }
private:
Graphics2D *gfx;
uint8_t _tileZ;
uint32_t _tileX;
uint32_t _tileY;
unsigned long lastUsed;
};
void drawTiles(Graphics2D *target, loadTile loadTileFn, float lat, float lon, uint8_t z);
void drawTilesBuffered(BufferedTile **buffer, uint8_t bufferLength, Graphics2D *target, //
loadTile loadTileFn, float lat, float lon, uint8_t z);
#endif