figments: command: rewrite command api to use Task instances instead of static functions
This commit is contained in:
@@ -256,19 +256,18 @@ ConfigService::handleEvent(const InputEvent &evt)
|
||||
}
|
||||
|
||||
void
|
||||
doMapList(Args& args, Print& out)
|
||||
ConfigService::doMapList(Args& args, Print& out)
|
||||
{
|
||||
static const auto conf = Static<ConfigService>::instance();
|
||||
out.println("Available maps:");
|
||||
LittleFS.begin();
|
||||
for(auto it = conf->mapsBegin();it != conf->mapsEnd(); it++) {
|
||||
for(auto it = mapsBegin();it != mapsEnd(); it++) {
|
||||
out.println(*it);
|
||||
}
|
||||
LittleFS.end();
|
||||
}
|
||||
|
||||
void
|
||||
doSave(Args& args, Print& print)
|
||||
ConfigService::doSave(Args& args, Print& print)
|
||||
{
|
||||
MainLoop::instance()->dispatch(InputEvent::SaveConfigurationRequest);
|
||||
}
|
||||
@@ -276,17 +275,17 @@ doSave(Args& args, Print& print)
|
||||
static String s;
|
||||
|
||||
void
|
||||
doSetProfile(Args& args, Print& out)
|
||||
ConfigService::doSetProfile(Args& args, Print& out)
|
||||
{
|
||||
s = args[1];
|
||||
MainLoop::instance()->dispatch(InputEvent{InputEvent::LoadConfigurationByName, s.c_str()});
|
||||
}
|
||||
|
||||
void
|
||||
doCoordMap(Args& args, Print& out)
|
||||
ConfigService::doCoordMap(Args& args, Print& out)
|
||||
{
|
||||
VirtualCoordinates coords{atoi(args[1].c_str()), atoi(args[2].c_str())};
|
||||
auto map = Static<ConfigService>::instance()->coordMap();
|
||||
auto map = coordMap();
|
||||
auto pPos = map->virtualToPhysicalCoords(coords);
|
||||
auto idx = map->physicalCoordsToIndex(pPos);
|
||||
char buf[32];
|
||||
@@ -298,10 +297,10 @@ const std::vector<Command>&
|
||||
ConfigService::commands() const
|
||||
{
|
||||
static const std::vector<Command> _commands = {
|
||||
{"save", doSave},
|
||||
{"profile", doSetProfile},
|
||||
{"maps", doMapList},
|
||||
{"coordmap", doCoordMap}
|
||||
{"save", &ConfigService::doSave},
|
||||
{"profile", &ConfigService::doSetProfile},
|
||||
{"maps", &ConfigService::doMapList},
|
||||
{"coordmap", &ConfigService::doCoordMap}
|
||||
};
|
||||
return _commands;
|
||||
}
|
||||
|
Reference in New Issue
Block a user