Skip to content

Commit

Permalink
💫 (activity): Add DisplayTag activity
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Sep 1, 2022
1 parent c820b63 commit 4d4b80b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/ActivityKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ target_include_directories(ActivityKit
target_sources(ActivityKit
PRIVATE
source/ActivityKit.cpp
source/activities/DisplayTags.cpp
)

target_link_libraries(ActivityKit
Expand Down
32 changes: 32 additions & 0 deletions libs/ActivityKit/include/activities/DisplayTags.h
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
36 changes: 36 additions & 0 deletions libs/ActivityKit/source/activities/DisplayTags.cpp
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

0 comments on commit 4d4b80b

Please sign in to comment.