Skip to content

Commit

Permalink
🎨 (OS): Update OS to naming and map
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Sep 1, 2022
1 parent 021e815 commit 86c5a04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_link_libraries(LekaOS
CoreBufferedSerial
CoreRFIDReader
RFIDKit
GameKit
ActivityKit
)

target_link_custom_leka_targets(LekaOS)
48 changes: 13 additions & 35 deletions app/os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "rtos/ThisThread.h"
#include "rtos/Thread.h"

#include "ActivityKit.h"
#include "CoreBattery.h"
#include "CoreBufferedSerial.h"
#include "CoreDMA2D.hpp"
Expand Down Expand Up @@ -39,14 +40,12 @@
#include "EventLoopKit.h"
#include "FATFileSystem.h"
#include "FirmwareKit.h"
#include "GameKit.h"
#include "HelloWorld.h"
#include "LogKit.h"
#include "QSPIFBlockDevice.h"
#include "RFIDKit.h"
#include "RobotController.h"
#include "SDBlockDevice.h"
#include "SMAutonomousGame.h"
#include "SerialNumberKit.h"
#include "SlicingBlockDevice.h"
#include "VideoKit.h"
Expand Down Expand Up @@ -326,15 +325,15 @@ namespace mcuboot {

} // namespace mcuboot

namespace game {
namespace activities {

auto display_tag = leka::game::DisplayTags(rfidkit, display::videokit);
;
auto display_tag = leka::activity::DisplayTags(rfidkit, display::videokit);

auto sm_autonomous_game = boost::sml::sm<leka::game::SMAutonomousGame> {};
auto gamekit = GameKit {};
inline const std::unordered_map<MagicCard, interface::Activity *> activities {{MagicCard::number_10, &display_tag}};

} // namespace game
} // namespace activities

auto activitykit = ActivityKit {};

namespace robot {

Expand All @@ -360,40 +359,18 @@ namespace robot {
display::videokit,
behaviorkit,
commandkit,
game::gamekit};
activitykit};

void onMagicCardAvailable(const MagicCard &card)
{
if (card == MagicCard::emergency_stop) {
controller.raiseEmergencyStop();
} else if (card == MagicCard::remote_standard) {
controller.raiseAutonomousGameTransition();
controller.stopStartAutonomousActivity();
return;
}
if (controller.state_machine.is(boost::sml::state<leka::game::SMAutonomousGame>)) {
if (card == MagicCard::number_0) {
game::gamekit.start(&game::display_tag);
}
// auto set_default_reinforcer_callback = [](const MagicCard &card) { setDefaultReinforcer(card); };
// _activity->registerCallback(set_default_reinforcer_callback);
// } else if (card == MagicCard::number_1) {
// magiccardkit.start(rfid::activity::color_recognition);
// } else if (card == MagicCard::number_2) {
// magiccardkit.start(rfid::activity::emotion_recognition);
// } else if (card == MagicCard::number_3) {
// magiccardkit.start(rfid::activity::number_recognition);
// } else if (card == MagicCard::number_4) {
// magiccardkit.start(rfid::activity::shape_recognition);
// } else if (card == MagicCard::number_5) {
// magiccardkit.start(rfid::activity::display_emotions);
// } else if (card == MagicCard::number_6) {
// magiccardkit.start(rfid::activity::color_leka);
// } else if (card == MagicCard::number_7) {
// magiccardkit.start(rfid::activity::two_numbers_addition);
// } else if (card == MagicCard::number_8) {
// magiccardkit.start(rfid::activity::two_numbers_substraction);
// } else if (card == MagicCard::number_9) {
// magiccardkit.start(rfid::activity::colored_shape_recognition);
// }
if (controller.state_machine.is(system::robot::sm::state::autonomous_activity)) {
activitykit.start(card);
}
}

Expand Down Expand Up @@ -523,6 +500,7 @@ auto main() -> int
firmware::initializeFlash();

commandkit.registerCommand(command::list);
activitykit.registerActivities(activities::activities);

robot::controller.initializeComponents();
robot::controller.registerOnUpdateLoadedCallback(firmware::setPendingUpdate);
Expand Down

0 comments on commit 86c5a04

Please sign in to comment.