mirror of
https://github.com/m5stack/meshtastic-device-ui.git
synced 2026-05-20 11:51:03 -07:00
feat: ethernet client support for MUI (#129)
* preliminary impl * update initialization * adapt to limited Portduino Ethernet(WiFi)Client * fixed space left calculation * inherit from SerialClient * updates Eth/SerialClient * update cmake files * protected declaration (for unit tests) * fix warning * tryfix: call lv_tick_inc() directly instead of lv_tick_set_cb() * added isStandalone() to determine use case * add reboot/shutdown for standalone; suppress animations during startup * add debug log * add error log * revert lv_tick_inc / lv_tick_set_cb * fix debug log * workaround sporadic map error * connection status handling * define pure virtual functions * adapt dimensions to allow map resize * replace [] by .at() when erasing * fix all communication issues; add thread names for logging * fix warnings * trunk fmt * cleanup * fix lv_tick interface for esp32 (revert to previous one as Indicator is frozen) * added client connection states to boot screen * fix reboot for standalone case * fix warning * fix UART connection timeout
This commit is contained in:
@@ -5,24 +5,14 @@
|
||||
#include "util/ILog.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define HASH(X, Y) (((X) << 16) | ((Y) & 0xFFFF))
|
||||
|
||||
#define HASH(X, Y) (((X) << 16) | ((Y)&0xFFFF))
|
||||
|
||||
MapPanel::MapPanel(lv_obj_t *p, ITileService *s)
|
||||
: home(GeoPoint(MapTileSettings::getDefaultLat(), MapTileSettings::getDefaultLon(), MapTileSettings::getZoomLevel())),
|
||||
: widthPixel(320), heightPixel(240),
|
||||
home(GeoPoint(MapTileSettings::getDefaultLat(), MapTileSettings::getDefaultLon(), MapTileSettings::getZoomLevel())),
|
||||
current(home), scrolled(home), panel(p), homeLocationImage(nullptr), gpsPositionImage(nullptr), noTileImage(nullptr),
|
||||
service(new TileService(s)), objectsOnMap(0)
|
||||
{
|
||||
if (p) {
|
||||
lv_obj_update_layout(panel);
|
||||
widthPixel = lv_obj_get_width(panel);
|
||||
heightPixel = lv_obj_get_height(panel);
|
||||
ILOG_DEBUG("panel size: %dx%d", widthPixel, heightPixel);
|
||||
} else {
|
||||
widthPixel = 320;
|
||||
heightPixel = 240;
|
||||
}
|
||||
|
||||
extern OSMTiles<lv_obj_t> *osm;
|
||||
osm = OSMTiles<lv_obj_t>::create([this](const char *name, void *img) -> bool { return service->load(name, img); });
|
||||
|
||||
@@ -53,6 +43,11 @@ void MapPanel::redraw(void)
|
||||
for (int x = 0; x < tilesX; x++) {
|
||||
for (int y = 0; y < tilesY; y++) {
|
||||
uint32_t hash = HASH(xStart + x, yStart + y);
|
||||
if (tiles.find(hash) != tiles.end()) {
|
||||
ILOG_ERROR("internal error: tile %d/%d (hash:%u) already exists", xStart + x, yStart + y, hash);
|
||||
needsRedraw = true;
|
||||
return;
|
||||
}
|
||||
tiles[hash] = std::move(std::unique_ptr<MapTile>(new MapTile(xStart + x, yStart + y)));
|
||||
tiles[hash]->load(panel, x * size + xOffset, y * size + yOffset, noTileImage);
|
||||
}
|
||||
@@ -165,6 +160,7 @@ void MapPanel::drawObject(MapObject &obj, bool count)
|
||||
*/
|
||||
void MapPanel::center(void)
|
||||
{
|
||||
updateDimensions();
|
||||
int16_t size = MapTileSettings::getTileSize();
|
||||
int16_t xpos = widthPixel / 2 - scrolled.xPos;
|
||||
int16_t ypos = heightPixel / 2 - scrolled.yPos;
|
||||
@@ -251,6 +247,16 @@ void MapPanel::setZoom(uint8_t zoom)
|
||||
}
|
||||
}
|
||||
|
||||
void MapPanel::updateDimensions(void)
|
||||
{
|
||||
if (panel) {
|
||||
lv_obj_update_layout(panel);
|
||||
widthPixel = lv_obj_get_width(panel);
|
||||
heightPixel = lv_obj_get_height(panel);
|
||||
ILOG_DEBUG("panel size: %dx%d", widthPixel, heightPixel);
|
||||
}
|
||||
}
|
||||
|
||||
void MapPanel::setLocked(bool lock)
|
||||
{
|
||||
locked = lock;
|
||||
@@ -503,10 +509,13 @@ void MapPanel::printTiles(void)
|
||||
for (int x = 0; x < tilesX; x++) {
|
||||
for (int y = 0; y < tilesY; y++) {
|
||||
uint32_t hash = HASH(xStart + x, yStart + y);
|
||||
ss << x << "/" << y << ": "
|
||||
<< "(" << (uint32_t)MapTileSettings::getZoomLevel() << "/" << tiles[hash].get()->xTile << "/"
|
||||
<< tiles[hash].get()->yTile << ") - " << tiles[hash].get()->xPos << "/" << tiles[hash].get()->yPos << " ==> "
|
||||
<< tiles[hash].get()->getX() << "/" << tiles[hash].get()->getY() << std::endl;
|
||||
if (tiles.find(hash) != tiles.end()) {
|
||||
ss << x << "/" << y << ": "
|
||||
<< "(" << (uint32_t)MapTileSettings::getZoomLevel() << "/" << tiles[hash].get()->xTile << "/"
|
||||
<< tiles[hash].get()->yTile << ") " << hash << " - " << tiles[hash].get()->xPos << "/"
|
||||
<< tiles[hash].get()->yPos << " ==> " << tiles[hash].get()->getX() << "/" << tiles[hash].get()->getY()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
ILOG_DEBUG("tiles: %d\n%s", tiles.size(), ss.str().c_str());
|
||||
|
||||
Reference in New Issue
Block a user