Files
Manuel cd0cdf997f fix: map scrolling (#101)
* prepare for map unit tests; fix scroll issue

* add map scroll unit tests

* force redraw on internal scroll error (kinda self-healing)
2025-03-23 12:31:34 +01:00

43 lines
1.0 KiB
C++

#pragma once
#include <stdint.h>
/**
* Abstract TileService interface; load tile from any source
*/
class ITileService
{
public:
// lvgl lv_fs_drv callbacks
virtual bool load(const char *name, void *img) = 0;
virtual ~ITileService() {}
protected:
ITileService(const char *id) : idLetter(id){};
const char *idLetter; // LVGL letter for file system drives
};
/**
* Envelope class to allow runtime configuration of TileService variants
* Note: This class will delete unused TileService objects.
*/
class TileService : public ITileService
{
public:
TileService(ITileService *s) : ITileService(""), service(s) {}
virtual void setService(ITileService *s);
virtual void setBackupService(ITileService *s);
bool load(const char *name, void *img) override
{
return service ? service->load(name, img) : backup ? backup->load(name, img) : false;
}
virtual ~TileService();
protected:
ITileService *service = nullptr;
ITileService *backup = nullptr;
};