-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge branch 'hugo/feature/Add-ChooseReinforcer-activity' into develop
- Loading branch information
Showing
5 changed files
with
98 additions
and
1 deletion.
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
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,37 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
// LCOV_EXCL_START | ||
|
||
#include "RFIDKit.h" | ||
#include "ReinforcerKit.h" | ||
#include "interface/Activity.h" | ||
#include "interface/libs/VideoKit.h" | ||
|
||
namespace leka::activity { | ||
|
||
class ChooseReinforcer : public interface::Activity | ||
{ | ||
public: | ||
explicit ChooseReinforcer(RFIDKit &rfidkit, interface::VideoKit &videokit, ReinforcerKit &reinforcerkit) | ||
: _rfidkit(rfidkit), _videokit(videokit), _reinforcerkit(reinforcerkit) {}; | ||
|
||
void start() final; | ||
void stop() final; | ||
|
||
private: | ||
void processCard(const MagicCard &card); | ||
|
||
RFIDKit &_rfidkit; | ||
interface::VideoKit &_videokit; | ||
ReinforcerKit &_reinforcerkit; | ||
|
||
std::function<void(const 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,56 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// LCOV_EXCL_START | ||
|
||
#include "ChooseReinforcer.h" | ||
|
||
namespace leka::activity { | ||
|
||
void ChooseReinforcer::start() | ||
{ | ||
_videokit.displayImage("fs/home/img/system/robot-face-smiling-slightly.jpg"); | ||
|
||
_backup_callback = _rfidkit.getCallback(); | ||
|
||
_rfidkit.onTagActivated([this](const MagicCard &card) { processCard(card); }); | ||
} | ||
|
||
void ChooseReinforcer::processCard(const MagicCard &card) | ||
{ | ||
switch (card.getId()) { | ||
case (MagicCard::reinforcer_1_blink_green.getId()): | ||
_reinforcerkit.setDefaultReinforcer(ReinforcerKit::Reinforcer::BlinkGreen); | ||
_reinforcerkit.playDefault(); | ||
break; | ||
case (MagicCard::reinforcer_2_spin_blink.getId()): | ||
_reinforcerkit.setDefaultReinforcer(ReinforcerKit::Reinforcer::SpinBlink); | ||
_reinforcerkit.playDefault(); | ||
break; | ||
case (MagicCard::reinforcer_3_fire.getId()): | ||
_reinforcerkit.setDefaultReinforcer(ReinforcerKit::Reinforcer::Fire); | ||
_reinforcerkit.playDefault(); | ||
break; | ||
case (MagicCard::reinforcer_4_sprinkles.getId()): | ||
_reinforcerkit.setDefaultReinforcer(ReinforcerKit::Reinforcer::Sprinkles); | ||
_reinforcerkit.playDefault(); | ||
break; | ||
case (MagicCard::reinforcer_5_rainbow.getId()): | ||
_reinforcerkit.setDefaultReinforcer(ReinforcerKit::Reinforcer::Rainbow); | ||
_reinforcerkit.playDefault(); | ||
break; | ||
default: | ||
_backup_callback(card); | ||
break; | ||
} | ||
} | ||
|
||
void ChooseReinforcer::stop() | ||
{ | ||
_rfidkit.onTagActivated(_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