mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
fix hanging
This commit is contained in:
@@ -61,6 +61,7 @@ private:
|
|||||||
class HighResClockService;
|
class HighResClockService;
|
||||||
class PowerService;
|
class PowerService;
|
||||||
class FilesystemService;
|
class FilesystemService;
|
||||||
|
class LoopHooksService;
|
||||||
|
|
||||||
std::unique_ptr<BuzzerService> buzzerService;
|
std::unique_ptr<BuzzerService> buzzerService;
|
||||||
std::unique_ptr<BatteryService> batteryService;
|
std::unique_ptr<BatteryService> batteryService;
|
||||||
@@ -70,6 +71,7 @@ private:
|
|||||||
std::unique_ptr<PowerService> powerService;
|
std::unique_ptr<PowerService> powerService;
|
||||||
std::unique_ptr<FilesystemService> filesystemService;
|
std::unique_ptr<FilesystemService> filesystemService;
|
||||||
std::unique_ptr<EventBus> eventBus;
|
std::unique_ptr<EventBus> eventBus;
|
||||||
|
std::unique_ptr<LoopHooksService> loopHooksService;
|
||||||
|
|
||||||
cardboy::sdk::Services services{};
|
cardboy::sdk::Services services{};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EspRuntime::LoopHooksService final : public cardboy::sdk::ILoopHooks {
|
||||||
|
public:
|
||||||
|
void onLoopIteration() override { vTaskDelay(1); }
|
||||||
|
};
|
||||||
|
|
||||||
EspRuntime::EspRuntime() : framebuffer(), input(), clock() {
|
EspRuntime::EspRuntime() : framebuffer(), input(), clock() {
|
||||||
initializeHardware();
|
initializeHardware();
|
||||||
|
|
||||||
@@ -139,6 +144,7 @@ EspRuntime::EspRuntime() : framebuffer(), input(), clock() {
|
|||||||
powerService = std::make_unique<PowerService>();
|
powerService = std::make_unique<PowerService>();
|
||||||
filesystemService = std::make_unique<FilesystemService>();
|
filesystemService = std::make_unique<FilesystemService>();
|
||||||
eventBus = std::make_unique<EventBus>();
|
eventBus = std::make_unique<EventBus>();
|
||||||
|
loopHooksService = std::make_unique<LoopHooksService>();
|
||||||
|
|
||||||
services.buzzer = buzzerService.get();
|
services.buzzer = buzzerService.get();
|
||||||
services.battery = batteryService.get();
|
services.battery = batteryService.get();
|
||||||
@@ -148,6 +154,7 @@ EspRuntime::EspRuntime() : framebuffer(), input(), clock() {
|
|||||||
services.powerManager = powerService.get();
|
services.powerManager = powerService.get();
|
||||||
services.filesystem = filesystemService.get();
|
services.filesystem = filesystemService.get();
|
||||||
services.eventBus = eventBus.get();
|
services.eventBus = eventBus.get();
|
||||||
|
services.loopHooks = loopHooksService.get();
|
||||||
|
|
||||||
Buttons::get().setEventBus(eventBus.get());
|
Buttons::get().setEventBus(eventBus.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ target_sources(cardboy_backend_interface
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/backend.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/backend.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/display_spec.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/display_spec.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/event_bus.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/event_bus.hpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/loop_hooks.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/input_state.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/input_state.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/platform.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/platform.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/services.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/cardboy/sdk/services.hpp
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace cardboy::sdk {
|
||||||
|
|
||||||
|
class ILoopHooks {
|
||||||
|
public:
|
||||||
|
virtual ~ILoopHooks() = default;
|
||||||
|
virtual void onLoopIteration() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cardboy::sdk
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cardboy/sdk/event_bus.hpp"
|
#include "cardboy/sdk/event_bus.hpp"
|
||||||
|
#include "cardboy/sdk/loop_hooks.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -85,6 +86,7 @@ struct Services {
|
|||||||
IPowerManager* powerManager = nullptr;
|
IPowerManager* powerManager = nullptr;
|
||||||
IFilesystem* filesystem = nullptr;
|
IFilesystem* filesystem = nullptr;
|
||||||
IEventBus* eventBus = nullptr;
|
IEventBus* eventBus = nullptr;
|
||||||
|
ILoopHooks* loopHooks = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cardboy::sdk
|
} // namespace cardboy::sdk
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ DesktopRuntime::DesktopRuntime() :
|
|||||||
services.powerManager = &powerService;
|
services.powerManager = &powerService;
|
||||||
services.filesystem = &filesystemService;
|
services.filesystem = &filesystemService;
|
||||||
services.eventBus = &eventBusService;
|
services.eventBus = &eventBusService;
|
||||||
|
services.loopHooks = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cardboy::sdk::Services& DesktopRuntime::serviceRegistry() { return services; }
|
cardboy::sdk::Services& DesktopRuntime::serviceRegistry() { return services; }
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ struct AppContext {
|
|||||||
[[nodiscard]] IPowerManager* powerManager() const { return services ? services->powerManager : nullptr; }
|
[[nodiscard]] IPowerManager* powerManager() const { return services ? services->powerManager : nullptr; }
|
||||||
[[nodiscard]] IFilesystem* filesystem() const { return services ? services->filesystem : nullptr; }
|
[[nodiscard]] IFilesystem* filesystem() const { return services ? services->filesystem : nullptr; }
|
||||||
[[nodiscard]] IEventBus* eventBus() const { return services ? services->eventBus : nullptr; }
|
[[nodiscard]] IEventBus* eventBus() const { return services ? services->eventBus : nullptr; }
|
||||||
|
[[nodiscard]] ILoopHooks* loopHooks() const { return services ? services->loopHooks : nullptr; }
|
||||||
|
|
||||||
void requestAppSwitchByIndex(std::size_t index) {
|
void requestAppSwitchByIndex(std::size_t index) {
|
||||||
pendingAppIndex = index;
|
pendingAppIndex = index;
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ void AppSystem::run() {
|
|||||||
eventBus->scheduleTimerSignal(waitMs);
|
eventBus->scheduleTimerSignal(waitMs);
|
||||||
eventBus->wait(mask, IEventBus::kWaitForever);
|
eventBus->wait(mask, IEventBus::kWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto* hooks = context.loopHooks())
|
||||||
|
hooks->onLoopIteration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user