-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💫 (activity): Add DisplayTag activity
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
// LCOV_EXCL_START | ||
|
||
#include "Activity.h" | ||
#include "RFIDKit.h" | ||
#include "interface/libs/VideoKit.h" | ||
|
||
namespace leka::activity { | ||
|
||
class DisplayTags : public interface::Activity | ||
{ | ||
public: | ||
explicit DisplayTags(RFIDKit &rfidkit, interface::VideoKit &videokit) : _rfidkit(rfidkit), _videokit(videokit) {}; | ||
|
||
void start() final; | ||
void stop() final; | ||
|
||
private: | ||
RFIDKit &_rfidkit; | ||
interface::VideoKit &_videokit; | ||
std::array<char, 32> path = {}; | ||
std::function<void(MagicCard &)> _backup_callback {}; | ||
}; | ||
|
||
} // namespace leka::activity | ||
|
||
// LCOV_EXCL_STOP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// LCOV_EXCL_START | ||
|
||
#include "DisplayTags.h" | ||
|
||
namespace leka::activity { | ||
|
||
void DisplayTags::start() | ||
{ | ||
_videokit.displayImage("fs/home/img/system/robot-misc-robot-misc-screen_empty_white.jpg"); | ||
|
||
_backup_callback = _rfidkit.getCallback(); | ||
|
||
auto on_tag_detected_callback = [this](const MagicCard &card) { | ||
if (card == MagicCard::remote_standard) { | ||
stop(); | ||
} else { | ||
snprintf(path.data(), path.size(), "fs/home/img/id/00%x.jpg", card.getId()); | ||
_videokit.displayImage(path.data()); | ||
} | ||
}; | ||
|
||
_rfidkit.onTagActivated(on_tag_detected_callback); | ||
} | ||
|
||
void DisplayTags::stop() | ||
{ | ||
_rfidkit.onTagActivated(_backup_callback); | ||
} | ||
|
||
} // namespace leka::activity | ||
|
||
// LCOV_EXCL_STOP |